diff --git a/gen/common/wasi/libretro.js b/gen/common/wasi/libretro.js new file mode 100644 index 00000000..8eaa09d0 --- /dev/null +++ b/gen/common/wasi/libretro.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LibRetroRunner = void 0; +const wasishim_1 = require("./wasishim"); +class LibRetroRunner extends wasishim_1.WASIRunner { + constructor() { + super(); + } + getEnv() { + return Object.assign(Object.assign({}, super.getEnv()), { retro_environment_callback: (cmd, data) => { + console.log(`retro_environment_callback: ${cmd}, ${data}`); + return 0; + }, retro_video_refresh_callback: (data, width, height, pitch) => { + console.log(`retro_video_refresh_callback: ${data}, ${width}, ${height}, ${pitch}`); + }, retro_audio_sample_batch_callback: (data, frames) => { + console.log(`retro_audio_sample_batch_callback: ${data}, ${frames}`); + }, retro_audio_sample_callback: (left, right) => { + console.log(`retro_audio_sample_callback: ${left}, ${right}`); + return 0; + }, retro_input_poll_callback: () => { + console.log(`retro_input_poll_callback`); + }, retro_input_state_callback: (port, device, index, id) => { + console.log(`retro_input_state_callback: ${port}, ${device}, ${index}, ${id}`); + return 0; + } }); + } + retro_init() { + let errno = this.initialize(); + // TODO: if (errno) throw new Error(`retro_init failed: ${errno}`); + this.exports().retro_init_callbacks(); + this.exports().retro_init(); + this.exports().retro_set_controller_port_device(0, 1); + this.exports().retro_set_controller_port_device(1, 1); + } + retro_api_version() { + return this.exports().retro_api_version(); + } + load_rom(path, data) { + const meta = ''; + this.exports().retro_load_rom(path, data, data.length, meta); + } + reset() { + this.exports().retro_reset(); + } + advance() { + this.exports().retro_run(); + } +} +exports.LibRetroRunner = LibRetroRunner; +//# sourceMappingURL=libretro.js.map \ No newline at end of file diff --git a/gen/common/wasi/libretro.js.map b/gen/common/wasi/libretro.js.map new file mode 100644 index 00000000..635cb281 --- /dev/null +++ b/gen/common/wasi/libretro.js.map @@ -0,0 +1 @@ +{"version":3,"file":"libretro.js","sourceRoot":"","sources":["../../../src/common/wasi/libretro.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AAExC,MAAa,cAAe,SAAQ,qBAAU;IAC1C;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IACD,MAAM;QACF,uCACO,KAAK,CAAC,MAAM,EAAE,KACjB,0BAA0B,EAAE,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE;gBACtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC3D,OAAO,CAAC,CAAC;YACb,CAAC,EACD,4BAA4B,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;gBACzF,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,EAAE,CAAC,CAAC;YACxF,CAAC,EACD,iCAAiC,EAAE,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE;gBAChE,OAAO,CAAC,GAAG,CAAC,sCAAsC,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;YACzE,CAAC,EACD,2BAA2B,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;gBACzD,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;gBAC9D,OAAO,CAAC,CAAC;YACb,CAAC,EACD,yBAAyB,EAAE,GAAG,EAAE;gBAC5B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAC7C,CAAC,EACD,0BAA0B,EAAE,CAAC,IAAY,EAAE,MAAc,EAAE,KAAa,EAAE,EAAU,EAAE,EAAE;gBACpF,OAAO,CAAC,GAAG,CAAC,+BAA+B,IAAI,KAAK,MAAM,KAAK,KAAK,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC/E,OAAO,CAAC,CAAC;YACb,CAAC,IACJ;IACL,CAAC;IACD,UAAU;QACN,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC9B,mEAAmE;QACnE,IAAI,CAAC,OAAO,EAAE,CAAC,oBAAoB,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,EAAE,CAAC,gCAAgC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC,gCAAgC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,iBAAiB;QACb,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IACD,QAAQ,CAAC,IAAY,EAAE,IAAgB;QACnC,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IACD,KAAK;QACD,IAAI,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;IACD,OAAO;QACH,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC;IAC/B,CAAC;CACJ;AAnDD,wCAmDC"} \ No newline at end of file diff --git a/gen/common/wasi/wasishim.js b/gen/common/wasi/wasishim.js index a068ebc1..241f7b1b 100644 --- a/gen/common/wasi/wasishim.js +++ b/gen/common/wasi/wasishim.js @@ -6,17 +6,17 @@ // https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/sources/preopens.c // https://fossies.org/linux/wasm3/source/extra/wasi_core.h // https://wasix.org/docs/api-reference/wasi/fd_read +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -}; var _WASIRunner_instance, _WASIRunner_memarr8, _WASIRunner_memarr32, _WASIRunner_args, _WASIRunner_envvars; Object.defineProperty(exports, "__esModule", { value: true }); exports.WASIRunner = exports.WASIMemoryFilesystem = exports.WASIFileDescriptor = exports.WASIErrors = exports.FDOpenFlags = exports.FDFlags = exports.FDRights = exports.FDType = void 0; @@ -287,6 +287,9 @@ class WASIRunner { this.fs = new WASIMemoryFilesystem(); this.createStdioBrowser(); } + exports() { + return __classPrivateFieldGet(this, _WASIRunner_instance, "f").exports; + } createStdioNode() { this.stdin = new WASIStreamingFileDescriptor(0, '', FDType.CHARACTER_DEVICE, FDRights.FD_READ, process.stdin); this.stdout = new WASIStreamingFileDescriptor(1, '', FDType.CHARACTER_DEVICE, FDRights.FD_WRITE, process.stdout); @@ -391,6 +394,10 @@ class WASIRunner { } return this.getErrno(); } + initialize() { + __classPrivateFieldGet(this, _WASIRunner_instance, "f").exports._initialize(); + return this.getErrno(); + } getImportObject() { return { "wasi_snapshot_preview1": this.getWASISnapshotPreview1(), @@ -503,7 +510,9 @@ class WASIRunner { } fd_seek(fd, offset, whence, newoffset_ptr) { const file = this.fds[fd]; - debug("fd_seek", fd, offset, whence, file); + if (typeof offset == 'bigint') + offset = Number(offset); + debug("fd_seek", fd, offset, whence, file + ""); if (file != null) { file.llseek(offset, whence); this.poke64(newoffset_ptr, file.offset); @@ -623,11 +632,12 @@ class WASIRunner { fd_readdir() { warning("TODO: fd_readdir"); return WASIErrors.NOTSUP; }, path_unlink_file() { warning("TODO: path_unlink_file"); return WASIErrors.NOTSUP; }, clock_time_get() { warning("TODO: clock_time_get"); return WASIErrors.NOTSUP; }, + fd_tell() { warning("TODO: fd_tell"); return WASIErrors.NOTSUP; }, }; } getEnv() { return { - __syscall_unlinkat() { warning('TODO: unlink'); return 0; }, + __syscall_unlinkat() { warning('TODO: unlink'); return WASIErrors.NOTSUP; }, }; } } diff --git a/gen/common/wasi/wasishim.js.map b/gen/common/wasi/wasishim.js.map index 1b9ca48d..8016816f 100644 --- a/gen/common/wasi/wasishim.js.map +++ b/gen/common/wasi/wasishim.js.map @@ -1 +1 @@ -{"version":3,"file":"wasishim.js","sourceRoot":"","sources":["../../../src/common/wasi/wasishim.ts"],"names":[],"mappings":";AACA,4EAA4E;AAC5E,sDAAsD;AACtD,uHAAuH;AACvH,gHAAgH;AAChH,yFAAyF;AACzF,2DAA2D;AAC3D,oDAAoD;;;;;;;;;;;;;;;AAEpD,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;AAE5B,IAAY,MASX;AATD,WAAY,MAAM;IACd,yCAAW,CAAA;IACX,mDAAgB,CAAA;IAChB,2DAAoB,CAAA;IACpB,6CAAa,CAAA;IACb,mDAAgB,CAAA;IAChB,mDAAgB,CAAA;IAChB,qDAAiB,CAAA;IACjB,qDAAiB,CAAA;AACrB,CAAC,EATW,MAAM,sBAAN,MAAM,QASjB;AAED,IAAY,QA+BX;AA/BD,WAAY,QAAQ;IAChB,qDAAe,CAAA;IACf,6CAAW,CAAA;IACX,6CAAW,CAAA;IACX,qEAAuB,CAAA;IACvB,8CAAY,CAAA;IACZ,8CAAY,CAAA;IACZ,gDAAa,CAAA;IACb,mDAAe,CAAA;IACf,uDAAiB,CAAA;IACjB,2EAA2B,CAAA;IAC3B,kEAAuB,CAAA;IACvB,kEAAuB,CAAA;IACvB,kEAAuB,CAAA;IACvB,oDAAgB,CAAA;IAChB,uDAAkB,CAAA;IAClB,6DAAqB,CAAA;IACrB,uEAA0B,CAAA;IAC1B,wEAA2B,CAAA;IAC3B,sEAA0B,CAAA;IAC1B,gFAA+B,CAAA;IAC/B,mFAAiC,CAAA;IACjC,mEAAyB,CAAA;IACzB,6EAA8B,CAAA;IAC9B,+EAA+B,CAAA;IAC/B,8DAAuB,CAAA;IACvB,gFAAgC,CAAA;IAChC,sEAA2B,CAAA;IAC3B,yEAA6B,CAAA;IAC7B,iEAAyB,CAAA;IACzB,mDAAkB,CAAA;AACtB,CAAC,EA/BW,QAAQ,wBAAR,QAAQ,QA+BnB;AAED,IAAY,OAMX;AAND,WAAY,OAAO;IACf,yCAAU,CAAA;IACV,uCAAS,CAAA;IACT,6CAAY,CAAA;IACZ,uCAAS,CAAA;IACT,sCAAS,CAAA;AACb,CAAC,EANW,OAAO,uBAAP,OAAO,QAMlB;AAED,IAAY,WAKX;AALD,WAAY,WAAW;IACnB,+CAAS,CAAA;IACT,uDAAa,CAAA;IACb,6CAAQ,CAAA;IACR,+CAAS,CAAA;AACb,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED,IAAY,UA8EX;AA9ED,WAAY,UAAU;IAClB,iDAAW,CAAA;IACX,+CAAU,CAAA;IACV,6CAAS,CAAA;IACT,qDAAa,CAAA;IACb,2DAAgB,CAAA;IAChB,yDAAe,CAAA;IACf,6CAAS,CAAA;IACT,iDAAW,CAAA;IACX,2CAAQ,CAAA;IACR,+CAAU,CAAA;IACV,4CAAS,CAAA;IACT,oDAAa,CAAA;IACb,8CAAU,CAAA;IACV,0DAAgB,CAAA;IAChB,0DAAgB,CAAA;IAChB,sDAAc,CAAA;IACd,gDAAW,CAAA;IACX,0DAAgB,CAAA;IAChB,0CAAQ,CAAA;IACR,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,0DAAgB,CAAA;IAChB,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,wDAAe,CAAA;IACf,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,wCAAO,CAAA;IACP,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,kDAAY,CAAA;IACZ,oDAAa,CAAA;IACb,0DAAgB,CAAA;IAChB,kDAAY,CAAA;IACZ,oDAAa,CAAA;IACb,wDAAe,CAAA;IACf,8CAAU,CAAA;IACV,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,wDAAe,CAAA;IACf,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,kDAAY,CAAA;IACZ,gDAAW,CAAA;IACX,oDAAa,CAAA;IACb,gEAAmB,CAAA;IACnB,kDAAY,CAAA;IACZ,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,oDAAa,CAAA;IACb,sDAAc,CAAA;IACd,4CAAS,CAAA;IACT,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,gEAAmB,CAAA;IACnB,sDAAc,CAAA;IACd,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,oDAAa,CAAA;IACb,gDAAW,CAAA;IACX,4CAAS,CAAA;IACT,wDAAe,CAAA;AACnB,CAAC,EA9EW,UAAU,0BAAV,UAAU,QA8ErB;AAID,MAAa,kBAAkB;IAO3B,YAAmB,IAAY,EAAS,IAAY,EAAS,MAAc;QAAxD,SAAI,GAAJ,IAAI,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAQ;QAN3E,YAAO,GAAW,CAAC,CAAC,CAAC;QACrB,SAAI,GAAe,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QACtC,UAAK,GAAW,CAAC,CAAC;QAClB,SAAI,GAAW,CAAC,CAAC;QACjB,WAAM,GAAW,CAAC,CAAC;QAGf,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;IAC9B,CAAC;IACD,cAAc,CAAC,IAAY;QACvB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,EAAE;YAC7B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;YAClD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;SACvB;IACL,CAAC;IACD,KAAK,CAAC,KAAiB;QACnB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC,KAAiB;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAChE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;QACnB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,QAAQ;QACJ,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,CAAC,MAAc,EAAE,MAAc;QACjC,QAAQ,MAAM,EAAE;YACZ,KAAK,CAAC,EAAE,WAAW;gBACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBACrB,MAAM;YACV,KAAK,CAAC,EAAE,WAAW;gBACf,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;gBACtB,MAAM;YACV,KAAK,CAAC,EAAE,WAAW;gBACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;gBACjC,MAAM;SACb;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;IACzD,CAAC;IACD,QAAQ;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,gBAAgB;QACZ,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,QAAQ;QACJ,OAAO,MAAM,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC;IAC9J,CAAC;CACJ;AAzDD,gDAyDC;AAED,MAAM,2BAA4B,SAAQ,kBAAkB;IACxD,YAAY,OAAe,EAAE,IAAY,EAAE,IAAY,EAAE,MAAc,EAC3D,MAA6B;QACrC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QADlB,WAAM,GAAN,MAAM,CAAuB;QAErC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,KAAiB;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACJ;AAMD,MAAa,oBAAoB;IAK7B;QAJQ,WAAM,GAA0B,IAAI,CAAC;QACrC,UAAK,GAAoC,IAAI,GAAG,EAAE,CAAC;QACnD,SAAI,GAAoC,IAAI,GAAG,EAAE,CAAC;QAGtD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,SAAS,CAAC,MAAsB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IACD,YAAY,CAAC,IAAY,EAAE,MAAe;QACtC,IAAI,CAAC,MAAM;YAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,qBAAqB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;QACtG,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,CAAC,IAAY,EAAE,IAAyB,EAAE,MAAe;QAC5D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACzC;QACD,IAAI,CAAC,MAAM;YAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,CAAC,IAAY;;QAChB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,GAAG,MAAA,IAAI,CAAC,MAAM,0CAAE,OAAO,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAnCD,oDAmCC;AAED,MAAa,UAAU;IAgBnB;QAfA,uCAAU,CAAC,OAAO;QAClB,sCAAqB;QACrB,uCAAsB;QACtB,2BAAsB,EAAE,EAAC;QACzB,8BAAyB,EAAE,EAAC;QAM5B,QAAG,GAAyB,EAAE,CAAC;QAC/B,WAAM,GAAG,KAAK,CAAC;QACf,UAAK,GAAG,CAAC,CAAC,CAAC;QACX,OAAE,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAG5B,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC9B,CAAC;IACD,eAAe;QACX,IAAI,CAAC,KAAK,GAAG,IAAI,2BAA2B,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACrH,IAAI,CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACzH,IAAI,CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACzH,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,kBAAkB;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC1F,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7F,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7F,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,QAAQ,CAAC,UAA8B;QACnC,uBAAA,IAAI,wBAAa,IAAI,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,MAAA,CAAC;IAClF,CAAC;IACD,QAAQ,CAAC,UAAsB;QAC3B,IAAI,UAAU,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IACD,KAAK,CAAC,SAAS,CAAC,UAAsB;QAClC,IAAI,UAAU,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACvD,uBAAA,IAAI,wBAAa,MAAM,WAAW,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,MAAA,CAAC;IACvF,CAAC;IACD,OAAO,CAAC,IAAc;QAClB,uBAAA,IAAI,oBAAS,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,MAAA,CAAC;IACvE,CAAC;IACD,mBAAmB,CAAC,IAAY;QAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC;IACD,QAAQ,CAAC,IAAY,EAAE,OAAe,EAAE,IAAa;QACjD,IAAI,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,GAAG,OAAO,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1D,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE;YAC7B,IAAI,IAAI,IAAI,IAAI,EAAE;gBACd,IAAI,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE;oBACjC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;iBACrC;qBAAM;oBACH,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,UAAU,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;iBACnE;aACJ;iBAAM;gBACH,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW;oBAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;iBACnB;;oBAAM,OAAO,UAAU,CAAC,KAAK,CAAC;aAClC;SACJ;aAAM;YACH,IAAI,IAAI,IAAI,IAAI;gBAAE,OAAO,UAAU,CAAC,KAAK,CAAC;YAC1C,IAAI,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa;gBAChD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS;oBAAE,OAAO,UAAU,CAAC,KAAK,CAAC;aAC/D;YACD,IAAI,OAAO,GAAG,WAAW,CAAC,IAAI;gBAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,iBAAiB;YAC1E,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW;gBAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;aACnB;iBAAM;gBACH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB;aACtC;SACJ;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI;;QACA,IAAI,CAAC,CAAA,MAAA,uBAAA,IAAI,2BAAS,0CAAE,UAAU,CAAA,EAAE;YAC5B,uBAAA,IAAI,uBAAY,IAAI,UAAU,CAAC,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAA,CAAC;SACxE;QACD,OAAO,uBAAA,IAAI,2BAAS,CAAC;IACzB,CAAC;IACD,KAAK;;QACD,IAAI,CAAC,CAAA,MAAA,uBAAA,IAAI,4BAAU,0CAAE,UAAU,CAAA,EAAE;YAC7B,uBAAA,IAAI,wBAAa,IAAI,UAAU,CAAC,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAA,CAAC;SACzE;QACD,OAAO,uBAAA,IAAI,4BAAU,CAAC;IAC1B,CAAC;IACD,GAAG;QACC,IAAI;YACA,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;aAClB;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,MAAM,GAAG,CAAC;SAC/B;QACD,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IACD,eAAe;QACX,OAAO;YACH,wBAAwB,EAAE,IAAI,CAAC,uBAAuB,EAAE;YACxD,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;SACvB,CAAA;IACL,CAAC;IACD,KAAK,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,GAAW,EAAE,GAAW;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC3B,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,GAAW;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,GAAW;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,GAAW;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IACD,QAAQ,CAAC,GAAW,EAAE,GAAW,EAAE,MAAc;QAC7C,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,QAAQ,CAAC,GAAW,EAAE,MAAc;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;QAClB,4DAA4D;QAC5D,gCAAgC;IACpC,CAAC;IACD,oBAAoB,CAAC,IAAkB,EAAE,SAAiB,EAAE,YAAoB;QAC5E,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,aAAa,CAAC,IAAkB,EAAE,QAAgB,EAAE,YAAoB;QACpE,IAAI,IAAI,GAAG,QAAQ,CAAC;QACpB,IAAI,QAAQ,GAAG,YAAY,CAAC;QAC5B,KAAK,IAAI,GAAG,IAAI,uBAAA,IAAI,wBAAM,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,CAAC;YACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACjC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7B,QAAQ,EAAE,CAAC;aACd;SACJ;IACL,CAAC;IACD,cAAc,CAAC,YAAoB,EAAE,iBAAyB;QAC1D,KAAK,CAAC,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACzD,IAAI,CAAC,oBAAoB,CAAC,uBAAA,IAAI,wBAAM,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACvE,OAAO,CAAC,CAAC;IACb,CAAC;IACD,QAAQ,CAAC,QAAgB,EAAE,YAAoB;QAC3C,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC1C,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,wBAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QACvD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,iBAAiB,CAAC,iBAAyB,EAAE,oBAA4B;QACrE,KAAK,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QACpE,IAAI,CAAC,oBAAoB,CAAC,uBAAA,IAAI,2BAAS,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QAClF,OAAO,CAAC,CAAC;IACb,CAAC;IACD,WAAW,CAAC,WAAmB,EAAE,eAAuB;QACpD,KAAK,CAAC,aAAa,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,2BAAS,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC;IACb,CAAC;IACD,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;YACnD,KAAK,IAAI,GAAG,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACvB;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACjC,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;YACnD,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/B;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9B,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,EAAU,EAAE,MAAc,EAAE,MAAc,EAAE,aAAqB;QACrE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,QAAQ,CAAC,EAAU;QACf,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;YACpB,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,SAAS,CAAC,KAAa;QACnB,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IACD,cAAc,CAAC,EAAU,EAAE,WAAmB;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,gBAAgB,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,CAAC;QACrD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS,EAAE;YACxC,MAAM,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,yBAAyB;YACzD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,aAAa,CAAC,EAAU,EAAE,UAAkB;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,eAAe,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAClD,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;YACtD,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW;YACpD,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB;YAC3D,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,uBAAuB;YACnE,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,mBAAmB,CAAC,EAAU,EAAE,QAAgB,EAAE,QAAgB;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,qBAAqB,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACrD,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC7C,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,KAAK,CAAC;IAC5B,CAAC;IACD,SAAS,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB,EAAE,QAAgB,EACzE,OAAe,EAAE,cAAsB,EAAE,oBAA4B,EACrE,QAAgB,EAAE,MAAc;QAEhC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO,UAAU,CAAC,IAAI,CAAC;QACxC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS;YAAE,OAAO,UAAU,CAAC,MAAM,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAClD,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EACpC,OAAO,EAAE,uCAAuC;QAChD,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,IAAI,OAAO,EAAE,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC,CAAC,YAAY;QACnD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,UAAU,CAAC,GAAW,EAAE,GAAW;QAC/B,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACtB,6BAA6B;YAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;SACxD;QACD,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,iBAAiB,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB,EAAE,QAAgB,EAAE,YAAoB;QACvG,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO,UAAU,CAAC,IAAI,CAAC;QACxC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS;YAAE,OAAO,UAAU,CAAC,MAAM,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,GAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAC,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,EAAE;YAAE,OAAO,UAAU,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;QAC7C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;QACxC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW;QACnD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ;QAC3C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;QAChD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QAC1C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QAC1C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;IAC9C,CAAC;IACD,uBAAuB;QACnB,OAAO;YACH,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpD,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;YACxC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9C,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;YACxD,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpD,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YACtC,mBAAmB,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACzF,UAAU,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACvE,gBAAgB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACnF,cAAc,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SAClF,CAAA;IACL,CAAC;IACD,MAAM;QACF,OAAO;YACH,kBAAkB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SAC9D,CAAA;IACL,CAAC;CACJ;AA3VD,gCA2VC"} \ No newline at end of file +{"version":3,"file":"wasishim.js","sourceRoot":"","sources":["../../../src/common/wasi/wasishim.ts"],"names":[],"mappings":";AACA,4EAA4E;AAC5E,sDAAsD;AACtD,uHAAuH;AACvH,gHAAgH;AAChH,yFAAyF;AACzF,2DAA2D;AAC3D,oDAAoD;;;;;;;;;;;;;;;AAEpD,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;AAE5B,IAAY,MASX;AATD,WAAY,MAAM;IACd,yCAAW,CAAA;IACX,mDAAgB,CAAA;IAChB,2DAAoB,CAAA;IACpB,6CAAa,CAAA;IACb,mDAAgB,CAAA;IAChB,mDAAgB,CAAA;IAChB,qDAAiB,CAAA;IACjB,qDAAiB,CAAA;AACrB,CAAC,EATW,MAAM,sBAAN,MAAM,QASjB;AAED,IAAY,QA+BX;AA/BD,WAAY,QAAQ;IAChB,qDAAe,CAAA;IACf,6CAAW,CAAA;IACX,6CAAW,CAAA;IACX,qEAAuB,CAAA;IACvB,8CAAY,CAAA;IACZ,8CAAY,CAAA;IACZ,gDAAa,CAAA;IACb,mDAAe,CAAA;IACf,uDAAiB,CAAA;IACjB,2EAA2B,CAAA;IAC3B,kEAAuB,CAAA;IACvB,kEAAuB,CAAA;IACvB,kEAAuB,CAAA;IACvB,oDAAgB,CAAA;IAChB,uDAAkB,CAAA;IAClB,6DAAqB,CAAA;IACrB,uEAA0B,CAAA;IAC1B,wEAA2B,CAAA;IAC3B,sEAA0B,CAAA;IAC1B,gFAA+B,CAAA;IAC/B,mFAAiC,CAAA;IACjC,mEAAyB,CAAA;IACzB,6EAA8B,CAAA;IAC9B,+EAA+B,CAAA;IAC/B,8DAAuB,CAAA;IACvB,gFAAgC,CAAA;IAChC,sEAA2B,CAAA;IAC3B,yEAA6B,CAAA;IAC7B,iEAAyB,CAAA;IACzB,mDAAkB,CAAA;AACtB,CAAC,EA/BW,QAAQ,wBAAR,QAAQ,QA+BnB;AAED,IAAY,OAMX;AAND,WAAY,OAAO;IACf,yCAAU,CAAA;IACV,uCAAS,CAAA;IACT,6CAAY,CAAA;IACZ,uCAAS,CAAA;IACT,sCAAS,CAAA;AACb,CAAC,EANW,OAAO,uBAAP,OAAO,QAMlB;AAED,IAAY,WAKX;AALD,WAAY,WAAW;IACnB,+CAAS,CAAA;IACT,uDAAa,CAAA;IACb,6CAAQ,CAAA;IACR,+CAAS,CAAA;AACb,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED,IAAY,UA8EX;AA9ED,WAAY,UAAU;IAClB,iDAAW,CAAA;IACX,+CAAU,CAAA;IACV,6CAAS,CAAA;IACT,qDAAa,CAAA;IACb,2DAAgB,CAAA;IAChB,yDAAe,CAAA;IACf,6CAAS,CAAA;IACT,iDAAW,CAAA;IACX,2CAAQ,CAAA;IACR,+CAAU,CAAA;IACV,4CAAS,CAAA;IACT,oDAAa,CAAA;IACb,8CAAU,CAAA;IACV,0DAAgB,CAAA;IAChB,0DAAgB,CAAA;IAChB,sDAAc,CAAA;IACd,gDAAW,CAAA;IACX,0DAAgB,CAAA;IAChB,0CAAQ,CAAA;IACR,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,0DAAgB,CAAA;IAChB,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,wDAAe,CAAA;IACf,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,wCAAO,CAAA;IACP,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,kDAAY,CAAA;IACZ,oDAAa,CAAA;IACb,0DAAgB,CAAA;IAChB,kDAAY,CAAA;IACZ,oDAAa,CAAA;IACb,wDAAe,CAAA;IACf,8CAAU,CAAA;IACV,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,wDAAe,CAAA;IACf,8CAAU,CAAA;IACV,8CAAU,CAAA;IACV,kDAAY,CAAA;IACZ,gDAAW,CAAA;IACX,oDAAa,CAAA;IACb,gEAAmB,CAAA;IACnB,kDAAY,CAAA;IACZ,gDAAW,CAAA;IACX,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,oDAAa,CAAA;IACb,sDAAc,CAAA;IACd,4CAAS,CAAA;IACT,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,gEAAmB,CAAA;IACnB,sDAAc,CAAA;IACd,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,4CAAS,CAAA;IACT,8CAAU,CAAA;IACV,oDAAa,CAAA;IACb,gDAAW,CAAA;IACX,4CAAS,CAAA;IACT,wDAAe,CAAA;AACnB,CAAC,EA9EW,UAAU,0BAAV,UAAU,QA8ErB;AAID,MAAa,kBAAkB;IAO3B,YAAmB,IAAY,EAAS,IAAY,EAAS,MAAc;QAAxD,SAAI,GAAJ,IAAI,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAQ;QAN3E,YAAO,GAAW,CAAC,CAAC,CAAC;QACrB,SAAI,GAAe,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QACtC,UAAK,GAAW,CAAC,CAAC;QAClB,SAAI,GAAW,CAAC,CAAC;QACjB,WAAM,GAAW,CAAC,CAAC;QAGf,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;IAC9B,CAAC;IACD,cAAc,CAAC,IAAY;QACvB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,EAAE;YAC7B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;YAClD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;SACvB;IACL,CAAC;IACD,KAAK,CAAC,KAAiB;QACnB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,CAAC,KAAiB;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAChE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;QACnB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,QAAQ;QACJ,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,CAAC,MAAc,EAAE,MAAc;QACjC,QAAQ,MAAM,EAAE;YACZ,KAAK,CAAC,EAAE,WAAW;gBACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBACrB,MAAM;YACV,KAAK,CAAC,EAAE,WAAW;gBACf,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;gBACtB,MAAM;YACV,KAAK,CAAC,EAAE,WAAW;gBACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;gBACjC,MAAM;SACb;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;IACzD,CAAC;IACD,QAAQ;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,gBAAgB;QACZ,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,QAAQ;QACJ,OAAO,MAAM,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC;IAC9J,CAAC;CACJ;AAzDD,gDAyDC;AAED,MAAM,2BAA4B,SAAQ,kBAAkB;IACxD,YAAY,OAAe,EAAE,IAAY,EAAE,IAAY,EAAE,MAAc,EAC3D,MAA6B;QACrC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QADlB,WAAM,GAAN,MAAM,CAAuB;QAErC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,KAAiB;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACJ;AAMD,MAAa,oBAAoB;IAK7B;QAJQ,WAAM,GAA0B,IAAI,CAAC;QACrC,UAAK,GAAoC,IAAI,GAAG,EAAE,CAAC;QACnD,SAAI,GAAoC,IAAI,GAAG,EAAE,CAAC;QAGtD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,SAAS,CAAC,MAAsB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IACD,YAAY,CAAC,IAAY,EAAE,MAAe;QACtC,IAAI,CAAC,MAAM;YAAE,MAAM,GAAG,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,qBAAqB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;QACtG,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACzB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,CAAC,IAAY,EAAE,IAAyB,EAAE,MAAe;QAC5D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACzC;QACD,IAAI,CAAC,MAAM;YAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,CAAC,IAAY;;QAChB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE;YACP,IAAI,GAAG,MAAA,IAAI,CAAC,MAAM,0CAAE,OAAO,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAnCD,oDAmCC;AAED,MAAa,UAAU;IAgBnB;QAfA,uCAAgB,CAAC,OAAO;QACxB,sCAAqB;QACrB,uCAAsB;QACtB,2BAAsB,EAAE,EAAC;QACzB,8BAAyB,EAAE,EAAC;QAM5B,QAAG,GAAyB,EAAE,CAAC;QAC/B,WAAM,GAAG,KAAK,CAAC;QACf,UAAK,GAAG,CAAC,CAAC,CAAC;QACX,OAAE,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAG5B,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO;QACH,OAAO,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC;IAClC,CAAC;IACD,eAAe;QACX,IAAI,CAAC,KAAK,GAAG,IAAI,2BAA2B,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACrH,IAAI,CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACzH,IAAI,CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACzH,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,kBAAkB;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC1F,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7F,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC7F,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,QAAQ,CAAC,UAA8B;QACnC,uBAAA,IAAI,wBAAa,IAAI,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,MAAA,CAAC;IAClF,CAAC;IACD,QAAQ,CAAC,UAAsB;QAC3B,IAAI,UAAU,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IACD,KAAK,CAAC,SAAS,CAAC,UAAsB;QAClC,IAAI,UAAU,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACvD,uBAAA,IAAI,wBAAa,MAAM,WAAW,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,MAAA,CAAC;IACvF,CAAC;IACD,OAAO,CAAC,IAAc;QAClB,uBAAA,IAAI,oBAAS,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,MAAA,CAAC;IACvE,CAAC;IACD,mBAAmB,CAAC,IAAY;QAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC;IACD,QAAQ,CAAC,IAAY,EAAE,OAAe,EAAE,IAAa;QACjD,IAAI,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,GAAG,OAAO,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1D,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE;YAC7B,IAAI,IAAI,IAAI,IAAI,EAAE;gBACd,IAAI,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE;oBACjC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;iBACrC;qBAAM;oBACH,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,UAAU,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;iBACnE;aACJ;iBAAM;gBACH,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW;oBAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;iBACnB;;oBAAM,OAAO,UAAU,CAAC,KAAK,CAAC;aAClC;SACJ;aAAM;YACH,IAAI,IAAI,IAAI,IAAI;gBAAE,OAAO,UAAU,CAAC,KAAK,CAAC;YAC1C,IAAI,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa;gBAChD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS;oBAAE,OAAO,UAAU,CAAC,KAAK,CAAC;aAC/D;YACD,IAAI,OAAO,GAAG,WAAW,CAAC,IAAI;gBAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,iBAAiB;YAC1E,IAAI,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW;gBAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;aACnB;iBAAM;gBACH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB;aACtC;SACJ;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI;;QACA,IAAI,CAAC,CAAA,MAAA,uBAAA,IAAI,2BAAS,0CAAE,UAAU,CAAA,EAAE;YAC5B,uBAAA,IAAI,uBAAY,IAAI,UAAU,CAAC,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAA,CAAC;SACxE;QACD,OAAO,uBAAA,IAAI,2BAAS,CAAC;IACzB,CAAC;IACD,KAAK;;QACD,IAAI,CAAC,CAAA,MAAA,uBAAA,IAAI,4BAAU,0CAAE,UAAU,CAAA,EAAE;YAC7B,uBAAA,IAAI,wBAAa,IAAI,UAAU,CAAC,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAA,CAAC;SACzE;QACD,OAAO,uBAAA,IAAI,4BAAU,CAAC;IAC1B,CAAC;IACD,GAAG;QACC,IAAI;YACA,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;aAClB;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,MAAM,GAAG,CAAC;SAC/B;QACD,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IACD,UAAU;QACN,uBAAA,IAAI,4BAAU,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IACD,eAAe;QACX,OAAO;YACH,wBAAwB,EAAE,IAAI,CAAC,uBAAuB,EAAE;YACxD,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;SACvB,CAAA;IACL,CAAC;IACD,KAAK,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,GAAW,EAAE,GAAW;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC3B,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,GAAW;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,GAAW;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;IAClC,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,GAAW;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IACD,QAAQ,CAAC,GAAW,EAAE,GAAW,EAAE,MAAc;QAC7C,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,QAAQ,CAAC,GAAW,EAAE,MAAc;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;QAClB,4DAA4D;QAC5D,gCAAgC;IACpC,CAAC;IACD,oBAAoB,CAAC,IAAkB,EAAE,SAAiB,EAAE,YAAoB;QAC5E,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IACD,aAAa,CAAC,IAAkB,EAAE,QAAgB,EAAE,YAAoB;QACpE,IAAI,IAAI,GAAG,QAAQ,CAAC;QACpB,IAAI,QAAQ,GAAG,YAAY,CAAC;QAC5B,KAAK,IAAI,GAAG,IAAI,uBAAA,IAAI,wBAAM,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,CAAC;YACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACjC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7B,QAAQ,EAAE,CAAC;aACd;SACJ;IACL,CAAC;IACD,cAAc,CAAC,YAAoB,EAAE,iBAAyB;QAC1D,KAAK,CAAC,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACzD,IAAI,CAAC,oBAAoB,CAAC,uBAAA,IAAI,wBAAM,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACvE,OAAO,CAAC,CAAC;IACb,CAAC;IACD,QAAQ,CAAC,QAAgB,EAAE,YAAoB;QAC3C,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC1C,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,wBAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QACvD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,iBAAiB,CAAC,iBAAyB,EAAE,oBAA4B;QACrE,KAAK,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QACpE,IAAI,CAAC,oBAAoB,CAAC,uBAAA,IAAI,2BAAS,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;QAClF,OAAO,CAAC,CAAC;IACb,CAAC;IACD,WAAW,CAAC,WAAmB,EAAE,eAAuB;QACpD,KAAK,CAAC,aAAa,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,2BAAS,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC;IACb,CAAC;IACD,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY;QACrC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;YACnD,KAAK,IAAI,GAAG,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACvB;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACjC,KAAK,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;YACnD,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/B;QACD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9B,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,EAAU,EAAE,MAAc,EAAE,MAAc,EAAE,aAAqB;QACrE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,OAAO,MAAM,IAAI,QAAQ;YAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACvD,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,QAAQ,CAAC,EAAU;QACf,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;YACpB,OAAO,CAAC,CAAC;SACZ;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,SAAS,CAAC,KAAa;QACnB,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IACD,cAAc,CAAC,EAAU,EAAE,WAAmB;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,gBAAgB,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,CAAC;QACrD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS,EAAE;YACxC,MAAM,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrD,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,yBAAyB;YACzD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,aAAa,CAAC,EAAU,EAAE,UAAkB;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,eAAe,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAClD,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;YACtD,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW;YACpD,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB;YAC3D,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAE,uBAAuB;YACnE,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3B,CAAC;IACD,mBAAmB,CAAC,EAAU,EAAE,QAAgB,EAAE,QAAgB;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,CAAC,qBAAqB,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACrD,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC7C,OAAO,UAAU,CAAC,OAAO,CAAC;SAC7B;QACD,OAAO,UAAU,CAAC,KAAK,CAAC;IAC5B,CAAC;IACD,SAAS,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB,EAAE,QAAgB,EACzE,OAAe,EAAE,cAAsB,EAAE,oBAA4B,EACrE,QAAgB,EAAE,MAAc;QAEhC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO,UAAU,CAAC,IAAI,CAAC;QACxC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS;YAAE,OAAO,UAAU,CAAC,MAAM,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAClD,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EACpC,OAAO,EAAE,uCAAuC;QAChD,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,IAAI,OAAO,EAAE,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC,CAAC,YAAY;QACnD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,UAAU,CAAC,GAAW,EAAE,GAAW;QAC/B,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACtB,6BAA6B;YAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;SACxD;QACD,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,iBAAiB,CAAC,KAAa,EAAE,QAAgB,EAAE,QAAgB,EAAE,QAAgB,EAAE,YAAoB;QACvG,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO,UAAU,CAAC,IAAI,CAAC;QACxC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,SAAS;YAAE,OAAO,UAAU,CAAC,MAAM,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,GAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAC,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,EAAE;YAAE,OAAO,UAAU,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;QAC7C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM;QACxC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW;QACnD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ;QAC3C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;QAChD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QAC1C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;QAC1C,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;IAC9C,CAAC;IACD,uBAAuB;QACnB,OAAO;YACH,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9C,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpD,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;YACxC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YACpC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9C,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;YACxD,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpD,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YACtC,mBAAmB,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACzF,UAAU,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACvE,gBAAgB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YACnF,cAAc,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/E,OAAO,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACpE,CAAA;IACL,CAAC;IACD,MAAM;QACF,OAAO;YACH,kBAAkB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SAC9E,CAAA;IACL,CAAC;CACJ;AApWD,gCAoWC"} \ No newline at end of file diff --git a/gen/server/server.js b/gen/server/server.js index 0d665a6a..25e586fe 100644 --- a/gen/server/server.js +++ b/gen/server/server.js @@ -19,24 +19,6 @@ var __reExport = (target, module2, desc) => { var __toModule = (module2) => { return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); }; -var __accessCheck = (obj, member, msg) => { - if (!member.has(obj)) - throw TypeError("Cannot " + msg); -}; -var __privateGet = (obj, member, getter) => { - __accessCheck(obj, member, "read from private field"); - return getter ? getter.call(obj) : member.get(obj); -}; -var __privateAdd = (obj, member, value) => { - if (member.has(obj)) - throw TypeError("Cannot add the same private member more than once"); - member instanceof WeakSet ? member.add(obj) : member.set(obj, value); -}; -var __privateSet = (obj, member, value, setter) => { - __accessCheck(obj, member, "write to private field"); - setter ? setter.call(obj, value) : member.set(obj, value); - return value; -}; // node_modules/depd/index.js var require_depd = __commonJS({ @@ -1036,15 +1018,15 @@ var require_debug = __commonJS({ return exports2.colors[Math.abs(hash) % exports2.colors.length]; } function createDebug(namespace) { - function debug3() { - if (!debug3.enabled) + function debug() { + if (!debug.enabled) return; - var self2 = debug3; + var self = debug; var curr = +new Date(); var ms = curr - (prevTime || curr); - self2.diff = ms; - self2.prev = prevTime; - self2.curr = curr; + self.diff = ms; + self.prev = prevTime; + self.curr = curr; prevTime = curr; var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { @@ -1062,24 +1044,24 @@ var require_debug = __commonJS({ var formatter = exports2.formatters[format]; if (typeof formatter === "function") { var val = args[index]; - match = formatter.call(self2, val); + match = formatter.call(self, val); args.splice(index, 1); index--; } return match; }); - exports2.formatArgs.call(self2, args); - var logFn = debug3.log || exports2.log || console.log.bind(console); - logFn.apply(self2, args); + exports2.formatArgs.call(self, args); + var logFn = debug.log || exports2.log || console.log.bind(console); + logFn.apply(self, args); } - debug3.namespace = namespace; - debug3.enabled = exports2.enabled(namespace); - debug3.useColors = exports2.useColors(); - debug3.color = selectColor(namespace); + debug.namespace = namespace; + debug.enabled = exports2.enabled(namespace); + debug.useColors = exports2.useColors(); + debug.color = selectColor(namespace); if (typeof exports2.init === "function") { - exports2.init(debug3); + exports2.init(debug); } - return debug3; + return debug; } function enable(namespaces) { exports2.save(namespaces); @@ -1130,7 +1112,7 @@ var require_browser = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.storage = typeof chrome != "undefined" && typeof chrome.storage != "undefined" ? chrome.storage.local : localstorage(); exports2.colors = [ @@ -1186,7 +1168,7 @@ var require_browser = __commonJS({ } catch (e) { } } - function load2() { + function load() { var r; try { r = exports2.storage.debug; @@ -1197,7 +1179,7 @@ var require_browser = __commonJS({ } return r; } - exports2.enable(load2()); + exports2.enable(load()); function localstorage() { try { return window.localStorage; @@ -1217,7 +1199,7 @@ var require_node = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.colors = [6, 2, 3, 4, 5, 1]; exports2.inspectOpts = Object.keys(process.env).filter(function(key) { @@ -1279,7 +1261,7 @@ var require_node = __commonJS({ process.env.DEBUG = namespaces; } } - function load2() { + function load() { return process.env.DEBUG; } function createWritableStdioStream(fd2) { @@ -1320,14 +1302,14 @@ var require_node = __commonJS({ stream2._isStdio = true; return stream2; } - function init(debug3) { - debug3.inspectOpts = {}; + function init(debug) { + debug.inspectOpts = {}; var keys = Object.keys(exports2.inspectOpts); for (var i = 0; i < keys.length; i++) { - debug3.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; + debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; } } - exports2.enable(load2()); + exports2.enable(load()); } }); @@ -8515,7 +8497,7 @@ var require_read = __commonJS({ var unpipe = require_unpipe(); var zlib = require("zlib"); module2.exports = read; - function read(req, res, next, parse, debug3, options) { + function read(req, res, next, parse, debug, options) { var length; var opts = options; var stream; @@ -8523,7 +8505,7 @@ var require_read = __commonJS({ var encoding = opts.encoding !== null ? opts.encoding : null; var verify = opts.verify; try { - stream = contentstream(req, debug3, opts.inflate); + stream = contentstream(req, debug, opts.inflate); length = stream.length; stream.length = void 0; } catch (err) { @@ -8537,7 +8519,7 @@ var require_read = __commonJS({ type: "charset.unsupported" })); } - debug3("read body"); + debug("read body"); getBody(stream, opts, function(error, body) { if (error) { var _error; @@ -8560,7 +8542,7 @@ var require_read = __commonJS({ } if (verify) { try { - debug3("verify body"); + debug("verify body"); verify(req, res, body, encoding); } catch (err) { next(createError(403, err, { @@ -8572,7 +8554,7 @@ var require_read = __commonJS({ } var str = body; try { - debug3("parse body"); + debug("parse body"); str = typeof body !== "string" && encoding !== null ? iconv.decode(body, encoding) : body; req.body = parse(str); } catch (err) { @@ -8585,11 +8567,11 @@ var require_read = __commonJS({ next(); }); } - function contentstream(req, debug3, inflate) { + function contentstream(req, debug, inflate) { var encoding = (req.headers["content-encoding"] || "identity").toLowerCase(); var length = req.headers["content-length"]; var stream; - debug3('content-encoding "%s"', encoding); + debug('content-encoding "%s"', encoding); if (inflate === false && encoding !== "identity") { throw createError(415, "content encoding unsupported", { encoding, @@ -8599,12 +8581,12 @@ var require_read = __commonJS({ switch (encoding) { case "deflate": stream = zlib.createInflate(); - debug3("inflate body"); + debug("inflate body"); req.pipe(stream); break; case "gzip": stream = zlib.createGunzip(); - debug3("gunzip body"); + debug("gunzip body"); req.pipe(stream); break; case "identity": @@ -17489,7 +17471,7 @@ var require_json = __commonJS({ var bytes = require_bytes(); var contentType = require_content_type(); var createError = require_http_errors(); - var debug3 = require_src()("body-parser:json"); + var debug = require_src()("body-parser:json"); var read = require_read(); var typeis = require_type_is(); module2.exports = json; @@ -17513,12 +17495,12 @@ var require_json = __commonJS({ if (strict) { var first = firstchar(body); if (first !== "{" && first !== "[") { - debug3("strict violation"); + debug("strict violation"); throw createStrictSyntaxError(body, first); } } try { - debug3("parse json"); + debug("parse json"); return JSON.parse(body, reviver); } catch (e) { throw normalizeJsonSyntaxError(e, { @@ -17529,32 +17511,32 @@ var require_json = __commonJS({ } return function jsonParser(req, res, next) { if (req._body) { - debug3("body already parsed"); + debug("body already parsed"); next(); return; } req.body = req.body || {}; if (!typeis.hasBody(req)) { - debug3("skip empty body"); + debug("skip empty body"); next(); return; } - debug3("content-type %j", req.headers["content-type"]); + debug("content-type %j", req.headers["content-type"]); if (!shouldParse(req)) { - debug3("skip parsing"); + debug("skip parsing"); next(); return; } var charset = getCharset(req) || "utf-8"; if (charset.slice(0, 4) !== "utf-") { - debug3("invalid charset"); + debug("invalid charset"); next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { charset, type: "charset.unsupported" })); return; } - read(req, res, next, parse, debug3, { + read(req, res, next, parse, debug, { encoding: charset, inflate, limit, @@ -17611,7 +17593,7 @@ var require_raw = __commonJS({ "node_modules/body-parser/lib/types/raw.js"(exports2, module2) { "use strict"; var bytes = require_bytes(); - var debug3 = require_src()("body-parser:raw"); + var debug = require_src()("body-parser:raw"); var read = require_read(); var typeis = require_type_is(); module2.exports = raw; @@ -17630,23 +17612,23 @@ var require_raw = __commonJS({ } return function rawParser(req, res, next) { if (req._body) { - debug3("body already parsed"); + debug("body already parsed"); next(); return; } req.body = req.body || {}; if (!typeis.hasBody(req)) { - debug3("skip empty body"); + debug("skip empty body"); next(); return; } - debug3("content-type %j", req.headers["content-type"]); + debug("content-type %j", req.headers["content-type"]); if (!shouldParse(req)) { - debug3("skip parsing"); + debug("skip parsing"); next(); return; } - read(req, res, next, parse, debug3, { + read(req, res, next, parse, debug, { encoding: null, inflate, limit, @@ -17668,7 +17650,7 @@ var require_text = __commonJS({ "use strict"; var bytes = require_bytes(); var contentType = require_content_type(); - var debug3 = require_src()("body-parser:text"); + var debug = require_src()("body-parser:text"); var read = require_read(); var typeis = require_type_is(); module2.exports = text; @@ -17688,24 +17670,24 @@ var require_text = __commonJS({ } return function textParser(req, res, next) { if (req._body) { - debug3("body already parsed"); + debug("body already parsed"); next(); return; } req.body = req.body || {}; if (!typeis.hasBody(req)) { - debug3("skip empty body"); + debug("skip empty body"); next(); return; } - debug3("content-type %j", req.headers["content-type"]); + debug("content-type %j", req.headers["content-type"]); if (!shouldParse(req)) { - debug3("skip parsing"); + debug("skip parsing"); next(); return; } var charset = getCharset(req) || defaultCharset; - read(req, res, next, parse, debug3, { + read(req, res, next, parse, debug, { encoding: charset, inflate, limit, @@ -18582,7 +18564,7 @@ var require_object_inspect = __commonJS({ } return "[ " + $join.call(xs, ", ") + " ]"; } - if (isError2(obj)) { + if (isError(obj)) { var parts = arrObjKeys(obj, inspect); if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) { return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect(obj.cause), parts), ", ") + " }"; @@ -18671,7 +18653,7 @@ var require_object_inspect = __commonJS({ function isRegExp(obj) { return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj)); } - function isError2(obj) { + function isError(obj) { return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj)); } function isString(obj) { @@ -19714,7 +19696,7 @@ var require_urlencoded = __commonJS({ var bytes = require_bytes(); var contentType = require_content_type(); var createError = require_http_errors(); - var debug3 = require_src()("body-parser:urlencoded"); + var debug = require_src()("body-parser:urlencoded"); var deprecate = require_depd()("body-parser"); var read = require_read(); var typeis = require_type_is(); @@ -19740,33 +19722,33 @@ var require_urlencoded = __commonJS({ } return function urlencodedParser(req, res, next) { if (req._body) { - debug3("body already parsed"); + debug("body already parsed"); next(); return; } req.body = req.body || {}; if (!typeis.hasBody(req)) { - debug3("skip empty body"); + debug("skip empty body"); next(); return; } - debug3("content-type %j", req.headers["content-type"]); + debug("content-type %j", req.headers["content-type"]); if (!shouldParse(req)) { - debug3("skip parsing"); + debug("skip parsing"); next(); return; } var charset = getCharset(req) || "utf-8"; if (charset !== "utf-8") { - debug3("invalid charset"); + debug("invalid charset"); next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { charset, type: "charset.unsupported" })); return; } - read(req, res, next, parse, debug3, { - debug: debug3, + read(req, res, next, parse, debug, { + debug, encoding: charset, inflate, limit, @@ -19786,13 +19768,13 @@ var require_urlencoded = __commonJS({ return function queryparse(body) { var paramCount = parameterCount(body, parameterLimit); if (paramCount === void 0) { - debug3("too many parameters"); + debug("too many parameters"); throw createError(413, "too many parameters", { type: "parameters.too.many" }); } var arrayLimit = Math.max(100, paramCount); - debug3("parse extended urlencoding"); + debug("parse extended urlencoding"); return parse(body, { allowPrototypes: true, arrayLimit, @@ -19848,12 +19830,12 @@ var require_urlencoded = __commonJS({ return function queryparse(body) { var paramCount = parameterCount(body, parameterLimit); if (paramCount === void 0) { - debug3("too many parameters"); + debug("too many parameters"); throw createError(413, "too many parameters", { type: "parameters.too.many" }); } - debug3("parse urlencoding"); + debug("parse urlencoding"); return parse(body, void 0, void 0, { maxKeys: parameterLimit }); }; } @@ -20088,15 +20070,15 @@ var require_debug2 = __commonJS({ return exports2.colors[Math.abs(hash) % exports2.colors.length]; } function createDebug(namespace) { - function debug3() { - if (!debug3.enabled) + function debug() { + if (!debug.enabled) return; - var self2 = debug3; + var self = debug; var curr = +new Date(); var ms = curr - (prevTime || curr); - self2.diff = ms; - self2.prev = prevTime; - self2.curr = curr; + self.diff = ms; + self.prev = prevTime; + self.curr = curr; prevTime = curr; var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { @@ -20114,24 +20096,24 @@ var require_debug2 = __commonJS({ var formatter = exports2.formatters[format]; if (typeof formatter === "function") { var val = args[index]; - match = formatter.call(self2, val); + match = formatter.call(self, val); args.splice(index, 1); index--; } return match; }); - exports2.formatArgs.call(self2, args); - var logFn = debug3.log || exports2.log || console.log.bind(console); - logFn.apply(self2, args); + exports2.formatArgs.call(self, args); + var logFn = debug.log || exports2.log || console.log.bind(console); + logFn.apply(self, args); } - debug3.namespace = namespace; - debug3.enabled = exports2.enabled(namespace); - debug3.useColors = exports2.useColors(); - debug3.color = selectColor(namespace); + debug.namespace = namespace; + debug.enabled = exports2.enabled(namespace); + debug.useColors = exports2.useColors(); + debug.color = selectColor(namespace); if (typeof exports2.init === "function") { - exports2.init(debug3); + exports2.init(debug); } - return debug3; + return debug; } function enable(namespaces) { exports2.save(namespaces); @@ -20182,7 +20164,7 @@ var require_browser2 = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.storage = typeof chrome != "undefined" && typeof chrome.storage != "undefined" ? chrome.storage.local : localstorage(); exports2.colors = [ @@ -20238,7 +20220,7 @@ var require_browser2 = __commonJS({ } catch (e) { } } - function load2() { + function load() { var r; try { r = exports2.storage.debug; @@ -20249,7 +20231,7 @@ var require_browser2 = __commonJS({ } return r; } - exports2.enable(load2()); + exports2.enable(load()); function localstorage() { try { return window.localStorage; @@ -20269,7 +20251,7 @@ var require_node2 = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.colors = [6, 2, 3, 4, 5, 1]; exports2.inspectOpts = Object.keys(process.env).filter(function(key) { @@ -20331,7 +20313,7 @@ var require_node2 = __commonJS({ process.env.DEBUG = namespaces; } } - function load2() { + function load() { return process.env.DEBUG; } function createWritableStdioStream(fd2) { @@ -20372,14 +20354,14 @@ var require_node2 = __commonJS({ stream2._isStdio = true; return stream2; } - function init(debug3) { - debug3.inspectOpts = {}; + function init(debug) { + debug.inspectOpts = {}; var keys = Object.keys(exports2.inspectOpts); for (var i = 0; i < keys.length; i++) { - debug3.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; + debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; } } - exports2.enable(load2()); + exports2.enable(load()); } }); @@ -20537,7 +20519,7 @@ var require_parseurl = __commonJS({ var require_finalhandler = __commonJS({ "node_modules/finalhandler/index.js"(exports2, module2) { "use strict"; - var debug3 = require_src2()("finalhandler"); + var debug = require_src2()("finalhandler"); var encodeUrl = require_encodeurl(); var escapeHtml = require_escape_html(); var onFinished = require_on_finished(); @@ -20564,7 +20546,7 @@ var require_finalhandler = __commonJS({ var msg; var status; if (!err && headersSent(res)) { - debug3("cannot 404 after headers sent"); + debug("cannot 404 after headers sent"); return; } if (err) { @@ -20579,12 +20561,12 @@ var require_finalhandler = __commonJS({ status = 404; msg = "Cannot " + req.method + " " + encodeUrl(getResourceName(req)); } - debug3("default %s", status); + debug("default %s", status); if (err && onerror) { defer(onerror, err, req, res); } if (headersSent(res)) { - debug3("cannot %d after headers sent", status); + debug("cannot %d after headers sent", status); req.socket.destroy(); return; } @@ -20799,15 +20781,15 @@ var require_debug3 = __commonJS({ return exports2.colors[Math.abs(hash) % exports2.colors.length]; } function createDebug(namespace) { - function debug3() { - if (!debug3.enabled) + function debug() { + if (!debug.enabled) return; - var self2 = debug3; + var self = debug; var curr = +new Date(); var ms = curr - (prevTime || curr); - self2.diff = ms; - self2.prev = prevTime; - self2.curr = curr; + self.diff = ms; + self.prev = prevTime; + self.curr = curr; prevTime = curr; var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { @@ -20825,24 +20807,24 @@ var require_debug3 = __commonJS({ var formatter = exports2.formatters[format]; if (typeof formatter === "function") { var val = args[index]; - match = formatter.call(self2, val); + match = formatter.call(self, val); args.splice(index, 1); index--; } return match; }); - exports2.formatArgs.call(self2, args); - var logFn = debug3.log || exports2.log || console.log.bind(console); - logFn.apply(self2, args); + exports2.formatArgs.call(self, args); + var logFn = debug.log || exports2.log || console.log.bind(console); + logFn.apply(self, args); } - debug3.namespace = namespace; - debug3.enabled = exports2.enabled(namespace); - debug3.useColors = exports2.useColors(); - debug3.color = selectColor(namespace); + debug.namespace = namespace; + debug.enabled = exports2.enabled(namespace); + debug.useColors = exports2.useColors(); + debug.color = selectColor(namespace); if (typeof exports2.init === "function") { - exports2.init(debug3); + exports2.init(debug); } - return debug3; + return debug; } function enable(namespaces) { exports2.save(namespaces); @@ -20893,7 +20875,7 @@ var require_browser3 = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.storage = typeof chrome != "undefined" && typeof chrome.storage != "undefined" ? chrome.storage.local : localstorage(); exports2.colors = [ @@ -20949,7 +20931,7 @@ var require_browser3 = __commonJS({ } catch (e) { } } - function load2() { + function load() { var r; try { r = exports2.storage.debug; @@ -20960,7 +20942,7 @@ var require_browser3 = __commonJS({ } return r; } - exports2.enable(load2()); + exports2.enable(load()); function localstorage() { try { return window.localStorage; @@ -20980,7 +20962,7 @@ var require_node3 = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.colors = [6, 2, 3, 4, 5, 1]; exports2.inspectOpts = Object.keys(process.env).filter(function(key) { @@ -21042,7 +21024,7 @@ var require_node3 = __commonJS({ process.env.DEBUG = namespaces; } } - function load2() { + function load() { return process.env.DEBUG; } function createWritableStdioStream(fd2) { @@ -21083,14 +21065,14 @@ var require_node3 = __commonJS({ stream2._isStdio = true; return stream2; } - function init(debug3) { - debug3.inspectOpts = {}; + function init(debug) { + debug.inspectOpts = {}; var keys = Object.keys(exports2.inspectOpts); for (var i = 0; i < keys.length; i++) { - debug3.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; + debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; } } - exports2.enable(load2()); + exports2.enable(load()); } }); @@ -21222,14 +21204,14 @@ var require_layer = __commonJS({ "node_modules/express/lib/router/layer.js"(exports2, module2) { "use strict"; var pathRegexp = require_path_to_regexp(); - var debug3 = require_src3()("express:router:layer"); + var debug = require_src3()("express:router:layer"); var hasOwnProperty = Object.prototype.hasOwnProperty; module2.exports = Layer; function Layer(path4, options, fn) { if (!(this instanceof Layer)) { return new Layer(path4, options, fn); } - debug3("new %o", path4); + debug("new %o", path4); var opts = options || {}; this.handle = fn; this.name = fn.name || ""; @@ -21360,7 +21342,7 @@ var require_methods = __commonJS({ var require_route = __commonJS({ "node_modules/express/lib/router/route.js"(exports2, module2) { "use strict"; - var debug3 = require_src3()("express:router:route"); + var debug = require_src3()("express:router:route"); var flatten = require_array_flatten(); var Layer = require_layer(); var methods = require_methods(); @@ -21370,7 +21352,7 @@ var require_route = __commonJS({ function Route(path4) { this.path = path4; this.stack = []; - debug3("new %o", path4); + debug("new %o", path4); this.methods = {}; } Route.prototype._handles_method = function _handles_method(method) { @@ -21456,7 +21438,7 @@ var require_route = __commonJS({ var msg = "Route." + method + "() requires a callback function but got a " + type; throw new Error(msg); } - debug3("%s %o", method, this.path); + debug("%s %o", method, this.path); var layer = Layer("/", {}, handle); layer.method = method; this.methods[method] = true; @@ -21490,7 +21472,7 @@ var require_router = __commonJS({ var Layer = require_layer(); var methods = require_methods(); var mixin = require_utils_merge(); - var debug3 = require_src3()("express:router"); + var debug = require_src3()("express:router"); var deprecate = require_depd()("express"); var flatten = require_array_flatten(); var parseUrl = require_parseurl(); @@ -21537,8 +21519,8 @@ var require_router = __commonJS({ return this; }; proto.handle = function handle(req, res, out) { - var self2 = this; - debug3("dispatching %s %s", req.method, req.url); + var self = this; + debug("dispatching %s %s", req.method, req.url); var idx = 0; var protohost = getProtohost(req.url) || ""; var removed = ""; @@ -21546,7 +21528,7 @@ var require_router = __commonJS({ var sync = 0; var paramcalled = {}; var options = []; - var stack = self2.stack; + var stack = self.stack; var parentParams = req.params; var parentUrl = req.baseUrl || ""; var done = restore(out, req, "baseUrl", "next", "params"); @@ -21622,9 +21604,9 @@ var require_router = __commonJS({ if (route) { req.route = route; } - req.params = self2.mergeParams ? mergeParams(layer.params, parentParams) : layer.params; + req.params = self.mergeParams ? mergeParams(layer.params, parentParams) : layer.params; var layerPath = layer.path; - self2.process_params(layer, paramcalled, req, res, function(err2) { + self.process_params(layer, paramcalled, req, res, function(err2) { if (err2) { next(layerError || err2); } else if (route) { @@ -21644,7 +21626,7 @@ var require_router = __commonJS({ var c = path4[layerPath.length]; if (c && c !== "/" && c !== ".") return next(layerError); - debug3("trim prefix (%s) from url %s", layerPath, req.url); + debug("trim prefix (%s) from url %s", layerPath, req.url); removed = layerPath; req.url = protohost + req.url.slice(protohost.length + removed.length); if (!protohost && req.url[0] !== "/") { @@ -21653,7 +21635,7 @@ var require_router = __commonJS({ } req.baseUrl = parentUrl + (removed[removed.length - 1] === "/" ? removed.substring(0, removed.length - 1) : removed); } - debug3("%s %s : %s", layer.name, layerPath, req.originalUrl); + debug("%s %s : %s", layer.name, layerPath, req.originalUrl); if (layerError) { layer.handle_error(layerError, req, res, next); } else { @@ -21741,7 +21723,7 @@ var require_router = __commonJS({ if (typeof fn !== "function") { throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn)); } - debug3("use %o %s", path4, fn.name || ""); + debug("use %o %s", path4, fn.name || ""); var layer = new Layer(path4, { sensitive: this.caseSensitive, strict: false, @@ -21921,7 +21903,7 @@ var require_query = __commonJS({ var require_view = __commonJS({ "node_modules/express/lib/view.js"(exports2, module2) { "use strict"; - var debug3 = require_src3()("express:view"); + var debug = require_src3()("express:view"); var path4 = require("path"); var fs3 = require("fs"); var dirname = path4.dirname; @@ -21946,7 +21928,7 @@ var require_view = __commonJS({ } if (!opts.engines[this.ext]) { var mod = this.ext.slice(1); - debug3('require "%s"', mod); + debug('require "%s"', mod); var fn = require(mod).__express; if (typeof fn !== "function") { throw new Error('Module "' + mod + '" does not provide a view engine.'); @@ -21959,7 +21941,7 @@ var require_view = __commonJS({ View.prototype.lookup = function lookup(name) { var path5; var roots = [].concat(this.root); - debug3('lookup "%s"', name); + debug('lookup "%s"', name); for (var i = 0; i < roots.length && !path5; i++) { var root = roots[i]; var loc = resolve(root, name); @@ -21970,7 +21952,7 @@ var require_view = __commonJS({ return path5; }; View.prototype.render = function render(options, callback) { - debug3('render "%s"', this.path); + debug('render "%s"', this.path); this.engine(this.path, options, callback); }; View.prototype.resolve = function resolve2(dir, file) { @@ -21987,7 +21969,7 @@ var require_view = __commonJS({ } }; function tryStat(path5) { - debug3('stat "%s"', path5); + debug('stat "%s"', path5); try { return fs3.statSync(path5); } catch (e) { @@ -22196,8 +22178,8 @@ var require_content_disposition = __commonJS({ } return new ContentDisposition(type, params); } - function pdecode(str, hex3) { - return String.fromCharCode(parseInt(hex3, 16)); + function pdecode(str, hex) { + return String.fromCharCode(parseInt(hex, 16)); } function pencode(char) { return "%" + String(char).charCodeAt(0).toString(16).toUpperCase(); @@ -22338,15 +22320,15 @@ var require_debug4 = __commonJS({ return exports2.colors[Math.abs(hash) % exports2.colors.length]; } function createDebug(namespace) { - function debug3() { - if (!debug3.enabled) + function debug() { + if (!debug.enabled) return; - var self2 = debug3; + var self = debug; var curr = +new Date(); var ms = curr - (prevTime || curr); - self2.diff = ms; - self2.prev = prevTime; - self2.curr = curr; + self.diff = ms; + self.prev = prevTime; + self.curr = curr; prevTime = curr; var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { @@ -22364,24 +22346,24 @@ var require_debug4 = __commonJS({ var formatter = exports2.formatters[format]; if (typeof formatter === "function") { var val = args[index]; - match = formatter.call(self2, val); + match = formatter.call(self, val); args.splice(index, 1); index--; } return match; }); - exports2.formatArgs.call(self2, args); - var logFn = debug3.log || exports2.log || console.log.bind(console); - logFn.apply(self2, args); + exports2.formatArgs.call(self, args); + var logFn = debug.log || exports2.log || console.log.bind(console); + logFn.apply(self, args); } - debug3.namespace = namespace; - debug3.enabled = exports2.enabled(namespace); - debug3.useColors = exports2.useColors(); - debug3.color = selectColor(namespace); + debug.namespace = namespace; + debug.enabled = exports2.enabled(namespace); + debug.useColors = exports2.useColors(); + debug.color = selectColor(namespace); if (typeof exports2.init === "function") { - exports2.init(debug3); + exports2.init(debug); } - return debug3; + return debug; } function enable(namespaces) { exports2.save(namespaces); @@ -22432,7 +22414,7 @@ var require_browser4 = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.storage = typeof chrome != "undefined" && typeof chrome.storage != "undefined" ? chrome.storage.local : localstorage(); exports2.colors = [ @@ -22488,7 +22470,7 @@ var require_browser4 = __commonJS({ } catch (e) { } } - function load2() { + function load() { var r; try { r = exports2.storage.debug; @@ -22499,7 +22481,7 @@ var require_browser4 = __commonJS({ } return r; } - exports2.enable(load2()); + exports2.enable(load()); function localstorage() { try { return window.localStorage; @@ -22519,7 +22501,7 @@ var require_node4 = __commonJS({ exports2.log = log; exports2.formatArgs = formatArgs; exports2.save = save; - exports2.load = load2; + exports2.load = load; exports2.useColors = useColors; exports2.colors = [6, 2, 3, 4, 5, 1]; exports2.inspectOpts = Object.keys(process.env).filter(function(key) { @@ -22581,7 +22563,7 @@ var require_node4 = __commonJS({ process.env.DEBUG = namespaces; } } - function load2() { + function load() { return process.env.DEBUG; } function createWritableStdioStream(fd2) { @@ -22622,14 +22604,14 @@ var require_node4 = __commonJS({ stream2._isStdio = true; return stream2; } - function init(debug3) { - debug3.inspectOpts = {}; + function init(debug) { + debug.inspectOpts = {}; var keys = Object.keys(exports2.inspectOpts); for (var i = 0; i < keys.length; i++) { - debug3.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; + debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]]; } } - exports2.enable(load2()); + exports2.enable(load()); } }); @@ -23018,7 +23000,7 @@ var require_send = __commonJS({ "node_modules/send/index.js"(exports2, module2) { "use strict"; var createError = require_http_errors(); - var debug3 = require_src4()("send"); + var debug = require_src4()("send"); var deprecate = require_depd()("send"); var destroy = require_destroy(); var encodeUrl = require_encodeurl(); @@ -23082,24 +23064,24 @@ var require_send = __commonJS({ util.inherits(SendStream, Stream); SendStream.prototype.etag = deprecate.function(function etag2(val) { this._etag = Boolean(val); - debug3("etag %s", this._etag); + debug("etag %s", this._etag); return this; }, "send.etag: pass etag as option"); SendStream.prototype.hidden = deprecate.function(function hidden(val) { this._hidden = Boolean(val); this._dotfiles = void 0; - debug3("hidden %s", this._hidden); + debug("hidden %s", this._hidden); return this; }, "send.hidden: use dotfiles option"); SendStream.prototype.index = deprecate.function(function index(paths) { var index2 = !paths ? [] : normalizeList(paths, "paths argument"); - debug3("index %o", paths); + debug("index %o", paths); this._index = index2; return this; }, "send.index: pass index as option"); SendStream.prototype.root = function root(path5) { this._root = resolve(String(path5)); - debug3("root %s", this._root); + debug("root %s", this._root); return this; }; SendStream.prototype.from = deprecate.function(SendStream.prototype.root, "send.from: pass root as option"); @@ -23107,7 +23089,7 @@ var require_send = __commonJS({ SendStream.prototype.maxage = deprecate.function(function maxage(maxAge) { this._maxage = typeof maxAge === "string" ? ms(maxAge) : Number(maxAge); this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0; - debug3("max-age %d", this._maxage); + debug("max-age %d", this._maxage); return this; }, "send.maxage: pass maxAge as option"); SendStream.prototype.error = function error(status, err) { @@ -23161,14 +23143,14 @@ var require_send = __commonJS({ }; SendStream.prototype.notModified = function notModified() { var res = this.res; - debug3("not modified"); + debug("not modified"); this.removeContentHeaderFields(); res.statusCode = 304; res.end(); }; SendStream.prototype.headersAlreadySent = function headersAlreadySent() { var err = new Error("Can't set headers after they are sent."); - debug3("headers already sent"); + debug("headers already sent"); this.error(500, err); }; SendStream.prototype.isCachable = function isCachable() { @@ -23243,7 +23225,7 @@ var require_send = __commonJS({ path5 = normalize("." + sep + path5); } if (UP_PATH_REGEXP.test(path5)) { - debug3('malicious path "%s"', path5); + debug('malicious path "%s"', path5); this.error(403); return res; } @@ -23251,7 +23233,7 @@ var require_send = __commonJS({ path5 = normalize(join(root, path5)); } else { if (UP_PATH_REGEXP.test(path5)) { - debug3('malicious path "%s"', path5); + debug('malicious path "%s"', path5); this.error(403); return res; } @@ -23263,7 +23245,7 @@ var require_send = __commonJS({ if (access === void 0) { access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow"; } - debug3('%s dotfile "%s"', access, path5); + debug('%s dotfile "%s"', access, path5); switch (access) { case "allow": break; @@ -23295,7 +23277,7 @@ var require_send = __commonJS({ this.headersAlreadySent(); return; } - debug3('pipe "%s"', path5); + debug('pipe "%s"', path5); this.setHeader(path5, stat); this.type(path5); if (this.isConditionalGET()) { @@ -23319,18 +23301,18 @@ var require_send = __commonJS({ combine: true }); if (!this.isRangeFresh()) { - debug3("range stale"); + debug("range stale"); ranges = -2; } if (ranges === -1) { - debug3("range unsatisfiable"); + debug("range unsatisfiable"); res.setHeader("Content-Range", contentRange("bytes", len)); return this.error(416, { headers: { "Content-Range": res.getHeader("Content-Range") } }); } if (ranges !== -2 && ranges.length === 1) { - debug3("range %j", ranges); + debug("range %j", ranges); res.statusCode = 206; res.setHeader("Content-Range", contentRange("bytes", len, ranges[0])); offset += ranges[0].start; @@ -23351,59 +23333,59 @@ var require_send = __commonJS({ }; SendStream.prototype.sendFile = function sendFile(path5) { var i = 0; - var self2 = this; - debug3('stat "%s"', path5); + var self = this; + debug('stat "%s"', path5); fs3.stat(path5, function onstat(err, stat) { if (err && err.code === "ENOENT" && !extname(path5) && path5[path5.length - 1] !== sep) { return next(err); } if (err) - return self2.onStatError(err); + return self.onStatError(err); if (stat.isDirectory()) - return self2.redirect(path5); - self2.emit("file", path5, stat); - self2.send(path5, stat); + return self.redirect(path5); + self.emit("file", path5, stat); + self.send(path5, stat); }); function next(err) { - if (self2._extensions.length <= i) { - return err ? self2.onStatError(err) : self2.error(404); + if (self._extensions.length <= i) { + return err ? self.onStatError(err) : self.error(404); } - var p = path5 + "." + self2._extensions[i++]; - debug3('stat "%s"', p); + var p = path5 + "." + self._extensions[i++]; + debug('stat "%s"', p); fs3.stat(p, function(err2, stat) { if (err2) return next(err2); if (stat.isDirectory()) return next(); - self2.emit("file", p, stat); - self2.send(p, stat); + self.emit("file", p, stat); + self.send(p, stat); }); } }; SendStream.prototype.sendIndex = function sendIndex(path5) { var i = -1; - var self2 = this; + var self = this; function next(err) { - if (++i >= self2._index.length) { + if (++i >= self._index.length) { if (err) - return self2.onStatError(err); - return self2.error(404); + return self.onStatError(err); + return self.error(404); } - var p = join(path5, self2._index[i]); - debug3('stat "%s"', p); + var p = join(path5, self._index[i]); + debug('stat "%s"', p); fs3.stat(p, function(err2, stat) { if (err2) return next(err2); if (stat.isDirectory()) return next(); - self2.emit("file", p, stat); - self2.send(p, stat); + self.emit("file", p, stat); + self.send(p, stat); }); } next(); }; SendStream.prototype.stream = function stream(path5, options) { - var self2 = this; + var self = this; var res = this.res; var stream2 = fs3.createReadStream(path5, options); this.emit("stream", stream2); @@ -23414,10 +23396,10 @@ var require_send = __commonJS({ onFinished(res, cleanup); stream2.on("error", function onerror(err) { cleanup(); - self2.onStatError(err); + self.onStatError(err); }); stream2.on("end", function onend() { - self2.emit("end"); + self.emit("end"); }); }; SendStream.prototype.type = function type(path5) { @@ -23426,18 +23408,18 @@ var require_send = __commonJS({ return; var type2 = mime.lookup(path5); if (!type2) { - debug3("no content-type"); + debug("no content-type"); return; } var charset = mime.charsets.lookup(type2); - debug3("content-type %s", type2); + debug("content-type %s", type2); res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : "")); }; SendStream.prototype.setHeader = function setHeader(path5, stat) { var res = this.res; this.emit("headers", res, path5, stat); if (this._acceptRanges && !res.getHeader("Accept-Ranges")) { - debug3("accept ranges"); + debug("accept ranges"); res.setHeader("Accept-Ranges", "bytes"); } if (this._cacheControl && !res.getHeader("Cache-Control")) { @@ -23445,17 +23427,17 @@ var require_send = __commonJS({ if (this._immutable) { cacheControl += ", immutable"; } - debug3("cache-control %s", cacheControl); + debug("cache-control %s", cacheControl); res.setHeader("Cache-Control", cacheControl); } if (this._lastModified && !res.getHeader("Last-Modified")) { var modified = stat.mtime.toUTCString(); - debug3("modified %s", modified); + debug("modified %s", modified); res.setHeader("Last-Modified", modified); } if (this._etag && !res.getHeader("ETag")) { var val = etag(stat); - debug3("etag %s", val); + debug("etag %s", val); res.setHeader("ETag", val); } }; @@ -24536,7 +24518,7 @@ var require_application = __commonJS({ var methods = require_methods(); var middleware = require_init(); var query = require_query(); - var debug3 = require_src3()("express:application"); + var debug = require_src3()("express:application"); var View = require_view(); var http = require("http"); var compileETag = require_utils2().compileETag; @@ -24569,7 +24551,7 @@ var require_application = __commonJS({ configurable: true, value: true }); - debug3("booting in %s mode", env); + debug("booting in %s mode", env); this.on("mount", function onmount(parent) { if (this.settings[trustProxyDefaultSymbol] === true && typeof parent.settings["trust proxy fn"] === "function") { delete this.settings["trust proxy"]; @@ -24612,7 +24594,7 @@ var require_application = __commonJS({ onerror: logerror.bind(this) }); if (!router) { - debug3("no routes defined on app"); + debug("no routes defined on app"); done(); return; } @@ -24641,7 +24623,7 @@ var require_application = __commonJS({ if (!fn2 || !fn2.handle || !fn2.set) { return router.use(path4, fn2); } - debug3(".use app under %s", path4); + debug(".use app under %s", path4); fn2.mountpath = path4; fn2.parent = this; router.use(path4, function mounted_app(req, res, next) { @@ -24690,7 +24672,7 @@ var require_application = __commonJS({ } return void 0; } - debug3('set "%s" to %o', setting, val); + debug('set "%s" to %o', setting, val); this.settings[setting] = val; switch (setting) { case "etag": @@ -26226,16 +26208,16 @@ var require_response = __commonJS({ var done = callback; var opts = options || {}; var req = this.req; - var self2 = this; + var self = this; if (typeof options === "function") { done = options; opts = {}; } - opts._locals = self2.locals; + opts._locals = self.locals; done = done || function(err, str) { if (err) return req.next(err); - self2.send(str); + self.send(str); }; app2.render(view, opts, done); }; @@ -26793,9034 +26775,6 @@ var require_lib4 = __commonJS({ } }); -// node_modules/process-nextick-args/index.js -var require_process_nextick_args = __commonJS({ - "node_modules/process-nextick-args/index.js"(exports2, module2) { - "use strict"; - if (typeof process === "undefined" || !process.version || process.version.indexOf("v0.") === 0 || process.version.indexOf("v1.") === 0 && process.version.indexOf("v1.8.") !== 0) { - module2.exports = { nextTick }; - } else { - module2.exports = process; - } - function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== "function") { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } - } - } -}); - -// node_modules/isarray/index.js -var require_isarray = __commonJS({ - "node_modules/isarray/index.js"(exports2, module2) { - var toString = {}.toString; - module2.exports = Array.isArray || function(arr) { - return toString.call(arr) == "[object Array]"; - }; - } -}); - -// node_modules/readable-stream/lib/internal/streams/stream.js -var require_stream = __commonJS({ - "node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) { - module2.exports = require("stream"); - } -}); - -// node_modules/readable-stream/node_modules/safe-buffer/index.js -var require_safe_buffer2 = __commonJS({ - "node_modules/readable-stream/node_modules/safe-buffer/index.js"(exports2, module2) { - var buffer = require("buffer"); - var Buffer2 = buffer.Buffer; - function copyProps(src, dst) { - for (var key in src) { - dst[key] = src[key]; - } - } - if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) { - module2.exports = buffer; - } else { - copyProps(buffer, exports2); - exports2.Buffer = SafeBuffer; - } - function SafeBuffer(arg, encodingOrOffset, length) { - return Buffer2(arg, encodingOrOffset, length); - } - copyProps(Buffer2, SafeBuffer); - SafeBuffer.from = function(arg, encodingOrOffset, length) { - if (typeof arg === "number") { - throw new TypeError("Argument must not be a number"); - } - return Buffer2(arg, encodingOrOffset, length); - }; - SafeBuffer.alloc = function(size, fill, encoding) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); - } - var buf = Buffer2(size); - if (fill !== void 0) { - if (typeof encoding === "string") { - buf.fill(fill, encoding); - } else { - buf.fill(fill); - } - } else { - buf.fill(0); - } - return buf; - }; - SafeBuffer.allocUnsafe = function(size) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); - } - return Buffer2(size); - }; - SafeBuffer.allocUnsafeSlow = function(size) { - if (typeof size !== "number") { - throw new TypeError("Argument must be a number"); - } - return buffer.SlowBuffer(size); - }; - } -}); - -// node_modules/core-util-is/lib/util.js -var require_util = __commonJS({ - "node_modules/core-util-is/lib/util.js"(exports2) { - function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); - } - return objectToString(arg) === "[object Array]"; - } - exports2.isArray = isArray; - function isBoolean(arg) { - return typeof arg === "boolean"; - } - exports2.isBoolean = isBoolean; - function isNull(arg) { - return arg === null; - } - exports2.isNull = isNull; - function isNullOrUndefined(arg) { - return arg == null; - } - exports2.isNullOrUndefined = isNullOrUndefined; - function isNumber(arg) { - return typeof arg === "number"; - } - exports2.isNumber = isNumber; - function isString(arg) { - return typeof arg === "string"; - } - exports2.isString = isString; - function isSymbol(arg) { - return typeof arg === "symbol"; - } - exports2.isSymbol = isSymbol; - function isUndefined(arg) { - return arg === void 0; - } - exports2.isUndefined = isUndefined; - function isRegExp(re) { - return objectToString(re) === "[object RegExp]"; - } - exports2.isRegExp = isRegExp; - function isObject(arg) { - return typeof arg === "object" && arg !== null; - } - exports2.isObject = isObject; - function isDate(d) { - return objectToString(d) === "[object Date]"; - } - exports2.isDate = isDate; - function isError2(e) { - return objectToString(e) === "[object Error]" || e instanceof Error; - } - exports2.isError = isError2; - function isFunction(arg) { - return typeof arg === "function"; - } - exports2.isFunction = isFunction; - function isPrimitive(arg) { - return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || typeof arg === "undefined"; - } - exports2.isPrimitive = isPrimitive; - exports2.isBuffer = require("buffer").Buffer.isBuffer; - function objectToString(o) { - return Object.prototype.toString.call(o); - } - } -}); - -// node_modules/readable-stream/lib/internal/streams/BufferList.js -var require_BufferList = __commonJS({ - "node_modules/readable-stream/lib/internal/streams/BufferList.js"(exports2, module2) { - "use strict"; - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - var Buffer2 = require_safe_buffer2().Buffer; - var util = require("util"); - function copyBuffer(src, target, offset) { - src.copy(target, offset); - } - module2.exports = function() { - function BufferList() { - _classCallCheck(this, BufferList); - this.head = null; - this.tail = null; - this.length = 0; - } - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) - this.tail.next = entry; - else - this.head = entry; - this.tail = entry; - ++this.length; - }; - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) - this.tail = entry; - this.head = entry; - ++this.length; - }; - BufferList.prototype.shift = function shift() { - if (this.length === 0) - return; - var ret = this.head.data; - if (this.length === 1) - this.head = this.tail = null; - else - this.head = this.head.next; - --this.length; - return ret; - }; - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; - BufferList.prototype.join = function join(s) { - if (this.length === 0) - return ""; - var p = this.head; - var ret = "" + p.data; - while (p = p.next) { - ret += s + p.data; - } - return ret; - }; - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) - return Buffer2.alloc(0); - if (this.length === 1) - return this.head.data; - var ret = Buffer2.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; - } - return ret; - }; - return BufferList; - }(); - if (util && util.inspect && util.inspect.custom) { - module2.exports.prototype[util.inspect.custom] = function() { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + " " + obj; - }; - } - } -}); - -// node_modules/readable-stream/lib/internal/streams/destroy.js -var require_destroy2 = __commonJS({ - "node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) { - "use strict"; - var pna = require_process_nextick_args(); - function destroy(err, cb) { - var _this = this; - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); - } - return this; - } - if (this._readableState) { - this._readableState.destroyed = true; - } - if (this._writableState) { - this._writableState.destroyed = true; - } - this._destroy(err || null, function(err2) { - if (!cb && err2) { - pna.nextTick(emitErrorNT, _this, err2); - if (_this._writableState) { - _this._writableState.errorEmitted = true; - } - } else if (cb) { - cb(err2); - } - }); - return this; - } - function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; - } - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; - } - } - function emitErrorNT(self2, err) { - self2.emit("error", err); - } - module2.exports = { - destroy, - undestroy - }; - } -}); - -// node_modules/util-deprecate/node.js -var require_node5 = __commonJS({ - "node_modules/util-deprecate/node.js"(exports2, module2) { - module2.exports = require("util").deprecate; - } -}); - -// node_modules/readable-stream/lib/_stream_writable.js -var require_stream_writable = __commonJS({ - "node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) { - "use strict"; - var pna = require_process_nextick_args(); - module2.exports = Writable; - function CorkedRequest(state) { - var _this = this; - this.next = null; - this.entry = null; - this.finish = function() { - onCorkedFinish(_this, state); - }; - } - var asyncWrite = !process.browser && ["v0.10", "v0.9."].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; - var Duplex; - Writable.WritableState = WritableState; - var util = Object.create(require_util()); - util.inherits = require_inherits(); - var internalUtil = { - deprecate: require_node5() - }; - var Stream = require_stream(); - var Buffer2 = require_safe_buffer2().Buffer; - var OurUint8Array = global.Uint8Array || function() { - }; - function _uint8ArrayToBuffer(chunk) { - return Buffer2.from(chunk); - } - function _isUint8Array(obj) { - return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; - } - var destroyImpl = require_destroy2(); - util.inherits(Writable, Stream); - function nop() { - } - function WritableState(options, stream) { - Duplex = Duplex || require_stream_duplex(); - options = options || {}; - var isDuplex = stream instanceof Duplex; - this.objectMode = !!options.objectMode; - if (isDuplex) - this.objectMode = this.objectMode || !!options.writableObjectMode; - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - if (hwm || hwm === 0) - this.highWaterMark = hwm; - else if (isDuplex && (writableHwm || writableHwm === 0)) - this.highWaterMark = writableHwm; - else - this.highWaterMark = defaultHwm; - this.highWaterMark = Math.floor(this.highWaterMark); - this.finalCalled = false; - this.needDrain = false; - this.ending = false; - this.ended = false; - this.finished = false; - this.destroyed = false; - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - this.defaultEncoding = options.defaultEncoding || "utf8"; - this.length = 0; - this.writing = false; - this.corked = 0; - this.sync = true; - this.bufferProcessing = false; - this.onwrite = function(er) { - onwrite(stream, er); - }; - this.writecb = null; - this.writelen = 0; - this.bufferedRequest = null; - this.lastBufferedRequest = null; - this.pendingcb = 0; - this.prefinished = false; - this.errorEmitted = false; - this.bufferedRequestCount = 0; - this.corkedRequestsFree = new CorkedRequest(this); - } - WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - while (current) { - out.push(current); - current = current.next; - } - return out; - }; - (function() { - try { - Object.defineProperty(WritableState.prototype, "buffer", { - get: internalUtil.deprecate(function() { - return this.getBuffer(); - }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") - }); - } catch (_) { - } - })(); - var realHasInstance; - if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function(object) { - if (realHasInstance.call(this, object)) - return true; - if (this !== Writable) - return false; - return object && object._writableState instanceof WritableState; - } - }); - } else { - realHasInstance = function(object) { - return object instanceof this; - }; - } - function Writable(options) { - Duplex = Duplex || require_stream_duplex(); - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); - } - this._writableState = new WritableState(options, this); - this.writable = true; - if (options) { - if (typeof options.write === "function") - this._write = options.write; - if (typeof options.writev === "function") - this._writev = options.writev; - if (typeof options.destroy === "function") - this._destroy = options.destroy; - if (typeof options.final === "function") - this._final = options.final; - } - Stream.call(this); - } - Writable.prototype.pipe = function() { - this.emit("error", new Error("Cannot pipe, not readable")); - }; - function writeAfterEnd(stream, cb) { - var er = new Error("write after end"); - stream.emit("error", er); - pna.nextTick(cb, er); - } - function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; - if (chunk === null) { - er = new TypeError("May not write null values to stream"); - } else if (typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) { - er = new TypeError("Invalid non-string/buffer chunk"); - } - if (er) { - stream.emit("error", er); - pna.nextTick(cb, er); - valid = false; - } - return valid; - } - Writable.prototype.write = function(chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - var isBuf = !state.objectMode && _isUint8Array(chunk); - if (isBuf && !Buffer2.isBuffer(chunk)) { - chunk = _uint8ArrayToBuffer(chunk); - } - if (typeof encoding === "function") { - cb = encoding; - encoding = null; - } - if (isBuf) - encoding = "buffer"; - else if (!encoding) - encoding = state.defaultEncoding; - if (typeof cb !== "function") - cb = nop; - if (state.ended) - writeAfterEnd(this, cb); - else if (isBuf || validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); - } - return ret; - }; - Writable.prototype.cork = function() { - var state = this._writableState; - state.corked++; - }; - Writable.prototype.uncork = function() { - var state = this._writableState; - if (state.corked) { - state.corked--; - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) - clearBuffer(this, state); - } - }; - Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - if (typeof encoding === "string") - encoding = encoding.toLowerCase(); - if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) - throw new TypeError("Unknown encoding: " + encoding); - this._writableState.defaultEncoding = encoding; - return this; - }; - function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") { - chunk = Buffer2.from(chunk, encoding); - } - return chunk; - } - Object.defineProperty(Writable.prototype, "writableHighWaterMark", { - enumerable: false, - get: function() { - return this._writableState.highWaterMark; - } - }); - function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { - if (!isBuf) { - var newChunk = decodeChunk(state, chunk, encoding); - if (chunk !== newChunk) { - isBuf = true; - encoding = "buffer"; - chunk = newChunk; - } - } - var len = state.objectMode ? 1 : chunk.length; - state.length += len; - var ret = state.length < state.highWaterMark; - if (!ret) - state.needDrain = true; - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = { - chunk, - encoding, - isBuf, - callback: cb, - next: null - }; - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; - } - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); - } - return ret; - } - function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) - stream._writev(chunk, state.onwrite); - else - stream._write(chunk, encoding, state.onwrite); - state.sync = false; - } - function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; - if (sync) { - pna.nextTick(cb, er); - pna.nextTick(finishMaybe, stream, state); - stream._writableState.errorEmitted = true; - stream.emit("error", er); - } else { - cb(er); - stream._writableState.errorEmitted = true; - stream.emit("error", er); - finishMaybe(stream, state); - } - } - function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; - } - function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; - onwriteStateUpdate(state); - if (er) - onwriteError(stream, state, sync, er, cb); - else { - var finished = needFinish(state); - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } - if (sync) { - asyncWrite(afterWrite, stream, state, finished, cb); - } else { - afterWrite(stream, state, finished, cb); - } - } - } - function afterWrite(stream, state, finished, cb) { - if (!finished) - onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); - } - function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit("drain"); - } - } - function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; - if (stream._writev && entry && entry.next) { - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; - var count = 0; - var allBuffers = true; - while (entry) { - buffer[count] = entry; - if (!entry.isBuf) - allBuffers = false; - entry = entry.next; - count += 1; - } - buffer.allBuffers = allBuffers; - doWrite(stream, state, true, state.length, buffer, "", holder.finish); - state.pendingcb++; - state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - state.bufferedRequestCount = 0; - } else { - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - state.bufferedRequestCount--; - if (state.writing) { - break; - } - } - if (entry === null) - state.lastBufferedRequest = null; - } - state.bufferedRequest = entry; - state.bufferProcessing = false; - } - Writable.prototype._write = function(chunk, encoding, cb) { - cb(new Error("_write() is not implemented")); - }; - Writable.prototype._writev = null; - Writable.prototype.end = function(chunk, encoding, cb) { - var state = this._writableState; - if (typeof chunk === "function") { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === "function") { - cb = encoding; - encoding = null; - } - if (chunk !== null && chunk !== void 0) - this.write(chunk, encoding); - if (state.corked) { - state.corked = 1; - this.uncork(); - } - if (!state.ending && !state.finished) - endWritable(this, state, cb); - }; - function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; - } - function callFinal(stream, state) { - stream._final(function(err) { - state.pendingcb--; - if (err) { - stream.emit("error", err); - } - state.prefinished = true; - stream.emit("prefinish"); - finishMaybe(stream, state); - }); - } - function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === "function") { - state.pendingcb++; - state.finalCalled = true; - pna.nextTick(callFinal, stream, state); - } else { - state.prefinished = true; - stream.emit("prefinish"); - } - } - } - function finishMaybe(stream, state) { - var need = needFinish(state); - if (need) { - prefinish(stream, state); - if (state.pendingcb === 0) { - state.finished = true; - stream.emit("finish"); - } - } - return need; - } - function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) - pna.nextTick(cb); - else - stream.once("finish", cb); - } - state.ended = true; - stream.writable = false; - } - function onCorkedFinish(corkReq, state, err) { - var entry = corkReq.entry; - corkReq.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } - } - Object.defineProperty(Writable.prototype, "destroyed", { - get: function() { - if (this._writableState === void 0) { - return false; - } - return this._writableState.destroyed; - }, - set: function(value) { - if (!this._writableState) { - return; - } - this._writableState.destroyed = value; - } - }); - Writable.prototype.destroy = destroyImpl.destroy; - Writable.prototype._undestroy = destroyImpl.undestroy; - Writable.prototype._destroy = function(err, cb) { - this.end(); - cb(err); - }; - } -}); - -// node_modules/readable-stream/lib/_stream_duplex.js -var require_stream_duplex = __commonJS({ - "node_modules/readable-stream/lib/_stream_duplex.js"(exports2, module2) { - "use strict"; - var pna = require_process_nextick_args(); - var objectKeys = Object.keys || function(obj) { - var keys2 = []; - for (var key in obj) { - keys2.push(key); - } - return keys2; - }; - module2.exports = Duplex; - var util = Object.create(require_util()); - util.inherits = require_inherits(); - var Readable = require_stream_readable(); - var Writable = require_stream_writable(); - util.inherits(Duplex, Readable); - { - keys = objectKeys(Writable.prototype); - for (v = 0; v < keys.length; v++) { - method = keys[v]; - if (!Duplex.prototype[method]) - Duplex.prototype[method] = Writable.prototype[method]; - } - } - var keys; - var method; - var v; - function Duplex(options) { - if (!(this instanceof Duplex)) - return new Duplex(options); - Readable.call(this, options); - Writable.call(this, options); - if (options && options.readable === false) - this.readable = false; - if (options && options.writable === false) - this.writable = false; - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) - this.allowHalfOpen = false; - this.once("end", onend); - } - Object.defineProperty(Duplex.prototype, "writableHighWaterMark", { - enumerable: false, - get: function() { - return this._writableState.highWaterMark; - } - }); - function onend() { - if (this.allowHalfOpen || this._writableState.ended) - return; - pna.nextTick(onEndNT, this); - } - function onEndNT(self2) { - self2.end(); - } - Object.defineProperty(Duplex.prototype, "destroyed", { - get: function() { - if (this._readableState === void 0 || this._writableState === void 0) { - return false; - } - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function(value) { - if (this._readableState === void 0 || this._writableState === void 0) { - return; - } - this._readableState.destroyed = value; - this._writableState.destroyed = value; - } - }); - Duplex.prototype._destroy = function(err, cb) { - this.push(null); - this.end(); - pna.nextTick(cb, err); - }; - } -}); - -// node_modules/readable-stream/lib/_stream_readable.js -var require_stream_readable = __commonJS({ - "node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) { - "use strict"; - var pna = require_process_nextick_args(); - module2.exports = Readable; - var isArray = require_isarray(); - var Duplex; - Readable.ReadableState = ReadableState; - var EE = require("events").EventEmitter; - var EElistenerCount = function(emitter, type) { - return emitter.listeners(type).length; - }; - var Stream = require_stream(); - var Buffer2 = require_safe_buffer2().Buffer; - var OurUint8Array = global.Uint8Array || function() { - }; - function _uint8ArrayToBuffer(chunk) { - return Buffer2.from(chunk); - } - function _isUint8Array(obj) { - return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array; - } - var util = Object.create(require_util()); - util.inherits = require_inherits(); - var debugUtil = require("util"); - var debug3 = void 0; - if (debugUtil && debugUtil.debuglog) { - debug3 = debugUtil.debuglog("stream"); - } else { - debug3 = function() { - }; - } - var BufferList = require_BufferList(); - var destroyImpl = require_destroy2(); - var StringDecoder; - util.inherits(Readable, Stream); - var kProxyEvents = ["error", "close", "destroy", "pause", "resume"]; - function prependListener(emitter, event, fn) { - if (typeof emitter.prependListener === "function") - return emitter.prependListener(event, fn); - if (!emitter._events || !emitter._events[event]) - emitter.on(event, fn); - else if (isArray(emitter._events[event])) - emitter._events[event].unshift(fn); - else - emitter._events[event] = [fn, emitter._events[event]]; - } - function ReadableState(options, stream) { - Duplex = Duplex || require_stream_duplex(); - options = options || {}; - var isDuplex = stream instanceof Duplex; - this.objectMode = !!options.objectMode; - if (isDuplex) - this.objectMode = this.objectMode || !!options.readableObjectMode; - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - if (hwm || hwm === 0) - this.highWaterMark = hwm; - else if (isDuplex && (readableHwm || readableHwm === 0)) - this.highWaterMark = readableHwm; - else - this.highWaterMark = defaultHwm; - this.highWaterMark = Math.floor(this.highWaterMark); - this.buffer = new BufferList(); - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; - this.sync = true; - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; - this.destroyed = false; - this.defaultEncoding = options.defaultEncoding || "utf8"; - this.awaitDrain = 0; - this.readingMore = false; - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) - StringDecoder = require("string_decoder/").StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } - } - function Readable(options) { - Duplex = Duplex || require_stream_duplex(); - if (!(this instanceof Readable)) - return new Readable(options); - this._readableState = new ReadableState(options, this); - this.readable = true; - if (options) { - if (typeof options.read === "function") - this._read = options.read; - if (typeof options.destroy === "function") - this._destroy = options.destroy; - } - Stream.call(this); - } - Object.defineProperty(Readable.prototype, "destroyed", { - get: function() { - if (this._readableState === void 0) { - return false; - } - return this._readableState.destroyed; - }, - set: function(value) { - if (!this._readableState) { - return; - } - this._readableState.destroyed = value; - } - }); - Readable.prototype.destroy = destroyImpl.destroy; - Readable.prototype._undestroy = destroyImpl.undestroy; - Readable.prototype._destroy = function(err, cb) { - this.push(null); - cb(err); - }; - Readable.prototype.push = function(chunk, encoding) { - var state = this._readableState; - var skipChunkCheck; - if (!state.objectMode) { - if (typeof chunk === "string") { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = Buffer2.from(chunk, encoding); - encoding = ""; - } - skipChunkCheck = true; - } - } else { - skipChunkCheck = true; - } - return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); - }; - Readable.prototype.unshift = function(chunk) { - return readableAddChunk(this, chunk, null, true, false); - }; - function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - var state = stream._readableState; - if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else { - var er; - if (!skipChunkCheck) - er = chunkInvalid(state, chunk); - if (er) { - stream.emit("error", er); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) { - chunk = _uint8ArrayToBuffer(chunk); - } - if (addToFront) { - if (state.endEmitted) - stream.emit("error", new Error("stream.unshift() after end event")); - else - addChunk(stream, state, chunk, true); - } else if (state.ended) { - stream.emit("error", new Error("stream.push() after EOF")); - } else { - state.reading = false; - if (state.decoder && !encoding) { - chunk = state.decoder.write(chunk); - if (state.objectMode || chunk.length !== 0) - addChunk(stream, state, chunk, false); - else - maybeReadMore(stream, state); - } else { - addChunk(stream, state, chunk, false); - } - } - } else if (!addToFront) { - state.reading = false; - } - } - return needMoreData(state); - } - function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit("data", chunk); - stream.read(0); - } else { - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) - state.buffer.unshift(chunk); - else - state.buffer.push(chunk); - if (state.needReadable) - emitReadable(stream); - } - maybeReadMore(stream, state); - } - function chunkInvalid(state, chunk) { - var er; - if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) { - er = new TypeError("Invalid non-string/buffer chunk"); - } - return er; - } - function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); - } - Readable.prototype.isPaused = function() { - return this._readableState.flowing === false; - }; - Readable.prototype.setEncoding = function(enc) { - if (!StringDecoder) - StringDecoder = require("string_decoder/").StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; - }; - var MAX_HWM = 8388608; - function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - return n; - } - function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) - return 0; - if (state.objectMode) - return 1; - if (n !== n) { - if (state.flowing && state.length) - return state.buffer.head.data.length; - else - return state.length; - } - if (n > state.highWaterMark) - state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) - return n; - if (!state.ended) { - state.needReadable = true; - return 0; - } - return state.length; - } - Readable.prototype.read = function(n) { - debug3("read", n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; - if (n !== 0) - state.emittedReadable = false; - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - debug3("read: emitReadable", state.length, state.ended); - if (state.length === 0 && state.ended) - endReadable(this); - else - emitReadable(this); - return null; - } - n = howMuchToRead(n, state); - if (n === 0 && state.ended) { - if (state.length === 0) - endReadable(this); - return null; - } - var doRead = state.needReadable; - debug3("need readable", doRead); - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug3("length less than watermark", doRead); - } - if (state.ended || state.reading) { - doRead = false; - debug3("reading or ended", doRead); - } else if (doRead) { - debug3("do read"); - state.reading = true; - state.sync = true; - if (state.length === 0) - state.needReadable = true; - this._read(state.highWaterMark); - state.sync = false; - if (!state.reading) - n = howMuchToRead(nOrig, state); - } - var ret; - if (n > 0) - ret = fromList(n, state); - else - ret = null; - if (ret === null) { - state.needReadable = true; - n = 0; - } else { - state.length -= n; - } - if (state.length === 0) { - if (!state.ended) - state.needReadable = true; - if (nOrig !== n && state.ended) - endReadable(this); - } - if (ret !== null) - this.emit("data", ret); - return ret; - }; - function onEofChunk(stream, state) { - if (state.ended) - return; - if (state.decoder) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - state.ended = true; - emitReadable(stream); - } - function emitReadable(stream) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug3("emitReadable", state.flowing); - state.emittedReadable = true; - if (state.sync) - pna.nextTick(emitReadable_, stream); - else - emitReadable_(stream); - } - } - function emitReadable_(stream) { - debug3("emit readable"); - stream.emit("readable"); - flow(stream); - } - function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); - } - } - function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { - debug3("maybeReadMore read 0"); - stream.read(0); - if (len === state.length) - break; - else - len = state.length; - } - state.readingMore = false; - } - Readable.prototype._read = function(n) { - this.emit("error", new Error("_read() is not implemented")); - }; - Readable.prototype.pipe = function(dest, pipeOpts) { - var src = this; - var state = this._readableState; - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug3("pipe count=%d opts=%j", state.pipesCount, pipeOpts); - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) - pna.nextTick(endFn); - else - src.once("end", endFn); - dest.on("unpipe", onunpipe); - function onunpipe(readable, unpipeInfo) { - debug3("onunpipe"); - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true; - cleanup(); - } - } - } - function onend() { - debug3("onend"); - dest.end(); - } - var ondrain = pipeOnDrain(src); - dest.on("drain", ondrain); - var cleanedUp = false; - function cleanup() { - debug3("cleanup"); - dest.removeListener("close", onclose); - dest.removeListener("finish", onfinish); - dest.removeListener("drain", ondrain); - dest.removeListener("error", onerror); - dest.removeListener("unpipe", onunpipe); - src.removeListener("end", onend); - src.removeListener("end", unpipe); - src.removeListener("data", ondata); - cleanedUp = true; - if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) - ondrain(); - } - var increasedAwaitDrain = false; - src.on("data", ondata); - function ondata(chunk) { - debug3("ondata"); - increasedAwaitDrain = false; - var ret = dest.write(chunk); - if (ret === false && !increasedAwaitDrain) { - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug3("false write response, pause", src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; - } - src.pause(); - } - } - function onerror(er) { - debug3("onerror", er); - unpipe(); - dest.removeListener("error", onerror); - if (EElistenerCount(dest, "error") === 0) - dest.emit("error", er); - } - prependListener(dest, "error", onerror); - function onclose() { - dest.removeListener("finish", onfinish); - unpipe(); - } - dest.once("close", onclose); - function onfinish() { - debug3("onfinish"); - dest.removeListener("close", onclose); - unpipe(); - } - dest.once("finish", onfinish); - function unpipe() { - debug3("unpipe"); - src.unpipe(dest); - } - dest.emit("pipe", src); - if (!state.flowing) { - debug3("pipe resume"); - src.resume(); - } - return dest; - }; - function pipeOnDrain(src) { - return function() { - var state = src._readableState; - debug3("pipeOnDrain", state.awaitDrain); - if (state.awaitDrain) - state.awaitDrain--; - if (state.awaitDrain === 0 && EElistenerCount(src, "data")) { - state.flowing = true; - flow(src); - } - }; - } - Readable.prototype.unpipe = function(dest) { - var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; - if (state.pipesCount === 0) - return this; - if (state.pipesCount === 1) { - if (dest && dest !== state.pipes) - return this; - if (!dest) - dest = state.pipes; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) - dest.emit("unpipe", this, unpipeInfo); - return this; - } - if (!dest) { - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - for (var i = 0; i < len; i++) { - dests[i].emit("unpipe", this, unpipeInfo); - } - return this; - } - var index = indexOf(state.pipes, dest); - if (index === -1) - return this; - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) - state.pipes = state.pipes[0]; - dest.emit("unpipe", this, unpipeInfo); - return this; - }; - Readable.prototype.on = function(ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - if (ev === "data") { - if (this._readableState.flowing !== false) - this.resume(); - } else if (ev === "readable") { - var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { - emitReadable(this); - } - } - } - return res; - }; - Readable.prototype.addListener = Readable.prototype.on; - function nReadingNextTick(self2) { - debug3("readable nexttick read 0"); - self2.read(0); - } - Readable.prototype.resume = function() { - var state = this._readableState; - if (!state.flowing) { - debug3("resume"); - state.flowing = true; - resume(this, state); - } - return this; - }; - function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); - } - } - function resume_(stream, state) { - if (!state.reading) { - debug3("resume read 0"); - stream.read(0); - } - state.resumeScheduled = false; - state.awaitDrain = 0; - stream.emit("resume"); - flow(stream); - if (state.flowing && !state.reading) - stream.read(0); - } - Readable.prototype.pause = function() { - debug3("call pause flowing=%j", this._readableState.flowing); - if (this._readableState.flowing !== false) { - debug3("pause"); - this._readableState.flowing = false; - this.emit("pause"); - } - return this; - }; - function flow(stream) { - var state = stream._readableState; - debug3("flow", state.flowing); - while (state.flowing && stream.read() !== null) { - } - } - Readable.prototype.wrap = function(stream) { - var _this = this; - var state = this._readableState; - var paused = false; - stream.on("end", function() { - debug3("wrapped end"); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) - _this.push(chunk); - } - _this.push(null); - }); - stream.on("data", function(chunk) { - debug3("wrapped data"); - if (state.decoder) - chunk = state.decoder.write(chunk); - if (state.objectMode && (chunk === null || chunk === void 0)) - return; - else if (!state.objectMode && (!chunk || !chunk.length)) - return; - var ret = _this.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - for (var i in stream) { - if (this[i] === void 0 && typeof stream[i] === "function") { - this[i] = function(method) { - return function() { - return stream[method].apply(stream, arguments); - }; - }(i); - } - } - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } - this._read = function(n2) { - debug3("wrapped _read", n2); - if (paused) { - paused = false; - stream.resume(); - } - }; - return this; - }; - Object.defineProperty(Readable.prototype, "readableHighWaterMark", { - enumerable: false, - get: function() { - return this._readableState.highWaterMark; - } - }); - Readable._fromList = fromList; - function fromList(n, state) { - if (state.length === 0) - return null; - var ret; - if (state.objectMode) - ret = state.buffer.shift(); - else if (!n || n >= state.length) { - if (state.decoder) - ret = state.buffer.join(""); - else if (state.buffer.length === 1) - ret = state.buffer.head.data; - else - ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - ret = fromListPartial(n, state.buffer, state.decoder); - } - return ret; - } - function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - ret = list.shift(); - } else { - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; - } - function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) - ret += str; - else - ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) - list.head = p.next; - else - list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; - } - function copyFromBuffer(n, list) { - var ret = Buffer2.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) - list.head = p.next; - else - list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; - } - function endReadable(stream) { - var state = stream._readableState; - if (state.length > 0) - throw new Error('"endReadable()" called on non-empty stream'); - if (!state.endEmitted) { - state.ended = true; - pna.nextTick(endReadableNT, state, stream); - } - } - function endReadableNT(state, stream) { - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit("end"); - } - } - function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) - return i; - } - return -1; - } - } -}); - -// node_modules/readable-stream/lib/_stream_transform.js -var require_stream_transform = __commonJS({ - "node_modules/readable-stream/lib/_stream_transform.js"(exports2, module2) { - "use strict"; - module2.exports = Transform; - var Duplex = require_stream_duplex(); - var util = Object.create(require_util()); - util.inherits = require_inherits(); - util.inherits(Transform, Duplex); - function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; - var cb = ts.writecb; - if (!cb) { - return this.emit("error", new Error("write callback called multiple times")); - } - ts.writechunk = null; - ts.writecb = null; - if (data != null) - this.push(data); - cb(er); - var rs = this._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); - } - } - function Transform(options) { - if (!(this instanceof Transform)) - return new Transform(options); - Duplex.call(this, options); - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null - }; - this._readableState.needReadable = true; - this._readableState.sync = false; - if (options) { - if (typeof options.transform === "function") - this._transform = options.transform; - if (typeof options.flush === "function") - this._flush = options.flush; - } - this.on("prefinish", prefinish); - } - function prefinish() { - var _this = this; - if (typeof this._flush === "function") { - this._flush(function(er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); - } - } - Transform.prototype.push = function(chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); - }; - Transform.prototype._transform = function(chunk, encoding, cb) { - throw new Error("_transform() is not implemented"); - }; - Transform.prototype._write = function(chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) - this._read(rs.highWaterMark); - } - }; - Transform.prototype._read = function(n) { - var ts = this._transformState; - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - ts.needTransform = true; - } - }; - Transform.prototype._destroy = function(err, cb) { - var _this2 = this; - Duplex.prototype._destroy.call(this, err, function(err2) { - cb(err2); - _this2.emit("close"); - }); - }; - function done(stream, er, data) { - if (er) - return stream.emit("error", er); - if (data != null) - stream.push(data); - if (stream._writableState.length) - throw new Error("Calling transform done when ws.length != 0"); - if (stream._transformState.transforming) - throw new Error("Calling transform done when still transforming"); - return stream.push(null); - } - } -}); - -// node_modules/readable-stream/lib/_stream_passthrough.js -var require_stream_passthrough = __commonJS({ - "node_modules/readable-stream/lib/_stream_passthrough.js"(exports2, module2) { - "use strict"; - module2.exports = PassThrough; - var Transform = require_stream_transform(); - var util = Object.create(require_util()); - util.inherits = require_inherits(); - util.inherits(PassThrough, Transform); - function PassThrough(options) { - if (!(this instanceof PassThrough)) - return new PassThrough(options); - Transform.call(this, options); - } - PassThrough.prototype._transform = function(chunk, encoding, cb) { - cb(null, chunk); - }; - } -}); - -// node_modules/readable-stream/readable.js -var require_readable = __commonJS({ - "node_modules/readable-stream/readable.js"(exports2, module2) { - var Stream = require("stream"); - if (process.env.READABLE_STREAM === "disable" && Stream) { - module2.exports = Stream; - exports2 = module2.exports = Stream.Readable; - exports2.Readable = Stream.Readable; - exports2.Writable = Stream.Writable; - exports2.Duplex = Stream.Duplex; - exports2.Transform = Stream.Transform; - exports2.PassThrough = Stream.PassThrough; - exports2.Stream = Stream; - } else { - exports2 = module2.exports = require_stream_readable(); - exports2.Stream = Stream || exports2; - exports2.Readable = exports2; - exports2.Writable = require_stream_writable(); - exports2.Duplex = require_stream_duplex(); - exports2.Transform = require_stream_transform(); - exports2.PassThrough = require_stream_passthrough(); - } - } -}); - -// node_modules/jszip/lib/support.js -var require_support = __commonJS({ - "node_modules/jszip/lib/support.js"(exports2) { - "use strict"; - exports2.base64 = true; - exports2.array = true; - exports2.string = true; - exports2.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined"; - exports2.nodebuffer = typeof Buffer !== "undefined"; - exports2.uint8array = typeof Uint8Array !== "undefined"; - if (typeof ArrayBuffer === "undefined") { - exports2.blob = false; - } else { - buffer = new ArrayBuffer(0); - try { - exports2.blob = new Blob([buffer], { - type: "application/zip" - }).size === 0; - } catch (e) { - try { - Builder2 = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder; - builder2 = new Builder2(); - builder2.append(buffer); - exports2.blob = builder2.getBlob("application/zip").size === 0; - } catch (e2) { - exports2.blob = false; - } - } - } - var buffer; - var Builder2; - var builder2; - try { - exports2.nodestream = !!require_readable().Readable; - } catch (e) { - exports2.nodestream = false; - } - } -}); - -// node_modules/jszip/lib/base64.js -var require_base64 = __commonJS({ - "node_modules/jszip/lib/base64.js"(exports2) { - "use strict"; - var utils = require_utils3(); - var support = require_support(); - var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - exports2.encode = function(input) { - var output = []; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0, len = input.length, remainingBytes = len; - var isArray = utils.getTypeOf(input) !== "string"; - while (i < input.length) { - remainingBytes = len - i; - if (!isArray) { - chr1 = input.charCodeAt(i++); - chr2 = i < len ? input.charCodeAt(i++) : 0; - chr3 = i < len ? input.charCodeAt(i++) : 0; - } else { - chr1 = input[i++]; - chr2 = i < len ? input[i++] : 0; - chr3 = i < len ? input[i++] : 0; - } - enc1 = chr1 >> 2; - enc2 = (chr1 & 3) << 4 | chr2 >> 4; - enc3 = remainingBytes > 1 ? (chr2 & 15) << 2 | chr3 >> 6 : 64; - enc4 = remainingBytes > 2 ? chr3 & 63 : 64; - output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4)); - } - return output.join(""); - }; - exports2.decode = function(input) { - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0, resultIndex = 0; - var dataUrlPrefix = "data:"; - if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) { - throw new Error("Invalid base64 input, it looks like a data url."); - } - input = input.replace(/[^A-Za-z0-9+/=]/g, ""); - var totalLength = input.length * 3 / 4; - if (input.charAt(input.length - 1) === _keyStr.charAt(64)) { - totalLength--; - } - if (input.charAt(input.length - 2) === _keyStr.charAt(64)) { - totalLength--; - } - if (totalLength % 1 !== 0) { - throw new Error("Invalid base64 input, bad content length."); - } - var output; - if (support.uint8array) { - output = new Uint8Array(totalLength | 0); - } else { - output = new Array(totalLength | 0); - } - while (i < input.length) { - enc1 = _keyStr.indexOf(input.charAt(i++)); - enc2 = _keyStr.indexOf(input.charAt(i++)); - enc3 = _keyStr.indexOf(input.charAt(i++)); - enc4 = _keyStr.indexOf(input.charAt(i++)); - chr1 = enc1 << 2 | enc2 >> 4; - chr2 = (enc2 & 15) << 4 | enc3 >> 2; - chr3 = (enc3 & 3) << 6 | enc4; - output[resultIndex++] = chr1; - if (enc3 !== 64) { - output[resultIndex++] = chr2; - } - if (enc4 !== 64) { - output[resultIndex++] = chr3; - } - } - return output; - }; - } -}); - -// node_modules/jszip/lib/nodejsUtils.js -var require_nodejsUtils = __commonJS({ - "node_modules/jszip/lib/nodejsUtils.js"(exports2, module2) { - "use strict"; - module2.exports = { - isNode: typeof Buffer !== "undefined", - newBufferFrom: function(data, encoding) { - if (Buffer.from && Buffer.from !== Uint8Array.from) { - return Buffer.from(data, encoding); - } else { - if (typeof data === "number") { - throw new Error('The "data" argument must not be a number'); - } - return new Buffer(data, encoding); - } - }, - allocBuffer: function(size) { - if (Buffer.alloc) { - return Buffer.alloc(size); - } else { - var buf = new Buffer(size); - buf.fill(0); - return buf; - } - }, - isBuffer: function(b) { - return Buffer.isBuffer(b); - }, - isStream: function(obj) { - return obj && typeof obj.on === "function" && typeof obj.pause === "function" && typeof obj.resume === "function"; - } - }; - } -}); - -// node_modules/immediate/lib/index.js -var require_lib5 = __commonJS({ - "node_modules/immediate/lib/index.js"(exports2, module2) { - "use strict"; - var Mutation = global.MutationObserver || global.WebKitMutationObserver; - var scheduleDrain; - if (process.browser) { - if (Mutation) { - called = 0; - observer = new Mutation(nextTick); - element = global.document.createTextNode(""); - observer.observe(element, { - characterData: true - }); - scheduleDrain = function() { - element.data = called = ++called % 2; - }; - } else if (!global.setImmediate && typeof global.MessageChannel !== "undefined") { - channel = new global.MessageChannel(); - channel.port1.onmessage = nextTick; - scheduleDrain = function() { - channel.port2.postMessage(0); - }; - } else if ("document" in global && "onreadystatechange" in global.document.createElement("script")) { - scheduleDrain = function() { - var scriptEl = global.document.createElement("script"); - scriptEl.onreadystatechange = function() { - nextTick(); - scriptEl.onreadystatechange = null; - scriptEl.parentNode.removeChild(scriptEl); - scriptEl = null; - }; - global.document.documentElement.appendChild(scriptEl); - }; - } else { - scheduleDrain = function() { - setTimeout(nextTick, 0); - }; - } - } else { - scheduleDrain = function() { - process.nextTick(nextTick); - }; - } - var called; - var observer; - var element; - var channel; - var draining; - var queue = []; - function nextTick() { - draining = true; - var i, oldQueue; - var len = queue.length; - while (len) { - oldQueue = queue; - queue = []; - i = -1; - while (++i < len) { - oldQueue[i](); - } - len = queue.length; - } - draining = false; - } - module2.exports = immediate; - function immediate(task) { - if (queue.push(task) === 1 && !draining) { - scheduleDrain(); - } - } - } -}); - -// node_modules/lie/lib/index.js -var require_lib6 = __commonJS({ - "node_modules/lie/lib/index.js"(exports2, module2) { - "use strict"; - var immediate = require_lib5(); - function INTERNAL() { - } - var handlers = {}; - var REJECTED = ["REJECTED"]; - var FULFILLED = ["FULFILLED"]; - var PENDING = ["PENDING"]; - if (!process.browser) { - UNHANDLED = ["UNHANDLED"]; - } - var UNHANDLED; - module2.exports = Promise2; - function Promise2(resolver) { - if (typeof resolver !== "function") { - throw new TypeError("resolver must be a function"); - } - this.state = PENDING; - this.queue = []; - this.outcome = void 0; - if (!process.browser) { - this.handled = UNHANDLED; - } - if (resolver !== INTERNAL) { - safelyResolveThenable(this, resolver); - } - } - Promise2.prototype.finally = function(callback) { - if (typeof callback !== "function") { - return this; - } - var p = this.constructor; - return this.then(resolve2, reject2); - function resolve2(value) { - function yes() { - return value; - } - return p.resolve(callback()).then(yes); - } - function reject2(reason) { - function no() { - throw reason; - } - return p.resolve(callback()).then(no); - } - }; - Promise2.prototype.catch = function(onRejected) { - return this.then(null, onRejected); - }; - Promise2.prototype.then = function(onFulfilled, onRejected) { - if (typeof onFulfilled !== "function" && this.state === FULFILLED || typeof onRejected !== "function" && this.state === REJECTED) { - return this; - } - var promise = new this.constructor(INTERNAL); - if (!process.browser) { - if (this.handled === UNHANDLED) { - this.handled = null; - } - } - if (this.state !== PENDING) { - var resolver = this.state === FULFILLED ? onFulfilled : onRejected; - unwrap(promise, resolver, this.outcome); - } else { - this.queue.push(new QueueItem(promise, onFulfilled, onRejected)); - } - return promise; - }; - function QueueItem(promise, onFulfilled, onRejected) { - this.promise = promise; - if (typeof onFulfilled === "function") { - this.onFulfilled = onFulfilled; - this.callFulfilled = this.otherCallFulfilled; - } - if (typeof onRejected === "function") { - this.onRejected = onRejected; - this.callRejected = this.otherCallRejected; - } - } - QueueItem.prototype.callFulfilled = function(value) { - handlers.resolve(this.promise, value); - }; - QueueItem.prototype.otherCallFulfilled = function(value) { - unwrap(this.promise, this.onFulfilled, value); - }; - QueueItem.prototype.callRejected = function(value) { - handlers.reject(this.promise, value); - }; - QueueItem.prototype.otherCallRejected = function(value) { - unwrap(this.promise, this.onRejected, value); - }; - function unwrap(promise, func, value) { - immediate(function() { - var returnValue; - try { - returnValue = func(value); - } catch (e) { - return handlers.reject(promise, e); - } - if (returnValue === promise) { - handlers.reject(promise, new TypeError("Cannot resolve promise with itself")); - } else { - handlers.resolve(promise, returnValue); - } - }); - } - handlers.resolve = function(self2, value) { - var result = tryCatch(getThen, value); - if (result.status === "error") { - return handlers.reject(self2, result.value); - } - var thenable = result.value; - if (thenable) { - safelyResolveThenable(self2, thenable); - } else { - self2.state = FULFILLED; - self2.outcome = value; - var i = -1; - var len = self2.queue.length; - while (++i < len) { - self2.queue[i].callFulfilled(value); - } - } - return self2; - }; - handlers.reject = function(self2, error) { - self2.state = REJECTED; - self2.outcome = error; - if (!process.browser) { - if (self2.handled === UNHANDLED) { - immediate(function() { - if (self2.handled === UNHANDLED) { - process.emit("unhandledRejection", error, self2); - } - }); - } - } - var i = -1; - var len = self2.queue.length; - while (++i < len) { - self2.queue[i].callRejected(error); - } - return self2; - }; - function getThen(obj) { - var then = obj && obj.then; - if (obj && (typeof obj === "object" || typeof obj === "function") && typeof then === "function") { - return function appyThen() { - then.apply(obj, arguments); - }; - } - } - function safelyResolveThenable(self2, thenable) { - var called = false; - function onError(value) { - if (called) { - return; - } - called = true; - handlers.reject(self2, value); - } - function onSuccess(value) { - if (called) { - return; - } - called = true; - handlers.resolve(self2, value); - } - function tryToUnwrap() { - thenable(onSuccess, onError); - } - var result = tryCatch(tryToUnwrap); - if (result.status === "error") { - onError(result.value); - } - } - function tryCatch(func, value) { - var out = {}; - try { - out.value = func(value); - out.status = "success"; - } catch (e) { - out.status = "error"; - out.value = e; - } - return out; - } - Promise2.resolve = resolve; - function resolve(value) { - if (value instanceof this) { - return value; - } - return handlers.resolve(new this(INTERNAL), value); - } - Promise2.reject = reject; - function reject(reason) { - var promise = new this(INTERNAL); - return handlers.reject(promise, reason); - } - Promise2.all = all; - function all(iterable) { - var self2 = this; - if (Object.prototype.toString.call(iterable) !== "[object Array]") { - return this.reject(new TypeError("must be an array")); - } - var len = iterable.length; - var called = false; - if (!len) { - return this.resolve([]); - } - var values = new Array(len); - var resolved = 0; - var i = -1; - var promise = new this(INTERNAL); - while (++i < len) { - allResolver(iterable[i], i); - } - return promise; - function allResolver(value, i2) { - self2.resolve(value).then(resolveFromAll, function(error) { - if (!called) { - called = true; - handlers.reject(promise, error); - } - }); - function resolveFromAll(outValue) { - values[i2] = outValue; - if (++resolved === len && !called) { - called = true; - handlers.resolve(promise, values); - } - } - } - } - Promise2.race = race; - function race(iterable) { - var self2 = this; - if (Object.prototype.toString.call(iterable) !== "[object Array]") { - return this.reject(new TypeError("must be an array")); - } - var len = iterable.length; - var called = false; - if (!len) { - return this.resolve([]); - } - var i = -1; - var promise = new this(INTERNAL); - while (++i < len) { - resolver(iterable[i]); - } - return promise; - function resolver(value) { - self2.resolve(value).then(function(response) { - if (!called) { - called = true; - handlers.resolve(promise, response); - } - }, function(error) { - if (!called) { - called = true; - handlers.reject(promise, error); - } - }); - } - } - } -}); - -// node_modules/jszip/lib/external.js -var require_external = __commonJS({ - "node_modules/jszip/lib/external.js"(exports2, module2) { - "use strict"; - var ES6Promise = null; - if (typeof Promise !== "undefined") { - ES6Promise = Promise; - } else { - ES6Promise = require_lib6(); - } - module2.exports = { - Promise: ES6Promise - }; - } -}); - -// node_modules/setimmediate/setImmediate.js -var require_setImmediate = __commonJS({ - "node_modules/setimmediate/setImmediate.js"(exports2) { - (function(global2, undefined2) { - "use strict"; - if (global2.setImmediate) { - return; - } - var nextHandle = 1; - var tasksByHandle = {}; - var currentlyRunningATask = false; - var doc = global2.document; - var registerImmediate; - function setImmediate2(callback) { - if (typeof callback !== "function") { - callback = new Function("" + callback); - } - var args = new Array(arguments.length - 1); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i + 1]; - } - var task = { callback, args }; - tasksByHandle[nextHandle] = task; - registerImmediate(nextHandle); - return nextHandle++; - } - function clearImmediate(handle) { - delete tasksByHandle[handle]; - } - function run(task) { - var callback = task.callback; - var args = task.args; - switch (args.length) { - case 0: - callback(); - break; - case 1: - callback(args[0]); - break; - case 2: - callback(args[0], args[1]); - break; - case 3: - callback(args[0], args[1], args[2]); - break; - default: - callback.apply(undefined2, args); - break; - } - } - function runIfPresent(handle) { - if (currentlyRunningATask) { - setTimeout(runIfPresent, 0, handle); - } else { - var task = tasksByHandle[handle]; - if (task) { - currentlyRunningATask = true; - try { - run(task); - } finally { - clearImmediate(handle); - currentlyRunningATask = false; - } - } - } - } - function installNextTickImplementation() { - registerImmediate = function(handle) { - process.nextTick(function() { - runIfPresent(handle); - }); - }; - } - function canUsePostMessage() { - if (global2.postMessage && !global2.importScripts) { - var postMessageIsAsynchronous = true; - var oldOnMessage = global2.onmessage; - global2.onmessage = function() { - postMessageIsAsynchronous = false; - }; - global2.postMessage("", "*"); - global2.onmessage = oldOnMessage; - return postMessageIsAsynchronous; - } - } - function installPostMessageImplementation() { - var messagePrefix = "setImmediate$" + Math.random() + "$"; - var onGlobalMessage = function(event) { - if (event.source === global2 && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) { - runIfPresent(+event.data.slice(messagePrefix.length)); - } - }; - if (global2.addEventListener) { - global2.addEventListener("message", onGlobalMessage, false); - } else { - global2.attachEvent("onmessage", onGlobalMessage); - } - registerImmediate = function(handle) { - global2.postMessage(messagePrefix + handle, "*"); - }; - } - function installMessageChannelImplementation() { - var channel = new MessageChannel(); - channel.port1.onmessage = function(event) { - var handle = event.data; - runIfPresent(handle); - }; - registerImmediate = function(handle) { - channel.port2.postMessage(handle); - }; - } - function installReadyStateChangeImplementation() { - var html = doc.documentElement; - registerImmediate = function(handle) { - var script = doc.createElement("script"); - script.onreadystatechange = function() { - runIfPresent(handle); - script.onreadystatechange = null; - html.removeChild(script); - script = null; - }; - html.appendChild(script); - }; - } - function installSetTimeoutImplementation() { - registerImmediate = function(handle) { - setTimeout(runIfPresent, 0, handle); - }; - } - var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global2); - attachTo = attachTo && attachTo.setTimeout ? attachTo : global2; - if ({}.toString.call(global2.process) === "[object process]") { - installNextTickImplementation(); - } else if (canUsePostMessage()) { - installPostMessageImplementation(); - } else if (global2.MessageChannel) { - installMessageChannelImplementation(); - } else if (doc && "onreadystatechange" in doc.createElement("script")) { - installReadyStateChangeImplementation(); - } else { - installSetTimeoutImplementation(); - } - attachTo.setImmediate = setImmediate2; - attachTo.clearImmediate = clearImmediate; - })(typeof self === "undefined" ? typeof global === "undefined" ? exports2 : global : self); - } -}); - -// node_modules/jszip/lib/utils.js -var require_utils3 = __commonJS({ - "node_modules/jszip/lib/utils.js"(exports2) { - "use strict"; - var support = require_support(); - var base64 = require_base64(); - var nodejsUtils = require_nodejsUtils(); - var external = require_external(); - require_setImmediate(); - function string2binary(str) { - var result = null; - if (support.uint8array) { - result = new Uint8Array(str.length); - } else { - result = new Array(str.length); - } - return stringToArrayLike(str, result); - } - exports2.newBlob = function(part, type) { - exports2.checkSupport("blob"); - try { - return new Blob([part], { - type - }); - } catch (e) { - try { - var Builder2 = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder; - var builder2 = new Builder2(); - builder2.append(part); - return builder2.getBlob(type); - } catch (e2) { - throw new Error("Bug : can't construct the Blob."); - } - } - }; - function identity(input) { - return input; - } - function stringToArrayLike(str, array) { - for (var i = 0; i < str.length; ++i) { - array[i] = str.charCodeAt(i) & 255; - } - return array; - } - var arrayToStringHelper = { - stringifyByChunk: function(array, type, chunk) { - var result = [], k = 0, len = array.length; - if (len <= chunk) { - return String.fromCharCode.apply(null, array); - } - while (k < len) { - if (type === "array" || type === "nodebuffer") { - result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len)))); - } else { - result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len)))); - } - k += chunk; - } - return result.join(""); - }, - stringifyByChar: function(array) { - var resultStr = ""; - for (var i = 0; i < array.length; i++) { - resultStr += String.fromCharCode(array[i]); - } - return resultStr; - }, - applyCanBeUsed: { - uint8array: function() { - try { - return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1; - } catch (e) { - return false; - } - }(), - nodebuffer: function() { - try { - return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1; - } catch (e) { - return false; - } - }() - } - }; - function arrayLikeToString(array) { - var chunk = 65536, type = exports2.getTypeOf(array), canUseApply = true; - if (type === "uint8array") { - canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array; - } else if (type === "nodebuffer") { - canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer; - } - if (canUseApply) { - while (chunk > 1) { - try { - return arrayToStringHelper.stringifyByChunk(array, type, chunk); - } catch (e) { - chunk = Math.floor(chunk / 2); - } - } - } - return arrayToStringHelper.stringifyByChar(array); - } - exports2.applyFromCharCode = arrayLikeToString; - function arrayLikeToArrayLike(arrayFrom, arrayTo) { - for (var i = 0; i < arrayFrom.length; i++) { - arrayTo[i] = arrayFrom[i]; - } - return arrayTo; - } - var transform = {}; - transform["string"] = { - "string": identity, - "array": function(input) { - return stringToArrayLike(input, new Array(input.length)); - }, - "arraybuffer": function(input) { - return transform["string"]["uint8array"](input).buffer; - }, - "uint8array": function(input) { - return stringToArrayLike(input, new Uint8Array(input.length)); - }, - "nodebuffer": function(input) { - return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length)); - } - }; - transform["array"] = { - "string": arrayLikeToString, - "array": identity, - "arraybuffer": function(input) { - return new Uint8Array(input).buffer; - }, - "uint8array": function(input) { - return new Uint8Array(input); - }, - "nodebuffer": function(input) { - return nodejsUtils.newBufferFrom(input); - } - }; - transform["arraybuffer"] = { - "string": function(input) { - return arrayLikeToString(new Uint8Array(input)); - }, - "array": function(input) { - return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength)); - }, - "arraybuffer": identity, - "uint8array": function(input) { - return new Uint8Array(input); - }, - "nodebuffer": function(input) { - return nodejsUtils.newBufferFrom(new Uint8Array(input)); - } - }; - transform["uint8array"] = { - "string": arrayLikeToString, - "array": function(input) { - return arrayLikeToArrayLike(input, new Array(input.length)); - }, - "arraybuffer": function(input) { - return input.buffer; - }, - "uint8array": identity, - "nodebuffer": function(input) { - return nodejsUtils.newBufferFrom(input); - } - }; - transform["nodebuffer"] = { - "string": arrayLikeToString, - "array": function(input) { - return arrayLikeToArrayLike(input, new Array(input.length)); - }, - "arraybuffer": function(input) { - return transform["nodebuffer"]["uint8array"](input).buffer; - }, - "uint8array": function(input) { - return arrayLikeToArrayLike(input, new Uint8Array(input.length)); - }, - "nodebuffer": identity - }; - exports2.transformTo = function(outputType, input) { - if (!input) { - input = ""; - } - if (!outputType) { - return input; - } - exports2.checkSupport(outputType); - var inputType = exports2.getTypeOf(input); - var result = transform[inputType][outputType](input); - return result; - }; - exports2.resolve = function(path4) { - var parts = path4.split("/"); - var result = []; - for (var index = 0; index < parts.length; index++) { - var part = parts[index]; - if (part === "." || part === "" && index !== 0 && index !== parts.length - 1) { - continue; - } else if (part === "..") { - result.pop(); - } else { - result.push(part); - } - } - return result.join("/"); - }; - exports2.getTypeOf = function(input) { - if (typeof input === "string") { - return "string"; - } - if (Object.prototype.toString.call(input) === "[object Array]") { - return "array"; - } - if (support.nodebuffer && nodejsUtils.isBuffer(input)) { - return "nodebuffer"; - } - if (support.uint8array && input instanceof Uint8Array) { - return "uint8array"; - } - if (support.arraybuffer && input instanceof ArrayBuffer) { - return "arraybuffer"; - } - }; - exports2.checkSupport = function(type) { - var supported = support[type.toLowerCase()]; - if (!supported) { - throw new Error(type + " is not supported by this platform"); - } - }; - exports2.MAX_VALUE_16BITS = 65535; - exports2.MAX_VALUE_32BITS = -1; - exports2.pretty = function(str) { - var res = "", code, i; - for (i = 0; i < (str || "").length; i++) { - code = str.charCodeAt(i); - res += "\\x" + (code < 16 ? "0" : "") + code.toString(16).toUpperCase(); - } - return res; - }; - exports2.delay = function(callback, args, self2) { - setImmediate(function() { - callback.apply(self2 || null, args || []); - }); - }; - exports2.inherits = function(ctor, superCtor) { - var Obj = function() { - }; - Obj.prototype = superCtor.prototype; - ctor.prototype = new Obj(); - }; - exports2.extend = function() { - var result = {}, i, attr; - for (i = 0; i < arguments.length; i++) { - for (attr in arguments[i]) { - if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === "undefined") { - result[attr] = arguments[i][attr]; - } - } - } - return result; - }; - exports2.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) { - var promise = external.Promise.resolve(inputData).then(function(data) { - var isBlob = support.blob && (data instanceof Blob || ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(data)) !== -1); - if (isBlob && typeof FileReader !== "undefined") { - return new external.Promise(function(resolve, reject) { - var reader = new FileReader(); - reader.onload = function(e) { - resolve(e.target.result); - }; - reader.onerror = function(e) { - reject(e.target.error); - }; - reader.readAsArrayBuffer(data); - }); - } else { - return data; - } - }); - return promise.then(function(data) { - var dataType = exports2.getTypeOf(data); - if (!dataType) { - return external.Promise.reject(new Error("Can't read the data of '" + name + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")); - } - if (dataType === "arraybuffer") { - data = exports2.transformTo("uint8array", data); - } else if (dataType === "string") { - if (isBase64) { - data = base64.decode(data); - } else if (isBinary) { - if (isOptimizedBinaryString !== true) { - data = string2binary(data); - } - } - } - return data; - }); - }; - } -}); - -// node_modules/jszip/lib/stream/GenericWorker.js -var require_GenericWorker = __commonJS({ - "node_modules/jszip/lib/stream/GenericWorker.js"(exports2, module2) { - "use strict"; - function GenericWorker(name) { - this.name = name || "default"; - this.streamInfo = {}; - this.generatedError = null; - this.extraStreamInfo = {}; - this.isPaused = true; - this.isFinished = false; - this.isLocked = false; - this._listeners = { - "data": [], - "end": [], - "error": [] - }; - this.previous = null; - } - GenericWorker.prototype = { - push: function(chunk) { - this.emit("data", chunk); - }, - end: function() { - if (this.isFinished) { - return false; - } - this.flush(); - try { - this.emit("end"); - this.cleanUp(); - this.isFinished = true; - } catch (e) { - this.emit("error", e); - } - return true; - }, - error: function(e) { - if (this.isFinished) { - return false; - } - if (this.isPaused) { - this.generatedError = e; - } else { - this.isFinished = true; - this.emit("error", e); - if (this.previous) { - this.previous.error(e); - } - this.cleanUp(); - } - return true; - }, - on: function(name, listener) { - this._listeners[name].push(listener); - return this; - }, - cleanUp: function() { - this.streamInfo = this.generatedError = this.extraStreamInfo = null; - this._listeners = []; - }, - emit: function(name, arg) { - if (this._listeners[name]) { - for (var i = 0; i < this._listeners[name].length; i++) { - this._listeners[name][i].call(this, arg); - } - } - }, - pipe: function(next) { - return next.registerPrevious(this); - }, - registerPrevious: function(previous) { - if (this.isLocked) { - throw new Error("The stream '" + this + "' has already been used."); - } - this.streamInfo = previous.streamInfo; - this.mergeStreamInfo(); - this.previous = previous; - var self2 = this; - previous.on("data", function(chunk) { - self2.processChunk(chunk); - }); - previous.on("end", function() { - self2.end(); - }); - previous.on("error", function(e) { - self2.error(e); - }); - return this; - }, - pause: function() { - if (this.isPaused || this.isFinished) { - return false; - } - this.isPaused = true; - if (this.previous) { - this.previous.pause(); - } - return true; - }, - resume: function() { - if (!this.isPaused || this.isFinished) { - return false; - } - this.isPaused = false; - var withError = false; - if (this.generatedError) { - this.error(this.generatedError); - withError = true; - } - if (this.previous) { - this.previous.resume(); - } - return !withError; - }, - flush: function() { - }, - processChunk: function(chunk) { - this.push(chunk); - }, - withStreamInfo: function(key, value) { - this.extraStreamInfo[key] = value; - this.mergeStreamInfo(); - return this; - }, - mergeStreamInfo: function() { - for (var key in this.extraStreamInfo) { - if (!Object.prototype.hasOwnProperty.call(this.extraStreamInfo, key)) { - continue; - } - this.streamInfo[key] = this.extraStreamInfo[key]; - } - }, - lock: function() { - if (this.isLocked) { - throw new Error("The stream '" + this + "' has already been used."); - } - this.isLocked = true; - if (this.previous) { - this.previous.lock(); - } - }, - toString: function() { - var me = "Worker " + this.name; - if (this.previous) { - return this.previous + " -> " + me; - } else { - return me; - } - } - }; - module2.exports = GenericWorker; - } -}); - -// node_modules/jszip/lib/utf8.js -var require_utf8 = __commonJS({ - "node_modules/jszip/lib/utf8.js"(exports2) { - "use strict"; - var utils = require_utils3(); - var support = require_support(); - var nodejsUtils = require_nodejsUtils(); - var GenericWorker = require_GenericWorker(); - var _utf8len = new Array(256); - for (i = 0; i < 256; i++) { - _utf8len[i] = i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1; - } - var i; - _utf8len[254] = _utf8len[254] = 1; - var string2buf = function(str) { - var buf, c, c2, m_pos, i2, str_len = str.length, buf_len = 0; - for (m_pos = 0; m_pos < str_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 64512) === 55296 && m_pos + 1 < str_len) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 64512) === 56320) { - c = 65536 + (c - 55296 << 10) + (c2 - 56320); - m_pos++; - } - } - buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4; - } - if (support.uint8array) { - buf = new Uint8Array(buf_len); - } else { - buf = new Array(buf_len); - } - for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 64512) === 55296 && m_pos + 1 < str_len) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 64512) === 56320) { - c = 65536 + (c - 55296 << 10) + (c2 - 56320); - m_pos++; - } - } - if (c < 128) { - buf[i2++] = c; - } else if (c < 2048) { - buf[i2++] = 192 | c >>> 6; - buf[i2++] = 128 | c & 63; - } else if (c < 65536) { - buf[i2++] = 224 | c >>> 12; - buf[i2++] = 128 | c >>> 6 & 63; - buf[i2++] = 128 | c & 63; - } else { - buf[i2++] = 240 | c >>> 18; - buf[i2++] = 128 | c >>> 12 & 63; - buf[i2++] = 128 | c >>> 6 & 63; - buf[i2++] = 128 | c & 63; - } - } - return buf; - }; - var utf8border = function(buf, max) { - var pos; - max = max || buf.length; - if (max > buf.length) { - max = buf.length; - } - pos = max - 1; - while (pos >= 0 && (buf[pos] & 192) === 128) { - pos--; - } - if (pos < 0) { - return max; - } - if (pos === 0) { - return max; - } - return pos + _utf8len[buf[pos]] > max ? pos : max; - }; - var buf2string = function(buf) { - var i2, out, c, c_len; - var len = buf.length; - var utf16buf = new Array(len * 2); - for (out = 0, i2 = 0; i2 < len; ) { - c = buf[i2++]; - if (c < 128) { - utf16buf[out++] = c; - continue; - } - c_len = _utf8len[c]; - if (c_len > 4) { - utf16buf[out++] = 65533; - i2 += c_len - 1; - continue; - } - c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; - while (c_len > 1 && i2 < len) { - c = c << 6 | buf[i2++] & 63; - c_len--; - } - if (c_len > 1) { - utf16buf[out++] = 65533; - continue; - } - if (c < 65536) { - utf16buf[out++] = c; - } else { - c -= 65536; - utf16buf[out++] = 55296 | c >> 10 & 1023; - utf16buf[out++] = 56320 | c & 1023; - } - } - if (utf16buf.length !== out) { - if (utf16buf.subarray) { - utf16buf = utf16buf.subarray(0, out); - } else { - utf16buf.length = out; - } - } - return utils.applyFromCharCode(utf16buf); - }; - exports2.utf8encode = function utf8encode(str) { - if (support.nodebuffer) { - return nodejsUtils.newBufferFrom(str, "utf-8"); - } - return string2buf(str); - }; - exports2.utf8decode = function utf8decode(buf) { - if (support.nodebuffer) { - return utils.transformTo("nodebuffer", buf).toString("utf-8"); - } - buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf); - return buf2string(buf); - }; - function Utf8DecodeWorker() { - GenericWorker.call(this, "utf-8 decode"); - this.leftOver = null; - } - utils.inherits(Utf8DecodeWorker, GenericWorker); - Utf8DecodeWorker.prototype.processChunk = function(chunk) { - var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data); - if (this.leftOver && this.leftOver.length) { - if (support.uint8array) { - var previousData = data; - data = new Uint8Array(previousData.length + this.leftOver.length); - data.set(this.leftOver, 0); - data.set(previousData, this.leftOver.length); - } else { - data = this.leftOver.concat(data); - } - this.leftOver = null; - } - var nextBoundary = utf8border(data); - var usableData = data; - if (nextBoundary !== data.length) { - if (support.uint8array) { - usableData = data.subarray(0, nextBoundary); - this.leftOver = data.subarray(nextBoundary, data.length); - } else { - usableData = data.slice(0, nextBoundary); - this.leftOver = data.slice(nextBoundary, data.length); - } - } - this.push({ - data: exports2.utf8decode(usableData), - meta: chunk.meta - }); - }; - Utf8DecodeWorker.prototype.flush = function() { - if (this.leftOver && this.leftOver.length) { - this.push({ - data: exports2.utf8decode(this.leftOver), - meta: {} - }); - this.leftOver = null; - } - }; - exports2.Utf8DecodeWorker = Utf8DecodeWorker; - function Utf8EncodeWorker() { - GenericWorker.call(this, "utf-8 encode"); - } - utils.inherits(Utf8EncodeWorker, GenericWorker); - Utf8EncodeWorker.prototype.processChunk = function(chunk) { - this.push({ - data: exports2.utf8encode(chunk.data), - meta: chunk.meta - }); - }; - exports2.Utf8EncodeWorker = Utf8EncodeWorker; - } -}); - -// node_modules/jszip/lib/stream/ConvertWorker.js -var require_ConvertWorker = __commonJS({ - "node_modules/jszip/lib/stream/ConvertWorker.js"(exports2, module2) { - "use strict"; - var GenericWorker = require_GenericWorker(); - var utils = require_utils3(); - function ConvertWorker(destType) { - GenericWorker.call(this, "ConvertWorker to " + destType); - this.destType = destType; - } - utils.inherits(ConvertWorker, GenericWorker); - ConvertWorker.prototype.processChunk = function(chunk) { - this.push({ - data: utils.transformTo(this.destType, chunk.data), - meta: chunk.meta - }); - }; - module2.exports = ConvertWorker; - } -}); - -// node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js -var require_NodejsStreamOutputAdapter = __commonJS({ - "node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js"(exports2, module2) { - "use strict"; - var Readable = require_readable().Readable; - var utils = require_utils3(); - utils.inherits(NodejsStreamOutputAdapter, Readable); - function NodejsStreamOutputAdapter(helper, options, updateCb) { - Readable.call(this, options); - this._helper = helper; - var self2 = this; - helper.on("data", function(data, meta) { - if (!self2.push(data)) { - self2._helper.pause(); - } - if (updateCb) { - updateCb(meta); - } - }).on("error", function(e) { - self2.emit("error", e); - }).on("end", function() { - self2.push(null); - }); - } - NodejsStreamOutputAdapter.prototype._read = function() { - this._helper.resume(); - }; - module2.exports = NodejsStreamOutputAdapter; - } -}); - -// node_modules/jszip/lib/stream/StreamHelper.js -var require_StreamHelper = __commonJS({ - "node_modules/jszip/lib/stream/StreamHelper.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var ConvertWorker = require_ConvertWorker(); - var GenericWorker = require_GenericWorker(); - var base64 = require_base64(); - var support = require_support(); - var external = require_external(); - var NodejsStreamOutputAdapter = null; - if (support.nodestream) { - try { - NodejsStreamOutputAdapter = require_NodejsStreamOutputAdapter(); - } catch (e) { - } - } - function transformZipOutput(type, content, mimeType) { - switch (type) { - case "blob": - return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType); - case "base64": - return base64.encode(content); - default: - return utils.transformTo(type, content); - } - } - function concat(type, dataArray) { - var i, index = 0, res = null, totalLength = 0; - for (i = 0; i < dataArray.length; i++) { - totalLength += dataArray[i].length; - } - switch (type) { - case "string": - return dataArray.join(""); - case "array": - return Array.prototype.concat.apply([], dataArray); - case "uint8array": - res = new Uint8Array(totalLength); - for (i = 0; i < dataArray.length; i++) { - res.set(dataArray[i], index); - index += dataArray[i].length; - } - return res; - case "nodebuffer": - return Buffer.concat(dataArray); - default: - throw new Error("concat : unsupported type '" + type + "'"); - } - } - function accumulate(helper, updateCallback) { - return new external.Promise(function(resolve, reject) { - var dataArray = []; - var chunkType = helper._internalType, resultType = helper._outputType, mimeType = helper._mimeType; - helper.on("data", function(data, meta) { - dataArray.push(data); - if (updateCallback) { - updateCallback(meta); - } - }).on("error", function(err) { - dataArray = []; - reject(err); - }).on("end", function() { - try { - var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType); - resolve(result); - } catch (e) { - reject(e); - } - dataArray = []; - }).resume(); - }); - } - function StreamHelper(worker, outputType, mimeType) { - var internalType = outputType; - switch (outputType) { - case "blob": - case "arraybuffer": - internalType = "uint8array"; - break; - case "base64": - internalType = "string"; - break; - } - try { - this._internalType = internalType; - this._outputType = outputType; - this._mimeType = mimeType; - utils.checkSupport(internalType); - this._worker = worker.pipe(new ConvertWorker(internalType)); - worker.lock(); - } catch (e) { - this._worker = new GenericWorker("error"); - this._worker.error(e); - } - } - StreamHelper.prototype = { - accumulate: function(updateCb) { - return accumulate(this, updateCb); - }, - on: function(evt, fn) { - var self2 = this; - if (evt === "data") { - this._worker.on(evt, function(chunk) { - fn.call(self2, chunk.data, chunk.meta); - }); - } else { - this._worker.on(evt, function() { - utils.delay(fn, arguments, self2); - }); - } - return this; - }, - resume: function() { - utils.delay(this._worker.resume, [], this._worker); - return this; - }, - pause: function() { - this._worker.pause(); - return this; - }, - toNodejsStream: function(updateCb) { - utils.checkSupport("nodestream"); - if (this._outputType !== "nodebuffer") { - throw new Error(this._outputType + " is not supported by this method"); - } - return new NodejsStreamOutputAdapter(this, { - objectMode: this._outputType !== "nodebuffer" - }, updateCb); - } - }; - module2.exports = StreamHelper; - } -}); - -// node_modules/jszip/lib/defaults.js -var require_defaults = __commonJS({ - "node_modules/jszip/lib/defaults.js"(exports2) { - "use strict"; - exports2.base64 = false; - exports2.binary = false; - exports2.dir = false; - exports2.createFolders = true; - exports2.date = null; - exports2.compression = null; - exports2.compressionOptions = null; - exports2.comment = null; - exports2.unixPermissions = null; - exports2.dosPermissions = null; - } -}); - -// node_modules/jszip/lib/stream/DataWorker.js -var require_DataWorker = __commonJS({ - "node_modules/jszip/lib/stream/DataWorker.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var GenericWorker = require_GenericWorker(); - var DEFAULT_BLOCK_SIZE = 16 * 1024; - function DataWorker(dataP) { - GenericWorker.call(this, "DataWorker"); - var self2 = this; - this.dataIsReady = false; - this.index = 0; - this.max = 0; - this.data = null; - this.type = ""; - this._tickScheduled = false; - dataP.then(function(data) { - self2.dataIsReady = true; - self2.data = data; - self2.max = data && data.length || 0; - self2.type = utils.getTypeOf(data); - if (!self2.isPaused) { - self2._tickAndRepeat(); - } - }, function(e) { - self2.error(e); - }); - } - utils.inherits(DataWorker, GenericWorker); - DataWorker.prototype.cleanUp = function() { - GenericWorker.prototype.cleanUp.call(this); - this.data = null; - }; - DataWorker.prototype.resume = function() { - if (!GenericWorker.prototype.resume.call(this)) { - return false; - } - if (!this._tickScheduled && this.dataIsReady) { - this._tickScheduled = true; - utils.delay(this._tickAndRepeat, [], this); - } - return true; - }; - DataWorker.prototype._tickAndRepeat = function() { - this._tickScheduled = false; - if (this.isPaused || this.isFinished) { - return; - } - this._tick(); - if (!this.isFinished) { - utils.delay(this._tickAndRepeat, [], this); - this._tickScheduled = true; - } - }; - DataWorker.prototype._tick = function() { - if (this.isPaused || this.isFinished) { - return false; - } - var size = DEFAULT_BLOCK_SIZE; - var data = null, nextIndex = Math.min(this.max, this.index + size); - if (this.index >= this.max) { - return this.end(); - } else { - switch (this.type) { - case "string": - data = this.data.substring(this.index, nextIndex); - break; - case "uint8array": - data = this.data.subarray(this.index, nextIndex); - break; - case "array": - case "nodebuffer": - data = this.data.slice(this.index, nextIndex); - break; - } - this.index = nextIndex; - return this.push({ - data, - meta: { - percent: this.max ? this.index / this.max * 100 : 0 - } - }); - } - }; - module2.exports = DataWorker; - } -}); - -// node_modules/jszip/lib/crc32.js -var require_crc32 = __commonJS({ - "node_modules/jszip/lib/crc32.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - function makeTable() { - var c, table = []; - for (var n = 0; n < 256; n++) { - c = n; - for (var k = 0; k < 8; k++) { - c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1; - } - table[n] = c; - } - return table; - } - var crcTable = makeTable(); - function crc32(crc, buf, len, pos) { - var t = crcTable, end = pos + len; - crc = crc ^ -1; - for (var i = pos; i < end; i++) { - crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255]; - } - return crc ^ -1; - } - function crc32str(crc, str, len, pos) { - var t = crcTable, end = pos + len; - crc = crc ^ -1; - for (var i = pos; i < end; i++) { - crc = crc >>> 8 ^ t[(crc ^ str.charCodeAt(i)) & 255]; - } - return crc ^ -1; - } - module2.exports = function crc32wrapper(input, crc) { - if (typeof input === "undefined" || !input.length) { - return 0; - } - var isArray = utils.getTypeOf(input) !== "string"; - if (isArray) { - return crc32(crc | 0, input, input.length, 0); - } else { - return crc32str(crc | 0, input, input.length, 0); - } - }; - } -}); - -// node_modules/jszip/lib/stream/Crc32Probe.js -var require_Crc32Probe = __commonJS({ - "node_modules/jszip/lib/stream/Crc32Probe.js"(exports2, module2) { - "use strict"; - var GenericWorker = require_GenericWorker(); - var crc32 = require_crc32(); - var utils = require_utils3(); - function Crc32Probe() { - GenericWorker.call(this, "Crc32Probe"); - this.withStreamInfo("crc32", 0); - } - utils.inherits(Crc32Probe, GenericWorker); - Crc32Probe.prototype.processChunk = function(chunk) { - this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0); - this.push(chunk); - }; - module2.exports = Crc32Probe; - } -}); - -// node_modules/jszip/lib/stream/DataLengthProbe.js -var require_DataLengthProbe = __commonJS({ - "node_modules/jszip/lib/stream/DataLengthProbe.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var GenericWorker = require_GenericWorker(); - function DataLengthProbe(propName) { - GenericWorker.call(this, "DataLengthProbe for " + propName); - this.propName = propName; - this.withStreamInfo(propName, 0); - } - utils.inherits(DataLengthProbe, GenericWorker); - DataLengthProbe.prototype.processChunk = function(chunk) { - if (chunk) { - var length = this.streamInfo[this.propName] || 0; - this.streamInfo[this.propName] = length + chunk.data.length; - } - GenericWorker.prototype.processChunk.call(this, chunk); - }; - module2.exports = DataLengthProbe; - } -}); - -// node_modules/jszip/lib/compressedObject.js -var require_compressedObject = __commonJS({ - "node_modules/jszip/lib/compressedObject.js"(exports2, module2) { - "use strict"; - var external = require_external(); - var DataWorker = require_DataWorker(); - var Crc32Probe = require_Crc32Probe(); - var DataLengthProbe = require_DataLengthProbe(); - function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) { - this.compressedSize = compressedSize; - this.uncompressedSize = uncompressedSize; - this.crc32 = crc32; - this.compression = compression; - this.compressedContent = data; - } - CompressedObject.prototype = { - getContentWorker: function() { - var worker = new DataWorker(external.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new DataLengthProbe("data_length")); - var that = this; - worker.on("end", function() { - if (this.streamInfo["data_length"] !== that.uncompressedSize) { - throw new Error("Bug : uncompressed data size mismatch"); - } - }); - return worker; - }, - getCompressedWorker: function() { - return new DataWorker(external.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression); - } - }; - CompressedObject.createWorkerFrom = function(uncompressedWorker, compression, compressionOptions) { - return uncompressedWorker.pipe(new Crc32Probe()).pipe(new DataLengthProbe("uncompressedSize")).pipe(compression.compressWorker(compressionOptions)).pipe(new DataLengthProbe("compressedSize")).withStreamInfo("compression", compression); - }; - module2.exports = CompressedObject; - } -}); - -// node_modules/jszip/lib/zipObject.js -var require_zipObject = __commonJS({ - "node_modules/jszip/lib/zipObject.js"(exports2, module2) { - "use strict"; - var StreamHelper = require_StreamHelper(); - var DataWorker = require_DataWorker(); - var utf8 = require_utf8(); - var CompressedObject = require_compressedObject(); - var GenericWorker = require_GenericWorker(); - var ZipObject = function(name, data, options) { - this.name = name; - this.dir = options.dir; - this.date = options.date; - this.comment = options.comment; - this.unixPermissions = options.unixPermissions; - this.dosPermissions = options.dosPermissions; - this._data = data; - this._dataBinary = options.binary; - this.options = { - compression: options.compression, - compressionOptions: options.compressionOptions - }; - }; - ZipObject.prototype = { - internalStream: function(type) { - var result = null, outputType = "string"; - try { - if (!type) { - throw new Error("No output type specified."); - } - outputType = type.toLowerCase(); - var askUnicodeString = outputType === "string" || outputType === "text"; - if (outputType === "binarystring" || outputType === "text") { - outputType = "string"; - } - result = this._decompressWorker(); - var isUnicodeString = !this._dataBinary; - if (isUnicodeString && !askUnicodeString) { - result = result.pipe(new utf8.Utf8EncodeWorker()); - } - if (!isUnicodeString && askUnicodeString) { - result = result.pipe(new utf8.Utf8DecodeWorker()); - } - } catch (e) { - result = new GenericWorker("error"); - result.error(e); - } - return new StreamHelper(result, outputType, ""); - }, - async: function(type, onUpdate) { - return this.internalStream(type).accumulate(onUpdate); - }, - nodeStream: function(type, onUpdate) { - return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate); - }, - _compressWorker: function(compression, compressionOptions) { - if (this._data instanceof CompressedObject && this._data.compression.magic === compression.magic) { - return this._data.getCompressedWorker(); - } else { - var result = this._decompressWorker(); - if (!this._dataBinary) { - result = result.pipe(new utf8.Utf8EncodeWorker()); - } - return CompressedObject.createWorkerFrom(result, compression, compressionOptions); - } - }, - _decompressWorker: function() { - if (this._data instanceof CompressedObject) { - return this._data.getContentWorker(); - } else if (this._data instanceof GenericWorker) { - return this._data; - } else { - return new DataWorker(this._data); - } - } - }; - var removedMethods = ["asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer"]; - var removedFn = function() { - throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); - }; - for (i = 0; i < removedMethods.length; i++) { - ZipObject.prototype[removedMethods[i]] = removedFn; - } - var i; - module2.exports = ZipObject; - } -}); - -// node_modules/pako/lib/utils/common.js -var require_common = __commonJS({ - "node_modules/pako/lib/utils/common.js"(exports2) { - "use strict"; - var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; - function _has(obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key); - } - exports2.assign = function(obj) { - var sources = Array.prototype.slice.call(arguments, 1); - while (sources.length) { - var source = sources.shift(); - if (!source) { - continue; - } - if (typeof source !== "object") { - throw new TypeError(source + "must be non-object"); - } - for (var p in source) { - if (_has(source, p)) { - obj[p] = source[p]; - } - } - } - return obj; - }; - exports2.shrinkBuf = function(buf, size) { - if (buf.length === size) { - return buf; - } - if (buf.subarray) { - return buf.subarray(0, size); - } - buf.length = size; - return buf; - }; - var fnTyped = { - arraySet: function(dest, src, src_offs, len, dest_offs) { - if (src.subarray && dest.subarray) { - dest.set(src.subarray(src_offs, src_offs + len), dest_offs); - return; - } - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } - }, - flattenChunks: function(chunks) { - var i, l, len, pos, chunk, result; - len = 0; - for (i = 0, l = chunks.length; i < l; i++) { - len += chunks[i].length; - } - result = new Uint8Array(len); - pos = 0; - for (i = 0, l = chunks.length; i < l; i++) { - chunk = chunks[i]; - result.set(chunk, pos); - pos += chunk.length; - } - return result; - } - }; - var fnUntyped = { - arraySet: function(dest, src, src_offs, len, dest_offs) { - for (var i = 0; i < len; i++) { - dest[dest_offs + i] = src[src_offs + i]; - } - }, - flattenChunks: function(chunks) { - return [].concat.apply([], chunks); - } - }; - exports2.setTyped = function(on) { - if (on) { - exports2.Buf8 = Uint8Array; - exports2.Buf16 = Uint16Array; - exports2.Buf32 = Int32Array; - exports2.assign(exports2, fnTyped); - } else { - exports2.Buf8 = Array; - exports2.Buf16 = Array; - exports2.Buf32 = Array; - exports2.assign(exports2, fnUntyped); - } - }; - exports2.setTyped(TYPED_OK); - } -}); - -// node_modules/pako/lib/zlib/trees.js -var require_trees = __commonJS({ - "node_modules/pako/lib/zlib/trees.js"(exports2) { - "use strict"; - var utils = require_common(); - var Z_FIXED = 4; - var Z_BINARY = 0; - var Z_TEXT = 1; - var Z_UNKNOWN = 2; - function zero(buf) { - var len = buf.length; - while (--len >= 0) { - buf[len] = 0; - } - } - var STORED_BLOCK = 0; - var STATIC_TREES = 1; - var DYN_TREES = 2; - var MIN_MATCH = 3; - var MAX_MATCH = 258; - var LENGTH_CODES = 29; - var LITERALS = 256; - var L_CODES = LITERALS + 1 + LENGTH_CODES; - var D_CODES = 30; - var BL_CODES = 19; - var HEAP_SIZE = 2 * L_CODES + 1; - var MAX_BITS = 15; - var Buf_size = 16; - var MAX_BL_BITS = 7; - var END_BLOCK = 256; - var REP_3_6 = 16; - var REPZ_3_10 = 17; - var REPZ_11_138 = 18; - var extra_lbits = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0]; - var extra_dbits = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]; - var extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]; - var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; - var DIST_CODE_LEN = 512; - var static_ltree = new Array((L_CODES + 2) * 2); - zero(static_ltree); - var static_dtree = new Array(D_CODES * 2); - zero(static_dtree); - var _dist_code = new Array(DIST_CODE_LEN); - zero(_dist_code); - var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); - zero(_length_code); - var base_length = new Array(LENGTH_CODES); - zero(base_length); - var base_dist = new Array(D_CODES); - zero(base_dist); - function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { - this.static_tree = static_tree; - this.extra_bits = extra_bits; - this.extra_base = extra_base; - this.elems = elems; - this.max_length = max_length; - this.has_stree = static_tree && static_tree.length; - } - var static_l_desc; - var static_d_desc; - var static_bl_desc; - function TreeDesc(dyn_tree, stat_desc) { - this.dyn_tree = dyn_tree; - this.max_code = 0; - this.stat_desc = stat_desc; - } - function d_code(dist) { - return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; - } - function put_short(s, w) { - s.pending_buf[s.pending++] = w & 255; - s.pending_buf[s.pending++] = w >>> 8 & 255; - } - function send_bits(s, value, length) { - if (s.bi_valid > Buf_size - length) { - s.bi_buf |= value << s.bi_valid & 65535; - put_short(s, s.bi_buf); - s.bi_buf = value >> Buf_size - s.bi_valid; - s.bi_valid += length - Buf_size; - } else { - s.bi_buf |= value << s.bi_valid & 65535; - s.bi_valid += length; - } - } - function send_code(s, c, tree) { - send_bits(s, tree[c * 2], tree[c * 2 + 1]); - } - function bi_reverse(code, len) { - var res = 0; - do { - res |= code & 1; - code >>>= 1; - res <<= 1; - } while (--len > 0); - return res >>> 1; - } - function bi_flush(s) { - if (s.bi_valid === 16) { - put_short(s, s.bi_buf); - s.bi_buf = 0; - s.bi_valid = 0; - } else if (s.bi_valid >= 8) { - s.pending_buf[s.pending++] = s.bi_buf & 255; - s.bi_buf >>= 8; - s.bi_valid -= 8; - } - } - function gen_bitlen(s, desc) { - var tree = desc.dyn_tree; - var max_code = desc.max_code; - var stree = desc.stat_desc.static_tree; - var has_stree = desc.stat_desc.has_stree; - var extra = desc.stat_desc.extra_bits; - var base = desc.stat_desc.extra_base; - var max_length = desc.stat_desc.max_length; - var h; - var n, m; - var bits; - var xbits; - var f; - var overflow = 0; - for (bits = 0; bits <= MAX_BITS; bits++) { - s.bl_count[bits] = 0; - } - tree[s.heap[s.heap_max] * 2 + 1] = 0; - for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { - n = s.heap[h]; - bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; - if (bits > max_length) { - bits = max_length; - overflow++; - } - tree[n * 2 + 1] = bits; - if (n > max_code) { - continue; - } - s.bl_count[bits]++; - xbits = 0; - if (n >= base) { - xbits = extra[n - base]; - } - f = tree[n * 2]; - s.opt_len += f * (bits + xbits); - if (has_stree) { - s.static_len += f * (stree[n * 2 + 1] + xbits); - } - } - if (overflow === 0) { - return; - } - do { - bits = max_length - 1; - while (s.bl_count[bits] === 0) { - bits--; - } - s.bl_count[bits]--; - s.bl_count[bits + 1] += 2; - s.bl_count[max_length]--; - overflow -= 2; - } while (overflow > 0); - for (bits = max_length; bits !== 0; bits--) { - n = s.bl_count[bits]; - while (n !== 0) { - m = s.heap[--h]; - if (m > max_code) { - continue; - } - if (tree[m * 2 + 1] !== bits) { - s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; - tree[m * 2 + 1] = bits; - } - n--; - } - } - } - function gen_codes(tree, max_code, bl_count) { - var next_code = new Array(MAX_BITS + 1); - var code = 0; - var bits; - var n; - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = code + bl_count[bits - 1] << 1; - } - for (n = 0; n <= max_code; n++) { - var len = tree[n * 2 + 1]; - if (len === 0) { - continue; - } - tree[n * 2] = bi_reverse(next_code[len]++, len); - } - } - function tr_static_init() { - var n; - var bits; - var length; - var code; - var dist; - var bl_count = new Array(MAX_BITS + 1); - length = 0; - for (code = 0; code < LENGTH_CODES - 1; code++) { - base_length[code] = length; - for (n = 0; n < 1 << extra_lbits[code]; n++) { - _length_code[length++] = code; - } - } - _length_code[length - 1] = code; - dist = 0; - for (code = 0; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < 1 << extra_dbits[code]; n++) { - _dist_code[dist++] = code; - } - } - dist >>= 7; - for (; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < 1 << extra_dbits[code] - 7; n++) { - _dist_code[256 + dist++] = code; - } - } - for (bits = 0; bits <= MAX_BITS; bits++) { - bl_count[bits] = 0; - } - n = 0; - while (n <= 143) { - static_ltree[n * 2 + 1] = 8; - n++; - bl_count[8]++; - } - while (n <= 255) { - static_ltree[n * 2 + 1] = 9; - n++; - bl_count[9]++; - } - while (n <= 279) { - static_ltree[n * 2 + 1] = 7; - n++; - bl_count[7]++; - } - while (n <= 287) { - static_ltree[n * 2 + 1] = 8; - n++; - bl_count[8]++; - } - gen_codes(static_ltree, L_CODES + 1, bl_count); - for (n = 0; n < D_CODES; n++) { - static_dtree[n * 2 + 1] = 5; - static_dtree[n * 2] = bi_reverse(n, 5); - } - static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); - static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); - static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); - } - function init_block(s) { - var n; - for (n = 0; n < L_CODES; n++) { - s.dyn_ltree[n * 2] = 0; - } - for (n = 0; n < D_CODES; n++) { - s.dyn_dtree[n * 2] = 0; - } - for (n = 0; n < BL_CODES; n++) { - s.bl_tree[n * 2] = 0; - } - s.dyn_ltree[END_BLOCK * 2] = 1; - s.opt_len = s.static_len = 0; - s.last_lit = s.matches = 0; - } - function bi_windup(s) { - if (s.bi_valid > 8) { - put_short(s, s.bi_buf); - } else if (s.bi_valid > 0) { - s.pending_buf[s.pending++] = s.bi_buf; - } - s.bi_buf = 0; - s.bi_valid = 0; - } - function copy_block(s, buf, len, header) { - bi_windup(s); - if (header) { - put_short(s, len); - put_short(s, ~len); - } - utils.arraySet(s.pending_buf, s.window, buf, len, s.pending); - s.pending += len; - } - function smaller(tree, n, m, depth) { - var _n2 = n * 2; - var _m2 = m * 2; - return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m]; - } - function pqdownheap(s, tree, k) { - var v = s.heap[k]; - var j = k << 1; - while (j <= s.heap_len) { - if (j < s.heap_len && smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { - j++; - } - if (smaller(tree, v, s.heap[j], s.depth)) { - break; - } - s.heap[k] = s.heap[j]; - k = j; - j <<= 1; - } - s.heap[k] = v; - } - function compress_block(s, ltree, dtree) { - var dist; - var lc; - var lx = 0; - var code; - var extra; - if (s.last_lit !== 0) { - do { - dist = s.pending_buf[s.d_buf + lx * 2] << 8 | s.pending_buf[s.d_buf + lx * 2 + 1]; - lc = s.pending_buf[s.l_buf + lx]; - lx++; - if (dist === 0) { - send_code(s, lc, ltree); - } else { - code = _length_code[lc]; - send_code(s, code + LITERALS + 1, ltree); - extra = extra_lbits[code]; - if (extra !== 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); - } - dist--; - code = d_code(dist); - send_code(s, code, dtree); - extra = extra_dbits[code]; - if (extra !== 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); - } - } - } while (lx < s.last_lit); - } - send_code(s, END_BLOCK, ltree); - } - function build_tree(s, desc) { - var tree = desc.dyn_tree; - var stree = desc.stat_desc.static_tree; - var has_stree = desc.stat_desc.has_stree; - var elems = desc.stat_desc.elems; - var n, m; - var max_code = -1; - var node; - s.heap_len = 0; - s.heap_max = HEAP_SIZE; - for (n = 0; n < elems; n++) { - if (tree[n * 2] !== 0) { - s.heap[++s.heap_len] = max_code = n; - s.depth[n] = 0; - } else { - tree[n * 2 + 1] = 0; - } - } - while (s.heap_len < 2) { - node = s.heap[++s.heap_len] = max_code < 2 ? ++max_code : 0; - tree[node * 2] = 1; - s.depth[node] = 0; - s.opt_len--; - if (has_stree) { - s.static_len -= stree[node * 2 + 1]; - } - } - desc.max_code = max_code; - for (n = s.heap_len >> 1; n >= 1; n--) { - pqdownheap(s, tree, n); - } - node = elems; - do { - n = s.heap[1]; - s.heap[1] = s.heap[s.heap_len--]; - pqdownheap(s, tree, 1); - m = s.heap[1]; - s.heap[--s.heap_max] = n; - s.heap[--s.heap_max] = m; - tree[node * 2] = tree[n * 2] + tree[m * 2]; - s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1; - tree[n * 2 + 1] = tree[m * 2 + 1] = node; - s.heap[1] = node++; - pqdownheap(s, tree, 1); - } while (s.heap_len >= 2); - s.heap[--s.heap_max] = s.heap[1]; - gen_bitlen(s, desc); - gen_codes(tree, max_code, s.bl_count); - } - function scan_tree(s, tree, max_code) { - var n; - var prevlen = -1; - var curlen; - var nextlen = tree[0 * 2 + 1]; - var count = 0; - var max_count = 7; - var min_count = 4; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } - tree[(max_code + 1) * 2 + 1] = 65535; - for (n = 0; n <= max_code; n++) { - curlen = nextlen; - nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen === nextlen) { - continue; - } else if (count < min_count) { - s.bl_tree[curlen * 2] += count; - } else if (curlen !== 0) { - if (curlen !== prevlen) { - s.bl_tree[curlen * 2]++; - } - s.bl_tree[REP_3_6 * 2]++; - } else if (count <= 10) { - s.bl_tree[REPZ_3_10 * 2]++; - } else { - s.bl_tree[REPZ_11_138 * 2]++; - } - count = 0; - prevlen = curlen; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } else if (curlen === nextlen) { - max_count = 6; - min_count = 3; - } else { - max_count = 7; - min_count = 4; - } - } - } - function send_tree(s, tree, max_code) { - var n; - var prevlen = -1; - var curlen; - var nextlen = tree[0 * 2 + 1]; - var count = 0; - var max_count = 7; - var min_count = 4; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } - for (n = 0; n <= max_code; n++) { - curlen = nextlen; - nextlen = tree[(n + 1) * 2 + 1]; - if (++count < max_count && curlen === nextlen) { - continue; - } else if (count < min_count) { - do { - send_code(s, curlen, s.bl_tree); - } while (--count !== 0); - } else if (curlen !== 0) { - if (curlen !== prevlen) { - send_code(s, curlen, s.bl_tree); - count--; - } - send_code(s, REP_3_6, s.bl_tree); - send_bits(s, count - 3, 2); - } else if (count <= 10) { - send_code(s, REPZ_3_10, s.bl_tree); - send_bits(s, count - 3, 3); - } else { - send_code(s, REPZ_11_138, s.bl_tree); - send_bits(s, count - 11, 7); - } - count = 0; - prevlen = curlen; - if (nextlen === 0) { - max_count = 138; - min_count = 3; - } else if (curlen === nextlen) { - max_count = 6; - min_count = 3; - } else { - max_count = 7; - min_count = 4; - } - } - } - function build_bl_tree(s) { - var max_blindex; - scan_tree(s, s.dyn_ltree, s.l_desc.max_code); - scan_tree(s, s.dyn_dtree, s.d_desc.max_code); - build_tree(s, s.bl_desc); - for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { - if (s.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) { - break; - } - } - s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; - return max_blindex; - } - function send_all_trees(s, lcodes, dcodes, blcodes) { - var rank; - send_bits(s, lcodes - 257, 5); - send_bits(s, dcodes - 1, 5); - send_bits(s, blcodes - 4, 4); - for (rank = 0; rank < blcodes; rank++) { - send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1], 3); - } - send_tree(s, s.dyn_ltree, lcodes - 1); - send_tree(s, s.dyn_dtree, dcodes - 1); - } - function detect_data_type(s) { - var black_mask = 4093624447; - var n; - for (n = 0; n <= 31; n++, black_mask >>>= 1) { - if (black_mask & 1 && s.dyn_ltree[n * 2] !== 0) { - return Z_BINARY; - } - } - if (s.dyn_ltree[9 * 2] !== 0 || s.dyn_ltree[10 * 2] !== 0 || s.dyn_ltree[13 * 2] !== 0) { - return Z_TEXT; - } - for (n = 32; n < LITERALS; n++) { - if (s.dyn_ltree[n * 2] !== 0) { - return Z_TEXT; - } - } - return Z_BINARY; - } - var static_init_done = false; - function _tr_init(s) { - if (!static_init_done) { - tr_static_init(); - static_init_done = true; - } - s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc); - s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc); - s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc); - s.bi_buf = 0; - s.bi_valid = 0; - init_block(s); - } - function _tr_stored_block(s, buf, stored_len, last) { - send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); - copy_block(s, buf, stored_len, true); - } - function _tr_align(s) { - send_bits(s, STATIC_TREES << 1, 3); - send_code(s, END_BLOCK, static_ltree); - bi_flush(s); - } - function _tr_flush_block(s, buf, stored_len, last) { - var opt_lenb, static_lenb; - var max_blindex = 0; - if (s.level > 0) { - if (s.strm.data_type === Z_UNKNOWN) { - s.strm.data_type = detect_data_type(s); - } - build_tree(s, s.l_desc); - build_tree(s, s.d_desc); - max_blindex = build_bl_tree(s); - opt_lenb = s.opt_len + 3 + 7 >>> 3; - static_lenb = s.static_len + 3 + 7 >>> 3; - if (static_lenb <= opt_lenb) { - opt_lenb = static_lenb; - } - } else { - opt_lenb = static_lenb = stored_len + 5; - } - if (stored_len + 4 <= opt_lenb && buf !== -1) { - _tr_stored_block(s, buf, stored_len, last); - } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) { - send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3); - compress_block(s, static_ltree, static_dtree); - } else { - send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3); - send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1); - compress_block(s, s.dyn_ltree, s.dyn_dtree); - } - init_block(s); - if (last) { - bi_windup(s); - } - } - function _tr_tally(s, dist, lc) { - s.pending_buf[s.d_buf + s.last_lit * 2] = dist >>> 8 & 255; - s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 255; - s.pending_buf[s.l_buf + s.last_lit] = lc & 255; - s.last_lit++; - if (dist === 0) { - s.dyn_ltree[lc * 2]++; - } else { - s.matches++; - dist--; - s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++; - s.dyn_dtree[d_code(dist) * 2]++; - } - return s.last_lit === s.lit_bufsize - 1; - } - exports2._tr_init = _tr_init; - exports2._tr_stored_block = _tr_stored_block; - exports2._tr_flush_block = _tr_flush_block; - exports2._tr_tally = _tr_tally; - exports2._tr_align = _tr_align; - } -}); - -// node_modules/pako/lib/zlib/adler32.js -var require_adler32 = __commonJS({ - "node_modules/pako/lib/zlib/adler32.js"(exports2, module2) { - "use strict"; - function adler32(adler, buf, len, pos) { - var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0; - while (len !== 0) { - n = len > 2e3 ? 2e3 : len; - len -= n; - do { - s1 = s1 + buf[pos++] | 0; - s2 = s2 + s1 | 0; - } while (--n); - s1 %= 65521; - s2 %= 65521; - } - return s1 | s2 << 16 | 0; - } - module2.exports = adler32; - } -}); - -// node_modules/pako/lib/zlib/crc32.js -var require_crc322 = __commonJS({ - "node_modules/pako/lib/zlib/crc32.js"(exports2, module2) { - "use strict"; - function makeTable() { - var c, table = []; - for (var n = 0; n < 256; n++) { - c = n; - for (var k = 0; k < 8; k++) { - c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1; - } - table[n] = c; - } - return table; - } - var crcTable = makeTable(); - function crc32(crc, buf, len, pos) { - var t = crcTable, end = pos + len; - crc ^= -1; - for (var i = pos; i < end; i++) { - crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255]; - } - return crc ^ -1; - } - module2.exports = crc32; - } -}); - -// node_modules/pako/lib/zlib/messages.js -var require_messages = __commonJS({ - "node_modules/pako/lib/zlib/messages.js"(exports2, module2) { - "use strict"; - module2.exports = { - 2: "need dictionary", - 1: "stream end", - 0: "", - "-1": "file error", - "-2": "stream error", - "-3": "data error", - "-4": "insufficient memory", - "-5": "buffer error", - "-6": "incompatible version" - }; - } -}); - -// node_modules/pako/lib/zlib/deflate.js -var require_deflate = __commonJS({ - "node_modules/pako/lib/zlib/deflate.js"(exports2) { - "use strict"; - var utils = require_common(); - var trees = require_trees(); - var adler32 = require_adler32(); - var crc32 = require_crc322(); - var msg = require_messages(); - var Z_NO_FLUSH = 0; - var Z_PARTIAL_FLUSH = 1; - var Z_FULL_FLUSH = 3; - var Z_FINISH = 4; - var Z_BLOCK = 5; - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - var Z_BUF_ERROR = -5; - var Z_DEFAULT_COMPRESSION = -1; - var Z_FILTERED = 1; - var Z_HUFFMAN_ONLY = 2; - var Z_RLE = 3; - var Z_FIXED = 4; - var Z_DEFAULT_STRATEGY = 0; - var Z_UNKNOWN = 2; - var Z_DEFLATED = 8; - var MAX_MEM_LEVEL = 9; - var MAX_WBITS = 15; - var DEF_MEM_LEVEL = 8; - var LENGTH_CODES = 29; - var LITERALS = 256; - var L_CODES = LITERALS + 1 + LENGTH_CODES; - var D_CODES = 30; - var BL_CODES = 19; - var HEAP_SIZE = 2 * L_CODES + 1; - var MAX_BITS = 15; - var MIN_MATCH = 3; - var MAX_MATCH = 258; - var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; - var PRESET_DICT = 32; - var INIT_STATE = 42; - var EXTRA_STATE = 69; - var NAME_STATE = 73; - var COMMENT_STATE = 91; - var HCRC_STATE = 103; - var BUSY_STATE = 113; - var FINISH_STATE = 666; - var BS_NEED_MORE = 1; - var BS_BLOCK_DONE = 2; - var BS_FINISH_STARTED = 3; - var BS_FINISH_DONE = 4; - var OS_CODE = 3; - function err(strm, errorCode) { - strm.msg = msg[errorCode]; - return errorCode; - } - function rank(f) { - return (f << 1) - (f > 4 ? 9 : 0); - } - function zero(buf) { - var len = buf.length; - while (--len >= 0) { - buf[len] = 0; - } - } - function flush_pending(strm) { - var s = strm.state; - var len = s.pending; - if (len > strm.avail_out) { - len = strm.avail_out; - } - if (len === 0) { - return; - } - utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out); - strm.next_out += len; - s.pending_out += len; - strm.total_out += len; - strm.avail_out -= len; - s.pending -= len; - if (s.pending === 0) { - s.pending_out = 0; - } - } - function flush_block_only(s, last) { - trees._tr_flush_block(s, s.block_start >= 0 ? s.block_start : -1, s.strstart - s.block_start, last); - s.block_start = s.strstart; - flush_pending(s.strm); - } - function put_byte(s, b) { - s.pending_buf[s.pending++] = b; - } - function putShortMSB(s, b) { - s.pending_buf[s.pending++] = b >>> 8 & 255; - s.pending_buf[s.pending++] = b & 255; - } - function read_buf(strm, buf, start, size) { - var len = strm.avail_in; - if (len > size) { - len = size; - } - if (len === 0) { - return 0; - } - strm.avail_in -= len; - utils.arraySet(buf, strm.input, strm.next_in, len, start); - if (strm.state.wrap === 1) { - strm.adler = adler32(strm.adler, buf, len, start); - } else if (strm.state.wrap === 2) { - strm.adler = crc32(strm.adler, buf, len, start); - } - strm.next_in += len; - strm.total_in += len; - return len; - } - function longest_match(s, cur_match) { - var chain_length = s.max_chain_length; - var scan = s.strstart; - var match; - var len; - var best_len = s.prev_length; - var nice_match = s.nice_match; - var limit = s.strstart > s.w_size - MIN_LOOKAHEAD ? s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0; - var _win = s.window; - var wmask = s.w_mask; - var prev = s.prev; - var strend = s.strstart + MAX_MATCH; - var scan_end1 = _win[scan + best_len - 1]; - var scan_end = _win[scan + best_len]; - if (s.prev_length >= s.good_match) { - chain_length >>= 2; - } - if (nice_match > s.lookahead) { - nice_match = s.lookahead; - } - do { - match = cur_match; - if (_win[match + best_len] !== scan_end || _win[match + best_len - 1] !== scan_end1 || _win[match] !== _win[scan] || _win[++match] !== _win[scan + 1]) { - continue; - } - scan += 2; - match++; - do { - } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && _win[++scan] === _win[++match] && scan < strend); - len = MAX_MATCH - (strend - scan); - scan = strend - MAX_MATCH; - if (len > best_len) { - s.match_start = cur_match; - best_len = len; - if (len >= nice_match) { - break; - } - scan_end1 = _win[scan + best_len - 1]; - scan_end = _win[scan + best_len]; - } - } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); - if (best_len <= s.lookahead) { - return best_len; - } - return s.lookahead; - } - function fill_window(s) { - var _w_size = s.w_size; - var p, n, m, more, str; - do { - more = s.window_size - s.lookahead - s.strstart; - if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { - utils.arraySet(s.window, s.window, _w_size, _w_size, 0); - s.match_start -= _w_size; - s.strstart -= _w_size; - s.block_start -= _w_size; - n = s.hash_size; - p = n; - do { - m = s.head[--p]; - s.head[p] = m >= _w_size ? m - _w_size : 0; - } while (--n); - n = _w_size; - p = n; - do { - m = s.prev[--p]; - s.prev[p] = m >= _w_size ? m - _w_size : 0; - } while (--n); - more += _w_size; - } - if (s.strm.avail_in === 0) { - break; - } - n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more); - s.lookahead += n; - if (s.lookahead + s.insert >= MIN_MATCH) { - str = s.strstart - s.insert; - s.ins_h = s.window[str]; - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + 1]) & s.hash_mask; - while (s.insert) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; - s.prev[str & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = str; - str++; - s.insert--; - if (s.lookahead + s.insert < MIN_MATCH) { - break; - } - } - } - } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0); - } - function deflate_stored(s, flush) { - var max_block_size = 65535; - if (max_block_size > s.pending_buf_size - 5) { - max_block_size = s.pending_buf_size - 5; - } - for (; ; ) { - if (s.lookahead <= 1) { - fill_window(s); - if (s.lookahead === 0 && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - s.strstart += s.lookahead; - s.lookahead = 0; - var max_start = s.block_start + max_block_size; - if (s.strstart === 0 || s.strstart >= max_start) { - s.lookahead = s.strstart - max_start; - s.strstart = max_start; - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - if (s.strstart - s.block_start >= s.w_size - MIN_LOOKAHEAD) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } - s.insert = 0; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; - } - if (s.strstart > s.block_start) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - return BS_NEED_MORE; - } - function deflate_fast(s, flush) { - var hash_head; - var bflush; - for (; ; ) { - if (s.lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - hash_head = 0; - if (s.lookahead >= MIN_MATCH) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } - if (hash_head !== 0 && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { - s.match_length = longest_match(s, hash_head); - } - if (s.match_length >= MIN_MATCH) { - bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH); - s.lookahead -= s.match_length; - if (s.match_length <= s.max_lazy_match && s.lookahead >= MIN_MATCH) { - s.match_length--; - do { - s.strstart++; - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } while (--s.match_length !== 0); - s.strstart++; - } else { - s.strstart += s.match_length; - s.match_length = 0; - s.ins_h = s.window[s.strstart]; - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + 1]) & s.hash_mask; - } - } else { - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; - } - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } - s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; - } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - return BS_BLOCK_DONE; - } - function deflate_slow(s, flush) { - var hash_head; - var bflush; - var max_insert; - for (; ; ) { - if (s.lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - hash_head = 0; - if (s.lookahead >= MIN_MATCH) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } - s.prev_length = s.match_length; - s.prev_match = s.match_start; - s.match_length = MIN_MATCH - 1; - if (hash_head !== 0 && s.prev_length < s.max_lazy_match && s.strstart - hash_head <= s.w_size - MIN_LOOKAHEAD) { - s.match_length = longest_match(s, hash_head); - if (s.match_length <= 5 && (s.strategy === Z_FILTERED || s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096)) { - s.match_length = MIN_MATCH - 1; - } - } - if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) { - max_insert = s.strstart + s.lookahead - MIN_MATCH; - bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH); - s.lookahead -= s.prev_length - 1; - s.prev_length -= 2; - do { - if (++s.strstart <= max_insert) { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask; - hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = s.strstart; - } - } while (--s.prev_length !== 0); - s.match_available = 0; - s.match_length = MIN_MATCH - 1; - s.strstart++; - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } else if (s.match_available) { - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); - if (bflush) { - flush_block_only(s, false); - } - s.strstart++; - s.lookahead--; - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } else { - s.match_available = 1; - s.strstart++; - s.lookahead--; - } - } - if (s.match_available) { - bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]); - s.match_available = 0; - } - s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; - } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - return BS_BLOCK_DONE; - } - function deflate_rle(s, flush) { - var bflush; - var prev; - var scan, strend; - var _win = s.window; - for (; ; ) { - if (s.lookahead <= MAX_MATCH) { - fill_window(s); - if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - if (s.lookahead === 0) { - break; - } - } - s.match_length = 0; - if (s.lookahead >= MIN_MATCH && s.strstart > 0) { - scan = s.strstart - 1; - prev = _win[scan]; - if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) { - strend = s.strstart + MAX_MATCH; - do { - } while (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan] && scan < strend); - s.match_length = MAX_MATCH - (strend - scan); - if (s.match_length > s.lookahead) { - s.match_length = s.lookahead; - } - } - } - if (s.match_length >= MIN_MATCH) { - bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH); - s.lookahead -= s.match_length; - s.strstart += s.match_length; - s.match_length = 0; - } else { - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; - } - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } - s.insert = 0; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; - } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - return BS_BLOCK_DONE; - } - function deflate_huff(s, flush) { - var bflush; - for (; ; ) { - if (s.lookahead === 0) { - fill_window(s); - if (s.lookahead === 0) { - if (flush === Z_NO_FLUSH) { - return BS_NEED_MORE; - } - break; - } - } - s.match_length = 0; - bflush = trees._tr_tally(s, 0, s.window[s.strstart]); - s.lookahead--; - s.strstart++; - if (bflush) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - } - s.insert = 0; - if (flush === Z_FINISH) { - flush_block_only(s, true); - if (s.strm.avail_out === 0) { - return BS_FINISH_STARTED; - } - return BS_FINISH_DONE; - } - if (s.last_lit) { - flush_block_only(s, false); - if (s.strm.avail_out === 0) { - return BS_NEED_MORE; - } - } - return BS_BLOCK_DONE; - } - function Config(good_length, max_lazy, nice_length, max_chain, func) { - this.good_length = good_length; - this.max_lazy = max_lazy; - this.nice_length = nice_length; - this.max_chain = max_chain; - this.func = func; - } - var configuration_table; - configuration_table = [ - new Config(0, 0, 0, 0, deflate_stored), - new Config(4, 4, 8, 4, deflate_fast), - new Config(4, 5, 16, 8, deflate_fast), - new Config(4, 6, 32, 32, deflate_fast), - new Config(4, 4, 16, 16, deflate_slow), - new Config(8, 16, 32, 32, deflate_slow), - new Config(8, 16, 128, 128, deflate_slow), - new Config(8, 32, 128, 256, deflate_slow), - new Config(32, 128, 258, 1024, deflate_slow), - new Config(32, 258, 258, 4096, deflate_slow) - ]; - function lm_init(s) { - s.window_size = 2 * s.w_size; - zero(s.head); - s.max_lazy_match = configuration_table[s.level].max_lazy; - s.good_match = configuration_table[s.level].good_length; - s.nice_match = configuration_table[s.level].nice_length; - s.max_chain_length = configuration_table[s.level].max_chain; - s.strstart = 0; - s.block_start = 0; - s.lookahead = 0; - s.insert = 0; - s.match_length = s.prev_length = MIN_MATCH - 1; - s.match_available = 0; - s.ins_h = 0; - } - function DeflateState() { - this.strm = null; - this.status = 0; - this.pending_buf = null; - this.pending_buf_size = 0; - this.pending_out = 0; - this.pending = 0; - this.wrap = 0; - this.gzhead = null; - this.gzindex = 0; - this.method = Z_DEFLATED; - this.last_flush = -1; - this.w_size = 0; - this.w_bits = 0; - this.w_mask = 0; - this.window = null; - this.window_size = 0; - this.prev = null; - this.head = null; - this.ins_h = 0; - this.hash_size = 0; - this.hash_bits = 0; - this.hash_mask = 0; - this.hash_shift = 0; - this.block_start = 0; - this.match_length = 0; - this.prev_match = 0; - this.match_available = 0; - this.strstart = 0; - this.match_start = 0; - this.lookahead = 0; - this.prev_length = 0; - this.max_chain_length = 0; - this.max_lazy_match = 0; - this.level = 0; - this.strategy = 0; - this.good_match = 0; - this.nice_match = 0; - this.dyn_ltree = new utils.Buf16(HEAP_SIZE * 2); - this.dyn_dtree = new utils.Buf16((2 * D_CODES + 1) * 2); - this.bl_tree = new utils.Buf16((2 * BL_CODES + 1) * 2); - zero(this.dyn_ltree); - zero(this.dyn_dtree); - zero(this.bl_tree); - this.l_desc = null; - this.d_desc = null; - this.bl_desc = null; - this.bl_count = new utils.Buf16(MAX_BITS + 1); - this.heap = new utils.Buf16(2 * L_CODES + 1); - zero(this.heap); - this.heap_len = 0; - this.heap_max = 0; - this.depth = new utils.Buf16(2 * L_CODES + 1); - zero(this.depth); - this.l_buf = 0; - this.lit_bufsize = 0; - this.last_lit = 0; - this.d_buf = 0; - this.opt_len = 0; - this.static_len = 0; - this.matches = 0; - this.insert = 0; - this.bi_buf = 0; - this.bi_valid = 0; - } - function deflateResetKeep(strm) { - var s; - if (!strm || !strm.state) { - return err(strm, Z_STREAM_ERROR); - } - strm.total_in = strm.total_out = 0; - strm.data_type = Z_UNKNOWN; - s = strm.state; - s.pending = 0; - s.pending_out = 0; - if (s.wrap < 0) { - s.wrap = -s.wrap; - } - s.status = s.wrap ? INIT_STATE : BUSY_STATE; - strm.adler = s.wrap === 2 ? 0 : 1; - s.last_flush = Z_NO_FLUSH; - trees._tr_init(s); - return Z_OK; - } - function deflateReset(strm) { - var ret = deflateResetKeep(strm); - if (ret === Z_OK) { - lm_init(strm.state); - } - return ret; - } - function deflateSetHeader(strm, head) { - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - if (strm.state.wrap !== 2) { - return Z_STREAM_ERROR; - } - strm.state.gzhead = head; - return Z_OK; - } - function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { - if (!strm) { - return Z_STREAM_ERROR; - } - var wrap = 1; - if (level === Z_DEFAULT_COMPRESSION) { - level = 6; - } - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } else if (windowBits > 15) { - wrap = 2; - windowBits -= 16; - } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return err(strm, Z_STREAM_ERROR); - } - if (windowBits === 8) { - windowBits = 9; - } - var s = new DeflateState(); - strm.state = s; - s.strm = strm; - s.wrap = wrap; - s.gzhead = null; - s.w_bits = windowBits; - s.w_size = 1 << s.w_bits; - s.w_mask = s.w_size - 1; - s.hash_bits = memLevel + 7; - s.hash_size = 1 << s.hash_bits; - s.hash_mask = s.hash_size - 1; - s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH); - s.window = new utils.Buf8(s.w_size * 2); - s.head = new utils.Buf16(s.hash_size); - s.prev = new utils.Buf16(s.w_size); - s.lit_bufsize = 1 << memLevel + 6; - s.pending_buf_size = s.lit_bufsize * 4; - s.pending_buf = new utils.Buf8(s.pending_buf_size); - s.d_buf = 1 * s.lit_bufsize; - s.l_buf = (1 + 2) * s.lit_bufsize; - s.level = level; - s.strategy = strategy; - s.method = method; - return deflateReset(strm); - } - function deflateInit(strm, level) { - return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); - } - function deflate(strm, flush) { - var old_flush, s; - var beg, val; - if (!strm || !strm.state || flush > Z_BLOCK || flush < 0) { - return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; - } - s = strm.state; - if (!strm.output || !strm.input && strm.avail_in !== 0 || s.status === FINISH_STATE && flush !== Z_FINISH) { - return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR); - } - s.strm = strm; - old_flush = s.last_flush; - s.last_flush = flush; - if (s.status === INIT_STATE) { - if (s.wrap === 2) { - strm.adler = 0; - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (!s.gzhead) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0); - put_byte(s, OS_CODE); - s.status = BUSY_STATE; - } else { - put_byte(s, (s.gzhead.text ? 1 : 0) + (s.gzhead.hcrc ? 2 : 0) + (!s.gzhead.extra ? 0 : 4) + (!s.gzhead.name ? 0 : 8) + (!s.gzhead.comment ? 0 : 16)); - put_byte(s, s.gzhead.time & 255); - put_byte(s, s.gzhead.time >> 8 & 255); - put_byte(s, s.gzhead.time >> 16 & 255); - put_byte(s, s.gzhead.time >> 24 & 255); - put_byte(s, s.level === 9 ? 2 : s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ? 4 : 0); - put_byte(s, s.gzhead.os & 255); - if (s.gzhead.extra && s.gzhead.extra.length) { - put_byte(s, s.gzhead.extra.length & 255); - put_byte(s, s.gzhead.extra.length >> 8 & 255); - } - if (s.gzhead.hcrc) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0); - } - s.gzindex = 0; - s.status = EXTRA_STATE; - } - } else { - var header = Z_DEFLATED + (s.w_bits - 8 << 4) << 8; - var level_flags = -1; - if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) { - level_flags = 0; - } else if (s.level < 6) { - level_flags = 1; - } else if (s.level === 6) { - level_flags = 2; - } else { - level_flags = 3; - } - header |= level_flags << 6; - if (s.strstart !== 0) { - header |= PRESET_DICT; - } - header += 31 - header % 31; - s.status = BUSY_STATE; - putShortMSB(s, header); - if (s.strstart !== 0) { - putShortMSB(s, strm.adler >>> 16); - putShortMSB(s, strm.adler & 65535); - } - strm.adler = 1; - } - } - if (s.status === EXTRA_STATE) { - if (s.gzhead.extra) { - beg = s.pending; - while (s.gzindex < (s.gzhead.extra.length & 65535)) { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - break; - } - } - put_byte(s, s.gzhead.extra[s.gzindex] & 255); - s.gzindex++; - } - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (s.gzindex === s.gzhead.extra.length) { - s.gzindex = 0; - s.status = NAME_STATE; - } - } else { - s.status = NAME_STATE; - } - } - if (s.status === NAME_STATE) { - if (s.gzhead.name) { - beg = s.pending; - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - if (s.gzindex < s.gzhead.name.length) { - val = s.gzhead.name.charCodeAt(s.gzindex++) & 255; - } else { - val = 0; - } - put_byte(s, val); - } while (val !== 0); - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (val === 0) { - s.gzindex = 0; - s.status = COMMENT_STATE; - } - } else { - s.status = COMMENT_STATE; - } - } - if (s.status === COMMENT_STATE) { - if (s.gzhead.comment) { - beg = s.pending; - do { - if (s.pending === s.pending_buf_size) { - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - flush_pending(strm); - beg = s.pending; - if (s.pending === s.pending_buf_size) { - val = 1; - break; - } - } - if (s.gzindex < s.gzhead.comment.length) { - val = s.gzhead.comment.charCodeAt(s.gzindex++) & 255; - } else { - val = 0; - } - put_byte(s, val); - } while (val !== 0); - if (s.gzhead.hcrc && s.pending > beg) { - strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg); - } - if (val === 0) { - s.status = HCRC_STATE; - } - } else { - s.status = HCRC_STATE; - } - } - if (s.status === HCRC_STATE) { - if (s.gzhead.hcrc) { - if (s.pending + 2 > s.pending_buf_size) { - flush_pending(strm); - } - if (s.pending + 2 <= s.pending_buf_size) { - put_byte(s, strm.adler & 255); - put_byte(s, strm.adler >> 8 & 255); - strm.adler = 0; - s.status = BUSY_STATE; - } - } else { - s.status = BUSY_STATE; - } - } - if (s.pending !== 0) { - flush_pending(strm); - if (strm.avail_out === 0) { - s.last_flush = -1; - return Z_OK; - } - } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) && flush !== Z_FINISH) { - return err(strm, Z_BUF_ERROR); - } - if (s.status === FINISH_STATE && strm.avail_in !== 0) { - return err(strm, Z_BUF_ERROR); - } - if (strm.avail_in !== 0 || s.lookahead !== 0 || flush !== Z_NO_FLUSH && s.status !== FINISH_STATE) { - var bstate = s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : s.strategy === Z_RLE ? deflate_rle(s, flush) : configuration_table[s.level].func(s, flush); - if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { - s.status = FINISH_STATE; - } - if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { - if (strm.avail_out === 0) { - s.last_flush = -1; - } - return Z_OK; - } - if (bstate === BS_BLOCK_DONE) { - if (flush === Z_PARTIAL_FLUSH) { - trees._tr_align(s); - } else if (flush !== Z_BLOCK) { - trees._tr_stored_block(s, 0, 0, false); - if (flush === Z_FULL_FLUSH) { - zero(s.head); - if (s.lookahead === 0) { - s.strstart = 0; - s.block_start = 0; - s.insert = 0; - } - } - } - flush_pending(strm); - if (strm.avail_out === 0) { - s.last_flush = -1; - return Z_OK; - } - } - } - if (flush !== Z_FINISH) { - return Z_OK; - } - if (s.wrap <= 0) { - return Z_STREAM_END; - } - if (s.wrap === 2) { - put_byte(s, strm.adler & 255); - put_byte(s, strm.adler >> 8 & 255); - put_byte(s, strm.adler >> 16 & 255); - put_byte(s, strm.adler >> 24 & 255); - put_byte(s, strm.total_in & 255); - put_byte(s, strm.total_in >> 8 & 255); - put_byte(s, strm.total_in >> 16 & 255); - put_byte(s, strm.total_in >> 24 & 255); - } else { - putShortMSB(s, strm.adler >>> 16); - putShortMSB(s, strm.adler & 65535); - } - flush_pending(strm); - if (s.wrap > 0) { - s.wrap = -s.wrap; - } - return s.pending !== 0 ? Z_OK : Z_STREAM_END; - } - function deflateEnd(strm) { - var status; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - status = strm.state.status; - if (status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) { - return err(strm, Z_STREAM_ERROR); - } - strm.state = null; - return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; - } - function deflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - var s; - var str, n; - var wrap; - var avail; - var next; - var input; - var tmpDict; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - s = strm.state; - wrap = s.wrap; - if (wrap === 2 || wrap === 1 && s.status !== INIT_STATE || s.lookahead) { - return Z_STREAM_ERROR; - } - if (wrap === 1) { - strm.adler = adler32(strm.adler, dictionary, dictLength, 0); - } - s.wrap = 0; - if (dictLength >= s.w_size) { - if (wrap === 0) { - zero(s.head); - s.strstart = 0; - s.block_start = 0; - s.insert = 0; - } - tmpDict = new utils.Buf8(s.w_size); - utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0); - dictionary = tmpDict; - dictLength = s.w_size; - } - avail = strm.avail_in; - next = strm.next_in; - input = strm.input; - strm.avail_in = dictLength; - strm.next_in = 0; - strm.input = dictionary; - fill_window(s); - while (s.lookahead >= MIN_MATCH) { - str = s.strstart; - n = s.lookahead - (MIN_MATCH - 1); - do { - s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask; - s.prev[str & s.w_mask] = s.head[s.ins_h]; - s.head[s.ins_h] = str; - str++; - } while (--n); - s.strstart = str; - s.lookahead = MIN_MATCH - 1; - fill_window(s); - } - s.strstart += s.lookahead; - s.block_start = s.strstart; - s.insert = s.lookahead; - s.lookahead = 0; - s.match_length = s.prev_length = MIN_MATCH - 1; - s.match_available = 0; - strm.next_in = next; - strm.input = input; - strm.avail_in = avail; - s.wrap = wrap; - return Z_OK; - } - exports2.deflateInit = deflateInit; - exports2.deflateInit2 = deflateInit2; - exports2.deflateReset = deflateReset; - exports2.deflateResetKeep = deflateResetKeep; - exports2.deflateSetHeader = deflateSetHeader; - exports2.deflate = deflate; - exports2.deflateEnd = deflateEnd; - exports2.deflateSetDictionary = deflateSetDictionary; - exports2.deflateInfo = "pako deflate (from Nodeca project)"; - } -}); - -// node_modules/pako/lib/utils/strings.js -var require_strings = __commonJS({ - "node_modules/pako/lib/utils/strings.js"(exports2) { - "use strict"; - var utils = require_common(); - var STR_APPLY_OK = true; - var STR_APPLY_UIA_OK = true; - try { - String.fromCharCode.apply(null, [0]); - } catch (__) { - STR_APPLY_OK = false; - } - try { - String.fromCharCode.apply(null, new Uint8Array(1)); - } catch (__) { - STR_APPLY_UIA_OK = false; - } - var _utf8len = new utils.Buf8(256); - for (q = 0; q < 256; q++) { - _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1; - } - var q; - _utf8len[254] = _utf8len[254] = 1; - exports2.string2buf = function(str) { - var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; - for (m_pos = 0; m_pos < str_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 64512) === 55296 && m_pos + 1 < str_len) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 64512) === 56320) { - c = 65536 + (c - 55296 << 10) + (c2 - 56320); - m_pos++; - } - } - buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4; - } - buf = new utils.Buf8(buf_len); - for (i = 0, m_pos = 0; i < buf_len; m_pos++) { - c = str.charCodeAt(m_pos); - if ((c & 64512) === 55296 && m_pos + 1 < str_len) { - c2 = str.charCodeAt(m_pos + 1); - if ((c2 & 64512) === 56320) { - c = 65536 + (c - 55296 << 10) + (c2 - 56320); - m_pos++; - } - } - if (c < 128) { - buf[i++] = c; - } else if (c < 2048) { - buf[i++] = 192 | c >>> 6; - buf[i++] = 128 | c & 63; - } else if (c < 65536) { - buf[i++] = 224 | c >>> 12; - buf[i++] = 128 | c >>> 6 & 63; - buf[i++] = 128 | c & 63; - } else { - buf[i++] = 240 | c >>> 18; - buf[i++] = 128 | c >>> 12 & 63; - buf[i++] = 128 | c >>> 6 & 63; - buf[i++] = 128 | c & 63; - } - } - return buf; - }; - function buf2binstring(buf, len) { - if (len < 65534) { - if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { - return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len)); - } - } - var result = ""; - for (var i = 0; i < len; i++) { - result += String.fromCharCode(buf[i]); - } - return result; - } - exports2.buf2binstring = function(buf) { - return buf2binstring(buf, buf.length); - }; - exports2.binstring2buf = function(str) { - var buf = new utils.Buf8(str.length); - for (var i = 0, len = buf.length; i < len; i++) { - buf[i] = str.charCodeAt(i); - } - return buf; - }; - exports2.buf2string = function(buf, max) { - var i, out, c, c_len; - var len = max || buf.length; - var utf16buf = new Array(len * 2); - for (out = 0, i = 0; i < len; ) { - c = buf[i++]; - if (c < 128) { - utf16buf[out++] = c; - continue; - } - c_len = _utf8len[c]; - if (c_len > 4) { - utf16buf[out++] = 65533; - i += c_len - 1; - continue; - } - c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; - while (c_len > 1 && i < len) { - c = c << 6 | buf[i++] & 63; - c_len--; - } - if (c_len > 1) { - utf16buf[out++] = 65533; - continue; - } - if (c < 65536) { - utf16buf[out++] = c; - } else { - c -= 65536; - utf16buf[out++] = 55296 | c >> 10 & 1023; - utf16buf[out++] = 56320 | c & 1023; - } - } - return buf2binstring(utf16buf, out); - }; - exports2.utf8border = function(buf, max) { - var pos; - max = max || buf.length; - if (max > buf.length) { - max = buf.length; - } - pos = max - 1; - while (pos >= 0 && (buf[pos] & 192) === 128) { - pos--; - } - if (pos < 0) { - return max; - } - if (pos === 0) { - return max; - } - return pos + _utf8len[buf[pos]] > max ? pos : max; - }; - } -}); - -// node_modules/pako/lib/zlib/zstream.js -var require_zstream = __commonJS({ - "node_modules/pako/lib/zlib/zstream.js"(exports2, module2) { - "use strict"; - function ZStream() { - this.input = null; - this.next_in = 0; - this.avail_in = 0; - this.total_in = 0; - this.output = null; - this.next_out = 0; - this.avail_out = 0; - this.total_out = 0; - this.msg = ""; - this.state = null; - this.data_type = 2; - this.adler = 0; - } - module2.exports = ZStream; - } -}); - -// node_modules/pako/lib/deflate.js -var require_deflate2 = __commonJS({ - "node_modules/pako/lib/deflate.js"(exports2) { - "use strict"; - var zlib_deflate = require_deflate(); - var utils = require_common(); - var strings = require_strings(); - var msg = require_messages(); - var ZStream = require_zstream(); - var toString = Object.prototype.toString; - var Z_NO_FLUSH = 0; - var Z_FINISH = 4; - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_SYNC_FLUSH = 2; - var Z_DEFAULT_COMPRESSION = -1; - var Z_DEFAULT_STRATEGY = 0; - var Z_DEFLATED = 8; - function Deflate(options) { - if (!(this instanceof Deflate)) - return new Deflate(options); - this.options = utils.assign({ - level: Z_DEFAULT_COMPRESSION, - method: Z_DEFLATED, - chunkSize: 16384, - windowBits: 15, - memLevel: 8, - strategy: Z_DEFAULT_STRATEGY, - to: "" - }, options || {}); - var opt = this.options; - if (opt.raw && opt.windowBits > 0) { - opt.windowBits = -opt.windowBits; - } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) { - opt.windowBits += 16; - } - this.err = 0; - this.msg = ""; - this.ended = false; - this.chunks = []; - this.strm = new ZStream(); - this.strm.avail_out = 0; - var status = zlib_deflate.deflateInit2(this.strm, opt.level, opt.method, opt.windowBits, opt.memLevel, opt.strategy); - if (status !== Z_OK) { - throw new Error(msg[status]); - } - if (opt.header) { - zlib_deflate.deflateSetHeader(this.strm, opt.header); - } - if (opt.dictionary) { - var dict; - if (typeof opt.dictionary === "string") { - dict = strings.string2buf(opt.dictionary); - } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { - dict = new Uint8Array(opt.dictionary); - } else { - dict = opt.dictionary; - } - status = zlib_deflate.deflateSetDictionary(this.strm, dict); - if (status !== Z_OK) { - throw new Error(msg[status]); - } - this._dict_set = true; - } - } - Deflate.prototype.push = function(data, mode) { - var strm = this.strm; - var chunkSize = this.options.chunkSize; - var status, _mode; - if (this.ended) { - return false; - } - _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH; - if (typeof data === "string") { - strm.input = strings.string2buf(data); - } else if (toString.call(data) === "[object ArrayBuffer]") { - strm.input = new Uint8Array(data); - } else { - strm.input = data; - } - strm.next_in = 0; - strm.avail_in = strm.input.length; - do { - if (strm.avail_out === 0) { - strm.output = new utils.Buf8(chunkSize); - strm.next_out = 0; - strm.avail_out = chunkSize; - } - status = zlib_deflate.deflate(strm, _mode); - if (status !== Z_STREAM_END && status !== Z_OK) { - this.onEnd(status); - this.ended = true; - return false; - } - if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) { - if (this.options.to === "string") { - this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out))); - } else { - this.onData(utils.shrinkBuf(strm.output, strm.next_out)); - } - } - } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END); - if (_mode === Z_FINISH) { - status = zlib_deflate.deflateEnd(this.strm); - this.onEnd(status); - this.ended = true; - return status === Z_OK; - } - if (_mode === Z_SYNC_FLUSH) { - this.onEnd(Z_OK); - strm.avail_out = 0; - return true; - } - return true; - }; - Deflate.prototype.onData = function(chunk) { - this.chunks.push(chunk); - }; - Deflate.prototype.onEnd = function(status) { - if (status === Z_OK) { - if (this.options.to === "string") { - this.result = this.chunks.join(""); - } else { - this.result = utils.flattenChunks(this.chunks); - } - } - this.chunks = []; - this.err = status; - this.msg = this.strm.msg; - }; - function deflate(input, options) { - var deflator = new Deflate(options); - deflator.push(input, true); - if (deflator.err) { - throw deflator.msg || msg[deflator.err]; - } - return deflator.result; - } - function deflateRaw(input, options) { - options = options || {}; - options.raw = true; - return deflate(input, options); - } - function gzip(input, options) { - options = options || {}; - options.gzip = true; - return deflate(input, options); - } - exports2.Deflate = Deflate; - exports2.deflate = deflate; - exports2.deflateRaw = deflateRaw; - exports2.gzip = gzip; - } -}); - -// node_modules/pako/lib/zlib/inffast.js -var require_inffast = __commonJS({ - "node_modules/pako/lib/zlib/inffast.js"(exports2, module2) { - "use strict"; - var BAD = 30; - var TYPE = 12; - module2.exports = function inflate_fast(strm, start) { - var state; - var _in; - var last; - var _out; - var beg; - var end; - var dmax; - var wsize; - var whave; - var wnext; - var s_window; - var hold; - var bits; - var lcode; - var dcode; - var lmask; - var dmask; - var here; - var op; - var len; - var dist; - var from; - var from_source; - var input, output; - state = strm.state; - _in = strm.next_in; - input = strm.input; - last = _in + (strm.avail_in - 5); - _out = strm.next_out; - output = strm.output; - beg = _out - (start - strm.avail_out); - end = _out + (strm.avail_out - 257); - dmax = state.dmax; - wsize = state.wsize; - whave = state.whave; - wnext = state.wnext; - s_window = state.window; - hold = state.hold; - bits = state.bits; - lcode = state.lencode; - dcode = state.distcode; - lmask = (1 << state.lenbits) - 1; - dmask = (1 << state.distbits) - 1; - top: - do { - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - here = lcode[hold & lmask]; - dolen: - for (; ; ) { - op = here >>> 24; - hold >>>= op; - bits -= op; - op = here >>> 16 & 255; - if (op === 0) { - output[_out++] = here & 65535; - } else if (op & 16) { - len = here & 65535; - op &= 15; - if (op) { - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - len += hold & (1 << op) - 1; - hold >>>= op; - bits -= op; - } - if (bits < 15) { - hold += input[_in++] << bits; - bits += 8; - hold += input[_in++] << bits; - bits += 8; - } - here = dcode[hold & dmask]; - dodist: - for (; ; ) { - op = here >>> 24; - hold >>>= op; - bits -= op; - op = here >>> 16 & 255; - if (op & 16) { - dist = here & 65535; - op &= 15; - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - if (bits < op) { - hold += input[_in++] << bits; - bits += 8; - } - } - dist += hold & (1 << op) - 1; - if (dist > dmax) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break top; - } - hold >>>= op; - bits -= op; - op = _out - beg; - if (dist > op) { - op = dist - op; - if (op > whave) { - if (state.sane) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break top; - } - } - from = 0; - from_source = s_window; - if (wnext === 0) { - from += wsize - op; - if (op < len) { - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; - from_source = output; - } - } else if (wnext < op) { - from += wsize + wnext - op; - op -= wnext; - if (op < len) { - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = 0; - if (wnext < len) { - op = wnext; - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; - from_source = output; - } - } - } else { - from += wnext - op; - if (op < len) { - len -= op; - do { - output[_out++] = s_window[from++]; - } while (--op); - from = _out - dist; - from_source = output; - } - } - while (len > 2) { - output[_out++] = from_source[from++]; - output[_out++] = from_source[from++]; - output[_out++] = from_source[from++]; - len -= 3; - } - if (len) { - output[_out++] = from_source[from++]; - if (len > 1) { - output[_out++] = from_source[from++]; - } - } - } else { - from = _out - dist; - do { - output[_out++] = output[from++]; - output[_out++] = output[from++]; - output[_out++] = output[from++]; - len -= 3; - } while (len > 2); - if (len) { - output[_out++] = output[from++]; - if (len > 1) { - output[_out++] = output[from++]; - } - } - } - } else if ((op & 64) === 0) { - here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; - continue dodist; - } else { - strm.msg = "invalid distance code"; - state.mode = BAD; - break top; - } - break; - } - } else if ((op & 64) === 0) { - here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; - continue dolen; - } else if (op & 32) { - state.mode = TYPE; - break top; - } else { - strm.msg = "invalid literal/length code"; - state.mode = BAD; - break top; - } - break; - } - } while (_in < last && _out < end); - len = bits >> 3; - _in -= len; - bits -= len << 3; - hold &= (1 << bits) - 1; - strm.next_in = _in; - strm.next_out = _out; - strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); - strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); - state.hold = hold; - state.bits = bits; - return; - }; - } -}); - -// node_modules/pako/lib/zlib/inftrees.js -var require_inftrees = __commonJS({ - "node_modules/pako/lib/zlib/inftrees.js"(exports2, module2) { - "use strict"; - var utils = require_common(); - var MAXBITS = 15; - var ENOUGH_LENS = 852; - var ENOUGH_DISTS = 592; - var CODES = 0; - var LENS = 1; - var DISTS = 2; - var lbase = [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 13, - 15, - 17, - 19, - 23, - 27, - 31, - 35, - 43, - 51, - 59, - 67, - 83, - 99, - 115, - 131, - 163, - 195, - 227, - 258, - 0, - 0 - ]; - var lext = [ - 16, - 16, - 16, - 16, - 16, - 16, - 16, - 16, - 17, - 17, - 17, - 17, - 18, - 18, - 18, - 18, - 19, - 19, - 19, - 19, - 20, - 20, - 20, - 20, - 21, - 21, - 21, - 21, - 16, - 72, - 78 - ]; - var dbase = [ - 1, - 2, - 3, - 4, - 5, - 7, - 9, - 13, - 17, - 25, - 33, - 49, - 65, - 97, - 129, - 193, - 257, - 385, - 513, - 769, - 1025, - 1537, - 2049, - 3073, - 4097, - 6145, - 8193, - 12289, - 16385, - 24577, - 0, - 0 - ]; - var dext = [ - 16, - 16, - 16, - 16, - 17, - 17, - 18, - 18, - 19, - 19, - 20, - 20, - 21, - 21, - 22, - 22, - 23, - 23, - 24, - 24, - 25, - 25, - 26, - 26, - 27, - 27, - 28, - 28, - 29, - 29, - 64, - 64 - ]; - module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { - var bits = opts.bits; - var len = 0; - var sym = 0; - var min = 0, max = 0; - var root = 0; - var curr = 0; - var drop = 0; - var left = 0; - var used = 0; - var huff = 0; - var incr; - var fill; - var low; - var mask; - var next; - var base = null; - var base_index = 0; - var end; - var count = new utils.Buf16(MAXBITS + 1); - var offs = new utils.Buf16(MAXBITS + 1); - var extra = null; - var extra_index = 0; - var here_bits, here_op, here_val; - for (len = 0; len <= MAXBITS; len++) { - count[len] = 0; - } - for (sym = 0; sym < codes; sym++) { - count[lens[lens_index + sym]]++; - } - root = bits; - for (max = MAXBITS; max >= 1; max--) { - if (count[max] !== 0) { - break; - } - } - if (root > max) { - root = max; - } - if (max === 0) { - table[table_index++] = 1 << 24 | 64 << 16 | 0; - table[table_index++] = 1 << 24 | 64 << 16 | 0; - opts.bits = 1; - return 0; - } - for (min = 1; min < max; min++) { - if (count[min] !== 0) { - break; - } - } - if (root < min) { - root = min; - } - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) { - return -1; - } - } - if (left > 0 && (type === CODES || max !== 1)) { - return -1; - } - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) { - offs[len + 1] = offs[len] + count[len]; - } - for (sym = 0; sym < codes; sym++) { - if (lens[lens_index + sym] !== 0) { - work[offs[lens[lens_index + sym]]++] = sym; - } - } - if (type === CODES) { - base = extra = work; - end = 19; - } else if (type === LENS) { - base = lbase; - base_index -= 257; - extra = lext; - extra_index -= 257; - end = 256; - } else { - base = dbase; - extra = dext; - end = -1; - } - huff = 0; - sym = 0; - len = min; - next = table_index; - curr = root; - drop = 0; - low = -1; - used = 1 << root; - mask = used - 1; - if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { - return 1; - } - for (; ; ) { - here_bits = len - drop; - if (work[sym] < end) { - here_op = 0; - here_val = work[sym]; - } else if (work[sym] > end) { - here_op = extra[extra_index + work[sym]]; - here_val = base[base_index + work[sym]]; - } else { - here_op = 32 + 64; - here_val = 0; - } - incr = 1 << len - drop; - fill = 1 << curr; - min = fill; - do { - fill -= incr; - table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; - } while (fill !== 0); - incr = 1 << len - 1; - while (huff & incr) { - incr >>= 1; - } - if (incr !== 0) { - huff &= incr - 1; - huff += incr; - } else { - huff = 0; - } - sym++; - if (--count[len] === 0) { - if (len === max) { - break; - } - len = lens[lens_index + work[sym]]; - } - if (len > root && (huff & mask) !== low) { - if (drop === 0) { - drop = root; - } - next += min; - curr = len - drop; - left = 1 << curr; - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) { - break; - } - curr++; - left <<= 1; - } - used += 1 << curr; - if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { - return 1; - } - low = huff & mask; - table[low] = root << 24 | curr << 16 | next - table_index | 0; - } - } - if (huff !== 0) { - table[next + huff] = len - drop << 24 | 64 << 16 | 0; - } - opts.bits = root; - return 0; - }; - } -}); - -// node_modules/pako/lib/zlib/inflate.js -var require_inflate = __commonJS({ - "node_modules/pako/lib/zlib/inflate.js"(exports2) { - "use strict"; - var utils = require_common(); - var adler32 = require_adler32(); - var crc32 = require_crc322(); - var inflate_fast = require_inffast(); - var inflate_table = require_inftrees(); - var CODES = 0; - var LENS = 1; - var DISTS = 2; - var Z_FINISH = 4; - var Z_BLOCK = 5; - var Z_TREES = 6; - var Z_OK = 0; - var Z_STREAM_END = 1; - var Z_NEED_DICT = 2; - var Z_STREAM_ERROR = -2; - var Z_DATA_ERROR = -3; - var Z_MEM_ERROR = -4; - var Z_BUF_ERROR = -5; - var Z_DEFLATED = 8; - var HEAD = 1; - var FLAGS = 2; - var TIME = 3; - var OS = 4; - var EXLEN = 5; - var EXTRA = 6; - var NAME = 7; - var COMMENT = 8; - var HCRC = 9; - var DICTID = 10; - var DICT = 11; - var TYPE = 12; - var TYPEDO = 13; - var STORED = 14; - var COPY_ = 15; - var COPY = 16; - var TABLE = 17; - var LENLENS = 18; - var CODELENS = 19; - var LEN_ = 20; - var LEN = 21; - var LENEXT = 22; - var DIST = 23; - var DISTEXT = 24; - var MATCH = 25; - var LIT = 26; - var CHECK = 27; - var LENGTH = 28; - var DONE = 29; - var BAD = 30; - var MEM = 31; - var SYNC = 32; - var ENOUGH_LENS = 852; - var ENOUGH_DISTS = 592; - var MAX_WBITS = 15; - var DEF_WBITS = MAX_WBITS; - function zswap32(q) { - return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24); - } - function InflateState() { - this.mode = 0; - this.last = false; - this.wrap = 0; - this.havedict = false; - this.flags = 0; - this.dmax = 0; - this.check = 0; - this.total = 0; - this.head = null; - this.wbits = 0; - this.wsize = 0; - this.whave = 0; - this.wnext = 0; - this.window = null; - this.hold = 0; - this.bits = 0; - this.length = 0; - this.offset = 0; - this.extra = 0; - this.lencode = null; - this.distcode = null; - this.lenbits = 0; - this.distbits = 0; - this.ncode = 0; - this.nlen = 0; - this.ndist = 0; - this.have = 0; - this.next = null; - this.lens = new utils.Buf16(320); - this.work = new utils.Buf16(288); - this.lendyn = null; - this.distdyn = null; - this.sane = 0; - this.back = 0; - this.was = 0; - } - function inflateResetKeep(strm) { - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - strm.total_in = strm.total_out = state.total = 0; - strm.msg = ""; - if (state.wrap) { - strm.adler = state.wrap & 1; - } - state.mode = HEAD; - state.last = 0; - state.havedict = 0; - state.dmax = 32768; - state.head = null; - state.hold = 0; - state.bits = 0; - state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS); - state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS); - state.sane = 1; - state.back = -1; - return Z_OK; - } - function inflateReset(strm) { - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - state.wsize = 0; - state.whave = 0; - state.wnext = 0; - return inflateResetKeep(strm); - } - function inflateReset2(strm, windowBits) { - var wrap; - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } else { - wrap = (windowBits >> 4) + 1; - if (windowBits < 48) { - windowBits &= 15; - } - } - if (windowBits && (windowBits < 8 || windowBits > 15)) { - return Z_STREAM_ERROR; - } - if (state.window !== null && state.wbits !== windowBits) { - state.window = null; - } - state.wrap = wrap; - state.wbits = windowBits; - return inflateReset(strm); - } - function inflateInit2(strm, windowBits) { - var ret; - var state; - if (!strm) { - return Z_STREAM_ERROR; - } - state = new InflateState(); - strm.state = state; - state.window = null; - ret = inflateReset2(strm, windowBits); - if (ret !== Z_OK) { - strm.state = null; - } - return ret; - } - function inflateInit(strm) { - return inflateInit2(strm, DEF_WBITS); - } - var virgin = true; - var lenfix; - var distfix; - function fixedtables(state) { - if (virgin) { - var sym; - lenfix = new utils.Buf32(512); - distfix = new utils.Buf32(32); - sym = 0; - while (sym < 144) { - state.lens[sym++] = 8; - } - while (sym < 256) { - state.lens[sym++] = 9; - } - while (sym < 280) { - state.lens[sym++] = 7; - } - while (sym < 288) { - state.lens[sym++] = 8; - } - inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); - sym = 0; - while (sym < 32) { - state.lens[sym++] = 5; - } - inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); - virgin = false; - } - state.lencode = lenfix; - state.lenbits = 9; - state.distcode = distfix; - state.distbits = 5; - } - function updatewindow(strm, src, end, copy) { - var dist; - var state = strm.state; - if (state.window === null) { - state.wsize = 1 << state.wbits; - state.wnext = 0; - state.whave = 0; - state.window = new utils.Buf8(state.wsize); - } - if (copy >= state.wsize) { - utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); - state.wnext = 0; - state.whave = state.wsize; - } else { - dist = state.wsize - state.wnext; - if (dist > copy) { - dist = copy; - } - utils.arraySet(state.window, src, end - copy, dist, state.wnext); - copy -= dist; - if (copy) { - utils.arraySet(state.window, src, end - copy, copy, 0); - state.wnext = copy; - state.whave = state.wsize; - } else { - state.wnext += dist; - if (state.wnext === state.wsize) { - state.wnext = 0; - } - if (state.whave < state.wsize) { - state.whave += dist; - } - } - } - return 0; - } - function inflate(strm, flush) { - var state; - var input, output; - var next; - var put; - var have, left; - var hold; - var bits; - var _in, _out; - var copy; - var from; - var from_source; - var here = 0; - var here_bits, here_op, here_val; - var last_bits, last_op, last_val; - var len; - var ret; - var hbuf = new utils.Buf8(4); - var opts; - var n; - var order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; - if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { - return Z_STREAM_ERROR; - } - state = strm.state; - if (state.mode === TYPE) { - state.mode = TYPEDO; - } - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - _in = have; - _out = left; - ret = Z_OK; - inf_leave: - for (; ; ) { - switch (state.mode) { - case HEAD: - if (state.wrap === 0) { - state.mode = TYPEDO; - break; - } - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (state.wrap & 2 && hold === 35615) { - state.check = 0; - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc32(state.check, hbuf, 2, 0); - hold = 0; - bits = 0; - state.mode = FLAGS; - break; - } - state.flags = 0; - if (state.head) { - state.head.done = false; - } - if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) { - strm.msg = "incorrect header check"; - state.mode = BAD; - break; - } - if ((hold & 15) !== Z_DEFLATED) { - strm.msg = "unknown compression method"; - state.mode = BAD; - break; - } - hold >>>= 4; - bits -= 4; - len = (hold & 15) + 8; - if (state.wbits === 0) { - state.wbits = len; - } else if (len > state.wbits) { - strm.msg = "invalid window size"; - state.mode = BAD; - break; - } - state.dmax = 1 << len; - strm.adler = state.check = 1; - state.mode = hold & 512 ? DICTID : TYPE; - hold = 0; - bits = 0; - break; - case FLAGS: - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.flags = hold; - if ((state.flags & 255) !== Z_DEFLATED) { - strm.msg = "unknown compression method"; - state.mode = BAD; - break; - } - if (state.flags & 57344) { - strm.msg = "unknown header flags set"; - state.mode = BAD; - break; - } - if (state.head) { - state.head.text = hold >> 8 & 1; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc32(state.check, hbuf, 2, 0); - } - hold = 0; - bits = 0; - state.mode = TIME; - case TIME: - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (state.head) { - state.head.time = hold; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - hbuf[2] = hold >>> 16 & 255; - hbuf[3] = hold >>> 24 & 255; - state.check = crc32(state.check, hbuf, 4, 0); - } - hold = 0; - bits = 0; - state.mode = OS; - case OS: - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (state.head) { - state.head.xflags = hold & 255; - state.head.os = hold >> 8; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc32(state.check, hbuf, 2, 0); - } - hold = 0; - bits = 0; - state.mode = EXLEN; - case EXLEN: - if (state.flags & 1024) { - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.length = hold; - if (state.head) { - state.head.extra_len = hold; - } - if (state.flags & 512) { - hbuf[0] = hold & 255; - hbuf[1] = hold >>> 8 & 255; - state.check = crc32(state.check, hbuf, 2, 0); - } - hold = 0; - bits = 0; - } else if (state.head) { - state.head.extra = null; - } - state.mode = EXTRA; - case EXTRA: - if (state.flags & 1024) { - copy = state.length; - if (copy > have) { - copy = have; - } - if (copy) { - if (state.head) { - len = state.head.extra_len - state.length; - if (!state.head.extra) { - state.head.extra = new Array(state.head.extra_len); - } - utils.arraySet(state.head.extra, input, next, copy, len); - } - if (state.flags & 512) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - state.length -= copy; - } - if (state.length) { - break inf_leave; - } - } - state.length = 0; - state.mode = NAME; - case NAME: - if (state.flags & 2048) { - if (have === 0) { - break inf_leave; - } - copy = 0; - do { - len = input[next + copy++]; - if (state.head && len && state.length < 65536) { - state.head.name += String.fromCharCode(len); - } - } while (len && copy < have); - if (state.flags & 512) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { - break inf_leave; - } - } else if (state.head) { - state.head.name = null; - } - state.length = 0; - state.mode = COMMENT; - case COMMENT: - if (state.flags & 4096) { - if (have === 0) { - break inf_leave; - } - copy = 0; - do { - len = input[next + copy++]; - if (state.head && len && state.length < 65536) { - state.head.comment += String.fromCharCode(len); - } - } while (len && copy < have); - if (state.flags & 512) { - state.check = crc32(state.check, input, copy, next); - } - have -= copy; - next += copy; - if (len) { - break inf_leave; - } - } else if (state.head) { - state.head.comment = null; - } - state.mode = HCRC; - case HCRC: - if (state.flags & 512) { - while (bits < 16) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (hold !== (state.check & 65535)) { - strm.msg = "header crc mismatch"; - state.mode = BAD; - break; - } - hold = 0; - bits = 0; - } - if (state.head) { - state.head.hcrc = state.flags >> 9 & 1; - state.head.done = true; - } - strm.adler = state.check = 0; - state.mode = TYPE; - break; - case DICTID: - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - strm.adler = state.check = zswap32(hold); - hold = 0; - bits = 0; - state.mode = DICT; - case DICT: - if (state.havedict === 0) { - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - return Z_NEED_DICT; - } - strm.adler = state.check = 1; - state.mode = TYPE; - case TYPE: - if (flush === Z_BLOCK || flush === Z_TREES) { - break inf_leave; - } - case TYPEDO: - if (state.last) { - hold >>>= bits & 7; - bits -= bits & 7; - state.mode = CHECK; - break; - } - while (bits < 3) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.last = hold & 1; - hold >>>= 1; - bits -= 1; - switch (hold & 3) { - case 0: - state.mode = STORED; - break; - case 1: - fixedtables(state); - state.mode = LEN_; - if (flush === Z_TREES) { - hold >>>= 2; - bits -= 2; - break inf_leave; - } - break; - case 2: - state.mode = TABLE; - break; - case 3: - strm.msg = "invalid block type"; - state.mode = BAD; - } - hold >>>= 2; - bits -= 2; - break; - case STORED: - hold >>>= bits & 7; - bits -= bits & 7; - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { - strm.msg = "invalid stored block lengths"; - state.mode = BAD; - break; - } - state.length = hold & 65535; - hold = 0; - bits = 0; - state.mode = COPY_; - if (flush === Z_TREES) { - break inf_leave; - } - case COPY_: - state.mode = COPY; - case COPY: - copy = state.length; - if (copy) { - if (copy > have) { - copy = have; - } - if (copy > left) { - copy = left; - } - if (copy === 0) { - break inf_leave; - } - utils.arraySet(output, input, next, copy, put); - have -= copy; - next += copy; - left -= copy; - put += copy; - state.length -= copy; - break; - } - state.mode = TYPE; - break; - case TABLE: - while (bits < 14) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.nlen = (hold & 31) + 257; - hold >>>= 5; - bits -= 5; - state.ndist = (hold & 31) + 1; - hold >>>= 5; - bits -= 5; - state.ncode = (hold & 15) + 4; - hold >>>= 4; - bits -= 4; - if (state.nlen > 286 || state.ndist > 30) { - strm.msg = "too many length or distance symbols"; - state.mode = BAD; - break; - } - state.have = 0; - state.mode = LENLENS; - case LENLENS: - while (state.have < state.ncode) { - while (bits < 3) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.lens[order[state.have++]] = hold & 7; - hold >>>= 3; - bits -= 3; - } - while (state.have < 19) { - state.lens[order[state.have++]] = 0; - } - state.lencode = state.lendyn; - state.lenbits = 7; - opts = { bits: state.lenbits }; - ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts); - state.lenbits = opts.bits; - if (ret) { - strm.msg = "invalid code lengths set"; - state.mode = BAD; - break; - } - state.have = 0; - state.mode = CODELENS; - case CODELENS: - while (state.have < state.nlen + state.ndist) { - for (; ; ) { - here = state.lencode[hold & (1 << state.lenbits) - 1]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (here_val < 16) { - hold >>>= here_bits; - bits -= here_bits; - state.lens[state.have++] = here_val; - } else { - if (here_val === 16) { - n = here_bits + 2; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= here_bits; - bits -= here_bits; - if (state.have === 0) { - strm.msg = "invalid bit length repeat"; - state.mode = BAD; - break; - } - len = state.lens[state.have - 1]; - copy = 3 + (hold & 3); - hold >>>= 2; - bits -= 2; - } else if (here_val === 17) { - n = here_bits + 3; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= here_bits; - bits -= here_bits; - len = 0; - copy = 3 + (hold & 7); - hold >>>= 3; - bits -= 3; - } else { - n = here_bits + 7; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= here_bits; - bits -= here_bits; - len = 0; - copy = 11 + (hold & 127); - hold >>>= 7; - bits -= 7; - } - if (state.have + copy > state.nlen + state.ndist) { - strm.msg = "invalid bit length repeat"; - state.mode = BAD; - break; - } - while (copy--) { - state.lens[state.have++] = len; - } - } - } - if (state.mode === BAD) { - break; - } - if (state.lens[256] === 0) { - strm.msg = "invalid code -- missing end-of-block"; - state.mode = BAD; - break; - } - state.lenbits = 9; - opts = { bits: state.lenbits }; - ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts); - state.lenbits = opts.bits; - if (ret) { - strm.msg = "invalid literal/lengths set"; - state.mode = BAD; - break; - } - state.distbits = 6; - state.distcode = state.distdyn; - opts = { bits: state.distbits }; - ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts); - state.distbits = opts.bits; - if (ret) { - strm.msg = "invalid distances set"; - state.mode = BAD; - break; - } - state.mode = LEN_; - if (flush === Z_TREES) { - break inf_leave; - } - case LEN_: - state.mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - inflate_fast(strm, _out); - put = strm.next_out; - output = strm.output; - left = strm.avail_out; - next = strm.next_in; - input = strm.input; - have = strm.avail_in; - hold = state.hold; - bits = state.bits; - if (state.mode === TYPE) { - state.back = -1; - } - break; - } - state.back = 0; - for (; ; ) { - here = state.lencode[hold & (1 << state.lenbits) - 1]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (here_op && (here_op & 240) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (; ; ) { - here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (last_bits + here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= last_bits; - bits -= last_bits; - state.back += last_bits; - } - hold >>>= here_bits; - bits -= here_bits; - state.back += here_bits; - state.length = here_val; - if (here_op === 0) { - state.mode = LIT; - break; - } - if (here_op & 32) { - state.back = -1; - state.mode = TYPE; - break; - } - if (here_op & 64) { - strm.msg = "invalid literal/length code"; - state.mode = BAD; - break; - } - state.extra = here_op & 15; - state.mode = LENEXT; - case LENEXT: - if (state.extra) { - n = state.extra; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.length += hold & (1 << state.extra) - 1; - hold >>>= state.extra; - bits -= state.extra; - state.back += state.extra; - } - state.was = state.length; - state.mode = DIST; - case DIST: - for (; ; ) { - here = state.distcode[hold & (1 << state.distbits) - 1]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if ((here_op & 240) === 0) { - last_bits = here_bits; - last_op = here_op; - last_val = here_val; - for (; ; ) { - here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; - here_bits = here >>> 24; - here_op = here >>> 16 & 255; - here_val = here & 65535; - if (last_bits + here_bits <= bits) { - break; - } - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - hold >>>= last_bits; - bits -= last_bits; - state.back += last_bits; - } - hold >>>= here_bits; - bits -= here_bits; - state.back += here_bits; - if (here_op & 64) { - strm.msg = "invalid distance code"; - state.mode = BAD; - break; - } - state.offset = here_val; - state.extra = here_op & 15; - state.mode = DISTEXT; - case DISTEXT: - if (state.extra) { - n = state.extra; - while (bits < n) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - state.offset += hold & (1 << state.extra) - 1; - hold >>>= state.extra; - bits -= state.extra; - state.back += state.extra; - } - if (state.offset > state.dmax) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break; - } - state.mode = MATCH; - case MATCH: - if (left === 0) { - break inf_leave; - } - copy = _out - left; - if (state.offset > copy) { - copy = state.offset - copy; - if (copy > state.whave) { - if (state.sane) { - strm.msg = "invalid distance too far back"; - state.mode = BAD; - break; - } - } - if (copy > state.wnext) { - copy -= state.wnext; - from = state.wsize - copy; - } else { - from = state.wnext - copy; - } - if (copy > state.length) { - copy = state.length; - } - from_source = state.window; - } else { - from_source = output; - from = put - state.offset; - copy = state.length; - } - if (copy > left) { - copy = left; - } - left -= copy; - state.length -= copy; - do { - output[put++] = from_source[from++]; - } while (--copy); - if (state.length === 0) { - state.mode = LEN; - } - break; - case LIT: - if (left === 0) { - break inf_leave; - } - output[put++] = state.length; - left--; - state.mode = LEN; - break; - case CHECK: - if (state.wrap) { - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold |= input[next++] << bits; - bits += 8; - } - _out -= left; - strm.total_out += _out; - state.total += _out; - if (_out) { - strm.adler = state.check = state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out); - } - _out = left; - if ((state.flags ? hold : zswap32(hold)) !== state.check) { - strm.msg = "incorrect data check"; - state.mode = BAD; - break; - } - hold = 0; - bits = 0; - } - state.mode = LENGTH; - case LENGTH: - if (state.wrap && state.flags) { - while (bits < 32) { - if (have === 0) { - break inf_leave; - } - have--; - hold += input[next++] << bits; - bits += 8; - } - if (hold !== (state.total & 4294967295)) { - strm.msg = "incorrect length check"; - state.mode = BAD; - break; - } - hold = 0; - bits = 0; - } - state.mode = DONE; - case DONE: - ret = Z_STREAM_END; - break inf_leave; - case BAD: - ret = Z_DATA_ERROR; - break inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - } - strm.next_out = put; - strm.avail_out = left; - strm.next_in = next; - strm.avail_in = have; - state.hold = hold; - state.bits = bits; - if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) { - if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) { - state.mode = MEM; - return Z_MEM_ERROR; - } - } - _in -= strm.avail_in; - _out -= strm.avail_out; - strm.total_in += _in; - strm.total_out += _out; - state.total += _out; - if (state.wrap && _out) { - strm.adler = state.check = state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out); - } - strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0); - if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) { - ret = Z_BUF_ERROR; - } - return ret; - } - function inflateEnd(strm) { - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - var state = strm.state; - if (state.window) { - state.window = null; - } - strm.state = null; - return Z_OK; - } - function inflateGetHeader(strm, head) { - var state; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - if ((state.wrap & 2) === 0) { - return Z_STREAM_ERROR; - } - state.head = head; - head.done = false; - return Z_OK; - } - function inflateSetDictionary(strm, dictionary) { - var dictLength = dictionary.length; - var state; - var dictid; - var ret; - if (!strm || !strm.state) { - return Z_STREAM_ERROR; - } - state = strm.state; - if (state.wrap !== 0 && state.mode !== DICT) { - return Z_STREAM_ERROR; - } - if (state.mode === DICT) { - dictid = 1; - dictid = adler32(dictid, dictionary, dictLength, 0); - if (dictid !== state.check) { - return Z_DATA_ERROR; - } - } - ret = updatewindow(strm, dictionary, dictLength, dictLength); - if (ret) { - state.mode = MEM; - return Z_MEM_ERROR; - } - state.havedict = 1; - return Z_OK; - } - exports2.inflateReset = inflateReset; - exports2.inflateReset2 = inflateReset2; - exports2.inflateResetKeep = inflateResetKeep; - exports2.inflateInit = inflateInit; - exports2.inflateInit2 = inflateInit2; - exports2.inflate = inflate; - exports2.inflateEnd = inflateEnd; - exports2.inflateGetHeader = inflateGetHeader; - exports2.inflateSetDictionary = inflateSetDictionary; - exports2.inflateInfo = "pako inflate (from Nodeca project)"; - } -}); - -// node_modules/pako/lib/zlib/constants.js -var require_constants = __commonJS({ - "node_modules/pako/lib/zlib/constants.js"(exports2, module2) { - "use strict"; - module2.exports = { - Z_NO_FLUSH: 0, - Z_PARTIAL_FLUSH: 1, - Z_SYNC_FLUSH: 2, - Z_FULL_FLUSH: 3, - Z_FINISH: 4, - Z_BLOCK: 5, - Z_TREES: 6, - Z_OK: 0, - Z_STREAM_END: 1, - Z_NEED_DICT: 2, - Z_ERRNO: -1, - Z_STREAM_ERROR: -2, - Z_DATA_ERROR: -3, - Z_BUF_ERROR: -5, - Z_NO_COMPRESSION: 0, - Z_BEST_SPEED: 1, - Z_BEST_COMPRESSION: 9, - Z_DEFAULT_COMPRESSION: -1, - Z_FILTERED: 1, - Z_HUFFMAN_ONLY: 2, - Z_RLE: 3, - Z_FIXED: 4, - Z_DEFAULT_STRATEGY: 0, - Z_BINARY: 0, - Z_TEXT: 1, - Z_UNKNOWN: 2, - Z_DEFLATED: 8 - }; - } -}); - -// node_modules/pako/lib/zlib/gzheader.js -var require_gzheader = __commonJS({ - "node_modules/pako/lib/zlib/gzheader.js"(exports2, module2) { - "use strict"; - function GZheader() { - this.text = 0; - this.time = 0; - this.xflags = 0; - this.os = 0; - this.extra = null; - this.extra_len = 0; - this.name = ""; - this.comment = ""; - this.hcrc = 0; - this.done = false; - } - module2.exports = GZheader; - } -}); - -// node_modules/pako/lib/inflate.js -var require_inflate2 = __commonJS({ - "node_modules/pako/lib/inflate.js"(exports2) { - "use strict"; - var zlib_inflate = require_inflate(); - var utils = require_common(); - var strings = require_strings(); - var c = require_constants(); - var msg = require_messages(); - var ZStream = require_zstream(); - var GZheader = require_gzheader(); - var toString = Object.prototype.toString; - function Inflate(options) { - if (!(this instanceof Inflate)) - return new Inflate(options); - this.options = utils.assign({ - chunkSize: 16384, - windowBits: 0, - to: "" - }, options || {}); - var opt = this.options; - if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { - opt.windowBits = -opt.windowBits; - if (opt.windowBits === 0) { - opt.windowBits = -15; - } - } - if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { - opt.windowBits += 32; - } - if (opt.windowBits > 15 && opt.windowBits < 48) { - if ((opt.windowBits & 15) === 0) { - opt.windowBits |= 15; - } - } - this.err = 0; - this.msg = ""; - this.ended = false; - this.chunks = []; - this.strm = new ZStream(); - this.strm.avail_out = 0; - var status = zlib_inflate.inflateInit2(this.strm, opt.windowBits); - if (status !== c.Z_OK) { - throw new Error(msg[status]); - } - this.header = new GZheader(); - zlib_inflate.inflateGetHeader(this.strm, this.header); - if (opt.dictionary) { - if (typeof opt.dictionary === "string") { - opt.dictionary = strings.string2buf(opt.dictionary); - } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") { - opt.dictionary = new Uint8Array(opt.dictionary); - } - if (opt.raw) { - status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary); - if (status !== c.Z_OK) { - throw new Error(msg[status]); - } - } - } - } - Inflate.prototype.push = function(data, mode) { - var strm = this.strm; - var chunkSize = this.options.chunkSize; - var dictionary = this.options.dictionary; - var status, _mode; - var next_out_utf8, tail, utf8str; - var allowBufError = false; - if (this.ended) { - return false; - } - _mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH; - if (typeof data === "string") { - strm.input = strings.binstring2buf(data); - } else if (toString.call(data) === "[object ArrayBuffer]") { - strm.input = new Uint8Array(data); - } else { - strm.input = data; - } - strm.next_in = 0; - strm.avail_in = strm.input.length; - do { - if (strm.avail_out === 0) { - strm.output = new utils.Buf8(chunkSize); - strm.next_out = 0; - strm.avail_out = chunkSize; - } - status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); - if (status === c.Z_NEED_DICT && dictionary) { - status = zlib_inflate.inflateSetDictionary(this.strm, dictionary); - } - if (status === c.Z_BUF_ERROR && allowBufError === true) { - status = c.Z_OK; - allowBufError = false; - } - if (status !== c.Z_STREAM_END && status !== c.Z_OK) { - this.onEnd(status); - this.ended = true; - return false; - } - if (strm.next_out) { - if (strm.avail_out === 0 || status === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) { - if (this.options.to === "string") { - next_out_utf8 = strings.utf8border(strm.output, strm.next_out); - tail = strm.next_out - next_out_utf8; - utf8str = strings.buf2string(strm.output, next_out_utf8); - strm.next_out = tail; - strm.avail_out = chunkSize - tail; - if (tail) { - utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); - } - this.onData(utf8str); - } else { - this.onData(utils.shrinkBuf(strm.output, strm.next_out)); - } - } - } - if (strm.avail_in === 0 && strm.avail_out === 0) { - allowBufError = true; - } - } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END); - if (status === c.Z_STREAM_END) { - _mode = c.Z_FINISH; - } - if (_mode === c.Z_FINISH) { - status = zlib_inflate.inflateEnd(this.strm); - this.onEnd(status); - this.ended = true; - return status === c.Z_OK; - } - if (_mode === c.Z_SYNC_FLUSH) { - this.onEnd(c.Z_OK); - strm.avail_out = 0; - return true; - } - return true; - }; - Inflate.prototype.onData = function(chunk) { - this.chunks.push(chunk); - }; - Inflate.prototype.onEnd = function(status) { - if (status === c.Z_OK) { - if (this.options.to === "string") { - this.result = this.chunks.join(""); - } else { - this.result = utils.flattenChunks(this.chunks); - } - } - this.chunks = []; - this.err = status; - this.msg = this.strm.msg; - }; - function inflate(input, options) { - var inflator = new Inflate(options); - inflator.push(input, true); - if (inflator.err) { - throw inflator.msg || msg[inflator.err]; - } - return inflator.result; - } - function inflateRaw(input, options) { - options = options || {}; - options.raw = true; - return inflate(input, options); - } - exports2.Inflate = Inflate; - exports2.inflate = inflate; - exports2.inflateRaw = inflateRaw; - exports2.ungzip = inflate; - } -}); - -// node_modules/pako/index.js -var require_pako = __commonJS({ - "node_modules/pako/index.js"(exports2, module2) { - "use strict"; - var assign = require_common().assign; - var deflate = require_deflate2(); - var inflate = require_inflate2(); - var constants = require_constants(); - var pako = {}; - assign(pako, deflate, inflate, constants); - module2.exports = pako; - } -}); - -// node_modules/jszip/lib/flate.js -var require_flate = __commonJS({ - "node_modules/jszip/lib/flate.js"(exports2) { - "use strict"; - var USE_TYPEDARRAY = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Uint32Array !== "undefined"; - var pako = require_pako(); - var utils = require_utils3(); - var GenericWorker = require_GenericWorker(); - var ARRAY_TYPE = USE_TYPEDARRAY ? "uint8array" : "array"; - exports2.magic = "\b\0"; - function FlateWorker(action, options) { - GenericWorker.call(this, "FlateWorker/" + action); - this._pako = null; - this._pakoAction = action; - this._pakoOptions = options; - this.meta = {}; - } - utils.inherits(FlateWorker, GenericWorker); - FlateWorker.prototype.processChunk = function(chunk) { - this.meta = chunk.meta; - if (this._pako === null) { - this._createPako(); - } - this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false); - }; - FlateWorker.prototype.flush = function() { - GenericWorker.prototype.flush.call(this); - if (this._pako === null) { - this._createPako(); - } - this._pako.push([], true); - }; - FlateWorker.prototype.cleanUp = function() { - GenericWorker.prototype.cleanUp.call(this); - this._pako = null; - }; - FlateWorker.prototype._createPako = function() { - this._pako = new pako[this._pakoAction]({ - raw: true, - level: this._pakoOptions.level || -1 - }); - var self2 = this; - this._pako.onData = function(data) { - self2.push({ - data, - meta: self2.meta - }); - }; - }; - exports2.compressWorker = function(compressionOptions) { - return new FlateWorker("Deflate", compressionOptions); - }; - exports2.uncompressWorker = function() { - return new FlateWorker("Inflate", {}); - }; - } -}); - -// node_modules/jszip/lib/compressions.js -var require_compressions = __commonJS({ - "node_modules/jszip/lib/compressions.js"(exports2) { - "use strict"; - var GenericWorker = require_GenericWorker(); - exports2.STORE = { - magic: "\0\0", - compressWorker: function() { - return new GenericWorker("STORE compression"); - }, - uncompressWorker: function() { - return new GenericWorker("STORE decompression"); - } - }; - exports2.DEFLATE = require_flate(); - } -}); - -// node_modules/jszip/lib/signature.js -var require_signature = __commonJS({ - "node_modules/jszip/lib/signature.js"(exports2) { - "use strict"; - exports2.LOCAL_FILE_HEADER = "PK"; - exports2.CENTRAL_FILE_HEADER = "PK"; - exports2.CENTRAL_DIRECTORY_END = "PK"; - exports2.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07"; - exports2.ZIP64_CENTRAL_DIRECTORY_END = "PK"; - exports2.DATA_DESCRIPTOR = "PK\x07\b"; - } -}); - -// node_modules/jszip/lib/generate/ZipFileWorker.js -var require_ZipFileWorker = __commonJS({ - "node_modules/jszip/lib/generate/ZipFileWorker.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var GenericWorker = require_GenericWorker(); - var utf8 = require_utf8(); - var crc32 = require_crc32(); - var signature = require_signature(); - var decToHex = function(dec, bytes) { - var hex3 = "", i; - for (i = 0; i < bytes; i++) { - hex3 += String.fromCharCode(dec & 255); - dec = dec >>> 8; - } - return hex3; - }; - var generateUnixExternalFileAttr = function(unixPermissions, isDir) { - var result = unixPermissions; - if (!unixPermissions) { - result = isDir ? 16893 : 33204; - } - return (result & 65535) << 16; - }; - var generateDosExternalFileAttr = function(dosPermissions) { - return (dosPermissions || 0) & 63; - }; - var generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) { - var file = streamInfo["file"], compression = streamInfo["compression"], useCustomEncoding = encodeFileName !== utf8.utf8encode, encodedFileName = utils.transformTo("string", encodeFileName(file.name)), utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)), comment = file.comment, encodedComment = utils.transformTo("string", encodeFileName(comment)), utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)), useUTF8ForFileName = utfEncodedFileName.length !== file.name.length, useUTF8ForComment = utfEncodedComment.length !== comment.length, dosTime, dosDate, extraFields = "", unicodePathExtraField = "", unicodeCommentExtraField = "", dir = file.dir, date = file.date; - var dataInfo = { - crc32: 0, - compressedSize: 0, - uncompressedSize: 0 - }; - if (!streamedContent || streamingEnded) { - dataInfo.crc32 = streamInfo["crc32"]; - dataInfo.compressedSize = streamInfo["compressedSize"]; - dataInfo.uncompressedSize = streamInfo["uncompressedSize"]; - } - var bitflag = 0; - if (streamedContent) { - bitflag |= 8; - } - if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) { - bitflag |= 2048; - } - var extFileAttr = 0; - var versionMadeBy = 0; - if (dir) { - extFileAttr |= 16; - } - if (platform === "UNIX") { - versionMadeBy = 798; - extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir); - } else { - versionMadeBy = 20; - extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir); - } - dosTime = date.getUTCHours(); - dosTime = dosTime << 6; - dosTime = dosTime | date.getUTCMinutes(); - dosTime = dosTime << 5; - dosTime = dosTime | date.getUTCSeconds() / 2; - dosDate = date.getUTCFullYear() - 1980; - dosDate = dosDate << 4; - dosDate = dosDate | date.getUTCMonth() + 1; - dosDate = dosDate << 5; - dosDate = dosDate | date.getUTCDate(); - if (useUTF8ForFileName) { - unicodePathExtraField = decToHex(1, 1) + decToHex(crc32(encodedFileName), 4) + utfEncodedFileName; - extraFields += "up" + decToHex(unicodePathExtraField.length, 2) + unicodePathExtraField; - } - if (useUTF8ForComment) { - unicodeCommentExtraField = decToHex(1, 1) + decToHex(crc32(encodedComment), 4) + utfEncodedComment; - extraFields += "uc" + decToHex(unicodeCommentExtraField.length, 2) + unicodeCommentExtraField; - } - var header = ""; - header += "\n\0"; - header += decToHex(bitflag, 2); - header += compression.magic; - header += decToHex(dosTime, 2); - header += decToHex(dosDate, 2); - header += decToHex(dataInfo.crc32, 4); - header += decToHex(dataInfo.compressedSize, 4); - header += decToHex(dataInfo.uncompressedSize, 4); - header += decToHex(encodedFileName.length, 2); - header += decToHex(extraFields.length, 2); - var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields; - var dirRecord = signature.CENTRAL_FILE_HEADER + decToHex(versionMadeBy, 2) + header + decToHex(encodedComment.length, 2) + "\0\0\0\0" + decToHex(extFileAttr, 4) + decToHex(offset, 4) + encodedFileName + extraFields + encodedComment; - return { - fileRecord, - dirRecord - }; - }; - var generateCentralDirectoryEnd = function(entriesCount, centralDirLength, localDirLength, comment, encodeFileName) { - var dirEnd = ""; - var encodedComment = utils.transformTo("string", encodeFileName(comment)); - dirEnd = signature.CENTRAL_DIRECTORY_END + "\0\0\0\0" + decToHex(entriesCount, 2) + decToHex(entriesCount, 2) + decToHex(centralDirLength, 4) + decToHex(localDirLength, 4) + decToHex(encodedComment.length, 2) + encodedComment; - return dirEnd; - }; - var generateDataDescriptors = function(streamInfo) { - var descriptor = ""; - descriptor = signature.DATA_DESCRIPTOR + decToHex(streamInfo["crc32"], 4) + decToHex(streamInfo["compressedSize"], 4) + decToHex(streamInfo["uncompressedSize"], 4); - return descriptor; - }; - function ZipFileWorker(streamFiles, comment, platform, encodeFileName) { - GenericWorker.call(this, "ZipFileWorker"); - this.bytesWritten = 0; - this.zipComment = comment; - this.zipPlatform = platform; - this.encodeFileName = encodeFileName; - this.streamFiles = streamFiles; - this.accumulate = false; - this.contentBuffer = []; - this.dirRecords = []; - this.currentSourceOffset = 0; - this.entriesCount = 0; - this.currentFile = null; - this._sources = []; - } - utils.inherits(ZipFileWorker, GenericWorker); - ZipFileWorker.prototype.push = function(chunk) { - var currentFilePercent = chunk.meta.percent || 0; - var entriesCount = this.entriesCount; - var remainingFiles = this._sources.length; - if (this.accumulate) { - this.contentBuffer.push(chunk); - } else { - this.bytesWritten += chunk.data.length; - GenericWorker.prototype.push.call(this, { - data: chunk.data, - meta: { - currentFile: this.currentFile, - percent: entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100 - } - }); - } - }; - ZipFileWorker.prototype.openedSource = function(streamInfo) { - this.currentSourceOffset = this.bytesWritten; - this.currentFile = streamInfo["file"].name; - var streamedContent = this.streamFiles && !streamInfo["file"].dir; - if (streamedContent) { - var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); - this.push({ - data: record.fileRecord, - meta: { percent: 0 } - }); - } else { - this.accumulate = true; - } - }; - ZipFileWorker.prototype.closedSource = function(streamInfo) { - this.accumulate = false; - var streamedContent = this.streamFiles && !streamInfo["file"].dir; - var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); - this.dirRecords.push(record.dirRecord); - if (streamedContent) { - this.push({ - data: generateDataDescriptors(streamInfo), - meta: { percent: 100 } - }); - } else { - this.push({ - data: record.fileRecord, - meta: { percent: 0 } - }); - while (this.contentBuffer.length) { - this.push(this.contentBuffer.shift()); - } - } - this.currentFile = null; - }; - ZipFileWorker.prototype.flush = function() { - var localDirLength = this.bytesWritten; - for (var i = 0; i < this.dirRecords.length; i++) { - this.push({ - data: this.dirRecords[i], - meta: { percent: 100 } - }); - } - var centralDirLength = this.bytesWritten - localDirLength; - var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName); - this.push({ - data: dirEnd, - meta: { percent: 100 } - }); - }; - ZipFileWorker.prototype.prepareNextSource = function() { - this.previous = this._sources.shift(); - this.openedSource(this.previous.streamInfo); - if (this.isPaused) { - this.previous.pause(); - } else { - this.previous.resume(); - } - }; - ZipFileWorker.prototype.registerPrevious = function(previous) { - this._sources.push(previous); - var self2 = this; - previous.on("data", function(chunk) { - self2.processChunk(chunk); - }); - previous.on("end", function() { - self2.closedSource(self2.previous.streamInfo); - if (self2._sources.length) { - self2.prepareNextSource(); - } else { - self2.end(); - } - }); - previous.on("error", function(e) { - self2.error(e); - }); - return this; - }; - ZipFileWorker.prototype.resume = function() { - if (!GenericWorker.prototype.resume.call(this)) { - return false; - } - if (!this.previous && this._sources.length) { - this.prepareNextSource(); - return true; - } - if (!this.previous && !this._sources.length && !this.generatedError) { - this.end(); - return true; - } - }; - ZipFileWorker.prototype.error = function(e) { - var sources = this._sources; - if (!GenericWorker.prototype.error.call(this, e)) { - return false; - } - for (var i = 0; i < sources.length; i++) { - try { - sources[i].error(e); - } catch (e2) { - } - } - return true; - }; - ZipFileWorker.prototype.lock = function() { - GenericWorker.prototype.lock.call(this); - var sources = this._sources; - for (var i = 0; i < sources.length; i++) { - sources[i].lock(); - } - }; - module2.exports = ZipFileWorker; - } -}); - -// node_modules/jszip/lib/generate/index.js -var require_generate = __commonJS({ - "node_modules/jszip/lib/generate/index.js"(exports2) { - "use strict"; - var compressions = require_compressions(); - var ZipFileWorker = require_ZipFileWorker(); - var getCompression = function(fileCompression, zipCompression) { - var compressionName = fileCompression || zipCompression; - var compression = compressions[compressionName]; - if (!compression) { - throw new Error(compressionName + " is not a valid compression method !"); - } - return compression; - }; - exports2.generateWorker = function(zip, options, comment) { - var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName); - var entriesCount = 0; - try { - zip.forEach(function(relativePath, file) { - entriesCount++; - var compression = getCompression(file.options.compression, options.compression); - var compressionOptions = file.options.compressionOptions || options.compressionOptions || {}; - var dir = file.dir, date = file.date; - file._compressWorker(compression, compressionOptions).withStreamInfo("file", { - name: relativePath, - dir, - date, - comment: file.comment || "", - unixPermissions: file.unixPermissions, - dosPermissions: file.dosPermissions - }).pipe(zipFileWorker); - }); - zipFileWorker.entriesCount = entriesCount; - } catch (e) { - zipFileWorker.error(e); - } - return zipFileWorker; - }; - } -}); - -// node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js -var require_NodejsStreamInputAdapter = __commonJS({ - "node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var GenericWorker = require_GenericWorker(); - function NodejsStreamInputAdapter(filename, stream) { - GenericWorker.call(this, "Nodejs stream input adapter for " + filename); - this._upstreamEnded = false; - this._bindStream(stream); - } - utils.inherits(NodejsStreamInputAdapter, GenericWorker); - NodejsStreamInputAdapter.prototype._bindStream = function(stream) { - var self2 = this; - this._stream = stream; - stream.pause(); - stream.on("data", function(chunk) { - self2.push({ - data: chunk, - meta: { - percent: 0 - } - }); - }).on("error", function(e) { - if (self2.isPaused) { - this.generatedError = e; - } else { - self2.error(e); - } - }).on("end", function() { - if (self2.isPaused) { - self2._upstreamEnded = true; - } else { - self2.end(); - } - }); - }; - NodejsStreamInputAdapter.prototype.pause = function() { - if (!GenericWorker.prototype.pause.call(this)) { - return false; - } - this._stream.pause(); - return true; - }; - NodejsStreamInputAdapter.prototype.resume = function() { - if (!GenericWorker.prototype.resume.call(this)) { - return false; - } - if (this._upstreamEnded) { - this.end(); - } else { - this._stream.resume(); - } - return true; - }; - module2.exports = NodejsStreamInputAdapter; - } -}); - -// node_modules/jszip/lib/object.js -var require_object = __commonJS({ - "node_modules/jszip/lib/object.js"(exports2, module2) { - "use strict"; - var utf8 = require_utf8(); - var utils = require_utils3(); - var GenericWorker = require_GenericWorker(); - var StreamHelper = require_StreamHelper(); - var defaults = require_defaults(); - var CompressedObject = require_compressedObject(); - var ZipObject = require_zipObject(); - var generate = require_generate(); - var nodejsUtils = require_nodejsUtils(); - var NodejsStreamInputAdapter = require_NodejsStreamInputAdapter(); - var fileAdd = function(name, data, originalOptions) { - var dataType = utils.getTypeOf(data), parent; - var o = utils.extend(originalOptions || {}, defaults); - o.date = o.date || new Date(); - if (o.compression !== null) { - o.compression = o.compression.toUpperCase(); - } - if (typeof o.unixPermissions === "string") { - o.unixPermissions = parseInt(o.unixPermissions, 8); - } - if (o.unixPermissions && o.unixPermissions & 16384) { - o.dir = true; - } - if (o.dosPermissions && o.dosPermissions & 16) { - o.dir = true; - } - if (o.dir) { - name = forceTrailingSlash(name); - } - if (o.createFolders && (parent = parentFolder(name))) { - folderAdd.call(this, parent, true); - } - var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false; - if (!originalOptions || typeof originalOptions.binary === "undefined") { - o.binary = !isUnicodeString; - } - var isCompressedEmpty = data instanceof CompressedObject && data.uncompressedSize === 0; - if (isCompressedEmpty || o.dir || !data || data.length === 0) { - o.base64 = false; - o.binary = true; - data = ""; - o.compression = "STORE"; - dataType = "string"; - } - var zipObjectContent = null; - if (data instanceof CompressedObject || data instanceof GenericWorker) { - zipObjectContent = data; - } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) { - zipObjectContent = new NodejsStreamInputAdapter(name, data); - } else { - zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64); - } - var object = new ZipObject(name, zipObjectContent, o); - this.files[name] = object; - }; - var parentFolder = function(path4) { - if (path4.slice(-1) === "/") { - path4 = path4.substring(0, path4.length - 1); - } - var lastSlash = path4.lastIndexOf("/"); - return lastSlash > 0 ? path4.substring(0, lastSlash) : ""; - }; - var forceTrailingSlash = function(path4) { - if (path4.slice(-1) !== "/") { - path4 += "/"; - } - return path4; - }; - var folderAdd = function(name, createFolders) { - createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders; - name = forceTrailingSlash(name); - if (!this.files[name]) { - fileAdd.call(this, name, null, { - dir: true, - createFolders - }); - } - return this.files[name]; - }; - function isRegExp(object) { - return Object.prototype.toString.call(object) === "[object RegExp]"; - } - var out = { - load: function() { - throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); - }, - forEach: function(cb) { - var filename, relativePath, file; - for (filename in this.files) { - file = this.files[filename]; - relativePath = filename.slice(this.root.length, filename.length); - if (relativePath && filename.slice(0, this.root.length) === this.root) { - cb(relativePath, file); - } - } - }, - filter: function(search) { - var result = []; - this.forEach(function(relativePath, entry) { - if (search(relativePath, entry)) { - result.push(entry); - } - }); - return result; - }, - file: function(name, data, o) { - if (arguments.length === 1) { - if (isRegExp(name)) { - var regexp = name; - return this.filter(function(relativePath, file) { - return !file.dir && regexp.test(relativePath); - }); - } else { - var obj = this.files[this.root + name]; - if (obj && !obj.dir) { - return obj; - } else { - return null; - } - } - } else { - name = this.root + name; - fileAdd.call(this, name, data, o); - } - return this; - }, - folder: function(arg) { - if (!arg) { - return this; - } - if (isRegExp(arg)) { - return this.filter(function(relativePath, file) { - return file.dir && arg.test(relativePath); - }); - } - var name = this.root + arg; - var newFolder = folderAdd.call(this, name); - var ret = this.clone(); - ret.root = newFolder.name; - return ret; - }, - remove: function(name) { - name = this.root + name; - var file = this.files[name]; - if (!file) { - if (name.slice(-1) !== "/") { - name += "/"; - } - file = this.files[name]; - } - if (file && !file.dir) { - delete this.files[name]; - } else { - var kids = this.filter(function(relativePath, file2) { - return file2.name.slice(0, name.length) === name; - }); - for (var i = 0; i < kids.length; i++) { - delete this.files[kids[i].name]; - } - } - return this; - }, - generate: function() { - throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); - }, - generateInternalStream: function(options) { - var worker, opts = {}; - try { - opts = utils.extend(options || {}, { - streamFiles: false, - compression: "STORE", - compressionOptions: null, - type: "", - platform: "DOS", - comment: null, - mimeType: "application/zip", - encodeFileName: utf8.utf8encode - }); - opts.type = opts.type.toLowerCase(); - opts.compression = opts.compression.toUpperCase(); - if (opts.type === "binarystring") { - opts.type = "string"; - } - if (!opts.type) { - throw new Error("No output type specified."); - } - utils.checkSupport(opts.type); - if (opts.platform === "darwin" || opts.platform === "freebsd" || opts.platform === "linux" || opts.platform === "sunos") { - opts.platform = "UNIX"; - } - if (opts.platform === "win32") { - opts.platform = "DOS"; - } - var comment = opts.comment || this.comment || ""; - worker = generate.generateWorker(this, opts, comment); - } catch (e) { - worker = new GenericWorker("error"); - worker.error(e); - } - return new StreamHelper(worker, opts.type || "string", opts.mimeType); - }, - generateAsync: function(options, onUpdate) { - return this.generateInternalStream(options).accumulate(onUpdate); - }, - generateNodeStream: function(options, onUpdate) { - options = options || {}; - if (!options.type) { - options.type = "nodebuffer"; - } - return this.generateInternalStream(options).toNodejsStream(onUpdate); - } - }; - module2.exports = out; - } -}); - -// node_modules/jszip/lib/reader/DataReader.js -var require_DataReader = __commonJS({ - "node_modules/jszip/lib/reader/DataReader.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - function DataReader(data) { - this.data = data; - this.length = data.length; - this.index = 0; - this.zero = 0; - } - DataReader.prototype = { - checkOffset: function(offset) { - this.checkIndex(this.index + offset); - }, - checkIndex: function(newIndex) { - if (this.length < this.zero + newIndex || newIndex < 0) { - throw new Error("End of data reached (data length = " + this.length + ", asked index = " + newIndex + "). Corrupted zip ?"); - } - }, - setIndex: function(newIndex) { - this.checkIndex(newIndex); - this.index = newIndex; - }, - skip: function(n) { - this.setIndex(this.index + n); - }, - byteAt: function() { - }, - readInt: function(size) { - var result = 0, i; - this.checkOffset(size); - for (i = this.index + size - 1; i >= this.index; i--) { - result = (result << 8) + this.byteAt(i); - } - this.index += size; - return result; - }, - readString: function(size) { - return utils.transformTo("string", this.readData(size)); - }, - readData: function() { - }, - lastIndexOfSignature: function() { - }, - readAndCheckSignature: function() { - }, - readDate: function() { - var dostime = this.readInt(4); - return new Date(Date.UTC((dostime >> 25 & 127) + 1980, (dostime >> 21 & 15) - 1, dostime >> 16 & 31, dostime >> 11 & 31, dostime >> 5 & 63, (dostime & 31) << 1)); - } - }; - module2.exports = DataReader; - } -}); - -// node_modules/jszip/lib/reader/ArrayReader.js -var require_ArrayReader = __commonJS({ - "node_modules/jszip/lib/reader/ArrayReader.js"(exports2, module2) { - "use strict"; - var DataReader = require_DataReader(); - var utils = require_utils3(); - function ArrayReader(data) { - DataReader.call(this, data); - for (var i = 0; i < this.data.length; i++) { - data[i] = data[i] & 255; - } - } - utils.inherits(ArrayReader, DataReader); - ArrayReader.prototype.byteAt = function(i) { - return this.data[this.zero + i]; - }; - ArrayReader.prototype.lastIndexOfSignature = function(sig) { - var sig0 = sig.charCodeAt(0), sig1 = sig.charCodeAt(1), sig2 = sig.charCodeAt(2), sig3 = sig.charCodeAt(3); - for (var i = this.length - 4; i >= 0; --i) { - if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) { - return i - this.zero; - } - } - return -1; - }; - ArrayReader.prototype.readAndCheckSignature = function(sig) { - var sig0 = sig.charCodeAt(0), sig1 = sig.charCodeAt(1), sig2 = sig.charCodeAt(2), sig3 = sig.charCodeAt(3), data = this.readData(4); - return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3]; - }; - ArrayReader.prototype.readData = function(size) { - this.checkOffset(size); - if (size === 0) { - return []; - } - var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); - this.index += size; - return result; - }; - module2.exports = ArrayReader; - } -}); - -// node_modules/jszip/lib/reader/StringReader.js -var require_StringReader = __commonJS({ - "node_modules/jszip/lib/reader/StringReader.js"(exports2, module2) { - "use strict"; - var DataReader = require_DataReader(); - var utils = require_utils3(); - function StringReader(data) { - DataReader.call(this, data); - } - utils.inherits(StringReader, DataReader); - StringReader.prototype.byteAt = function(i) { - return this.data.charCodeAt(this.zero + i); - }; - StringReader.prototype.lastIndexOfSignature = function(sig) { - return this.data.lastIndexOf(sig) - this.zero; - }; - StringReader.prototype.readAndCheckSignature = function(sig) { - var data = this.readData(4); - return sig === data; - }; - StringReader.prototype.readData = function(size) { - this.checkOffset(size); - var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); - this.index += size; - return result; - }; - module2.exports = StringReader; - } -}); - -// node_modules/jszip/lib/reader/Uint8ArrayReader.js -var require_Uint8ArrayReader = __commonJS({ - "node_modules/jszip/lib/reader/Uint8ArrayReader.js"(exports2, module2) { - "use strict"; - var ArrayReader = require_ArrayReader(); - var utils = require_utils3(); - function Uint8ArrayReader(data) { - ArrayReader.call(this, data); - } - utils.inherits(Uint8ArrayReader, ArrayReader); - Uint8ArrayReader.prototype.readData = function(size) { - this.checkOffset(size); - if (size === 0) { - return new Uint8Array(0); - } - var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size); - this.index += size; - return result; - }; - module2.exports = Uint8ArrayReader; - } -}); - -// node_modules/jszip/lib/reader/NodeBufferReader.js -var require_NodeBufferReader = __commonJS({ - "node_modules/jszip/lib/reader/NodeBufferReader.js"(exports2, module2) { - "use strict"; - var Uint8ArrayReader = require_Uint8ArrayReader(); - var utils = require_utils3(); - function NodeBufferReader(data) { - Uint8ArrayReader.call(this, data); - } - utils.inherits(NodeBufferReader, Uint8ArrayReader); - NodeBufferReader.prototype.readData = function(size) { - this.checkOffset(size); - var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); - this.index += size; - return result; - }; - module2.exports = NodeBufferReader; - } -}); - -// node_modules/jszip/lib/reader/readerFor.js -var require_readerFor = __commonJS({ - "node_modules/jszip/lib/reader/readerFor.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var support = require_support(); - var ArrayReader = require_ArrayReader(); - var StringReader = require_StringReader(); - var NodeBufferReader = require_NodeBufferReader(); - var Uint8ArrayReader = require_Uint8ArrayReader(); - module2.exports = function(data) { - var type = utils.getTypeOf(data); - utils.checkSupport(type); - if (type === "string" && !support.uint8array) { - return new StringReader(data); - } - if (type === "nodebuffer") { - return new NodeBufferReader(data); - } - if (support.uint8array) { - return new Uint8ArrayReader(utils.transformTo("uint8array", data)); - } - return new ArrayReader(utils.transformTo("array", data)); - }; - } -}); - -// node_modules/jszip/lib/zipEntry.js -var require_zipEntry = __commonJS({ - "node_modules/jszip/lib/zipEntry.js"(exports2, module2) { - "use strict"; - var readerFor = require_readerFor(); - var utils = require_utils3(); - var CompressedObject = require_compressedObject(); - var crc32fn = require_crc32(); - var utf8 = require_utf8(); - var compressions = require_compressions(); - var support = require_support(); - var MADE_BY_DOS = 0; - var MADE_BY_UNIX = 3; - var findCompression = function(compressionMethod) { - for (var method in compressions) { - if (!Object.prototype.hasOwnProperty.call(compressions, method)) { - continue; - } - if (compressions[method].magic === compressionMethod) { - return compressions[method]; - } - } - return null; - }; - function ZipEntry(options, loadOptions) { - this.options = options; - this.loadOptions = loadOptions; - } - ZipEntry.prototype = { - isEncrypted: function() { - return (this.bitFlag & 1) === 1; - }, - useUTF8: function() { - return (this.bitFlag & 2048) === 2048; - }, - readLocalPart: function(reader) { - var compression, localExtraFieldsLength; - reader.skip(22); - this.fileNameLength = reader.readInt(2); - localExtraFieldsLength = reader.readInt(2); - this.fileName = reader.readData(this.fileNameLength); - reader.skip(localExtraFieldsLength); - if (this.compressedSize === -1 || this.uncompressedSize === -1) { - throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)"); - } - compression = findCompression(this.compressionMethod); - if (compression === null) { - throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")"); - } - this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize)); - }, - readCentralPart: function(reader) { - this.versionMadeBy = reader.readInt(2); - reader.skip(2); - this.bitFlag = reader.readInt(2); - this.compressionMethod = reader.readString(2); - this.date = reader.readDate(); - this.crc32 = reader.readInt(4); - this.compressedSize = reader.readInt(4); - this.uncompressedSize = reader.readInt(4); - var fileNameLength = reader.readInt(2); - this.extraFieldsLength = reader.readInt(2); - this.fileCommentLength = reader.readInt(2); - this.diskNumberStart = reader.readInt(2); - this.internalFileAttributes = reader.readInt(2); - this.externalFileAttributes = reader.readInt(4); - this.localHeaderOffset = reader.readInt(4); - if (this.isEncrypted()) { - throw new Error("Encrypted zip are not supported"); - } - reader.skip(fileNameLength); - this.readExtraFields(reader); - this.parseZIP64ExtraField(reader); - this.fileComment = reader.readData(this.fileCommentLength); - }, - processAttributes: function() { - this.unixPermissions = null; - this.dosPermissions = null; - var madeBy = this.versionMadeBy >> 8; - this.dir = this.externalFileAttributes & 16 ? true : false; - if (madeBy === MADE_BY_DOS) { - this.dosPermissions = this.externalFileAttributes & 63; - } - if (madeBy === MADE_BY_UNIX) { - this.unixPermissions = this.externalFileAttributes >> 16 & 65535; - } - if (!this.dir && this.fileNameStr.slice(-1) === "/") { - this.dir = true; - } - }, - parseZIP64ExtraField: function() { - if (!this.extraFields[1]) { - return; - } - var extraReader = readerFor(this.extraFields[1].value); - if (this.uncompressedSize === utils.MAX_VALUE_32BITS) { - this.uncompressedSize = extraReader.readInt(8); - } - if (this.compressedSize === utils.MAX_VALUE_32BITS) { - this.compressedSize = extraReader.readInt(8); - } - if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) { - this.localHeaderOffset = extraReader.readInt(8); - } - if (this.diskNumberStart === utils.MAX_VALUE_32BITS) { - this.diskNumberStart = extraReader.readInt(4); - } - }, - readExtraFields: function(reader) { - var end = reader.index + this.extraFieldsLength, extraFieldId, extraFieldLength, extraFieldValue; - if (!this.extraFields) { - this.extraFields = {}; - } - while (reader.index + 4 < end) { - extraFieldId = reader.readInt(2); - extraFieldLength = reader.readInt(2); - extraFieldValue = reader.readData(extraFieldLength); - this.extraFields[extraFieldId] = { - id: extraFieldId, - length: extraFieldLength, - value: extraFieldValue - }; - } - reader.setIndex(end); - }, - handleUTF8: function() { - var decodeParamType = support.uint8array ? "uint8array" : "array"; - if (this.useUTF8()) { - this.fileNameStr = utf8.utf8decode(this.fileName); - this.fileCommentStr = utf8.utf8decode(this.fileComment); - } else { - var upath = this.findExtraFieldUnicodePath(); - if (upath !== null) { - this.fileNameStr = upath; - } else { - var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName); - this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray); - } - var ucomment = this.findExtraFieldUnicodeComment(); - if (ucomment !== null) { - this.fileCommentStr = ucomment; - } else { - var commentByteArray = utils.transformTo(decodeParamType, this.fileComment); - this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray); - } - } - }, - findExtraFieldUnicodePath: function() { - var upathField = this.extraFields[28789]; - if (upathField) { - var extraReader = readerFor(upathField.value); - if (extraReader.readInt(1) !== 1) { - return null; - } - if (crc32fn(this.fileName) !== extraReader.readInt(4)) { - return null; - } - return utf8.utf8decode(extraReader.readData(upathField.length - 5)); - } - return null; - }, - findExtraFieldUnicodeComment: function() { - var ucommentField = this.extraFields[25461]; - if (ucommentField) { - var extraReader = readerFor(ucommentField.value); - if (extraReader.readInt(1) !== 1) { - return null; - } - if (crc32fn(this.fileComment) !== extraReader.readInt(4)) { - return null; - } - return utf8.utf8decode(extraReader.readData(ucommentField.length - 5)); - } - return null; - } - }; - module2.exports = ZipEntry; - } -}); - -// node_modules/jszip/lib/zipEntries.js -var require_zipEntries = __commonJS({ - "node_modules/jszip/lib/zipEntries.js"(exports2, module2) { - "use strict"; - var readerFor = require_readerFor(); - var utils = require_utils3(); - var sig = require_signature(); - var ZipEntry = require_zipEntry(); - var support = require_support(); - function ZipEntries(loadOptions) { - this.files = []; - this.loadOptions = loadOptions; - } - ZipEntries.prototype = { - checkSignature: function(expectedSignature) { - if (!this.reader.readAndCheckSignature(expectedSignature)) { - this.reader.index -= 4; - var signature = this.reader.readString(4); - throw new Error("Corrupted zip or bug: unexpected signature (" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")"); - } - }, - isSignature: function(askedIndex, expectedSignature) { - var currentIndex = this.reader.index; - this.reader.setIndex(askedIndex); - var signature = this.reader.readString(4); - var result = signature === expectedSignature; - this.reader.setIndex(currentIndex); - return result; - }, - readBlockEndOfCentral: function() { - this.diskNumber = this.reader.readInt(2); - this.diskWithCentralDirStart = this.reader.readInt(2); - this.centralDirRecordsOnThisDisk = this.reader.readInt(2); - this.centralDirRecords = this.reader.readInt(2); - this.centralDirSize = this.reader.readInt(4); - this.centralDirOffset = this.reader.readInt(4); - this.zipCommentLength = this.reader.readInt(2); - var zipComment = this.reader.readData(this.zipCommentLength); - var decodeParamType = support.uint8array ? "uint8array" : "array"; - var decodeContent = utils.transformTo(decodeParamType, zipComment); - this.zipComment = this.loadOptions.decodeFileName(decodeContent); - }, - readBlockZip64EndOfCentral: function() { - this.zip64EndOfCentralSize = this.reader.readInt(8); - this.reader.skip(4); - this.diskNumber = this.reader.readInt(4); - this.diskWithCentralDirStart = this.reader.readInt(4); - this.centralDirRecordsOnThisDisk = this.reader.readInt(8); - this.centralDirRecords = this.reader.readInt(8); - this.centralDirSize = this.reader.readInt(8); - this.centralDirOffset = this.reader.readInt(8); - this.zip64ExtensibleData = {}; - var extraDataSize = this.zip64EndOfCentralSize - 44, index = 0, extraFieldId, extraFieldLength, extraFieldValue; - while (index < extraDataSize) { - extraFieldId = this.reader.readInt(2); - extraFieldLength = this.reader.readInt(4); - extraFieldValue = this.reader.readData(extraFieldLength); - this.zip64ExtensibleData[extraFieldId] = { - id: extraFieldId, - length: extraFieldLength, - value: extraFieldValue - }; - } - }, - readBlockZip64EndOfCentralLocator: function() { - this.diskWithZip64CentralDirStart = this.reader.readInt(4); - this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8); - this.disksCount = this.reader.readInt(4); - if (this.disksCount > 1) { - throw new Error("Multi-volumes zip are not supported"); - } - }, - readLocalFiles: function() { - var i, file; - for (i = 0; i < this.files.length; i++) { - file = this.files[i]; - this.reader.setIndex(file.localHeaderOffset); - this.checkSignature(sig.LOCAL_FILE_HEADER); - file.readLocalPart(this.reader); - file.handleUTF8(); - file.processAttributes(); - } - }, - readCentralDir: function() { - var file; - this.reader.setIndex(this.centralDirOffset); - while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) { - file = new ZipEntry({ - zip64: this.zip64 - }, this.loadOptions); - file.readCentralPart(this.reader); - this.files.push(file); - } - if (this.centralDirRecords !== this.files.length) { - if (this.centralDirRecords !== 0 && this.files.length === 0) { - throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length); - } else { - } - } - }, - readEndOfCentral: function() { - var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END); - if (offset < 0) { - var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER); - if (isGarbage) { - throw new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"); - } else { - throw new Error("Corrupted zip: can't find end of central directory"); - } - } - this.reader.setIndex(offset); - var endOfCentralDirOffset = offset; - this.checkSignature(sig.CENTRAL_DIRECTORY_END); - this.readBlockEndOfCentral(); - if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) { - this.zip64 = true; - offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR); - if (offset < 0) { - throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator"); - } - this.reader.setIndex(offset); - this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR); - this.readBlockZip64EndOfCentralLocator(); - if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) { - this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END); - if (this.relativeOffsetEndOfZip64CentralDir < 0) { - throw new Error("Corrupted zip: can't find the ZIP64 end of central directory"); - } - } - this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir); - this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END); - this.readBlockZip64EndOfCentral(); - } - var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize; - if (this.zip64) { - expectedEndOfCentralDirOffset += 20; - expectedEndOfCentralDirOffset += 12 + this.zip64EndOfCentralSize; - } - var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset; - if (extraBytes > 0) { - if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) { - } else { - this.reader.zero = extraBytes; - } - } else if (extraBytes < 0) { - throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes."); - } - }, - prepareReader: function(data) { - this.reader = readerFor(data); - }, - load: function(data) { - this.prepareReader(data); - this.readEndOfCentral(); - this.readCentralDir(); - this.readLocalFiles(); - } - }; - module2.exports = ZipEntries; - } -}); - -// node_modules/jszip/lib/load.js -var require_load = __commonJS({ - "node_modules/jszip/lib/load.js"(exports2, module2) { - "use strict"; - var utils = require_utils3(); - var external = require_external(); - var utf8 = require_utf8(); - var ZipEntries = require_zipEntries(); - var Crc32Probe = require_Crc32Probe(); - var nodejsUtils = require_nodejsUtils(); - function checkEntryCRC32(zipEntry) { - return new external.Promise(function(resolve, reject) { - var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe()); - worker.on("error", function(e) { - reject(e); - }).on("end", function() { - if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) { - reject(new Error("Corrupted zip : CRC32 mismatch")); - } else { - resolve(); - } - }).resume(); - }); - } - module2.exports = function(data, options) { - var zip = this; - options = utils.extend(options || {}, { - base64: false, - checkCRC32: false, - optimizedBinaryString: false, - createFolders: false, - decodeFileName: utf8.utf8decode - }); - if (nodejsUtils.isNode && nodejsUtils.isStream(data)) { - return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")); - } - return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64).then(function(data2) { - var zipEntries = new ZipEntries(options); - zipEntries.load(data2); - return zipEntries; - }).then(function checkCRC32(zipEntries) { - var promises = [external.Promise.resolve(zipEntries)]; - var files = zipEntries.files; - if (options.checkCRC32) { - for (var i = 0; i < files.length; i++) { - promises.push(checkEntryCRC32(files[i])); - } - } - return external.Promise.all(promises); - }).then(function addFiles(results) { - var zipEntries = results.shift(); - var files = zipEntries.files; - for (var i = 0; i < files.length; i++) { - var input = files[i]; - var unsafeName = input.fileNameStr; - var safeName = utils.resolve(input.fileNameStr); - zip.file(safeName, input.decompressed, { - binary: true, - optimizedBinaryString: true, - date: input.date, - dir: input.dir, - comment: input.fileCommentStr.length ? input.fileCommentStr : null, - unixPermissions: input.unixPermissions, - dosPermissions: input.dosPermissions, - createFolders: options.createFolders - }); - if (!input.dir) { - zip.file(safeName).unsafeOriginalName = unsafeName; - } - } - if (zipEntries.zipComment.length) { - zip.comment = zipEntries.zipComment; - } - return zip; - }); - }; - } -}); - -// node_modules/jszip/lib/index.js -var require_lib7 = __commonJS({ - "node_modules/jszip/lib/index.js"(exports2, module2) { - "use strict"; - function JSZip2() { - if (!(this instanceof JSZip2)) { - return new JSZip2(); - } - if (arguments.length) { - throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide."); - } - this.files = Object.create(null); - this.comment = null; - this.root = ""; - this.clone = function() { - var newObj = new JSZip2(); - for (var i in this) { - if (typeof this[i] !== "function") { - newObj[i] = this[i]; - } - } - return newObj; - }; - } - JSZip2.prototype = require_object(); - JSZip2.prototype.loadAsync = require_load(); - JSZip2.support = require_support(); - JSZip2.defaults = require_defaults(); - JSZip2.version = "3.10.1"; - JSZip2.loadAsync = function(content, options) { - return new JSZip2().loadAsync(content, options); - }; - JSZip2.external = require_external(); - module2.exports = JSZip2; - } -}); - // src/worker/server/server.ts var import_fs2 = __toModule(require("fs")); var import_path3 = __toModule(require("path")); @@ -35833,54 +26787,11 @@ var import_path2 = __toModule(require("path")); var import_child_process = __toModule(require("child_process")); // src/common/workertypes.ts -function isUnchanged(result) { - return "unchanged" in result; -} -function isErrorResult(result) { - return "errors" in result; -} function isOutputResult(result) { return "output" in result; } // src/common/util.ts -function hex(v, nd) { - if (!nd) - nd = 2; - if (nd == 8) { - return hex(v >> 16 & 65535, 4) + hex(v & 65535, 4); - } else { - return toradix(v, nd, 16); - } -} -function toradix(v, nd, radix) { - try { - var s = v.toString(radix).toUpperCase(); - while (s.length < nd) - s = "0" + s; - return s; - } catch (e) { - return v + ""; - } -} -function stringToByteArray(s) { - var a = new Uint8Array(s.length); - for (var i = 0; i < s.length; i++) - a[i] = s.charCodeAt(i); - return a; -} -function byteArrayToString(data) { - var str = ""; - if (data != null) { - var charLUT = new Array(); - for (var i = 0; i < 256; ++i) - charLUT[i] = String.fromCharCode(i); - var len = data.length; - for (var i = 0; i < len; i++) - str += charLUT[data[i]]; - } - return str; -} function getBasePlatform(platform) { return platform.split(".")[0]; } @@ -35890,74 +26801,6 @@ function getRootPlatform(platform) { function getRootBasePlatform(platform) { return getRootPlatform(getBasePlatform(platform)); } -function convertDataToUint8Array(data) { - return typeof data === "string" ? stringToByteArray(data) : data; -} -var XMLParseError = class extends Error { -}; -function escapeXML(s) { - if (s.indexOf("&") >= 0) { - return s.replace(/'/g, "'").replace(/"/g, '"').replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&"); - } else { - return s; - } -} -function parseXMLPoorly(s, openfn, closefn) { - const tag_re = /[<]([/]?)([?a-z_-]+)([^>]*)[>]+|(\s*[^<]+)/gi; - const attr_re = /\s*(\w+)="(.*?)"\s*/gi; - var fm; - var stack = []; - var top; - function closetop() { - top = stack.pop(); - if (top == null || top.type != ident) - throw new XMLParseError("mismatch close tag: " + ident); - if (closefn) { - top.obj = closefn(top); - } - if (stack.length == 0) - throw new XMLParseError("close tag without open: " + ident); - stack[stack.length - 1].children.push(top); - } - function parseattrs(as) { - var am; - var attrs2 = {}; - if (as != null) { - while (am = attr_re.exec(as)) { - attrs2[am[1]] = escapeXML(am[2]); - } - } - return attrs2; - } - while (fm = tag_re.exec(s)) { - var [_m0, close, ident, attrs, content] = fm; - if (close) { - closetop(); - } else if (ident) { - var node = { type: ident, text: null, children: [], attrs: parseattrs(attrs), obj: null }; - stack.push(node); - if (attrs) { - parseattrs(attrs); - } - if (openfn) { - node.obj = openfn(node); - } - if (attrs && attrs.endsWith("/")) - closetop(); - } else if (content != null) { - if (stack.length == 0) - throw new XMLParseError("content without element"); - var txt = escapeXML(content).trim(); - if (txt.length) - stack[stack.length - 1].text = txt; - } - } - if (stack.length != 1) - throw new XMLParseError("tag not closed"); - if (stack[0].type != "?xml") - throw new XMLParseError("?xml needs to be first element"); - return top; -} function replaceAll(s, search, replace) { if (s == "") return ""; @@ -35966,10615 +26809,6 @@ function replaceAll(s, search, replace) { return s.split(search).join(replace); } -// src/common/basic/compiler.ts -var CompileError = class extends Error { - constructor(msg, loc) { - super(msg); - Object.setPrototypeOf(this, CompileError.prototype); - this.$loc = loc; - } -}; -var re_toks = /([0-9.]+[E][+-]?\d+|\d+[.][E0-9]*|[.][E0-9]+)|[0]*(\d+)|&([OH][0-9A-F]+)|(['].*)|([A-Z_]\w*[$]?)|(".*?")|([<>]?[=<>#])|(\*\*)|([-+*/^,;:()\[\]\?\\])|(\S+)|(\s+)/gi; -var TokenType; -(function(TokenType3) { - TokenType3[TokenType3["EOL"] = 0] = "EOL"; - TokenType3[TokenType3["Float"] = 1] = "Float"; - TokenType3[TokenType3["Int"] = 2] = "Int"; - TokenType3[TokenType3["HexOctalInt"] = 3] = "HexOctalInt"; - TokenType3[TokenType3["Remark"] = 4] = "Remark"; - TokenType3[TokenType3["Ident"] = 5] = "Ident"; - TokenType3[TokenType3["String"] = 6] = "String"; - TokenType3[TokenType3["Relational"] = 7] = "Relational"; - TokenType3[TokenType3["DoubleStar"] = 8] = "DoubleStar"; - TokenType3[TokenType3["Operator"] = 9] = "Operator"; - TokenType3[TokenType3["CatchAll"] = 10] = "CatchAll"; - TokenType3[TokenType3["Whitespace"] = 11] = "Whitespace"; - TokenType3[TokenType3["_LAST"] = 12] = "_LAST"; -})(TokenType || (TokenType = {})); -var OPERATORS = { - "IMP": { f: "bimp", p: 4 }, - "EQV": { f: "beqv", p: 5 }, - "XOR": { f: "bxor", p: 6 }, - "OR": { f: "bor", p: 7 }, - "AND": { f: "band", p: 8 }, - "||": { f: "lor", p: 17 }, - "&&": { f: "land", p: 18 }, - "=": { f: "eq", p: 50 }, - "==": { f: "eq", p: 50 }, - "<>": { f: "ne", p: 50 }, - "><": { f: "ne", p: 50 }, - "!=": { f: "ne", p: 50 }, - "#": { f: "ne", p: 50 }, - "<": { f: "lt", p: 50 }, - ">": { f: "gt", p: 50 }, - "<=": { f: "le", p: 50 }, - ">=": { f: "ge", p: 50 }, - "MIN": { f: "min", p: 75 }, - "MAX": { f: "max", p: 75 }, - "+": { f: "add", p: 100 }, - "-": { f: "sub", p: 100 }, - "%": { f: "mod", p: 140 }, - "MOD": { f: "mod", p: 140 }, - "\\": { f: "idiv", p: 150 }, - "*": { f: "mul", p: 200 }, - "/": { f: "div", p: 200 }, - "^": { f: "pow", p: 300 }, - "**": { f: "pow", p: 300 } -}; -function getOperator(op) { - return OPERATORS[op]; -} -function getPrecedence(tok) { - switch (tok.type) { - case 9: - case 8: - case 7: - case 5: - let op = getOperator(tok.str); - if (op) - return op.p; - } - return -1; -} -function isEOS(tok) { - return tok.type == 0 || tok.type == 4 || tok.str == ":" || tok.str == "ELSE"; -} -function stripQuotes(s) { - return s.substr(1, s.length - 2); -} -function isLiteral(arg) { - return arg.value != null; -} -function isLookup(arg) { - return arg.name != null; -} -function isBinOp(arg) { - return arg.op != null && arg.left != null && arg.right != null; -} -function isUnOp(arg) { - return arg.op != null && arg.expr != null; -} -function mergeLocs(a, b) { - return { - line: Math.min(a.line, b.line), - start: Math.min(a.start, b.start), - end: Math.max(a.end, b.end), - label: a.label || b.label, - path: a.path || b.path - }; -} -var BASICParser = class { - constructor() { - this.opts = DIALECTS["DEFAULT"]; - this.maxlinelen = 255; - this.optionCount = 0; - this.lineno = 0; - this.curlabel = null; - this.stmts = []; - this.labels = {}; - this.targets = {}; - this.errors = []; - this.listings = {}; - this.vardefs = {}; - this.varrefs = {}; - this.fnrefs = {}; - this.scopestack = []; - this.elseifcount = 0; - } - addError(msg, loc) { - var tok = this.lasttoken || this.peekToken(); - if (!loc) - loc = tok.$loc; - this.errors.push({ path: loc.path, line: loc.line, label: this.curlabel, start: loc.start, end: loc.end, msg }); - } - compileError(msg, loc, loc2) { - this.addError(msg, loc); - throw new CompileError(msg, loc); - } - dialectError(what, loc) { - this.compileError(`${what} in this dialect of BASIC (${this.opts.dialectName}).`, loc); - } - dialectErrorNoSupport(what, loc) { - this.compileError(`You can't use ${what} in this dialect of BASIC (${this.opts.dialectName}).`, loc); - } - consumeToken() { - var tok = this.lasttoken = this.tokens.shift() || this.eol; - return tok; - } - expectToken(str, msg) { - var tok = this.consumeToken(); - var tokstr = tok.str; - if (str != tokstr) { - this.compileError(msg || `There should be a "${str}" here.`); - } - return tok; - } - expectTokens(strlist, msg) { - var tok = this.consumeToken(); - var tokstr = tok.str; - if (strlist.indexOf(tokstr) < 0) { - this.compileError(msg || `There should be a ${strlist.map((s) => `"${s}"`).join(" or ")} here.`); - } - return tok; - } - peekToken(lookahead) { - var tok = this.tokens[lookahead || 0]; - return tok ? tok : this.eol; - } - pushbackToken(tok) { - this.tokens.unshift(tok); - } - parseOptLabel() { - let tok = this.consumeToken(); - switch (tok.type) { - case 5: - if (this.opts.optionalLabels || tok.str == "OPTION") { - if (this.peekToken().str == ":" && !this.supportsCommand(tok.str)) { - this.consumeToken(); - } else { - this.pushbackToken(tok); - break; - } - } else - this.dialectError(`Each line must begin with a line number`); - case 2: - this.addLabel(tok.str); - return; - case 3: - case 1: - this.compileError(`Line numbers must be positive integers.`); - break; - case 9: - if (this.supportsCommand(tok.str) && this.validKeyword(tok.str)) { - this.pushbackToken(tok); - break; - } - default: - if (this.opts.optionalLabels) - this.compileError(`A line must start with a line number, command, or label.`); - else - this.compileError(`A line must start with a line number.`); - case 4: - break; - } - this.addLabel("#" + this.lineno); - } - getPC() { - return this.stmts.length; - } - addStatement(stmt, cmdtok, endtok) { - if (endtok == null) - endtok = this.peekToken(); - stmt.$loc = { - path: cmdtok.$loc.path, - line: cmdtok.$loc.line, - start: cmdtok.$loc.start, - end: endtok.$loc.start, - label: this.curlabel, - offset: this.stmts.length - }; - this.modifyScope(stmt); - this.stmts.push(stmt); - } - addLabel(str, offset) { - if (this.labels[str] != null) - this.compileError(`There's a duplicated label named "${str}".`); - this.labels[str] = this.getPC() + (offset || 0); - this.curlabel = str; - this.tokens.forEach((tok) => tok.$loc.label = str); - } - parseFile(file, path4) { - this.path = path4; - var txtlines = file.split(/\n|\r\n?/); - txtlines.forEach((line) => this.parseLine(line)); - var program = { opts: this.opts, stmts: this.stmts, labels: this.labels }; - this.checkAll(program); - this.listings[path4] = this.generateListing(file, program); - return program; - } - parseLine(line) { - try { - this.tokenize(line); - this.parse(); - } catch (e) { - if (!(e instanceof CompileError)) - throw e; - } - } - _tokenize(line) { - let splitre = this.opts.optionalWhitespace && new RegExp("(" + this.opts.validKeywords.map((s) => `${s}`).join("|") + ")"); - var lastTokType = 10; - var m; - while (m = re_toks.exec(line)) { - for (var i = 1; i <= lastTokType; i++) { - let s = m[i]; - if (s != null) { - let loc = { path: this.path, line: this.lineno, start: m.index, end: m.index + s.length }; - if (this.opts.asciiOnly && !/^[\x00-\x7F]*$/.test(s)) - this.dialectErrorNoSupport(`non-ASCII characters`); - if (i == 5 || i == 3 || this.opts.uppercaseOnly) { - s = s.toUpperCase(); - if (s == "DATA") - lastTokType = 11; - if (s == "DATA") - splitre = null; - if (s == "OPTION") - splitre = null; - if (lastTokType == 10 && s.startsWith("REM")) { - s = "REM"; - lastTokType = 0; - } - } - if (s == "[" || s == "]") { - if (!this.opts.squareBrackets) - this.dialectErrorNoSupport(`square brackets`); - if (s == "[") - s = "("; - if (s == "]") - s = ")"; - } - if (splitre && i == 5) { - var splittoks = s.split(splitre).filter((s2) => s2 != ""); - if (splittoks.length > 1) { - splittoks.forEach((ss) => { - if (/^[0-9]+$/.test(ss)) - i = 2; - else if (/^[A-Z_]\w*[$]?$/.test(ss)) - i = 5; - else - this.compileError(`Try adding whitespace before "${ss}".`); - this.tokens.push({ str: ss, type: i, $loc: loc }); - }); - s = null; - } - } - if (s) - this.tokens.push({ str: s, type: i, $loc: loc }); - break; - } - } - } - } - tokenize(line) { - this.lineno++; - this.tokens = []; - this.eol = { type: 0, str: "", $loc: { path: this.path, line: this.lineno, start: line.length } }; - if (line.length > this.maxlinelen) - this.compileError(`A line should be no more than ${this.maxlinelen} characters long.`); - this._tokenize(line); - } - parse() { - if (this.tokens.length) { - this.parseOptLabel(); - if (this.tokens.length) { - this.parseCompoundStatement(); - } - var next = this.peekToken(); - if (!isEOS(next)) - this.compileError(`Expected end of line or ':'`, next.$loc); - this.curlabel = null; - } - } - parseCompoundStatement() { - if (this.opts.multipleStmtsPerLine) { - this.parseList(this.parseStatement, ":"); - } else { - this.parseList(this.parseStatement, "\0"); - if (this.peekToken().str == ":") - this.dialectErrorNoSupport(`multiple statements on a line`); - } - } - validKeyword(keyword) { - return this.opts.validKeywords && this.opts.validKeywords.indexOf(keyword) < 0 ? null : keyword; - } - validFunction(funcname) { - return this.opts.validFunctions && this.opts.validFunctions.indexOf(funcname) < 0 ? null : funcname; - } - supportsCommand(cmd) { - if (cmd == "?") - return this.stmt__PRINT; - else - return this["stmt__" + cmd]; - } - parseStatement() { - if (this.opts.optionalWhitespace && this.peekToken().str == ":") - return null; - var cmdtok = this.consumeToken(); - var cmd = cmdtok.str; - var stmt; - switch (cmdtok.type) { - case 4: - if (cmdtok.str.startsWith("'") && !this.opts.tickComments) - this.dialectErrorNoSupport(`tick comments`); - return null; - case 9: - if (cmd == this.validKeyword("?")) - cmd = "PRINT"; - case 5: - if (cmd == "REM") - return null; - if (cmd == "GO" && this.peekToken().str == "TO") { - this.consumeToken(); - cmd = "GOTO"; - } else if (cmd == "GO" && this.peekToken().str == "SUB") { - this.consumeToken(); - cmd = "GOSUB"; - } - var fn = this.supportsCommand(cmd); - if (fn) { - if (this.validKeyword(cmd) == null) - this.dialectErrorNoSupport(`the ${cmd} statement`); - stmt = fn.bind(this)(); - break; - } else if (this.peekToken().str == "=" || this.peekToken().str == "(") { - if (!this.opts.optionalLet) - this.dialectError(`Assignments must have a preceding LET`); - this.pushbackToken(cmdtok); - stmt = this.stmt__LET(); - break; - } else { - this.compileError(`I don't understand the command "${cmd}".`); - } - case 0: - if (this.opts.optionalWhitespace) - return null; - default: - this.compileError(`There should be a command here.`); - return null; - } - if (stmt != null) - this.addStatement(stmt, cmdtok); - return stmt; - } - modifyScope(stmt) { - if (this.opts.compiledBlocks) { - var cmd = stmt.command; - if (cmd == "FOR" || cmd == "WHILE" || cmd == "SUB") { - this.scopestack.push(this.getPC()); - } else if (cmd == "NEXT") { - this.popScope(stmt, "FOR"); - } else if (cmd == "WEND") { - this.popScope(stmt, "WHILE"); - } - } - } - popScope(close, open) { - var popidx = this.scopestack.pop(); - var popstmt = popidx != null ? this.stmts[popidx] : null; - if (popstmt == null) - this.compileError(`There's a ${close.command} without a matching ${open}.`, close.$loc); - else if (popstmt.command != open) - this.compileError(`There's a ${close.command} paired with ${popstmt.command}, but it should be paired with ${open}.`, close.$loc, popstmt.$loc); - else if (close.command == "NEXT" && !this.opts.optionalNextVar && close.lexpr.name != popstmt.lexpr.name) - this.compileError(`This NEXT statement is matched with the wrong FOR variable (${close.lexpr.name}).`, close.$loc, popstmt.$loc); - close.startpc = popidx; - popstmt.endpc = this.getPC(); - } - popIfThenScope(nextpc) { - var popidx = this.scopestack.pop(); - var popstmt = popidx != null ? this.stmts[popidx] : null; - if (popstmt == null) - this.compileError(`There's an END IF without a matching IF or ELSE.`); - if (popstmt.command == "ELSE") { - popstmt.endpc = this.getPC(); - this.popIfThenScope(popidx + 1); - } else if (popstmt.command == "IF") { - popstmt.endpc = nextpc != null ? nextpc : this.getPC(); - } else { - this.compileError(`There's an END IF paired with a ${popstmt.command}, not IF or ELSE.`, this.lasttoken.$loc, popstmt.$loc); - } - } - parseVarSubscriptOrFunc() { - var tok = this.consumeToken(); - switch (tok.type) { - case 5: - let args = null; - if (this.peekToken().str == "(") { - this.expectToken("("); - args = this.parseExprList(); - this.expectToken(")", `There should be another expression or a ")" here.`); - } - var loc = mergeLocs(tok.$loc, this.lasttoken.$loc); - var valtype = this.exprTypeForSubscript(tok.str, args, loc); - return { valtype, name: tok.str, args, $loc: loc }; - default: - this.compileError(`There should be a variable name here.`); - break; - } - } - parseLexpr() { - var lexpr = this.parseVarSubscriptOrFunc(); - this.vardefs[lexpr.name] = lexpr; - this.validateVarName(lexpr); - return lexpr; - } - parseForNextLexpr() { - var lexpr = this.parseLexpr(); - if (lexpr.args || lexpr.name.endsWith("$")) - this.compileError(`A FOR ... NEXT loop can only use numeric variables.`, lexpr.$loc); - return lexpr; - } - parseList(parseFunc, delim) { - var sep; - var list = []; - do { - var el = parseFunc.bind(this)(); - if (el != null) - list.push(el); - sep = this.consumeToken(); - } while (sep.str == delim); - this.pushbackToken(sep); - return list; - } - parseLexprList() { - return this.parseList(this.parseLexpr, ","); - } - parseExprList() { - return this.parseList(this.parseExpr, ","); - } - parseLabelList() { - return this.parseList(this.parseLabel, ","); - } - parseLabel() { - if (this.opts.computedGoto) { - var expr = this.parseExpr(); - if (isLiteral(expr)) - this.targets[expr.value] = this.lasttoken.$loc; - return expr; - } else { - var tok = this.consumeToken(); - switch (tok.type) { - case 5: - if (!this.opts.optionalLabels) - this.dialectError(`All labels must be line numbers`); - case 2: - var label = tok.str; - this.targets[label] = tok.$loc; - return { valtype: "label", value: label }; - default: - var what = this.opts.optionalLabels ? "label or line number" : "line number"; - this.compileError(`There should be a ${what} here.`); - } - } - } - parseDatumList() { - return this.parseList(this.parseDatum, ","); - } - parseDatum() { - var tok = this.consumeToken(); - while (tok.type == 11) - tok = this.consumeToken(); - if (isEOS(tok)) - this.compileError(`There should be a datum here.`); - if (tok.type <= 3) { - return this.parseValue(tok); - } - if (tok.str == "-" && this.peekToken().type <= 3) { - tok = this.consumeToken(); - return { valtype: "number", value: -this.parseValue(tok).value }; - } - if (tok.str == "+" && this.peekToken().type <= 3) { - tok = this.consumeToken(); - return this.parseValue(tok); - } - var s = ""; - while (!isEOS(tok) && tok.str != ",") { - s += this.parseValue(tok).value; - tok = this.consumeToken(); - } - this.pushbackToken(tok); - return { valtype: "string", value: s }; - } - parseValue(tok) { - switch (tok.type) { - case 3: - if (!this.opts.hexOctalConsts) - this.dialectErrorNoSupport(`hex/octal constants`); - let base = tok.str.startsWith("H") ? 16 : 8; - return { valtype: "number", value: parseInt(tok.str.substr(1), base) }; - case 2: - case 1: - return { valtype: "number", value: this.parseNumber(tok.str) }; - case 6: - return { valtype: "string", value: stripQuotes(tok.str) }; - default: - return { valtype: "string", value: tok.str }; - } - } - parsePrimary() { - let tok = this.consumeToken(); - switch (tok.type) { - case 3: - case 2: - case 1: - case 6: - return this.parseValue(tok); - case 5: - if (tok.str == "NOT") { - let expr = this.parsePrimary(); - return { valtype: "number", op: this.opts.bitwiseLogic ? "bnot" : "lnot", expr }; - } else { - this.pushbackToken(tok); - return this.parseVarSubscriptOrFunc(); - } - case 9: - if (tok.str == "(") { - let expr = this.parseExpr(); - this.expectToken(")", `There should be another expression or a ")" here.`); - return expr; - } else if (tok.str == "-") { - let expr = this.parsePrimary(); - return { valtype: "number", op: "neg", expr }; - } else if (tok.str == "+") { - return this.parsePrimary(); - } - default: - this.compileError(`The expression is incomplete.`); - return; - } - } - parseNumber(str) { - var n = parseFloat(str); - if (isNaN(n)) - this.compileError(`The number ${str} is not a valid floating-point number.`); - if (this.opts.checkOverflow && !isFinite(n)) - this.compileError(`The number ${str} is too big to fit into a floating-point value.`); - return n; - } - parseExpr1(left, minPred) { - let look = this.peekToken(); - while (getPrecedence(look) >= minPred) { - let op = this.consumeToken(); - if (this.opts.validOperators && this.opts.validOperators.indexOf(op.str) < 0) - this.dialectErrorNoSupport(`the "${op.str}" operator`); - let right = this.parsePrimary(); - look = this.peekToken(); - while (getPrecedence(look) > getPrecedence(op)) { - right = this.parseExpr1(right, getPrecedence(look)); - look = this.peekToken(); - } - var opfn = getOperator(op.str).f; - if (!this.opts.bitwiseLogic && op.str == "AND") - opfn = "land"; - if (!this.opts.bitwiseLogic && op.str == "OR") - opfn = "lor"; - var valtype = this.exprTypeForOp(opfn, left, right, op); - left = { valtype, op: opfn, left, right }; - } - return left; - } - parseExpr() { - var startloc = this.peekToken().$loc; - var expr = this.parseExpr1(this.parsePrimary(), 0); - var endloc = this.lasttoken.$loc; - expr.$loc = mergeLocs(startloc, endloc); - return expr; - } - parseExprWithType(expecttype) { - var expr = this.parseExpr(); - if (expr.valtype != expecttype) - this.compileError(`There should be a ${expecttype} here, but this expression evaluates to a ${expr.valtype}.`, expr.$loc); - return expr; - } - validateVarName(lexpr) { - switch (this.opts.varNaming) { - case "A": - if (!/^[A-Z]$/i.test(lexpr.name)) - this.dialectErrorNoSupport(`variable names other than a single letter`); - break; - case "A1": - if (lexpr.args == null && !/^[A-Z][0-9]?[$]?$/i.test(lexpr.name)) - this.dialectErrorNoSupport(`variable names other than a letter followed by an optional digit`); - if (lexpr.args != null && !/^[A-Z]?[$]?$/i.test(lexpr.name)) - this.dialectErrorNoSupport(`array names other than a single letter`); - break; - case "A1$": - if (!/^[A-Z][0-9]?[$]?$/i.test(lexpr.name)) - this.dialectErrorNoSupport(`variable names other than a letter followed by an optional digit`); - break; - case "AA": - if (lexpr.args == null && !/^[A-Z][A-Z0-9]?[$]?$/i.test(lexpr.name)) - this.dialectErrorNoSupport(`variable names other than a letter followed by an optional letter or digit`); - break; - case "*": - break; - } - } - visitExpr(expr, callback) { - if (isBinOp(expr)) { - this.visitExpr(expr.left, callback); - this.visitExpr(expr.right, callback); - } - if (isUnOp(expr)) { - this.visitExpr(expr.expr, callback); - } - if (isLookup(expr) && expr.args != null) { - for (var arg of expr.args) - this.visitExpr(arg, callback); - } - callback(expr); - } - exprTypeForOp(fnname, left, right, optok) { - if (left.valtype == "string" || right.valtype == "string") { - if (fnname == "add") { - if (this.opts.stringConcat) - return "string"; - else - this.dialectErrorNoSupport(`the "+" operator to concatenate strings`, optok.$loc); - } else if (fnname.length != 2) - this.compileError(`You can't do math on strings until they're converted to numbers.`, optok.$loc); - } - return "number"; - } - exprTypeForSubscript(fnname, args, loc) { - args = args || []; - var defs = BUILTIN_MAP[fnname]; - if (defs != null) { - if (!this.validFunction(fnname)) - this.dialectErrorNoSupport(`the ${fnname} function`, loc); - for (var def of defs) { - if (args.length == def.args.length) - return def.result; - } - this.compileError(`The ${fnname} function takes ${def.args.length} arguments, but ${args.length} are given.`, loc); - } - this.varrefs[fnname] = loc; - return fnname.endsWith("$") ? "string" : "number"; - } - stmt__LET() { - var lexprs = [this.parseLexpr()]; - this.expectToken("="); - while (this.opts.chainAssignments && this.peekToken().type == 5 && this.peekToken(1).str == "=") { - lexprs.push(this.parseLexpr()); - this.expectToken("="); - } - var right = this.parseExprWithType(lexprs[0].valtype); - return { command: "LET", lexprs, right }; - } - stmt__PRINT() { - var sep, lastsep; - var list = []; - do { - sep = this.peekToken(); - if (isEOS(sep)) { - break; - } else if (sep.str == ";") { - this.consumeToken(); - lastsep = sep; - } else if (sep.str == ",") { - this.consumeToken(); - list.push({ value: " " }); - lastsep = sep; - } else { - list.push(this.parseExpr()); - lastsep = null; - } - } while (true); - if (!(lastsep && (lastsep.str == ";" || sep.str != ","))) { - list.push({ value: "\n" }); - } - return { command: "PRINT", args: list }; - } - stmt__GOTO() { - return this.__GO("GOTO"); - } - stmt__GOSUB() { - return this.__GO("GOSUB"); - } - __GO(cmd) { - var expr = this.parseLabel(); - if (this.peekToken().str == this.validKeyword("OF")) { - this.expectToken("OF"); - let newcmd = cmd == "GOTO" ? "ONGOTO" : "ONGOSUB"; - return { command: newcmd, expr, labels: this.parseLabelList() }; - } else { - return { command: cmd, label: expr }; - } - } - stmt__IF() { - var cmdtok = this.lasttoken; - var cond = this.parseExprWithType("number"); - var ifstmt = { command: "IF", cond }; - this.addStatement(ifstmt, cmdtok); - var thengoto = this.expectTokens(["THEN", "GOTO", "GO"]); - if (thengoto.str == "GO") - this.expectToken("TO"); - if (this.opts.multilineIfThen && isEOS(this.peekToken())) { - this.scopestack.push(this.getPC() - 1); - } else { - this.parseGotoOrStatements(); - if (this.peekToken().str == "ELSE") { - this.expectToken("ELSE"); - ifstmt.endpc = this.getPC() + 1; - this.stmt__ELSE(); - } else { - ifstmt.endpc = this.getPC(); - } - } - } - stmt__ELSE() { - var elsestmt = { command: "ELSE" }; - this.addStatement(elsestmt, this.lasttoken); - var nexttok = this.peekToken(); - if (this.opts.multilineIfThen && isEOS(nexttok)) { - this.scopestack.push(this.getPC() - 1); - } else if (this.opts.multilineIfThen && nexttok.str == "IF") { - this.scopestack.push(this.getPC() - 1); - this.parseGotoOrStatements(); - this.elseifcount++; - } else { - this.parseGotoOrStatements(); - elsestmt.endpc = this.getPC(); - } - } - parseGotoOrStatements() { - var lineno = this.peekToken(); - if (lineno.type == 2) { - this.parseLabel(); - var gotostmt = { command: "GOTO", label: { valtype: "label", value: lineno.str } }; - this.addStatement(gotostmt, lineno); - } else { - this.parseCompoundStatement(); - } - } - stmt__FOR() { - var lexpr = this.parseForNextLexpr(); - this.expectToken("="); - var init = this.parseExprWithType("number"); - this.expectToken("TO"); - var targ = this.parseExprWithType("number"); - if (this.peekToken().str == "STEP") { - this.consumeToken(); - var step = this.parseExprWithType("number"); - } - return { command: "FOR", lexpr, initial: init, target: targ, step }; - } - stmt__NEXT() { - var lexpr = null; - if (!this.opts.optionalNextVar || !isEOS(this.peekToken())) { - lexpr = this.parseForNextLexpr(); - if (this.opts.multipleNextVars && this.peekToken().str == ",") { - this.consumeToken(); - this.tokens.unshift({ type: 5, str: "NEXT", $loc: this.peekToken().$loc }); - this.tokens.unshift({ type: 9, str: ":", $loc: this.peekToken().$loc }); - } - } - return { command: "NEXT", lexpr }; - } - stmt__WHILE() { - var cond = this.parseExprWithType("number"); - return { command: "WHILE", cond }; - } - stmt__WEND() { - return { command: "WEND" }; - } - stmt__DIM() { - var lexprs = this.parseLexprList(); - lexprs.forEach((arr) => { - if (arr.args == null || arr.args.length == 0) - this.compileError(`An array defined by DIM must have at least one dimension.`); - else if (arr.args.length > this.opts.maxDimensions) - this.dialectErrorNoSupport(`arrays with more than ${this.opts.maxDimensions} dimensionals`); - for (var arrdim of arr.args) { - if (arrdim.valtype != "number") - this.compileError(`Array dimensions must be numeric.`, arrdim.$loc); - if (isLiteral(arrdim) && typeof arrdim.value === "number" && arrdim.value < this.opts.defaultArrayBase) - this.compileError(`An array dimension cannot be less than ${this.opts.defaultArrayBase}.`, arrdim.$loc); - } - }); - return { command: "DIM", args: lexprs }; - } - stmt__INPUT() { - var prompt = this.consumeToken(); - var promptstr; - if (prompt.type == 6) { - this.expectTokens([";", ","]); - promptstr = stripQuotes(prompt.str); - } else { - this.pushbackToken(prompt); - promptstr = ""; - } - return { command: "INPUT", prompt: { valtype: "string", value: promptstr }, args: this.parseLexprList() }; - } - stmt__ENTER() { - var timeout = this.parseExpr(); - this.expectToken(","); - var elapsed = this.parseLexpr(); - this.expectToken(","); - return { command: "INPUT", prompt: null, args: this.parseLexprList(), timeout, elapsed }; - } - stmt__DATA() { - return { command: "DATA", datums: this.parseDatumList() }; - } - stmt__READ() { - return { command: "READ", args: this.parseLexprList() }; - } - stmt__RESTORE() { - var label = null; - if (this.opts.restoreWithLabel && !isEOS(this.peekToken())) - label = this.parseLabel(); - return { command: "RESTORE", label }; - } - stmt__RETURN() { - return { command: "RETURN" }; - } - stmt__STOP() { - return { command: "STOP" }; - } - stmt__END() { - if (this.opts.multilineIfThen && this.scopestack.length) { - let endtok = this.expectTokens(["IF", "SUB"]); - if (endtok.str == "IF") { - this.popIfThenScope(); - while (this.elseifcount--) - this.popIfThenScope(); - this.elseifcount = 0; - } else if (endtok.str == "SUB") { - this.addStatement({ command: "RETURN" }, endtok); - this.popScope({ command: "END" }, "SUB"); - } - } else { - return { command: "END" }; - } - } - stmt__ON() { - var expr = this.parseExprWithType("number"); - var gotok = this.consumeToken(); - var cmd = { GOTO: "ONGOTO", THEN: "ONGOTO", GOSUB: "ONGOSUB" }[gotok.str]; - if (!cmd) - this.compileError(`There should be a GOTO or GOSUB here.`); - var labels = this.parseLabelList(); - return { command: cmd, expr, labels }; - } - stmt__DEF() { - var lexpr = this.parseVarSubscriptOrFunc(); - if (lexpr.args && lexpr.args.length > this.opts.maxDefArgs) - this.compileError(`There can be no more than ${this.opts.maxDefArgs} arguments to a function or subscript.`, lexpr.$loc); - if (!lexpr.name.startsWith("FN")) - this.compileError(`Functions defined with DEF must begin with the letters "FN".`, lexpr.$loc); - this.markVarDefs(lexpr); - this.expectToken("="); - var func = this.parseExpr(); - this.visitExpr(func, (expr) => { - if (isLookup(expr) && expr.name.startsWith("FN")) { - if (!this.fnrefs[lexpr.name]) - this.fnrefs[lexpr.name] = []; - this.fnrefs[lexpr.name].push(expr.name); - } - }); - this.checkCallGraph(lexpr.name, new Set()); - return { command: "DEF", lexpr, def: func }; - } - stmt__SUB() { - var lexpr = this.parseVarSubscriptOrFunc(); - this.markVarDefs(lexpr); - this.addLabel(lexpr.name, 1); - return { command: "SUB", lexpr }; - } - stmt__CALL() { - return { command: "CALL", call: this.parseVarSubscriptOrFunc() }; - } - markVarDefs(lexpr) { - this.vardefs[lexpr.name] = lexpr; - if (lexpr.args != null) - for (let arg of lexpr.args) { - if (isLookup(arg) && arg.args == null) - this.vardefs[arg.name] = arg; - else - this.compileError(`A definition can only define symbols, not expressions.`); - } - } - checkCallGraph(name, visited) { - if (visited.has(name)) - this.compileError(`There was a cycle in the function definition graph for ${name}.`); - visited.add(name); - var refs = this.fnrefs[name] || []; - for (var ref of refs) - this.checkCallGraph(ref, visited); - visited.delete(name); - } - stmt__POP() { - return { command: "POP" }; - } - stmt__GET() { - var lexpr = this.parseLexpr(); - return { command: "GET", lexpr }; - } - stmt__CLEAR() { - return { command: "CLEAR" }; - } - stmt__RANDOMIZE() { - return { command: "RANDOMIZE" }; - } - stmt__CHANGE() { - var src = this.parseExpr(); - this.expectToken("TO"); - var dest = this.parseLexpr(); - if (dest.valtype == src.valtype) - this.compileError(`CHANGE can only convert strings to numeric arrays, or vice-versa.`, mergeLocs(src.$loc, dest.$loc)); - return { command: "CHANGE", src, dest }; - } - stmt__CONVERT() { - var src = this.parseExpr(); - this.expectToken("TO"); - var dest = this.parseLexpr(); - if (dest.valtype == src.valtype) - this.compileError(`CONVERT can only convert strings to numbers, or vice-versa.`, mergeLocs(src.$loc, dest.$loc)); - return { command: "CONVERT", src, dest }; - } - stmt__OPTION() { - this.optionCount++; - var tokname = this.consumeToken(); - var optname = tokname.str.toUpperCase(); - if (tokname.type != 5) - this.compileError(`There must be a name after the OPTION statement.`); - var tokarg = this.consumeToken(); - var arg = tokarg.str.toUpperCase(); - switch (optname) { - case "DIALECT": - if (this.optionCount > 1) - this.compileError(`OPTION DIALECT must be the first OPTION statement in the file.`, tokname.$loc); - let dname = arg || ""; - if (dname == "") - this.compileError(`OPTION DIALECT requires a dialect name.`, tokname.$loc); - let dialect = DIALECTS[dname.toUpperCase()]; - if (dialect) - this.opts = dialect; - else - this.compileError(`${dname} is not a valid dialect.`); - break; - case "BASE": - let base = parseInt(arg); - if (base == 0 || base == 1) - this.opts.defaultArrayBase = base; - else - this.compileError("OPTION BASE can only be 0 or 1."); - break; - case "CPUSPEED": - if (!(this.opts.commandsPerSec = Math.min(1e7, arg == "MAX" ? Infinity : parseFloat(arg)))) - this.compileError(`OPTION CPUSPEED takes a positive number or MAX.`); - break; - default: - let propname = Object.getOwnPropertyNames(this.opts).find((n) => n.toUpperCase() == optname); - if (propname == null) - this.compileError(`${optname} is not a valid option.`, tokname.$loc); - if (arg == null) - this.compileError(`OPTION ${optname} requires a parameter.`); - switch (typeof this.opts[propname]) { - case "boolean": - this.opts[propname] = arg.toUpperCase().startsWith("T") || arg > 0; - return; - case "number": - this.opts[propname] = parseFloat(arg); - return; - case "string": - this.opts[propname] = arg; - return; - case "object": - if (Array.isArray(this.opts[propname]) && arg == "ALL") { - this.opts[propname] = null; - return; - } - this.compileError(`OPTION ${optname} ALL is the only option supported.`); - } - break; - } - return { command: "OPTION", optname, optargs: [arg] }; - } - generateListing(file, program) { - var srclines = []; - var laststmt; - program.stmts.forEach((stmt, idx) => { - laststmt = stmt; - srclines.push(stmt.$loc); - }); - if (this.opts.endStmtRequired && (laststmt == null || laststmt.command != "END")) - this.dialectError(`All programs must have a final END statement`); - return { lines: srclines }; - } - getListings() { - return this.listings; - } - checkAll(program) { - this.checkLabels(); - this.checkScopes(); - this.checkVarRefs(); - } - checkLabels() { - for (let targ in this.targets) { - if (this.labels[targ] == null) { - var what = this.opts.optionalLabels && isNaN(parseInt(targ)) ? "label named" : "line number"; - this.addError(`There isn't a ${what} ${targ}.`, this.targets[targ]); - } - } - } - checkScopes() { - if (this.opts.compiledBlocks && this.scopestack.length) { - var open = this.stmts[this.scopestack.pop()]; - var close = { FOR: "NEXT", WHILE: "WEND", IF: "END IF", SUB: "END SUB" }; - this.compileError(`Don't forget to add a matching ${close[open.command]} statement.`, open.$loc); - } - } - checkVarRefs() { - if (!this.opts.defaultValues) { - for (var varname in this.varrefs) { - if (this.vardefs[varname] == null) - this.compileError(`The variable ${varname} isn't defined anywhere in the program.`, this.varrefs[varname]); - } - } - } -}; -var ECMA55_MINIMAL = { - dialectName: "ECMA55", - asciiOnly: true, - uppercaseOnly: true, - optionalLabels: false, - optionalWhitespace: false, - multipleStmtsPerLine: false, - varNaming: "A1", - staticArrays: true, - sharedArrayNamespace: true, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: false, - stringConcat: false, - maxDimensions: 2, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "BASE", - "DATA", - "DEF", - "DIM", - "END", - "FOR", - "GO", - "GOSUB", - "GOTO", - "IF", - "INPUT", - "LET", - "NEXT", - "ON", - "OPTION", - "PRINT", - "RANDOMIZE", - "READ", - "REM", - "RESTORE", - "RETURN", - "STEP", - "STOP", - "THEN", - "TO" - ], - validFunctions: [ - "ABS", - "ATN", - "COS", - "EXP", - "INT", - "LOG", - "RND", - "SGN", - "SIN", - "SQR", - "TAB", - "TAN" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^" - ], - printZoneLength: 15, - numericPadding: true, - checkOverflow: true, - testInitialFor: true, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: true, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: true, - chainAssignments: false, - optionalLet: false, - compiledBlocks: true -}; -var DARTMOUTH_4TH_EDITION = { - dialectName: "DARTMOUTH4", - asciiOnly: true, - uppercaseOnly: true, - optionalLabels: false, - optionalWhitespace: false, - multipleStmtsPerLine: false, - varNaming: "A1", - staticArrays: true, - sharedArrayNamespace: false, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: false, - stringConcat: false, - maxDimensions: 2, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: true, - hexOctalConsts: false, - validKeywords: [ - "BASE", - "DATA", - "DEF", - "DIM", - "END", - "FOR", - "GO", - "GOSUB", - "GOTO", - "IF", - "INPUT", - "LET", - "NEXT", - "ON", - "OPTION", - "PRINT", - "RANDOMIZE", - "READ", - "REM", - "RESTORE", - "RETURN", - "STEP", - "STOP", - "THEN", - "TO", - "CHANGE", - "MAT", - "RANDOM", - "RESTORE$", - "RESTORE*" - ], - validFunctions: [ - "ABS", - "ATN", - "COS", - "EXP", - "INT", - "LOG", - "RND", - "SGN", - "SIN", - "SQR", - "TAB", - "TAN", - "TRN", - "INV", - "DET", - "NUM", - "ZER" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^" - ], - printZoneLength: 15, - numericPadding: true, - checkOverflow: true, - testInitialFor: true, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: true, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: true, - chainAssignments: true, - optionalLet: false, - compiledBlocks: true -}; -var TINY_BASIC = { - dialectName: "TINY", - asciiOnly: true, - uppercaseOnly: true, - optionalLabels: false, - optionalWhitespace: false, - multipleStmtsPerLine: false, - varNaming: "A", - staticArrays: false, - sharedArrayNamespace: true, - defaultArrayBase: 0, - defaultArraySize: 0, - defaultValues: true, - stringConcat: false, - maxDimensions: 0, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "OPTION", - "PRINT", - "IF", - "THEN", - "GOTO", - "INPUT", - "LET", - "GOSUB", - "RETURN", - "CLEAR", - "END" - ], - validFunctions: [], - validOperators: [ - "=", - "<>", - "><", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/" - ], - printZoneLength: 1, - numericPadding: false, - checkOverflow: false, - testInitialFor: false, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: false, - computedGoto: true, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: false, - compiledBlocks: false -}; -var HP_TIMESHARED_BASIC = { - dialectName: "HP2000", - asciiOnly: true, - uppercaseOnly: true, - optionalLabels: false, - optionalWhitespace: false, - multipleStmtsPerLine: true, - varNaming: "A1$", - staticArrays: true, - sharedArrayNamespace: false, - defaultArrayBase: 1, - defaultArraySize: 11, - defaultValues: false, - stringConcat: false, - maxDimensions: 2, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "BASE", - "DATA", - "DEF", - "DIM", - "END", - "FOR", - "GO", - "GOSUB", - "GOTO", - "IF", - "INPUT", - "LET", - "NEXT", - "OPTION", - "PRINT", - "RANDOMIZE", - "READ", - "REM", - "RESTORE", - "RETURN", - "STEP", - "STOP", - "THEN", - "TO", - "ENTER", - "MAT", - "CONVERT", - "OF", - "IMAGE", - "USING" - ], - validFunctions: [ - "ABS", - "ATN", - "BRK", - "COS", - "CTL", - "EXP", - "INT", - "LEN", - "LIN", - "LOG", - "NUM", - "POS", - "RND", - "SGN", - "SIN", - "SPA", - "SQR", - "TAB", - "TAN", - "TIM", - "TYP", - "UPS$", - "NFORMAT$" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^", - "**", - "#", - "NOT", - "AND", - "OR", - "MIN", - "MAX" - ], - printZoneLength: 15, - numericPadding: true, - checkOverflow: false, - testInitialFor: true, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: false, - computedGoto: true, - restoreWithLabel: true, - squareBrackets: true, - arraysContainChars: true, - endStmtRequired: true, - chainAssignments: true, - optionalLet: true, - compiledBlocks: true, - maxArrayElements: 5e3 -}; -var DEC_BASIC_11 = { - dialectName: "DEC11", - asciiOnly: true, - uppercaseOnly: true, - optionalLabels: false, - optionalWhitespace: false, - multipleStmtsPerLine: false, - varNaming: "A1", - staticArrays: true, - sharedArrayNamespace: false, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: true, - stringConcat: true, - maxDimensions: 2, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "OPTION", - "DATA", - "DEF", - "DIM", - "END", - "FOR", - "STEP", - "GOSUB", - "GOTO", - "GO", - "TO", - "IF", - "THEN", - "INPUT", - "LET", - "NEXT", - "ON", - "PRINT", - "RANDOMIZE", - "READ", - "REM", - "RESET", - "RESTORE", - "RETURN", - "STOP" - ], - validFunctions: [ - "ABS", - "ATN", - "COS", - "EXP", - "INT", - "LOG", - "LOG10", - "PI", - "RND", - "SGN", - "SIN", - "SQR", - "TAB", - "ASC", - "BIN", - "CHR$", - "CLK$", - "DAT$", - "LEN", - "OCT", - "POS", - "SEG$", - "STR$", - "TRM$", - "VAL", - "NFORMAT$" - ], - validOperators: [ - "=", - "<>", - "><", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^" - ], - printZoneLength: 14, - numericPadding: true, - checkOverflow: true, - testInitialFor: true, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: true, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: true, - compiledBlocks: true -}; -var DEC_BASIC_PLUS = { - dialectName: "DECPLUS", - asciiOnly: true, - uppercaseOnly: false, - optionalLabels: false, - optionalWhitespace: false, - multipleStmtsPerLine: true, - varNaming: "A1", - staticArrays: true, - sharedArrayNamespace: false, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: true, - stringConcat: true, - maxDimensions: 2, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: true, - hexOctalConsts: false, - validKeywords: [ - "OPTION", - "REM", - "LET", - "DIM", - "RANDOM", - "RANDOMIZE", - "IF", - "THEN", - "ELSE", - "FOR", - "TO", - "STEP", - "WHILE", - "UNTIL", - "NEXT", - "DEF", - "ON", - "GOTO", - "GOSUB", - "RETURN", - "CHANGE", - "READ", - "DATA", - "RESTORE", - "PRINT", - "USING", - "INPUT", - "LINE", - "NAME", - "AS", - "ERROR", - "RESUME", - "CHAIN", - "STOP", - "END", - "MAT", - "UNLESS", - "SLEEP", - "WAIT" - ], - validFunctions: [ - "ABS", - "ATN", - "COS", - "EXP", - "INT", - "LOG", - "LOG10", - "PI", - "RND", - "SGN", - "SIN", - "SQR", - "TAB", - "TAN", - "POS", - "TAB", - "ASCII", - "CHR$", - "CVT%$", - "CVTF$", - "CVT$%", - "CVT$F", - "LEFT$", - "RIGHT$", - "MID$", - "LEN", - "INSTR", - "SPACE$", - "NUM$", - "VAL", - "XLATE", - "DATE$", - "TIME$", - "TIME", - "ERR", - "ERL", - "SWAP%", - "RAD$", - "NFORMAT$" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^", - "**", - "==", - "NOT", - "AND", - "OR", - "XOR", - "IMP", - "EQV" - ], - printZoneLength: 14, - numericPadding: true, - checkOverflow: true, - testInitialFor: true, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: true, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: true, - compiledBlocks: true -}; -var BASICODE = { - dialectName: "BASICODE", - asciiOnly: true, - uppercaseOnly: false, - optionalLabels: false, - optionalWhitespace: true, - multipleStmtsPerLine: true, - varNaming: "AA", - staticArrays: true, - sharedArrayNamespace: false, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: false, - stringConcat: true, - maxDimensions: 2, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "BASE", - "DATA", - "DEF", - "DIM", - "END", - "FOR", - "GO", - "GOSUB", - "GOTO", - "IF", - "INPUT", - "LET", - "NEXT", - "ON", - "OPTION", - "PRINT", - "READ", - "REM", - "RESTORE", - "RETURN", - "STEP", - "STOP", - "THEN", - "TO", - "AND", - "NOT", - "OR" - ], - validFunctions: [ - "ABS", - "ASC", - "ATN", - "CHR$", - "COS", - "EXP", - "INT", - "LEFT$", - "LEN", - "LOG", - "MID$", - "RIGHT$", - "SGN", - "SIN", - "SQR", - "TAB", - "TAN", - "VAL" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^", - "AND", - "NOT", - "OR" - ], - printZoneLength: 15, - numericPadding: true, - checkOverflow: true, - testInitialFor: true, - optionalNextVar: false, - multipleNextVars: false, - bitwiseLogic: false, - checkOnGotoIndex: true, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: true, - compiledBlocks: false -}; -var ALTAIR_BASIC41 = { - dialectName: "ALTAIR41", - asciiOnly: true, - uppercaseOnly: true, - optionalLabels: false, - optionalWhitespace: true, - multipleStmtsPerLine: true, - varNaming: "*", - staticArrays: false, - sharedArrayNamespace: true, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: true, - stringConcat: true, - maxDimensions: 128, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "OPTION", - "CONSOLE", - "DATA", - "DEF", - "DEFUSR", - "DIM", - "END", - "ERASE", - "ERROR", - "FOR", - "GOTO", - "GOSUB", - "IF", - "THEN", - "ELSE", - "INPUT", - "LET", - "LINE", - "PRINT", - "LPRINT", - "USING", - "NEXT", - "ON", - "OUT", - "POKE", - "READ", - "REM", - "RESTORE", - "RESUME", - "RETURN", - "STOP", - "SWAP", - "TROFF", - "TRON", - "WAIT", - "TO", - "STEP", - "AND", - "NOT", - "OR", - "XOR", - "IMP", - "EQV", - "MOD", - "RANDOMIZE" - ], - validFunctions: [ - "ABS", - "ASC", - "ATN", - "CDBL", - "CHR$", - "CINT", - "COS", - "ERL", - "ERR", - "EXP", - "FIX", - "FRE", - "HEX$", - "INP", - "INSTR", - "INT", - "LEFT$", - "LEN", - "LOG", - "LPOS", - "MID$", - "OCT$", - "POS", - "RIGHT$", - "RND", - "SGN", - "SIN", - "SPACE$", - "SPC", - "SQR", - "STR$", - "STRING$", - "TAB", - "TAN", - "USR", - "VAL", - "VARPTR" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^", - "\\", - "AND", - "NOT", - "OR", - "XOR", - "IMP", - "EQV", - "MOD" - ], - printZoneLength: 15, - numericPadding: true, - checkOverflow: true, - testInitialFor: false, - optionalNextVar: true, - multipleNextVars: true, - bitwiseLogic: true, - checkOnGotoIndex: false, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: true, - compiledBlocks: false -}; -var APPLESOFT_BASIC = { - dialectName: "APPLESOFT", - asciiOnly: true, - uppercaseOnly: false, - optionalLabels: false, - optionalWhitespace: true, - multipleStmtsPerLine: true, - varNaming: "*", - staticArrays: false, - sharedArrayNamespace: false, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: true, - stringConcat: true, - maxDimensions: 88, - maxDefArgs: 1, - maxStringLength: 255, - tickComments: false, - hexOctalConsts: false, - validKeywords: [ - "OPTION", - "CLEAR", - "LET", - "DIM", - "DEF", - "GOTO", - "GOSUB", - "RETURN", - "ON", - "POP", - "FOR", - "NEXT", - "IF", - "THEN", - "END", - "STOP", - "ONERR", - "RESUME", - "PRINT", - "INPUT", - "GET", - "HOME", - "HTAB", - "VTAB", - "INVERSE", - "FLASH", - "NORMAL", - "TEXT", - "GR", - "COLOR", - "PLOT", - "HLIN", - "VLIN", - "HGR", - "HGR2", - "HPLOT", - "HCOLOR", - "AT", - "DATA", - "READ", - "RESTORE", - "REM", - "TRACE", - "NOTRACE", - "TO", - "STEP", - "AND", - "NOT", - "OR" - ], - validFunctions: [ - "ABS", - "ATN", - "COS", - "EXP", - "INT", - "LOG", - "RND", - "SGN", - "SIN", - "SQR", - "TAN", - "LEN", - "LEFT$", - "MID$", - "RIGHT$", - "STR$", - "VAL", - "CHR$", - "ASC", - "FRE", - "SCRN", - "PDL", - "PEEK", - "POS" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^", - "AND", - "NOT", - "OR" - ], - printZoneLength: 16, - numericPadding: false, - checkOverflow: true, - testInitialFor: false, - optionalNextVar: true, - multipleNextVars: true, - bitwiseLogic: false, - checkOnGotoIndex: false, - computedGoto: false, - restoreWithLabel: false, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: true, - compiledBlocks: false -}; -var BASIC80 = { - dialectName: "BASIC80", - asciiOnly: true, - uppercaseOnly: false, - optionalLabels: false, - optionalWhitespace: true, - multipleStmtsPerLine: true, - varNaming: "*", - staticArrays: false, - sharedArrayNamespace: true, - defaultArrayBase: 0, - defaultArraySize: 11, - defaultValues: true, - stringConcat: true, - maxDimensions: 255, - maxDefArgs: 255, - maxStringLength: 255, - tickComments: true, - hexOctalConsts: true, - validKeywords: [ - "OPTION", - "CONSOLE", - "DATA", - "DEF", - "DEFUSR", - "DIM", - "END", - "ERASE", - "ERROR", - "FOR", - "GOTO", - "GOSUB", - "IF", - "THEN", - "ELSE", - "INPUT", - "LET", - "LINE", - "PRINT", - "LPRINT", - "USING", - "NEXT", - "ON", - "OUT", - "POKE", - "READ", - "REM", - "RESTORE", - "RESUME", - "RETURN", - "STOP", - "SWAP", - "TROFF", - "TRON", - "WAIT", - "CALL", - "CHAIN", - "COMMON", - "WHILE", - "WEND", - "WRITE", - "RANDOMIZE", - "TO", - "STEP", - "AND", - "NOT", - "OR", - "XOR", - "IMP", - "EQV", - "MOD" - ], - validFunctions: [ - "ABS", - "ASC", - "ATN", - "CDBL", - "CHR$", - "CINT", - "COS", - "CSNG", - "CVI", - "CVS", - "CVD", - "EOF", - "EXP", - "FIX", - "FRE", - "HEX$", - "INP", - "INPUT$", - "INSTR", - "INT", - "LEFT$", - "LEN", - "LOC", - "LOG", - "LPOS", - "MID$", - "MKI$", - "MKS$", - "MKD$", - "OCT$", - "PEEK", - "POS", - "RIGHT$", - "RND", - "SGN", - "SIN", - "SPACE$", - "SPC", - "SQR", - "STR$", - "STRING$", - "TAB", - "TAN", - "USR", - "VAL", - "VARPTR" - ], - validOperators: [ - "=", - "<>", - "<", - ">", - "<=", - ">=", - "+", - "-", - "*", - "/", - "^", - "\\", - "AND", - "NOT", - "OR", - "XOR", - "IMP", - "EQV", - "MOD" - ], - printZoneLength: 14, - numericPadding: true, - checkOverflow: false, - testInitialFor: true, - optionalNextVar: true, - multipleNextVars: true, - bitwiseLogic: true, - checkOnGotoIndex: false, - computedGoto: false, - restoreWithLabel: true, - squareBrackets: false, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: false, - optionalLet: true, - compiledBlocks: false -}; -var MODERN_BASIC = { - dialectName: "MODERN", - asciiOnly: false, - uppercaseOnly: false, - optionalLabels: true, - optionalWhitespace: false, - multipleStmtsPerLine: true, - varNaming: "*", - staticArrays: false, - sharedArrayNamespace: false, - defaultArrayBase: 0, - defaultArraySize: 0, - defaultValues: false, - stringConcat: true, - maxDimensions: 255, - maxDefArgs: 255, - maxStringLength: 2048, - tickComments: true, - hexOctalConsts: true, - validKeywords: null, - validFunctions: null, - validOperators: null, - printZoneLength: 16, - numericPadding: false, - checkOverflow: true, - testInitialFor: true, - optionalNextVar: true, - multipleNextVars: true, - bitwiseLogic: true, - checkOnGotoIndex: true, - computedGoto: false, - restoreWithLabel: true, - squareBrackets: true, - arraysContainChars: false, - endStmtRequired: false, - chainAssignments: true, - optionalLet: true, - compiledBlocks: true, - multilineIfThen: true -}; -var BUILTIN_DEFS = [ - ["ABS", ["number"], "number"], - ["ASC", ["string"], "number"], - ["ATN", ["number"], "number"], - ["CHR$", ["number"], "string"], - ["CINT", ["number"], "number"], - ["COS", ["number"], "number"], - ["COT", ["number"], "number"], - ["CTL", ["number"], "string"], - ["EXP", ["number"], "number"], - ["FIX", ["number"], "number"], - ["HEX$", ["number"], "string"], - ["INSTR", ["number", "string", "string"], "number"], - ["INSTR", ["string", "string"], "number"], - ["INT", ["number"], "number"], - ["LEFT$", ["string", "number"], "string"], - ["LEN", ["string"], "number"], - ["LIN", ["number"], "string"], - ["LOG", ["number"], "number"], - ["LOG10", ["number"], "number"], - ["MID$", ["string", "number"], "string"], - ["MID$", ["string", "number", "number"], "string"], - ["OCT$", ["number"], "string"], - ["PI", [], "number"], - ["POS", ["number"], "number"], - ["POS", ["string", "string"], "number"], - ["RIGHT$", ["string", "number"], "string"], - ["RND", [], "number"], - ["RND", ["number"], "number"], - ["ROUND", ["number"], "number"], - ["SGN", ["number"], "number"], - ["SIN", ["number"], "number"], - ["SPACE$", ["number"], "string"], - ["SPC", ["number"], "string"], - ["SQR", ["number"], "number"], - ["STR$", ["number"], "string"], - ["STRING$", ["number", "number"], "string"], - ["STRING$", ["number", "string"], "string"], - ["TAB", ["number"], "string"], - ["TAN", ["number"], "number"], - ["TIM", ["number"], "number"], - ["TIMER", [], "number"], - ["UPS$", ["string"], "string"], - ["VAL", ["string"], "number"], - ["LPAD$", ["string", "number"], "string"], - ["RPAD$", ["string", "number"], "string"], - ["NFORMAT$", ["number", "number"], "string"] -]; -var BUILTIN_MAP = {}; -BUILTIN_DEFS.forEach((def, idx) => { - let [name, args, result] = def; - if (!BUILTIN_MAP[name]) - BUILTIN_MAP[name] = []; - BUILTIN_MAP[name].push({ args, result }); -}); -var DIALECTS = { - "DEFAULT": MODERN_BASIC, - "DARTMOUTH": DARTMOUTH_4TH_EDITION, - "DARTMOUTH4": DARTMOUTH_4TH_EDITION, - "ALTAIR": ALTAIR_BASIC41, - "ALTAIR4": ALTAIR_BASIC41, - "ALTAIR41": ALTAIR_BASIC41, - "TINY": TINY_BASIC, - "ECMA55": ECMA55_MINIMAL, - "MINIMAL": ECMA55_MINIMAL, - "HP": HP_TIMESHARED_BASIC, - "HPB": HP_TIMESHARED_BASIC, - "HPTSB": HP_TIMESHARED_BASIC, - "HP2000": HP_TIMESHARED_BASIC, - "HPBASIC": HP_TIMESHARED_BASIC, - "HPACCESS": HP_TIMESHARED_BASIC, - "DEC11": DEC_BASIC_11, - "DEC": DEC_BASIC_PLUS, - "DECPLUS": DEC_BASIC_PLUS, - "BASICPLUS": DEC_BASIC_PLUS, - "BASICODE": BASICODE, - "APPLESOFT": APPLESOFT_BASIC, - "BASIC80": BASIC80, - "MODERN": MODERN_BASIC -}; - -// src/worker/tools/misc.ts -function translateShowdown(step) { - setupRequireFunction(); - load("showdown.min"); - var showdown = emglobal["showdown"]; - var converter = new showdown.Converter({ - tables: "true", - smoothLivePreview: "true", - requireSpaceBeforeHeadingText: "true", - emoji: "true" - }); - var code = getWorkFileAsString(step.path); - var html = converter.makeHtml(code); - delete emglobal["require"]; - return { - output: html - }; -} -function compileInform6(step) { - loadNative("inform"); - var errors = []; - gatherFiles(step, { mainFilePath: "main.inf" }); - var objpath = step.prefix + ".z5"; - if (staleFiles(step, [objpath])) { - var errorMatcher = msvcErrorMatcher(errors); - var lstout = ""; - var match_fn = (s) => { - if (s.indexOf("Error:") >= 0) { - errorMatcher(s); - } else { - lstout += s; - lstout += "\n"; - } - }; - var args = ["-afjnops", "-v5", "-Cu", "-E1", "-k", "+/share/lib", step.path]; - var inform = emglobal.inform({ - instantiateWasm: moduleInstFn("inform"), - noInitialRun: true, - print: match_fn, - printErr: match_fn - }); - var FS = inform.FS; - setupFS(FS, "inform"); - populateFiles(step, FS); - execMain(step, inform, args); - if (errors.length) - return { errors }; - var objout = FS.readFile(objpath, { encoding: "binary" }); - putWorkFile(objpath, objout); - if (!anyTargetChanged(step, [objpath])) - return; - var symbolmap = {}; - var segments = []; - var entitymap = { - "object": {}, - "property": {}, - "attribute": {}, - "constant": {}, - "global-variable": {}, - "routine": {} - }; - var dbgout = FS.readFile("gameinfo.dbg", { encoding: "utf8" }); - var xmlroot = parseXMLPoorly(dbgout); - var segtype = "ram"; - xmlroot.children.forEach((node) => { - switch (node.type) { - case "global-variable": - case "routine": - var ident = node.children.find((c, v) => c.type == "identifier").text; - var address = parseInt(node.children.find((c, v) => c.type == "address").text); - symbolmap[ident] = address; - entitymap[node.type][address] = ident; - break; - case "object": - case "property": - case "attribute": - var ident = node.children.find((c, v) => c.type == "identifier").text; - var value = parseInt(node.children.find((c, v) => c.type == "value").text); - entitymap[node.type][value] = ident; - break; - case "story-file-section": - var name = node.children.find((c, v) => c.type == "type").text; - var address = parseInt(node.children.find((c, v) => c.type == "address").text); - var endAddress = parseInt(node.children.find((c, v) => c.type == "end-address").text); - if (name == "grammar table") - segtype = "rom"; - segments.push({ name, start: address, size: endAddress - address, type: segtype }); - } - }); - var listings = {}; - var lines = parseListing(lstout, /\s*(\d+)\s+[+]([0-9a-f]+)\s+([<*>]*)\s*(\w+)\s+(.+)/i, -1, 2, 4); - var lstpath = step.prefix + ".lst"; - listings[lstpath] = { lines: [], asmlines: lines, text: lstout }; - return { - output: objout, - listings, - errors, - symbolmap, - segments, - debuginfo: entitymap - }; - } -} -function compileBASIC(step) { - var jsonpath = step.path + ".json"; - gatherFiles(step); - if (staleFiles(step, [jsonpath])) { - var parser = new BASICParser(); - var code = getWorkFileAsString(step.path); - try { - var ast = parser.parseFile(code, step.path); - } catch (e) { - console.log(e); - if (parser.errors.length == 0) - throw e; - } - if (parser.errors.length) { - return { errors: parser.errors }; - } - var json = JSON.stringify(ast, (key, value) => { - return key == "$loc" ? void 0 : value; - }); - putWorkFile(jsonpath, json); - if (anyTargetChanged(step, [jsonpath])) - return { - output: ast, - listings: parser.getListings() - }; - } -} -function compileWiz(step) { - loadNative("wiz"); - var params = step.params; - gatherFiles(step, { mainFilePath: "main.wiz" }); - var destpath = step.prefix + (params.wiz_rom_ext || ".bin"); - var errors = []; - if (staleFiles(step, [destpath])) { - var wiz = emglobal.wiz({ - instantiateWasm: moduleInstFn("wiz"), - noInitialRun: true, - print: print_fn, - printErr: makeErrorMatcher(errors, /(.+?):(\d+):\s*(.+)/, 2, 3, step.path, 1) - }); - var FS = wiz.FS; - setupFS(FS, "wiz"); - populateFiles(step, FS); - populateExtraFiles(step, FS, params.extra_compile_files); - const FWDIR = "/share/common"; - var args = [ - "-o", - destpath, - "-I", - FWDIR + "/" + (params.wiz_inc_dir || getRootBasePlatform(step.platform)), - "-s", - "wla", - "--color=none", - step.path - ]; - args.push("--system", params.wiz_sys_type || params.arch); - execMain(step, wiz, args); - if (errors.length) - return { errors }; - var binout = FS.readFile(destpath, { encoding: "binary" }); - putWorkFile(destpath, binout); - var dbgout = FS.readFile(step.prefix + ".sym", { encoding: "utf8" }); - var symbolmap = {}; - for (var s of dbgout.split("\n")) { - var toks = s.split(/ /); - if (toks && toks.length >= 2) { - var tokrange = toks[0].split(":"); - var start = parseInt(tokrange[1], 16); - var sym = toks[1]; - symbolmap[sym] = start; - } - } - return { - output: binout, - errors, - symbolmap - }; - } -} - -// src/worker/tools/cc65.ts -function parseCA65Listing(asmfn, code, symbols, segments, params, dbg, listings) { - var segofs = 0; - var offset = 0; - var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+(\w+), "([^"]+)", (.+)/; - var funcLineMatch = /"(\w+)", (\w+), "(\w+)"/; - var insnLineMatch = /^([0-9A-F]+)([r]?)\s{1,2}(\d+)\s{1,2}([0-9A-Frx ]{11})\s+(.*)/; - var segMatch = /[.]segment\s+"(\w+)"/i; - var origlines = []; - var lines = origlines; - var linenum = 0; - let curpath = asmfn || ""; - for (var line of code.split(re_crlf)) { - var dbgm = dbgLineMatch.exec(line); - if (dbgm && dbgm[1]) { - var dbgtype = dbgm[4]; - offset = parseInt(dbgm[1], 16); - curpath = dbgm[5]; - if (curpath && listings) { - let l = listings[curpath]; - if (!l) - l = listings[curpath] = { lines: [] }; - lines = l.lines; - } - if (dbgtype == "func") { - var funcm = funcLineMatch.exec(dbgm[6]); - if (funcm) { - var funcofs = symbols[funcm[3]]; - if (typeof funcofs === "number") { - segofs = funcofs - offset; - } - } - } - } - if (dbg && dbgm && dbgtype == "line") { - lines.push({ - path: dbgm[5], - line: parseInt(dbgm[6]), - offset: offset + segofs, - insns: null - }); - } - let linem = insnLineMatch.exec(line); - let topfile = linem && linem[3] == "1"; - if (topfile) { - let insns = linem[4]?.trim() || ""; - if (!(insns != "" && linem[5] == "")) { - linenum++; - } - if (linem[1]) { - var offset = parseInt(linem[1], 16); - if (insns.length) { - if (!dbg) { - lines.push({ - path: curpath, - line: linenum, - offset: offset + segofs, - insns, - iscode: true - }); - } - } else { - var sym = null; - var label = linem[5]; - if (label?.endsWith(":")) { - sym = label.substring(0, label.length - 1); - } else if (label?.toLowerCase().startsWith(".proc")) { - sym = label.split(" ")[1]; - } - if (sym && !sym.startsWith("@")) { - var symofs = symbols[sym]; - if (typeof symofs === "number") { - segofs = symofs - offset; - } - } - } - } - } - } - return origlines; -} -function assembleCA65(step) { - loadNative("ca65"); - var errors = []; - gatherFiles(step, { mainFilePath: "main.s" }); - var objpath = step.prefix + ".o"; - var lstpath = step.prefix + ".lst"; - if (staleFiles(step, [objpath, lstpath])) { - var objout, lstout; - var CA65 = emglobal.ca65({ - instantiateWasm: moduleInstFn("ca65"), - noInitialRun: true, - print: print_fn, - printErr: makeErrorMatcher(errors, /(.+?):(\d+): (.+)/, 2, 3, step.path, 1) - }); - var FS = CA65.FS; - setupFS(FS, "65-" + getRootBasePlatform(step.platform)); - populateFiles(step, FS); - fixParamsWithDefines(step.path, step.params); - var args = ["-v", "-g", "-I", "/share/asminc", "-o", objpath, "-l", lstpath, step.path]; - args.unshift.apply(args, ["-D", "__8BITWORKSHOP__=1"]); - if (step.mainfile) { - args.unshift.apply(args, ["-D", "__MAIN__=1"]); - } - execMain(step, CA65, args); - if (errors.length) { - let listings = {}; - return { errors, listings }; - } - objout = FS.readFile(objpath, { encoding: "binary" }); - lstout = FS.readFile(lstpath, { encoding: "utf8" }); - putWorkFile(objpath, objout); - putWorkFile(lstpath, lstout); - } - return { - linktool: "ld65", - files: [objpath, lstpath], - args: [objpath] - }; -} -function linkLD65(step) { - loadNative("ld65"); - var params = step.params; - gatherFiles(step); - var binpath = "main"; - if (staleFiles(step, [binpath])) { - var errors = []; - var LD65 = emglobal.ld65({ - instantiateWasm: moduleInstFn("ld65"), - noInitialRun: true, - print: print_fn, - printErr: function(s2) { - errors.push({ msg: s2, line: 0 }); - } - }); - var FS = LD65.FS; - setupFS(FS, "65-" + getRootBasePlatform(step.platform)); - populateFiles(step, FS); - populateExtraFiles(step, FS, params.extra_link_files); - if (store.hasFile(params.cfgfile)) { - populateEntry(FS, params.cfgfile, store.getFileEntry(params.cfgfile), null); - } - var libargs = params.libargs || []; - var cfgfile = params.cfgfile; - var args = [ - "--cfg-path", - "/share/cfg", - "--lib-path", - "/share/lib", - "-C", - cfgfile, - "-Ln", - "main.vice", - "-o", - "main", - "-m", - "main.map" - ].concat(step.args, libargs); - execMain(step, LD65, args); - if (errors.length) - return { errors }; - var aout = FS.readFile("main", { encoding: "binary" }); - var mapout = FS.readFile("main.map", { encoding: "utf8" }); - var viceout = FS.readFile("main.vice", { encoding: "utf8" }); - if (step.platform == "pce" && aout.length > 8192) { - let newrom = new Uint8Array(aout.length); - newrom.set(aout.slice(aout.length - 8192), 0); - newrom.set(aout.slice(0, aout.length - 8192), 8192); - aout = newrom; - } - putWorkFile("main", aout); - putWorkFile("main.map", mapout); - putWorkFile("main.vice", viceout); - if (!anyTargetChanged(step, ["main", "main.map", "main.vice"])) - return; - var symbolmap = {}; - for (var s of viceout.split("\n")) { - var toks = s.split(" "); - if (toks[0] == "al") { - let ident = toks[2].substr(1); - if (ident.length != 5 || !ident.startsWith("L")) { - let ofs = parseInt(toks[1], 16); - symbolmap[ident] = ofs; - } - } - } - var segments = []; - let re_seglist = /(\w+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+([0-9A-F]+)/; - let parseseglist = false; - let m; - for (let s2 of mapout.split("\n")) { - if (parseseglist && (m = re_seglist.exec(s2))) { - let seg = m[1]; - let start = parseInt(m[2], 16); - let size = parseInt(m[4], 16); - let type = ""; - if (seg.startsWith("CODE") || seg == "STARTUP" || seg == "RODATA" || seg.endsWith("ROM")) - type = "rom"; - else if (seg == "ZP" || seg == "DATA" || seg == "BSS" || seg.endsWith("RAM")) - type = "ram"; - segments.push({ name: seg, start, size, type }); - } - if (s2 == "Segment list:") - parseseglist = true; - if (s2 == "") - parseseglist = false; - } - var listings = {}; - for (var fn of step.files) { - if (fn.endsWith(".lst")) { - var lstout = FS.readFile(fn, { encoding: "utf8" }); - lstout = lstout.split("\n\n")[1] || lstout; - putWorkFile(fn, lstout); - let isECS = step.debuginfo?.systems?.Init != null; - if (isECS) { - var asmlines = []; - var srclines = parseCA65Listing(fn, lstout, symbolmap, segments, params, true, listings); - listings[fn] = { - lines: [], - text: lstout - }; - } else { - var asmlines = parseCA65Listing(fn, lstout, symbolmap, segments, params, false); - var srclines = parseCA65Listing("", lstout, symbolmap, segments, params, true); - listings[fn] = { - asmlines: srclines.length ? asmlines : null, - lines: srclines.length ? srclines : asmlines, - text: lstout - }; - } - } - } - return { - output: aout, - listings, - errors, - symbolmap, - segments - }; - } -} -function processIncbin(code) { - let re3 = /^\s*#embed\s+"(.+?)"/gm; - return code.replace(re3, (m, m1) => { - let filename = m1; - let filedata = store.getFileData(filename); - let bytes = convertDataToUint8Array(filedata); - if (!bytes) - throw new Error('#embed: file not found: "' + filename + '"'); - let out = ""; - for (let i = 0; i < bytes.length; i++) { - out += bytes[i].toString() + ","; - } - return out; - }); -} -function compileCC65(step) { - loadNative("cc65"); - var params = step.params; - var re_err1 = /(.*?):(\d+): (.+)/; - var errors = []; - var errline = 0; - function match_fn(s) { - console.log(s); - var matches = re_err1.exec(s); - if (matches) { - errline = parseInt(matches[2]); - errors.push({ - line: errline, - msg: matches[3], - path: matches[1] - }); - } - } - gatherFiles(step, { mainFilePath: "main.c" }); - var destpath = step.prefix + ".s"; - if (staleFiles(step, [destpath])) { - var CC65 = emglobal.cc65({ - instantiateWasm: moduleInstFn("cc65"), - noInitialRun: true, - print: print_fn, - printErr: match_fn - }); - var FS = CC65.FS; - setupFS(FS, "65-" + getRootBasePlatform(step.platform)); - populateFiles(step, FS, { - mainFilePath: step.path, - processFn: (path4, code) => { - if (typeof code === "string") { - code = processIncbin(code); - } - return code; - } - }); - fixParamsWithDefines(step.path, params); - var args = [ - "-I", - "/share/include", - "-I", - ".", - "-D", - "__8BITWORKSHOP__" - ]; - if (params.define) { - params.define.forEach((x) => args.push("-D" + x)); - } - if (step.mainfile) { - args.unshift.apply(args, ["-D", "__MAIN__"]); - } - var customArgs = params.extra_compiler_args || ["-T", "-g", "-Oirs", "-Cl", "-W", "-pointer-sign,-no-effect"]; - args = args.concat(customArgs, args); - args.push(step.path); - execMain(step, CC65, args); - if (errors.length) - return { errors }; - var asmout = FS.readFile(destpath, { encoding: "utf8" }); - putWorkFile(destpath, asmout); - } - return { - nexttool: "ca65", - path: destpath, - args: [destpath], - files: [destpath] - }; -} - -// src/worker/tools/dasm.ts -function parseDASMListing(lstpath, lsttext, listings, errors, unresolved) { - let lineMatch = /\s*(\d+)\s+(\S+)\s+([0-9a-f]+)\s+([?0-9a-f][?0-9a-f ]+)?\s+(.+)?/i; - let equMatch = /\bequ\b/i; - let macroMatch = /\bMAC\s+(\S+)?/i; - let lastline = 0; - let macros = {}; - let lstline = 0; - let lstlist = listings[lstpath]; - for (let line of lsttext.split(re_crlf)) { - lstline++; - let linem = lineMatch.exec(line + " "); - if (linem && linem[1] != null) { - let linenum = parseInt(linem[1]); - let filename = linem[2]; - let offset = parseInt(linem[3], 16); - let insns = linem[4]; - let restline = linem[5]; - if (insns && insns.startsWith("?")) - insns = null; - if (lstlist && lstlist.lines) { - lstlist.lines.push({ - line: lstline, - offset, - insns, - iscode: true - }); - } - let lst = listings[filename]; - if (lst) { - var lines = lst.lines; - let macmatch = macroMatch.exec(restline); - if (macmatch) { - macros[macmatch[1]] = { line: parseInt(linem[1]), file: linem[2].toLowerCase() }; - } else if (insns && restline && !restline.match(equMatch)) { - lines.push({ - line: linenum, - offset, - insns, - iscode: restline[0] != "." - }); - } - lastline = linenum; - } else { - let mac = macros[filename.toLowerCase()]; - if (mac && linenum == 0) { - lines.push({ - line: lastline + 1, - offset, - insns, - iscode: true - }); - } - if (insns && mac) { - let maclst = listings[mac.file]; - if (maclst && maclst.lines) { - maclst.lines.push({ - path: mac.file, - line: mac.line + linenum, - offset, - insns, - iscode: true - }); - } - } else { - if (insns && linem[3] && lastline > 0) { - lines.push({ - line: lastline + 1, - offset, - insns: null - }); - } - } - } - for (let key in unresolved) { - let l = restline || line; - let pos = l.indexOf(key); - if (pos >= 0) { - let cmt = l.indexOf(";"); - if (cmt < 0 || cmt > pos) { - if (new RegExp("\\b" + key + "\\b").exec(l)) { - errors.push({ - path: filename, - line: linenum, - msg: "Unresolved symbol '" + key + "'" - }); - } - } - } - } - } - let errm = re_msvc.exec(line); - if (errm) { - errors.push({ - path: errm[1], - line: parseInt(errm[2]), - msg: errm[4] - }); - } - } -} -function assembleDASM(step) { - load("dasm"); - var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/; - var unresolved = {}; - var errors = []; - var errorMatcher = msvcErrorMatcher(errors); - function match_fn(s2) { - var matches = re_usl.exec(s2); - if (matches) { - var key = matches[1]; - if (key != "NO_ILLEGAL_OPCODES") { - unresolved[matches[1]] = 0; - } - } else if (s2.startsWith("Warning:")) { - errors.push({ line: 0, msg: s2.substr(9) }); - } else if (s2.startsWith("unable ")) { - errors.push({ line: 0, msg: s2 }); - } else if (s2.startsWith("segment: ")) { - errors.push({ line: 0, msg: "Segment overflow: " + s2.substring(9) }); - } else if (s2.toLowerCase().indexOf("error:") >= 0) { - errors.push({ line: 0, msg: s2.trim() }); - } else { - errorMatcher(s2); - } - } - var Module = emglobal.DASM({ - noInitialRun: true, - print: match_fn - }); - var FS = Module.FS; - populateFiles(step, FS, { - mainFilePath: "main.a" - }); - var binpath = step.prefix + ".bin"; - var lstpath = step.prefix + ".lst"; - var sympath = step.prefix + ".sym"; - execMain(step, Module, [ - step.path, - "-f3", - "-l" + lstpath, - "-o" + binpath, - "-s" + sympath - ]); - var alst = FS.readFile(lstpath, { "encoding": "utf8" }); - var listings = {}; - for (let path4 of step.files) { - listings[path4] = { lines: [] }; - } - parseDASMListing(lstpath, alst, listings, errors, unresolved); - if (errors.length) { - return { errors }; - } - var aout, asym; - aout = FS.readFile(binpath); - try { - asym = FS.readFile(sympath, { "encoding": "utf8" }); - } catch (e) { - console.log(e); - errors.push({ line: 0, msg: "No symbol table generated, maybe segment overflow?" }); - return { errors }; - } - putWorkFile(binpath, aout); - putWorkFile(lstpath, alst); - putWorkFile(sympath, asym); - if (!anyTargetChanged(step, [binpath])) - return; - var symbolmap = {}; - for (var s of asym.split("\n")) { - var toks = s.split(/\s+/); - if (toks && toks.length >= 2 && !toks[0].startsWith("-")) { - symbolmap[toks[0]] = parseInt(toks[1], 16); - } - } - if (step["bblines"]) { - let lst = listings[step.path]; - if (lst) { - lst.asmlines = lst.lines; - lst.text = alst; - lst.lines = []; - } - } - return { - output: aout, - listings, - errors, - symbolmap - }; -} -function preprocessBatariBasic(code) { - load("bbpreprocess"); - var bbout = ""; - function addbbout_fn(s) { - bbout += s; - bbout += "\n"; - } - var BBPRE = emglobal.preprocess({ - noInitialRun: true, - print: addbbout_fn, - printErr: print_fn, - noFSInit: true - }); - var FS = BBPRE.FS; - setupStdin(FS, code); - BBPRE.callMain([]); - console.log("preprocess " + code.length + " -> " + bbout.length + " bytes"); - return bbout; -} -function compileBatariBasic(step) { - load("bb2600basic"); - var params = step.params; - var asmout = ""; - function addasmout_fn(s) { - asmout += s; - asmout += "\n"; - } - var re_err1 = /[(](\d+)[)]:?\s*(.+)/; - var errors = []; - var errline = 0; - function match_fn(s) { - console.log(s); - var matches = re_err1.exec(s); - if (matches) { - errline = parseInt(matches[1]); - errors.push({ - line: errline, - msg: matches[2] - }); - } - } - gatherFiles(step, { mainFilePath: "main.bas" }); - var destpath = step.prefix + ".asm"; - if (staleFiles(step, [destpath])) { - var BB = emglobal.bb2600basic({ - noInitialRun: true, - print: addasmout_fn, - printErr: match_fn, - noFSInit: true, - TOTAL_MEMORY: 64 * 1024 * 1024 - }); - var FS = BB.FS; - populateFiles(step, FS); - var code = getWorkFileAsString(step.path); - code = preprocessBatariBasic(code); - setupStdin(FS, code); - setupFS(FS, "2600basic"); - execMain(step, BB, ["-i", "/share", step.path]); - if (errors.length) - return { errors }; - var includesout = FS.readFile("includes.bB", { encoding: "utf8" }); - var redefsout = FS.readFile("2600basic_variable_redefs.h", { encoding: "utf8" }); - var includes = includesout.trim().split("\n"); - var combinedasm = ""; - var splitasm = asmout.split("bB.asm file is split here"); - for (var incfile of includes) { - var inctext; - if (incfile == "bB.asm") - inctext = splitasm[0]; - else if (incfile == "bB2.asm") - inctext = splitasm[1]; - else - inctext = FS.readFile("/share/includes/" + incfile, { encoding: "utf8" }); - console.log(incfile, inctext.length); - combinedasm += "\n\n;;;" + incfile + "\n\n"; - combinedasm += inctext; - } - putWorkFile(destpath, combinedasm); - putWorkFile("2600basic.h", FS.readFile("/share/includes/2600basic.h")); - putWorkFile("2600basic_variable_redefs.h", redefsout); - } - return { - nexttool: "dasm", - path: destpath, - args: [destpath], - files: [destpath, "2600basic.h", "2600basic_variable_redefs.h"], - bblines: true - }; -} - -// src/worker/tools/sdcc.ts -function hexToArray(s, ofs) { - var buf = new ArrayBuffer(s.length / 2); - var arr = new Uint8Array(buf); - for (var i = 0; i < arr.length; i++) { - arr[i] = parseInt(s.slice(i * 2 + ofs, i * 2 + ofs + 2), 16); - } - return arr; -} -function parseIHX(ihx, rom_start, rom_size, errors) { - var output = new Uint8Array(new ArrayBuffer(rom_size)); - var high_size = 0; - for (var s of ihx.split("\n")) { - if (s[0] == ":") { - var arr = hexToArray(s, 1); - var count = arr[0]; - var address = (arr[1] << 8) + arr[2] - rom_start; - var rectype = arr[3]; - if (rectype == 0) { - for (var i = 0; i < count; i++) { - var b = arr[4 + i]; - output[i + address] = b; - } - if (i + address > high_size) - high_size = i + address; - } else if (rectype == 1) { - break; - } else { - console.log(s); - } - } - } - if (high_size > rom_size) { - } - return output; -} -function assembleSDASZ80(step) { - loadNative("sdasz80"); - var objout, lstout, symout; - var errors = []; - gatherFiles(step, { mainFilePath: "main.asm" }); - var objpath = step.prefix + ".rel"; - var lstpath = step.prefix + ".lst"; - if (staleFiles(step, [objpath, lstpath])) { - var match_asm_re1 = / in line (\d+) of (\S+)/; - var match_asm_re2 = / <\w> (.+)/; - var errline = 0; - var errpath = step.path; - var match_asm_fn = (s) => { - var m = match_asm_re1.exec(s); - if (m) { - errline = parseInt(m[1]); - errpath = m[2]; - } else { - m = match_asm_re2.exec(s); - if (m) { - errors.push({ - line: errline, - path: errpath, - msg: m[1] - }); - } - } - }; - var ASZ80 = emglobal.sdasz80({ - instantiateWasm: moduleInstFn("sdasz80"), - noInitialRun: true, - print: match_asm_fn, - printErr: match_asm_fn - }); - var FS = ASZ80.FS; - populateFiles(step, FS); - execMain(step, ASZ80, ["-plosgffwy", step.path]); - if (errors.length) { - return { errors }; - } - objout = FS.readFile(objpath, { encoding: "utf8" }); - lstout = FS.readFile(lstpath, { encoding: "utf8" }); - putWorkFile(objpath, objout); - putWorkFile(lstpath, lstout); - } - return { - linktool: "sdldz80", - files: [objpath, lstpath], - args: [objpath] - }; -} -function linkSDLDZ80(step) { - loadNative("sdldz80"); - var errors = []; - gatherFiles(step); - var binpath = "main.ihx"; - if (staleFiles(step, [binpath])) { - var match_aslink_re = /\?ASlink-(\w+)-(.+)/; - var match_aslink_fn = (s2) => { - var matches = match_aslink_re.exec(s2); - if (matches) { - errors.push({ - line: 0, - msg: matches[2] - }); - } - }; - var params = step.params; - var LDZ80 = emglobal.sdldz80({ - instantiateWasm: moduleInstFn("sdldz80"), - noInitialRun: true, - print: match_aslink_fn, - printErr: match_aslink_fn - }); - var FS = LDZ80.FS; - setupFS(FS, "sdcc"); - populateFiles(step, FS); - populateExtraFiles(step, FS, params.extra_link_files); - if (step.platform.startsWith("coleco")) { - FS.writeFile("crt0.rel", FS.readFile("/share/lib/coleco/crt0.rel", { encoding: "utf8" })); - FS.writeFile("crt0.lst", "\n"); - } - var args = [ - "-mjwxyu", - "-i", - "main.ihx", - "-b", - "_CODE=0x" + params.code_start.toString(16), - "-b", - "_DATA=0x" + params.data_start.toString(16), - "-k", - "/share/lib/z80", - "-l", - "z80" - ]; - if (params.extra_link_args) - args.push.apply(args, params.extra_link_args); - args.push.apply(args, step.args); - execMain(step, LDZ80, args); - var hexout = FS.readFile("main.ihx", { encoding: "utf8" }); - var noiout = FS.readFile("main.noi", { encoding: "utf8" }); - putWorkFile("main.ihx", hexout); - putWorkFile("main.noi", noiout); - if (!anyTargetChanged(step, ["main.ihx", "main.noi"])) - return; - var binout = parseIHX(hexout, params.rom_start !== void 0 ? params.rom_start : params.code_start, params.rom_size, errors); - if (errors.length) { - return { errors }; - } - var listings = {}; - for (var fn of step.files) { - if (fn.endsWith(".lst")) { - var rstout = FS.readFile(fn.replace(".lst", ".rst"), { encoding: "utf8" }); - var asmlines = parseListing(rstout, /^\s*([0-9A-F]{4})\s+([0-9A-F][0-9A-F r]*[0-9A-F])\s+\[([0-9 ]+)\]?\s+(\d+) (.*)/i, 4, 1, 2, 3); - var srclines = parseSourceLines(rstout, /^\s+\d+ ;:(\d+):/i, /^\s*([0-9A-F]{4})/i); - putWorkFile(fn, rstout); - listings[fn] = { - asmlines: srclines.length ? asmlines : null, - lines: srclines.length ? srclines : asmlines, - text: rstout - }; - } - } - var symbolmap = {}; - for (var s of noiout.split("\n")) { - var toks = s.split(" "); - if (toks[0] == "DEF" && !toks[1].startsWith("A$")) { - symbolmap[toks[1]] = parseInt(toks[2], 16); - } - } - var seg_re = /^s__(\w+)$/; - var segments = []; - for (let ident in symbolmap) { - let m = seg_re.exec(ident); - if (m) { - let seg = m[1]; - let segstart = symbolmap[ident]; - let segsize = symbolmap["l__" + seg]; - if (segstart >= 0 && segsize > 0) { - var type = null; - if (["INITIALIZER", "GSINIT", "GSFINAL"].includes(seg)) - type = "rom"; - else if (seg.startsWith("CODE")) - type = "rom"; - else if (["DATA", "INITIALIZED"].includes(seg)) - type = "ram"; - if (type == "rom" || segstart > 0) - segments.push({ name: seg, start: segstart, size: segsize, type }); - } - } - } - return { - output: binout, - listings, - errors, - symbolmap, - segments - }; - } -} -function compileSDCC(step) { - gatherFiles(step, { - mainFilePath: "main.c" - }); - var outpath = step.prefix + ".asm"; - if (staleFiles(step, [outpath])) { - var errors = []; - var params = step.params; - loadNative("sdcc"); - var SDCC = emglobal.sdcc({ - instantiateWasm: moduleInstFn("sdcc"), - noInitialRun: true, - noFSInit: true, - print: print_fn, - printErr: msvcErrorMatcher(errors) - }); - var FS = SDCC.FS; - populateFiles(step, FS); - var code = getWorkFileAsString(step.path); - var preproc = preprocessMCPP(step, "sdcc"); - if (preproc.errors) { - return { errors: preproc.errors }; - } else - code = preproc.code; - setupStdin(FS, code); - setupFS(FS, "sdcc"); - var args = [ - "--vc", - "--std-sdcc99", - "-mz80", - "--c1mode", - "--less-pedantic", - "-o", - outpath - ]; - if (!/^\s*#pragma\s+opt_code/m.exec(code)) { - args.push.apply(args, [ - "--oldralloc", - "--no-peep", - "--nolospre" - ]); - } - if (params.extra_compile_args) { - args.push.apply(args, params.extra_compile_args); - } - execMain(step, SDCC, args); - if (errors.length) { - return { errors }; - } - var asmout = FS.readFile(outpath, { encoding: "utf8" }); - asmout = " .area _HOME\n .area _CODE\n .area _INITIALIZER\n .area _DATA\n .area _INITIALIZED\n .area _BSEG\n .area _BSS\n .area _HEAP\n" + asmout; - putWorkFile(outpath, asmout); - } - return { - nexttool: "sdasz80", - path: outpath, - args: [outpath], - files: [outpath] - }; -} - -// src/worker/assembler.ts -var isError = (o) => o.error !== void 0; -function hex2(v, nd) { - try { - if (!nd) - nd = 2; - if (nd == 8) { - return hex2(v >> 16 & 65535, 4) + hex2(v & 65535, 4); - } - var s = v.toString(16).toUpperCase(); - while (s.length < nd) - s = "0" + s; - return s; - } catch (e) { - return v + ""; - } -} -function stringToData(s) { - var data = []; - for (var i = 0; i < s.length; i++) { - data[i] = s.charCodeAt(i); - } - return data; -} -var Assembler = class { - constructor(spec) { - this.ip = 0; - this.origin = 0; - this.linenum = 0; - this.symbols = {}; - this.errors = []; - this.outwords = []; - this.asmlines = []; - this.fixups = []; - this.width = 8; - this.codelen = 0; - this.aborted = false; - this.spec = spec; - if (spec) { - this.preprocessRules(); - } - } - rule2regex(rule, vars) { - var s = rule.fmt; - if (!s || !(typeof s === "string")) - throw Error('Each rule must have a "fmt" string field'); - if (!rule.bits || !(rule.bits instanceof Array)) - throw Error('Each rule must have a "bits" array field'); - var varlist = []; - rule.prefix = s.split(/\s+/)[0]; - s = s.replace(/\+/g, "\\+"); - s = s.replace(/\*/g, "\\*"); - s = s.replace(/\s+/g, "\\s+"); - s = s.replace(/\[/g, "\\["); - s = s.replace(/\]/g, "\\]"); - s = s.replace(/\(/g, "\\("); - s = s.replace(/\)/g, "\\)"); - s = s.replace(/\./g, "\\."); - s = s.replace(/~\w+/g, (varname) => { - varname = varname.substr(1); - var v = vars[varname]; - varlist.push(varname); - if (!v) - throw Error('Could not find variable definition for "~' + varname + '"'); - else if (v.toks) - return "(\\w+)"; - else - return "([0-9]+|[$][0-9a-f]+|\\w+)"; - }); - try { - rule.re = new RegExp("^" + s + "$", "i"); - } catch (e) { - throw Error('Bad regex for rule "' + rule.fmt + '": /' + s + "/ -- " + e); - } - rule.varlist = varlist; - return rule; - } - preprocessRules() { - if (this.spec.width) { - this.width = this.spec.width || 8; - } - for (var rule of this.spec.rules) { - this.rule2regex(rule, this.spec.vars); - } - } - warning(msg, line) { - this.errors.push({ msg, line: line ? line : this.linenum }); - } - fatal(msg, line) { - this.warning(msg, line); - this.aborted = true; - } - fatalIf(msg, line) { - if (msg) - this.fatal(msg, line); - } - addBytes(result) { - this.asmlines.push({ - line: this.linenum, - offset: this.ip, - nbits: result.nbits - }); - var op = result.opcode; - var nb = result.nbits / this.width; - for (var i = 0; i < nb; i++) { - if (this.width < 32) - this.outwords[this.ip++ - this.origin] = op >> (nb - 1 - i) * this.width & (1 << this.width) - 1; - else - this.outwords[this.ip++ - this.origin] = op; - } - } - addWords(data) { - this.asmlines.push({ - line: this.linenum, - offset: this.ip, - nbits: this.width * data.length - }); - for (var i = 0; i < data.length; i++) { - if (this.width < 32) - this.outwords[this.ip++ - this.origin] = data[i] & (1 << this.width) - 1; - else - this.outwords[this.ip++ - this.origin] = data[i]; - } - } - parseData(toks) { - var data = []; - for (var i = 0; i < toks.length; i++) { - data[i] = this.parseConst(toks[i]); - } - return data; - } - alignIP(align) { - if (align < 1 || align > this.codelen) - this.fatal("Invalid alignment value"); - else - this.ip = Math.floor((this.ip + align - 1) / align) * align; - } - parseConst(s, nbits) { - if (s && s[0] == "$") - return parseInt(s.substr(1), 16); - else - return parseInt(s); - } - swapEndian(x, nbits) { - var y = 0; - while (nbits > 0) { - var n = Math.min(nbits, this.width); - var mask = (1 << n) - 1; - y <<= n; - y |= x & mask; - x >>>= n; - nbits -= n; - } - return y; - } - buildInstruction(rule, m) { - var opcode = 0; - var oplen = 0; - for (let b of rule.bits) { - let n, x; - if (typeof b === "string") { - n = b.length; - x = parseInt(b, 2); - } else { - var index = typeof b === "number" ? b : b.a; - var id = m[index + 1]; - var v = this.spec.vars[rule.varlist[index]]; - if (!v) { - return { error: `Could not find matching identifier for '${m[0]}' index ${index}` }; - } - n = v.bits; - var shift = 0; - if (typeof b !== "number") { - n = b.n; - shift = b.b; - } - if (v.toks) { - x = v.toks.indexOf(id); - if (x < 0) - return { error: "Can't use '" + id + "' here, only one of: " + v.toks.join(", ") }; - } else { - x = this.parseConst(id, n); - if (isNaN(x)) { - this.fixups.push({ - sym: id, - ofs: this.ip, - size: v.bits, - line: this.linenum, - dstlen: n, - dstofs: oplen, - srcofs: shift, - endian: v.endian, - iprel: !!v.iprel, - ipofs: v.ipofs + 0, - ipmul: v.ipmul || 1 - }); - x = 0; - } else { - var mask = (1 << v.bits) - 1; - if ((x & mask) != x) - return { error: "Value " + x + " does not fit in " + v.bits + " bits" }; - } - } - if (v.endian == "little") - x = this.swapEndian(x, v.bits); - if (typeof b !== "number") { - x = x >>> shift & (1 << b.n) - 1; - } - } - opcode = opcode << n | x; - oplen += n; - } - if (oplen == 0) - this.warning("Opcode had zero length"); - else if (oplen > 32) - this.warning("Opcodes > 32 bits not supported"); - else if (oplen % this.width != 0) - this.warning("Opcode was not word-aligned (" + oplen + " bits)"); - return { opcode, nbits: oplen }; - } - loadArch(arch) { - if (this.loadJSON) { - var json = this.loadJSON(arch + ".json"); - if (json && json.vars && json.rules) { - this.spec = json; - this.preprocessRules(); - } else { - return "Could not load arch file '" + arch + ".json'"; - } - } - } - parseDirective(tokens) { - var cmd = tokens[0].toLowerCase(); - if (cmd == ".define") - this.symbols[tokens[1].toLowerCase()] = { value: tokens[2] }; - else if (cmd == ".org") - this.ip = this.origin = parseInt(tokens[1]); - else if (cmd == ".len") - this.codelen = parseInt(tokens[1]); - else if (cmd == ".width") - this.width = parseInt(tokens[1]); - else if (cmd == ".arch") - this.fatalIf(this.loadArch(tokens[1])); - else if (cmd == ".include") - this.fatalIf(this.loadInclude(tokens[1])); - else if (cmd == ".module") - this.fatalIf(this.loadModule(tokens[1])); - else if (cmd == ".data") - this.addWords(this.parseData(tokens.slice(1))); - else if (cmd == ".string") - this.addWords(stringToData(tokens.slice(1).join(" "))); - else if (cmd == ".align") - this.alignIP(this.parseConst(tokens[1])); - else - this.warning("Unrecognized directive: " + tokens); - } - assemble(line) { - this.linenum++; - line = line.replace(/[;].*/g, "").trim(); - if (line[0] == ".") { - var tokens = line.split(/\s+/); - this.parseDirective(tokens); - return; - } - line = line.toLowerCase(); - line = line.replace(/(\w+):/, (_label, label) => { - this.symbols[label] = { value: this.ip }; - return ""; - }); - line = line.trim(); - if (line == "") - return; - if (!this.spec) { - this.fatal("Need to load .arch first"); - return; - } - var lastError; - for (var rule of this.spec.rules) { - var m = rule.re.exec(line); - if (m) { - var result = this.buildInstruction(rule, m); - if (!isError(result)) { - this.addBytes(result); - return result; - } else { - lastError = result.error; - } - } - } - this.warning(lastError ? lastError : "Could not decode instruction: " + line); - } - applyFixup(fix, sym) { - var ofs = fix.ofs + Math.floor(fix.dstofs / this.width); - var mask = (1 << fix.size) - 1; - var value = this.parseConst(sym.value + "", fix.dstlen); - if (fix.iprel) - value = (value - fix.ofs) * fix.ipmul - fix.ipofs; - if (fix.srcofs == 0 && (value > mask || value < -mask)) - this.warning("Symbol " + fix.sym + " (" + value + ") does not fit in " + fix.dstlen + " bits", fix.line); - if (fix.srcofs > 0) - value >>>= fix.srcofs; - value &= (1 << fix.dstlen) - 1; - if (this.width == 32) { - var shift = 32 - fix.dstofs - fix.dstlen; - value <<= shift; - } - if (fix.size <= this.width) { - this.outwords[ofs - this.origin] ^= value; - } else { - if (fix.endian == "big") - value = this.swapEndian(value, fix.size); - while (value) { - if (value & this.outwords[ofs - this.origin]) { - this.warning("Instruction bits overlapped: " + hex2(this.outwords[ofs - this.origin], 8), hex2(value, 8)); - } else { - this.outwords[ofs - this.origin] ^= value & (1 << this.width) - 1; - } - value >>>= this.width; - ofs++; - } - } - } - finish() { - for (var i = 0; i < this.fixups.length; i++) { - var fix = this.fixups[i]; - var sym = this.symbols[fix.sym]; - if (sym) { - this.applyFixup(fix, sym); - } else { - this.warning("Symbol '" + fix.sym + "' not found"); - } - } - for (var i = 0; i < this.asmlines.length; i++) { - var al = this.asmlines[i]; - al.insns = ""; - for (var j = 0; j < al.nbits / this.width; j++) { - var word = this.outwords[al.offset + j - this.origin]; - if (j > 0) - al.insns += " "; - al.insns += hex2(word, this.width / 4); - } - } - while (this.outwords.length < this.codelen) { - this.outwords.push(0); - } - this.fixups = []; - return this.state(); - } - assembleFile(text) { - var lines = text.split(/\n/g); - for (var i = 0; i < lines.length && !this.aborted; i++) { - try { - this.assemble(lines[i]); - } catch (e) { - console.log(e); - this.fatal("Exception during assembly: " + e); - } - } - return this.finish(); - } - state() { - return { - ip: this.ip, - line: this.linenum, - origin: this.origin, - codelen: this.codelen, - intermediate: {}, - output: this.outwords, - lines: this.asmlines, - errors: this.errors, - fixups: this.fixups - }; - } -}; - -// src/common/hdl/hdltypes.ts -function isVarDecl(arg) { - return typeof arg.isParam !== "undefined"; -} -function isConstExpr(arg) { - return typeof arg.cvalue === "number"; -} - -// src/common/hdl/vxmlparser.ts -var CompileError2 = class extends Error { - constructor($loc, msg) { - super(msg); - this.$loc = $loc; - Object.setPrototypeOf(this, CompileError2.prototype); - } -}; -var VerilogXMLParser = class { - constructor() { - this.files = {}; - this.dtypes = {}; - this.modules = {}; - this.hierarchies = {}; - this.cur_deferred = []; - this.dtypes["QData"] = { left: 63, right: 0, signed: false }; - this.dtypes["IData"] = { left: 31, right: 0, signed: false }; - this.dtypes["SData"] = { left: 15, right: 0, signed: false }; - this.dtypes["CData"] = { left: 7, right: 0, signed: false }; - this.dtypes["byte"] = { left: 7, right: 0, signed: true }; - this.dtypes["shortint"] = { left: 15, right: 0, signed: true }; - this.dtypes["int"] = { left: 31, right: 0, signed: true }; - this.dtypes["integer"] = { left: 31, right: 0, signed: true }; - this.dtypes["longint"] = { left: 63, right: 0, signed: true }; - this.dtypes["time"] = { left: 63, right: 0, signed: false }; - } - defer(fn) { - this.cur_deferred.unshift(fn); - } - defer2(fn) { - this.cur_deferred.push(fn); - } - run_deferred() { - this.cur_deferred.forEach((fn) => fn()); - this.cur_deferred = []; - } - name2js(s) { - if (s == null) - throw new CompileError2(this.cur_loc, `no name`); - return s.replace(/[^a-z0-9_]/gi, "$"); - } - findChildren(node, type, required) { - var arr = node.children.filter((n) => n.type == type); - if (arr.length == 0 && required) - throw new CompileError2(this.cur_loc, `no child of type ${type}`); - return arr; - } - parseSourceLocation(node) { - var loc = node.attrs["loc"]; - if (loc) { - if (loc == this.cur_loc_str) { - return this.cur_loc; - } else { - var [fileid, line, col, end_line, end_col] = loc.split(","); - var $loc = { - hdlfile: this.files[fileid], - path: this.files[fileid].filename, - line: parseInt(line), - start: parseInt(col) - 1, - end_line: parseInt(end_line), - end: parseInt(end_col) - 1 - }; - this.cur_loc = $loc; - this.cur_loc_str = loc; - return $loc; - } - } else { - return null; - } - } - open_module(node) { - var module2 = { - $loc: this.parseSourceLocation(node), - name: node.attrs["name"], - origName: node.attrs["origName"], - blocks: [], - instances: [], - vardefs: {} - }; - if (this.cur_module) - throw new CompileError2(this.cur_loc, `nested modules not supported`); - this.cur_module = module2; - return module2; - } - deferDataType(node, def) { - var dtype_id = node.attrs["dtype_id"]; - if (dtype_id != null) { - this.defer(() => { - def.dtype = this.dtypes[dtype_id]; - if (!def.dtype) { - throw new CompileError2(this.cur_loc, `Unknown data type ${dtype_id} for ${node.type}`); - } - }); - } - } - parseConstValue(s) { - const re_const = /(\d+)'([s]?)h([0-9a-f]+)/i; - var m = re_const.exec(s); - if (m) { - var numstr = m[3]; - if (numstr.length <= 8) - return parseInt(numstr, 16); - else - return BigInt("0x" + numstr); - } else { - throw new CompileError2(this.cur_loc, `could not parse constant "${s}"`); - } - } - resolveVar(s, mod) { - var def = mod.vardefs[s]; - if (def == null) - throw new CompileError2(this.cur_loc, `could not resolve variable "${s}"`); - return def; - } - resolveModule(s) { - var mod = this.modules[s]; - if (mod == null) - throw new CompileError2(this.cur_loc, `could not resolve module "${s}"`); - return mod; - } - visit_verilator_xml(node) { - } - visit_package(node) { - } - visit_module(node) { - this.findChildren(node, "var", false).forEach((n) => { - if (isVarDecl(n.obj)) { - this.cur_module.vardefs[n.obj.name] = n.obj; - } - }); - this.modules[this.cur_module.name] = this.cur_module; - this.cur_module = null; - } - visit_var(node) { - var name = node.attrs["name"]; - name = this.name2js(name); - var vardef = { - $loc: this.parseSourceLocation(node), - name, - origName: node.attrs["origName"], - isInput: node.attrs["dir"] == "input", - isOutput: node.attrs["dir"] == "output", - isParam: node.attrs["param"] == "true", - dtype: null - }; - this.deferDataType(node, vardef); - var const_nodes = this.findChildren(node, "const", false); - if (const_nodes.length) { - vardef.constValue = const_nodes[0].obj; - } - var init_nodes = this.findChildren(node, "initarray", false); - if (init_nodes.length) { - vardef.initValue = init_nodes[0].obj; - } - return vardef; - } - visit_const(node) { - var name = node.attrs["name"]; - var cvalue = this.parseConstValue(name); - var constdef = { - $loc: this.parseSourceLocation(node), - dtype: null, - cvalue: typeof cvalue === "number" ? cvalue : null, - bigvalue: typeof cvalue === "bigint" ? cvalue : null - }; - this.deferDataType(node, constdef); - return constdef; - } - visit_varref(node) { - var name = node.attrs["name"]; - name = this.name2js(name); - var varref = { - $loc: this.parseSourceLocation(node), - dtype: null, - refname: name - }; - this.deferDataType(node, varref); - var mod = this.cur_module; - return varref; - } - visit_sentree(node) { - } - visit_always(node) { - var sentree; - var expr; - if (node.children.length == 2) { - sentree = node.children[0].obj; - expr = node.children[1].obj; - } else { - sentree = null; - expr = node.children[0].obj; - } - var always = { - $loc: this.parseSourceLocation(node), - blocktype: node.type, - name: null, - senlist: sentree, - exprs: [expr] - }; - this.cur_module.blocks.push(always); - return always; - } - visit_begin(node) { - var exprs = []; - node.children.forEach((n) => exprs.push(n.obj)); - return { - $loc: this.parseSourceLocation(node), - blocktype: node.type, - name: node.attrs["name"], - exprs - }; - } - visit_initarray(node) { - return this.visit_begin(node); - } - visit_inititem(node) { - this.expectChildren(node, 1, 1); - return { - index: parseInt(node.attrs["index"]), - expr: node.children[0].obj - }; - } - visit_cfunc(node) { - if (this.cur_module == null) { - return; - } - var block = this.visit_begin(node); - block.exprs = []; - node.children.forEach((n) => block.exprs.push(n.obj)); - this.cur_module.blocks.push(block); - return block; - } - visit_cuse(node) { - } - visit_instance(node) { - var instance = { - $loc: this.parseSourceLocation(node), - name: node.attrs["name"], - origName: node.attrs["origName"], - ports: [], - module: null - }; - node.children.forEach((child) => { - instance.ports.push(child.obj); - }); - this.cur_module.instances.push(instance); - this.defer(() => { - instance.module = this.resolveModule(node.attrs["defName"]); - }); - return instance; - } - visit_iface(node) { - throw new CompileError2(this.cur_loc, `interfaces not supported`); - } - visit_intfref(node) { - throw new CompileError2(this.cur_loc, `interfaces not supported`); - } - visit_port(node) { - this.expectChildren(node, 1, 1); - var varref = { - $loc: this.parseSourceLocation(node), - name: node.attrs["name"], - expr: node.children[0].obj - }; - return varref; - } - visit_netlist(node) { - } - visit_files(node) { - } - visit_module_files(node) { - node.children.forEach((n) => { - if (n.obj) { - var file = this.files[n.obj.id]; - if (file) - file.isModule = true; - } - }); - } - visit_file(node) { - return this.visit_file_or_module(node, false); - } - visit_scope(node) { - } - visit_topscope(node) { - } - visit_file_or_module(node, isModule) { - var file = { - id: node.attrs["id"], - filename: node.attrs["filename"], - isModule - }; - this.files[file.id] = file; - return file; - } - visit_cells(node) { - this.expectChildren(node, 1, 9999); - var hier = node.children[0].obj; - if (hier != null) { - var hiername = hier.name; - this.hierarchies[hiername] = hier; - } - } - visit_cell(node) { - var hier = { - $loc: this.parseSourceLocation(node), - name: node.attrs["name"], - module: null, - parent: null, - children: node.children.map((n) => n.obj) - }; - if (node.children.length > 0) - throw new CompileError2(this.cur_loc, `multiple non-flattened modules not yet supported`); - node.children.forEach((n) => n.obj.parent = hier); - this.defer(() => { - hier.module = this.resolveModule(node.attrs["submodname"]); - }); - return hier; - } - visit_basicdtype(node) { - let id = node.attrs["id"]; - var dtype; - var dtypename = node.attrs["name"]; - switch (dtypename) { - case "logic": - case "integer": - case "bit": - let dlogic = { - $loc: this.parseSourceLocation(node), - left: parseInt(node.attrs["left"] || "0"), - right: parseInt(node.attrs["right"] || "0"), - signed: node.attrs["signed"] == "true" - }; - dtype = dlogic; - break; - case "string": - let dstring = { - $loc: this.parseSourceLocation(node), - jstype: "string" - }; - dtype = dstring; - break; - default: - dtype = this.dtypes[dtypename]; - if (dtype == null) { - throw new CompileError2(this.cur_loc, `unknown data type ${dtypename}`); - } - } - this.dtypes[id] = dtype; - return dtype; - } - visit_refdtype(node) { - } - visit_enumdtype(node) { - } - visit_enumitem(node) { - } - visit_packarraydtype(node) { - return this.visit_unpackarraydtype(node); - } - visit_memberdtype(node) { - throw new CompileError2(null, `structs not supported`); - } - visit_constdtype(node) { - } - visit_paramtypedtype(node) { - } - visit_unpackarraydtype(node) { - let id = node.attrs["id"]; - let sub_dtype_id = node.attrs["sub_dtype_id"]; - let range = node.children[0].obj; - if (isConstExpr(range.left) && isConstExpr(range.right)) { - var dtype = { - $loc: this.parseSourceLocation(node), - subtype: null, - low: range.left, - high: range.right - }; - this.dtypes[id] = dtype; - this.defer(() => { - dtype.subtype = this.dtypes[sub_dtype_id]; - if (!dtype.subtype) - throw new CompileError2(this.cur_loc, `Unknown data type ${sub_dtype_id} for array`); - }); - return dtype; - } else { - throw new CompileError2(this.cur_loc, `could not parse constant exprs in array`); - } - } - visit_senitem(node) { - var edgeType = node.attrs["edgeType"]; - if (edgeType != "POS" && edgeType != "NEG") - throw new CompileError2(this.cur_loc, "POS/NEG required"); - return { - $loc: this.parseSourceLocation(node), - edgeType, - expr: node.obj - }; - } - visit_text(node) { - } - visit_cstmt(node) { - } - visit_cfile(node) { - } - visit_typetable(node) { - } - visit_constpool(node) { - } - visit_comment(node) { - } - expectChildren(node, low, high) { - if (node.children.length < low || node.children.length > high) - throw new CompileError2(this.cur_loc, `expected between ${low} and ${high} children`); - } - __visit_unop(node) { - this.expectChildren(node, 1, 1); - var expr = { - $loc: this.parseSourceLocation(node), - op: node.type, - dtype: null, - left: node.children[0].obj - }; - this.deferDataType(node, expr); - return expr; - } - visit_extend(node) { - var unop = this.__visit_unop(node); - unop.width = parseInt(node.attrs["width"]); - unop.widthminv = parseInt(node.attrs["widthminv"]); - if (unop.width != 32) - throw new CompileError2(this.cur_loc, `extends width ${unop.width} != 32`); - return unop; - } - visit_extends(node) { - return this.visit_extend(node); - } - __visit_binop(node) { - this.expectChildren(node, 2, 2); - var expr = { - $loc: this.parseSourceLocation(node), - op: node.type, - dtype: null, - left: node.children[0].obj, - right: node.children[1].obj - }; - this.deferDataType(node, expr); - return expr; - } - visit_if(node) { - this.expectChildren(node, 2, 3); - var expr = { - $loc: this.parseSourceLocation(node), - op: "if", - dtype: null, - cond: node.children[0].obj, - left: node.children[1].obj, - right: node.children[2] && node.children[2].obj - }; - return expr; - } - visit_while(node) { - this.expectChildren(node, 2, 4); - var expr = { - $loc: this.parseSourceLocation(node), - op: "while", - dtype: null, - precond: node.children[0].obj, - loopcond: node.children[1].obj, - body: node.children[2] && node.children[2].obj, - inc: node.children[3] && node.children[3].obj - }; - return expr; - } - __visit_triop(node) { - this.expectChildren(node, 3, 3); - var expr = { - $loc: this.parseSourceLocation(node), - op: node.type, - dtype: null, - cond: node.children[0].obj, - left: node.children[1].obj, - right: node.children[2].obj - }; - this.deferDataType(node, expr); - return expr; - } - __visit_func(node) { - var expr = { - $loc: this.parseSourceLocation(node), - dtype: null, - funcname: node.attrs["func"] || "$" + node.type, - args: node.children.map((n) => n.obj) - }; - this.deferDataType(node, expr); - return expr; - } - visit_not(node) { - return this.__visit_unop(node); - } - visit_negate(node) { - return this.__visit_unop(node); - } - visit_redand(node) { - return this.__visit_unop(node); - } - visit_redor(node) { - return this.__visit_unop(node); - } - visit_redxor(node) { - return this.__visit_unop(node); - } - visit_initial(node) { - return this.__visit_unop(node); - } - visit_ccast(node) { - return this.__visit_unop(node); - } - visit_creset(node) { - return this.__visit_unop(node); - } - visit_creturn(node) { - return this.__visit_unop(node); - } - visit_contassign(node) { - return this.__visit_binop(node); - } - visit_assigndly(node) { - return this.__visit_binop(node); - } - visit_assignpre(node) { - return this.__visit_binop(node); - } - visit_assignpost(node) { - return this.__visit_binop(node); - } - visit_assign(node) { - return this.__visit_binop(node); - } - visit_arraysel(node) { - return this.__visit_binop(node); - } - visit_wordsel(node) { - return this.__visit_binop(node); - } - visit_eq(node) { - return this.__visit_binop(node); - } - visit_neq(node) { - return this.__visit_binop(node); - } - visit_lte(node) { - return this.__visit_binop(node); - } - visit_gte(node) { - return this.__visit_binop(node); - } - visit_lt(node) { - return this.__visit_binop(node); - } - visit_gt(node) { - return this.__visit_binop(node); - } - visit_and(node) { - return this.__visit_binop(node); - } - visit_or(node) { - return this.__visit_binop(node); - } - visit_xor(node) { - return this.__visit_binop(node); - } - visit_add(node) { - return this.__visit_binop(node); - } - visit_sub(node) { - return this.__visit_binop(node); - } - visit_concat(node) { - return this.__visit_binop(node); - } - visit_shiftl(node) { - return this.__visit_binop(node); - } - visit_shiftr(node) { - return this.__visit_binop(node); - } - visit_shiftrs(node) { - return this.__visit_binop(node); - } - visit_mul(node) { - return this.__visit_binop(node); - } - visit_div(node) { - return this.__visit_binop(node); - } - visit_moddiv(node) { - return this.__visit_binop(node); - } - visit_muls(node) { - return this.__visit_binop(node); - } - visit_divs(node) { - return this.__visit_binop(node); - } - visit_moddivs(node) { - return this.__visit_binop(node); - } - visit_gts(node) { - return this.__visit_binop(node); - } - visit_lts(node) { - return this.__visit_binop(node); - } - visit_gtes(node) { - return this.__visit_binop(node); - } - visit_ltes(node) { - return this.__visit_binop(node); - } - visit_range(node) { - return this.__visit_binop(node); - } - visit_cond(node) { - return this.__visit_triop(node); - } - visit_condbound(node) { - return this.__visit_triop(node); - } - visit_sel(node) { - return this.__visit_triop(node); - } - visit_changedet(node) { - if (node.children.length == 0) - return null; - else - return this.__visit_binop(node); - } - visit_ccall(node) { - return this.__visit_func(node); - } - visit_finish(node) { - return this.__visit_func(node); - } - visit_stop(node) { - return this.__visit_func(node); - } - visit_rand(node) { - return this.__visit_func(node); - } - visit_time(node) { - return this.__visit_func(node); - } - visit_display(node) { - return null; - } - visit_sformatf(node) { - return null; - } - visit_scopename(node) { - return null; - } - visit_readmem(node) { - return this.__visit_func(node); - } - xml_open(node) { - this.cur_node = node; - var method = this[`open_${node.type}`]; - if (method) { - return method.bind(this)(node); - } - } - xml_close(node) { - this.cur_node = node; - var method = this[`visit_${node.type}`]; - if (method) { - return method.bind(this)(node); - } else { - throw new CompileError2(this.cur_loc, `no visitor for ${node.type}`); - } - } - parse(xmls) { - parseXMLPoorly(xmls, this.xml_open.bind(this), this.xml_close.bind(this)); - this.cur_node = null; - this.run_deferred(); - } -}; - -// src/worker/tools/verilog.ts -function detectModuleName(code) { - var m = /^\s*module\s+(\w+_top)\b/m.exec(code) || /^\s*module\s+(top|t)\b/m.exec(code) || /^\s*module\s+(\w+)\b/m.exec(code); - return m ? m[1] : null; -} -function detectTopModuleName(code) { - var topmod = detectModuleName(code) || "top"; - var m = /^\s*module\s+(\w+?_top)/m.exec(code); - if (m && m[1]) - topmod = m[1]; - return topmod; -} -var jsasm_module_top; -var jsasm_module_output; -var jsasm_module_key; -function compileJSASM(asmcode, platform, options, is_inline) { - var asm = new Assembler(null); - var includes = []; - asm.loadJSON = (filename) => { - var jsontext = getWorkFileAsString(filename); - if (!jsontext) - throw Error("could not load " + filename); - return JSON.parse(jsontext); - }; - asm.loadInclude = (filename) => { - if (!filename.startsWith('"') || !filename.endsWith('"')) - return 'Expected filename in "double quotes"'; - filename = filename.substr(1, filename.length - 2); - includes.push(filename); - }; - var loaded_module = false; - asm.loadModule = (top_module) => { - loaded_module = true; - var key = top_module + "/" + includes; - if (jsasm_module_key != key) { - jsasm_module_key = key; - jsasm_module_output = null; - } - jsasm_module_top = top_module; - var main_filename = includes[includes.length - 1]; - var voutput = compileVerilator({ platform, files: includes, path: main_filename, tool: "verilator" }); - if (voutput) - jsasm_module_output = voutput; - return null; - }; - var result = asm.assembleFile(asmcode); - if (loaded_module && jsasm_module_output) { - if (jsasm_module_output.errors && jsasm_module_output.errors.length) - return jsasm_module_output; - var asmout = result.output; - result.output = jsasm_module_output.output; - result.output.program_rom = asmout; - result.output.program_rom_variable = jsasm_module_top + "$program_rom"; - result.listings = {}; - result.listings[options.path] = { lines: result.lines }; - return result; - } else { - return result; - } -} -function compileJSASMStep(step) { - gatherFiles(step); - var code = getWorkFileAsString(step.path); - var platform = step.platform || "verilog"; - return compileJSASM(code, platform, step, false); -} -function compileInlineASM(code, platform, options, errors, asmlines) { - code = code.replace(/__asm\b([\s\S]+?)\b__endasm\b/g, function(s, asmcode, index) { - var firstline = code.substr(0, index).match(/\n/g).length; - var asmout = compileJSASM(asmcode, platform, options, true); - if (asmout.errors && asmout.errors.length) { - for (var i = 0; i < asmout.errors.length; i++) { - asmout.errors[i].line += firstline; - errors.push(asmout.errors[i]); - } - return ""; - } else if (asmout.output) { - let s2 = ""; - var out = asmout.output; - for (var i = 0; i < out.length; i++) { - if (i > 0) { - s2 += ","; - if ((i & 255) == 0) - s2 += "\n"; - } - s2 += 0 | out[i]; - } - if (asmlines) { - var al = asmout.lines; - for (var i = 0; i < al.length; i++) { - al[i].line += firstline; - asmlines.push(al[i]); - } - } - return s2; - } - }); - return code; -} -function compileVerilator(step) { - loadNative("verilator_bin"); - var platform = step.platform || "verilog"; - var errors = []; - gatherFiles(step); - if (staleFiles(step, [xmlPath])) { - var match_fn = makeErrorMatcher(errors, /%(.+?): (.+?):(\d+)?[:]?\s*(.+)/i, 3, 4, step.path, 2); - var verilator_mod = emglobal.verilator_bin({ - instantiateWasm: moduleInstFn("verilator_bin"), - noInitialRun: true, - noExitRuntime: true, - print: print_fn, - printErr: match_fn, - wasmMemory: getWASMMemory() - }); - var code = getWorkFileAsString(step.path); - var topmod = detectTopModuleName(code); - var FS = verilator_mod.FS; - var listings = {}; - populateFiles(step, FS, { - mainFilePath: step.path, - processFn: (path4, code2) => { - if (typeof code2 === "string") { - let asmlines = []; - code2 = compileInlineASM(code2, platform, step, errors, asmlines); - if (asmlines.length) { - listings[path4] = { lines: asmlines }; - } - } - return code2; - } - }); - starttime(); - var xmlPath = `obj_dir/V${topmod}.xml`; - try { - var args = [ - "--cc", - "-O3", - "-DEXT_INLINE_ASM", - "-DTOPMOD__" + topmod, - "-D__8BITWORKSHOP__", - "-Wall", - "-Wno-DECLFILENAME", - "-Wno-UNUSED", - "-Wno-EOFNEWLINE", - "-Wno-PROCASSWIRE", - "--x-assign", - "fast", - "--noassert", - "--pins-sc-biguint", - "--debug-check", - "--top-module", - topmod, - step.path - ]; - execMain(step, verilator_mod, args); - } catch (e) { - console.log(e); - errors.push({ line: 0, msg: "Compiler internal error: " + e }); - } - endtime("compile"); - errors = errors.filter(function(e) { - return !/Exiting due to \d+/.exec(e.msg); - }, errors); - errors = errors.filter(function(e) { - return !/Use ["][/][*]/.exec(e.msg); - }, errors); - if (errors.length) { - return { errors }; - } - starttime(); - var xmlParser = new VerilogXMLParser(); - try { - var xmlContent = FS.readFile(xmlPath, { encoding: "utf8" }); - var xmlScrubbed = xmlContent.replace(/ fl=".+?" loc=".+?"/g, ""); - putWorkFile(xmlPath, xmlScrubbed); - if (!anyTargetChanged(step, [xmlPath])) - return; - xmlParser.parse(xmlContent); - } catch (e) { - console.log(e, e.stack); - if (e.$loc != null) { - let $loc = e.$loc; - errors.push({ msg: "" + e, path: $loc.path, line: $loc.line }); - } else { - errors.push({ line: 0, msg: "" + e }); - } - return { errors, listings }; - } finally { - endtime("parse"); - } - return { - output: xmlParser, - errors, - listings - }; - } -} -function compileYosys(step) { - loadNative("yosys"); - var code = step.code; - var errors = []; - var match_fn = makeErrorMatcher(errors, /ERROR: (.+?) in line (.+?[.]v):(\d+)[: ]+(.+)/i, 3, 4, step.path); - starttime(); - var yosys_mod = emglobal.yosys({ - instantiateWasm: moduleInstFn("yosys"), - noInitialRun: true, - print: print_fn, - printErr: match_fn - }); - endtime("create module"); - var topmod = detectTopModuleName(code); - var FS = yosys_mod.FS; - FS.writeFile(topmod + ".v", code); - starttime(); - try { - execMain(step, yosys_mod, ["-q", "-o", topmod + ".json", "-S", topmod + ".v"]); - } catch (e) { - console.log(e); - endtime("compile"); - return { errors }; - } - endtime("compile"); - if (errors.length) - return { errors }; - try { - var json_file = FS.readFile(topmod + ".json", { encoding: "utf8" }); - var json = JSON.parse(json_file); - console.log(json); - return { output: json, errors }; - } catch (e) { - console.log(e); - return { errors }; - } -} -function compileSilice(step) { - loadNative("silice"); - var params = step.params; - gatherFiles(step, { mainFilePath: "main.ice" }); - var destpath = step.prefix + ".v"; - var errors = []; - var errfile; - var errline; - if (staleFiles(step, [destpath])) { - var match_fn = (s) => { - s = s.replaceAll(/\033\[\d+\w/g, ""); - var mf = /file:\s*(\w+)/.exec(s); - var ml = /line:\s+(\d+)/.exec(s); - var preproc = /\[preprocessor\] (\d+)\] (.+)/.exec(s); - if (mf) - errfile = mf[1]; - else if (ml) - errline = parseInt(ml[1]); - else if (preproc) { - errors.push({ path: step.path, line: parseInt(preproc[1]), msg: preproc[2] }); - } else if (errfile && errline && s.length > 1) { - if (s.length > 2) { - errors.push({ path: errfile + ".ice", line: errline, msg: s }); - } else { - errfile = null; - errline = null; - } - } else - console.log(s); - }; - var silice = emglobal.silice({ - instantiateWasm: moduleInstFn("silice"), - noInitialRun: true, - print: match_fn, - printErr: match_fn - }); - var FS = silice.FS; - setupFS(FS, "Silice"); - populateFiles(step, FS); - populateExtraFiles(step, FS, params.extra_compile_files); - const FWDIR = "/share/frameworks"; - var args = [ - "-D", - "NTSC=1", - "--frameworks_dir", - FWDIR, - "-f", - `/8bitworkshop.v`, - "-o", - destpath, - step.path - ]; - execMain(step, silice, args); - if (errors.length) - return { errors }; - var vout = FS.readFile(destpath, { encoding: "utf8" }); - putWorkFile(destpath, vout); - } - return { - nexttool: "verilator", - path: destpath, - args: [destpath], - files: [destpath] - }; -} - -// src/worker/tools/m6809.ts -function assembleXASM6809(step) { - load("xasm6809"); - var alst = ""; - var lasterror = null; - var errors = []; - function match_fn(s) { - alst += s; - alst += "\n"; - if (lasterror) { - var line = parseInt(s.slice(0, 5)) || 0; - errors.push({ - line, - msg: lasterror - }); - lasterror = null; - } else if (s.startsWith("***** ")) { - lasterror = s.slice(6); - } - } - var Module = emglobal.xasm6809({ - noInitialRun: true, - print: match_fn, - printErr: print_fn - }); - var FS = Module.FS; - populateFiles(step, FS, { - mainFilePath: "main.asm" - }); - var binpath = step.prefix + ".bin"; - var lstpath = step.prefix + ".lst"; - execMain(step, Module, ["-c", "-l", "-s", "-y", "-o=" + binpath, step.path]); - if (errors.length) - return { errors }; - var aout = FS.readFile(binpath, { encoding: "binary" }); - if (aout.length == 0) { - errors.push({ line: 0, msg: "Empty output file" }); - return { errors }; - } - putWorkFile(binpath, aout); - putWorkFile(lstpath, alst); - var symbolmap = {}; - var asmlines = parseListing(alst, /^\s*([0-9]+) .+ ([0-9A-F]+)\s+\[([0-9 ]+)\]\s+([0-9A-F]+) (.*)/i, 1, 2, 4, 3); - var listings = {}; - listings[step.prefix + ".lst"] = { lines: asmlines, text: alst }; - return { - output: aout, - listings, - errors, - symbolmap - }; -} -function compileCMOC(step) { - loadNative("cmoc"); - var params = step.params; - var re_err1 = /^[/]*([^:]*):(\d+): (.+)$/; - var errors = []; - var errline = 0; - function match_fn(s) { - var matches = re_err1.exec(s); - if (matches) { - errors.push({ - line: parseInt(matches[2]), - msg: matches[3], - path: matches[1] || step.path - }); - } else { - console.log(s); - } - } - gatherFiles(step, { mainFilePath: "main.c" }); - var destpath = step.prefix + ".s"; - if (staleFiles(step, [destpath])) { - var args = [ - "-S", - "-Werror", - "-V", - "-I/share/include", - "-I.", - step.path - ]; - var CMOC = emglobal.cmoc({ - instantiateWasm: moduleInstFn("cmoc"), - noInitialRun: true, - print: match_fn, - printErr: match_fn - }); - var code = getWorkFileAsString(step.path); - var preproc = preprocessMCPP(step, null); - if (preproc.errors) { - return { errors: preproc.errors }; - } else - code = preproc.code; - var FS = CMOC.FS; - populateFiles(step, FS); - FS.writeFile(step.path, code); - fixParamsWithDefines(step.path, params); - if (params.extra_compile_args) { - args.unshift.apply(args, params.extra_compile_args); - } - execMain(step, CMOC, args); - if (errors.length) - return { errors }; - var asmout = FS.readFile(destpath, { encoding: "utf8" }); - if (step.params.set_stack_end) - asmout = asmout.replace("stack space in bytes", ` - lds #${step.params.set_stack_end} -`); - putWorkFile(destpath, asmout); - } - return { - nexttool: "lwasm", - path: destpath, - args: [destpath], - files: [destpath] - }; -} -function assembleLWASM(step) { - loadNative("lwasm"); - var errors = []; - gatherFiles(step, { mainFilePath: "main.s" }); - var objpath = step.prefix + ".o"; - var lstpath = step.prefix + ".lst"; - const isRaw = step.path.endsWith(".asm"); - if (staleFiles(step, [objpath, lstpath])) { - var objout, lstout; - var args = ["-9", "-I/share/asminc", "-o" + objpath, "-l" + lstpath, step.path]; - args.push(isRaw ? "-r" : "--obj"); - var LWASM = emglobal.lwasm({ - instantiateWasm: moduleInstFn("lwasm"), - noInitialRun: true, - print: print_fn, - printErr: msvcErrorMatcher(errors) - }); - var FS = LWASM.FS; - populateFiles(step, FS); - fixParamsWithDefines(step.path, step.params); - execMain(step, LWASM, args); - if (errors.length) - return { errors }; - objout = FS.readFile(objpath, { encoding: "binary" }); - lstout = FS.readFile(lstpath, { encoding: "utf8" }); - putWorkFile(objpath, objout); - putWorkFile(lstpath, lstout); - if (isRaw) { - return { - output: objout - }; - } - } - return { - linktool: "lwlink", - files: [objpath, lstpath], - args: [objpath] - }; -} -function linkLWLINK(step) { - loadNative("lwlink"); - var params = step.params; - gatherFiles(step); - var binpath = "main"; - if (staleFiles(step, [binpath])) { - var errors = []; - var LWLINK = emglobal.lwlink({ - instantiateWasm: moduleInstFn("lwlink"), - noInitialRun: true, - print: print_fn, - printErr: function(s2) { - if (s2.startsWith("Warning:")) - console.log(s2); - else - errors.push({ msg: s2, line: 0 }); - } - }); - var FS = LWLINK.FS; - populateFiles(step, FS); - populateExtraFiles(step, FS, params.extra_link_files); - var libargs = params.extra_link_args || []; - var args = [ - "-L.", - "--entry=program_start", - "--raw", - "--output=main", - "--map=main.map" - ].concat(libargs, step.args); - console.log(args); - execMain(step, LWLINK, args); - if (errors.length) - return { errors }; - var aout = FS.readFile("main", { encoding: "binary" }); - var mapout = FS.readFile("main.map", { encoding: "utf8" }); - putWorkFile("main", aout); - putWorkFile("main.map", mapout); - if (!anyTargetChanged(step, ["main", "main.map"])) - return; - var symbolmap = {}; - var segments = []; - for (var s of mapout.split("\n")) { - var toks = s.split(" "); - if (toks[0] == "Symbol:") { - let ident = toks[1]; - let ofs = parseInt(toks[4], 16); - if (ident && ofs >= 0 && !ident.startsWith("l_") && !ident.startsWith("funcsize_") && !ident.startsWith("funcend_")) { - symbolmap[ident] = ofs; - } - } else if (toks[0] == "Section:") { - let seg = toks[1]; - let segstart = parseInt(toks[5], 16); - let segsize = parseInt(toks[7], 16); - segments.push({ name: seg, start: segstart, size: segsize }); - } - } - const re_segment = /\s*SECTION\s+(\w+)/i; - const re_function = /\s*([0-9a-f]+).+?(\w+)\s+EQU\s+[*]/i; - var listings = {}; - for (var fn of step.files) { - if (fn.endsWith(".lst")) { - var lstout = FS.readFile(fn, { encoding: "utf8" }); - var asmlines = parseListing(lstout, /^([0-9A-F]+)\s+([0-9A-F]+)\s+[(]\s*(.+?)[)]:(\d+) (.*)/i, 4, 1, 2, 3, re_function, re_segment); - for (let l of asmlines) { - l.offset += symbolmap[l.func] || 0; - } - var srclines = parseSourceLines(lstout, /Line .+?:(\d+)/i, /^([0-9A-F]{4})/i, re_function, re_segment); - for (let l of srclines) { - l.offset += symbolmap[l.func] || 0; - } - putWorkFile(fn, lstout); - lstout = lstout.split("\n").map((l) => l.substring(0, 15) + l.substring(56)).join("\n"); - listings[fn] = { - asmlines: srclines.length ? asmlines : null, - lines: srclines.length ? srclines : asmlines, - text: lstout - }; - } - } - return { - output: aout, - listings, - errors, - symbolmap, - segments - }; - } -} - -// src/worker/tools/m6502.ts -function assembleNESASM(step) { - loadNative("nesasm"); - var re_filename = /\#\[(\d+)\]\s+(\S+)/; - var re_insn = /\s+(\d+)\s+([0-9A-F]+):([0-9A-F]+)/; - var re_error = /\s+(.+)/; - var errors = []; - var state = 0; - var lineno = 0; - var filename; - function match_fn(s2) { - var m2; - switch (state) { - case 0: - m2 = re_filename.exec(s2); - if (m2) { - filename = m2[2]; - } - m2 = re_insn.exec(s2); - if (m2) { - lineno = parseInt(m2[1]); - state = 1; - } - break; - case 1: - m2 = re_error.exec(s2); - if (m2) { - errors.push({ path: filename, line: lineno, msg: m2[1] }); - state = 0; - } - break; - } - } - var Module = emglobal.nesasm({ - instantiateWasm: moduleInstFn("nesasm"), - noInitialRun: true, - print: match_fn - }); - var FS = Module.FS; - populateFiles(step, FS, { - mainFilePath: "main.a" - }); - var binpath = step.prefix + ".nes"; - var lstpath = step.prefix + ".lst"; - var sympath = step.prefix + ".fns"; - execMain(step, Module, [step.path, "-s", "-l", "2"]); - var listings = {}; - try { - var alst = FS.readFile(lstpath, { "encoding": "utf8" }); - var asmlines = parseListing(alst, /^\s*(\d+)\s+([0-9A-F]+):([0-9A-F]+)\s+([0-9A-F ]+?) (.*)/i, 1, 3, 4); - putWorkFile(lstpath, alst); - listings[lstpath] = { - lines: asmlines, - text: alst - }; - } catch (e) { - } - if (errors.length) { - return { errors }; - } - var aout, asym; - aout = FS.readFile(binpath); - try { - asym = FS.readFile(sympath, { "encoding": "utf8" }); - } catch (e) { - console.log(e); - errors.push({ line: 0, msg: "No symbol table generated, maybe missing ENDM or segment overflow?" }); - return { errors }; - } - putWorkFile(binpath, aout); - putWorkFile(sympath, asym); - if (alst) - putWorkFile(lstpath, alst); - if (!anyTargetChanged(step, [binpath, sympath])) - return; - var symbolmap = {}; - for (var s of asym.split("\n")) { - if (!s.startsWith(";")) { - var m = /(\w+)\s+=\s+[$]([0-9A-F]+)/.exec(s); - if (m) { - symbolmap[m[1]] = parseInt(m[2], 16); - } - } - } - return { - output: aout, - listings, - errors, - symbolmap - }; -} -function assembleMerlin32(step) { - loadNative("merlin32"); - var errors = []; - var lstfiles = []; - gatherFiles(step, { mainFilePath: "main.lnk" }); - var objpath = step.prefix + ".bin"; - if (staleFiles(step, [objpath])) { - var args = ["-v", step.path]; - var merlin32 = emglobal.merlin32({ - instantiateWasm: moduleInstFn("merlin32"), - noInitialRun: true, - print: (s) => { - var m = /\s*=>\s*Creating Output file '(.+?)'/.exec(s); - if (m) { - lstfiles.push(m[1]); - } - var errpos = s.indexOf("Error"); - if (errpos >= 0) { - s = s.slice(errpos + 6).trim(); - var mline = /\bline (\d+)\b/.exec(s); - var mpath = /\bfile '(.+?)'/.exec(s); - errors.push({ - line: parseInt(mline[1]) || 0, - msg: s, - path: mpath[1] || step.path - }); - } - }, - printErr: print_fn - }); - var FS = merlin32.FS; - populateFiles(step, FS); - execMain(step, merlin32, args); - if (errors.length) - return { errors }; - var errout = null; - try { - errout = FS.readFile("error_output.txt", { encoding: "utf8" }); - } catch (e) { - } - var objout = FS.readFile(objpath, { encoding: "binary" }); - putWorkFile(objpath, objout); - if (!anyTargetChanged(step, [objpath])) - return; - var symbolmap = {}; - var segments = []; - var listings = {}; - lstfiles.forEach((lstfn) => { - var lst = FS.readFile(lstfn, { encoding: "utf8" }); - lst.split("\n").forEach((line) => { - var toks = line.split(/\s*\|\s*/); - if (toks && toks[6]) { - var toks2 = toks[1].split(/\s+/); - var toks3 = toks[6].split(/[:/]/, 4); - var path4 = toks2[1]; - if (path4 && toks2[2] && toks3[1]) { - var lstline = { - line: parseInt(toks2[2]), - offset: parseInt(toks3[1].trim(), 16), - insns: toks3[2], - cycles: null, - iscode: false - }; - var lst2 = listings[path4]; - if (!lst2) - listings[path4] = lst2 = { lines: [] }; - lst2.lines.push(lstline); - } - } - }); - }); - return { - output: objout, - listings, - errors, - symbolmap, - segments - }; - } -} -function compileFastBasic(step) { - loadNative("fastbasic-int"); - var params = step.params; - gatherFiles(step, { mainFilePath: "main.fb" }); - var destpath = step.prefix + ".s"; - var errors = []; - if (staleFiles(step, [destpath])) { - var fastbasic = emglobal.fastbasic({ - instantiateWasm: moduleInstFn("fastbasic-int"), - noInitialRun: true, - print: print_fn, - printErr: makeErrorMatcher(errors, /(.+?):(\d+):(\d+):\s*(.+)/, 2, 4, step.path, 1) - }); - var FS = fastbasic.FS; - populateFiles(step, FS); - var libfile = "fastbasic-int.lib"; - params.libargs = [libfile]; - params.cfgfile = params.fastbasic_cfgfile; - params.extra_link_files = [libfile, params.cfgfile]; - var args = [step.path, destpath]; - execMain(step, fastbasic, args); - if (errors.length) - return { errors }; - var asmout = FS.readFile(destpath, { encoding: "utf8" }); - putWorkFile(destpath, asmout); - } - return { - nexttool: "ca65", - path: destpath, - args: [destpath], - files: [destpath] - }; -} - -// src/worker/tools/z80.ts -function assembleZMAC(step) { - loadNative("zmac"); - var hexout, lstout, binout; - var errors = []; - var params = step.params; - gatherFiles(step, { mainFilePath: "main.asm" }); - var lstpath = step.prefix + ".lst"; - var binpath = step.prefix + ".cim"; - if (staleFiles(step, [binpath])) { - var ZMAC = emglobal.zmac({ - instantiateWasm: moduleInstFn("zmac"), - noInitialRun: true, - print: print_fn, - printErr: makeErrorMatcher(errors, /([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+)/, 2, 3, step.path) - }); - var FS = ZMAC.FS; - populateFiles(step, FS); - execMain(step, ZMAC, ["-z", "-c", "--oo", "lst,cim", step.path]); - if (errors.length) { - return { errors }; - } - lstout = FS.readFile("zout/" + lstpath, { encoding: "utf8" }); - binout = FS.readFile("zout/" + binpath, { encoding: "binary" }); - putWorkFile(binpath, binout); - putWorkFile(lstpath, lstout); - if (!anyTargetChanged(step, [binpath, lstpath])) - return; - var lines = parseListing(lstout, /\s*(\d+):\s*([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3); - var listings = {}; - listings[lstpath] = { lines }; - var symbolmap = {}; - var sympos = lstout.indexOf("Symbol Table:"); - if (sympos > 0) { - var symout = lstout.slice(sympos + 14); - symout.split("\n").forEach(function(l) { - var m = l.match(/(\S+)\s+([= ]*)([0-9a-f]+)/i); - if (m) { - symbolmap[m[1]] = parseInt(m[3], 16); - } - }); - } - return { - output: binout, - listings, - errors, - symbolmap - }; - } -} - -// src/worker/tools/x86.ts -function compileSmallerC(step) { - loadNative("smlrc"); - var params = step.params; - var re_err1 = /^Error in "[/]*(.+)" [(](\d+):(\d+)[)]/; - var errors = []; - var errline = 0; - var errpath = step.path; - function match_fn(s) { - var matches = re_err1.exec(s); - if (matches) { - errline = parseInt(matches[2]); - errpath = matches[1]; - } else { - errors.push({ - line: errline, - msg: s, - path: errpath - }); - } - } - gatherFiles(step, { mainFilePath: "main.c" }); - var destpath = step.prefix + ".asm"; - if (staleFiles(step, [destpath])) { - var args = [ - "-seg16", - "-no-externs", - step.path, - destpath - ]; - var smlrc = emglobal.smlrc({ - instantiateWasm: moduleInstFn("smlrc"), - noInitialRun: true, - print: match_fn, - printErr: match_fn - }); - var code = getWorkFileAsString(step.path); - var preproc = preprocessMCPP(step, null); - if (preproc.errors) { - return { errors: preproc.errors }; - } else - code = preproc.code; - var FS = smlrc.FS; - populateFiles(step, FS); - FS.writeFile(step.path, code); - fixParamsWithDefines(step.path, params); - if (params.extra_compile_args) { - args.unshift.apply(args, params.extra_compile_args); - } - execMain(step, smlrc, args); - if (errors.length) - return { errors }; - var asmout = FS.readFile(destpath, { encoding: "utf8" }); - putWorkFile(destpath, asmout); - } - return { - nexttool: "yasm", - path: destpath, - args: [destpath], - files: [destpath] - }; -} -function assembleYASM(step) { - loadNative("yasm"); - var errors = []; - gatherFiles(step, { mainFilePath: "main.asm" }); - var objpath = step.prefix + ".exe"; - var lstpath = step.prefix + ".lst"; - var mappath = step.prefix + ".map"; - if (staleFiles(step, [objpath])) { - var args = [ - "-X", - "vc", - "-a", - "x86", - "-f", - "dosexe", - "-p", - "nasm", - "-D", - "freedos", - "-o", - objpath, - "-l", - lstpath, - "--mapfile=" + mappath, - step.path - ]; - var YASM = emglobal.yasm({ - instantiateWasm: moduleInstFn("yasm"), - noInitialRun: true, - print: print_fn, - printErr: msvcErrorMatcher(errors) - }); - var FS = YASM.FS; - populateFiles(step, FS); - execMain(step, YASM, args); - if (errors.length) - return { errors }; - var objout, lstout, mapout; - objout = FS.readFile(objpath, { encoding: "binary" }); - lstout = FS.readFile(lstpath, { encoding: "utf8" }); - mapout = FS.readFile(mappath, { encoding: "utf8" }); - putWorkFile(objpath, objout); - putWorkFile(lstpath, lstout); - if (!anyTargetChanged(step, [objpath])) - return; - var symbolmap = {}; - var segments = []; - var lines = parseListing(lstout, /\s*(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3); - var listings = {}; - listings[lstpath] = { lines, text: lstout }; - return { - output: objout, - listings, - errors, - symbolmap, - segments - }; - } -} - -// src/worker/tools/arm.ts -function assembleARMIPS(step) { - loadNative("armips"); - var errors = []; - gatherFiles(step, { mainFilePath: "main.asm" }); - var objpath = "main.bin"; - var lstpath = step.prefix + ".lst"; - var sympath = step.prefix + ".sym"; - var error_fn = makeErrorMatcher(errors, /^(.+?)\((\d+)\)\s+(fatal error|error|warning):\s+(.+)/, 2, 4, step.path, 1); - if (staleFiles(step, [objpath])) { - var args = [step.path, "-temp", lstpath, "-sym", sympath, "-erroronwarning"]; - var armips = emglobal.armips({ - instantiateWasm: moduleInstFn("armips"), - noInitialRun: true, - print: error_fn, - printErr: error_fn - }); - var FS = armips.FS; - var code = getWorkFileAsString(step.path); - code = `.arm.little :: .create "${objpath}",0 :: ${code} - .close`; - putWorkFile(step.path, code); - populateFiles(step, FS); - execMain(step, armips, args); - if (errors.length) - return { errors }; - var objout = FS.readFile(objpath, { encoding: "binary" }); - putWorkFile(objpath, objout); - if (!anyTargetChanged(step, [objpath])) - return; - var symbolmap = {}; - var segments = []; - var listings = {}; - var lstout = FS.readFile(lstpath, { encoding: "utf8" }); - var lines = lstout.split(re_crlf); - var re_asmline = /^([0-9A-F]+) (.+?); [/](.+?) line (\d+)/; - var lastofs = -1; - for (var line of lines) { - var m; - if (m = re_asmline.exec(line)) { - var path4 = m[3]; - var path22 = getPrefix(path4) + ".lst"; - var lst = listings[path22]; - if (lst == null) { - lst = listings[path22] = { lines: [] }; - } - var ofs = parseInt(m[1], 16); - if (lastofs == ofs) { - lst.lines.pop(); - } else if (ofs > lastofs) { - var lastline = lst.lines[lst.lines.length - 1]; - if (lastline && !lastline.insns) { - var insns = objout.slice(lastofs, ofs).reverse(); - lastline.insns = Array.from(insns).map((b) => hex(b, 2)).join(""); - } - } - lst.lines.push({ - path: path4, - line: parseInt(m[4]), - offset: ofs - }); - lastofs = ofs; - } - } - var symout = FS.readFile(sympath, { encoding: "utf8" }); - var re_symline = /^([0-9A-F]+)\s+(.+)/; - for (var line of symout.split(re_crlf)) { - var m; - if (m = re_symline.exec(line)) { - symbolmap[m[2]] = parseInt(m[1], 16); - } - } - return { - output: objout, - listings, - errors, - symbolmap, - segments - }; - } -} -function assembleVASMARM(step) { - loadNative("vasmarm_std"); - var re_err1 = /^(fatal error|error|warning)? (\d+) in line (\d+) of "(.+)": (.+)/; - var re_err2 = /^(fatal error|error|warning)? (\d+): (.+)/; - var re_undefsym = /symbol <(.+?)>/; - var errors = []; - var undefsyms = []; - function findUndefinedSymbols(line2) { - undefsyms.forEach((sym) => { - if (line2.indexOf(sym) >= 0) { - errors.push({ - path: curpath, - line: curline, - msg: "Undefined symbol: " + sym - }); - } - }); - } - function match_fn(s) { - let matches = re_err1.exec(s); - if (matches) { - errors.push({ - line: parseInt(matches[3]), - path: matches[4], - msg: matches[5] - }); - } else { - matches = re_err2.exec(s); - if (matches) { - let m2 = re_undefsym.exec(matches[3]); - if (m2) { - undefsyms.push(m2[1]); - } else { - errors.push({ - line: 0, - msg: s - }); - } - } else { - console.log(s); - } - } - } - gatherFiles(step, { mainFilePath: "main.asm" }); - var objpath = step.prefix + ".bin"; - var lstpath = step.prefix + ".lst"; - if (staleFiles(step, [objpath])) { - var args = ["-Fbin", "-m7tdmi", "-x", "-wfail", step.path, "-o", objpath, "-L", lstpath]; - var vasm = emglobal.vasm({ - instantiateWasm: moduleInstFn("vasmarm_std"), - noInitialRun: true, - print: match_fn, - printErr: match_fn - }); - var FS = vasm.FS; - populateFiles(step, FS); - execMain(step, vasm, args); - if (errors.length) { - return { errors }; - } - if (undefsyms.length == 0) { - var objout = FS.readFile(objpath, { encoding: "binary" }); - putWorkFile(objpath, objout); - if (!anyTargetChanged(step, [objpath])) - return; - } - var lstout = FS.readFile(lstpath, { encoding: "utf8" }); - var symbolmap = {}; - var segments = []; - var listings = {}; - var re_asmline = /^(\d+):([0-9A-F]+)\s+([0-9A-F ]+)\s+(\d+)([:M])/; - var re_secline = /^(\d+):\s+"(.+)"/; - var re_nameline = /^Source:\s+"(.+)"/; - var re_symline = /^(\w+)\s+(\d+):([0-9A-F]+)/; - var re_emptyline = /^\s+(\d+)([:M])/; - var curpath = step.path; - var curline = 0; - var sections = {}; - var lines = lstout.split(re_crlf); - var lstlines = []; - for (var line of lines) { - var m; - if (m = re_secline.exec(line)) { - sections[m[1]] = m[2]; - } else if (m = re_nameline.exec(line)) { - curpath = m[1]; - } else if (m = re_symline.exec(line)) { - symbolmap[m[1]] = parseInt(m[3], 16); - } else if (m = re_asmline.exec(line)) { - if (m[5] == ":") { - curline = parseInt(m[4]); - } else { - } - lstlines.push({ - path: curpath, - line: curline, - offset: parseInt(m[2], 16), - insns: m[3].replaceAll(" ", "") - }); - findUndefinedSymbols(line); - } else if (m = re_emptyline.exec(line)) { - curline = parseInt(m[1]); - findUndefinedSymbols(line); - } else { - } - } - listings[lstpath] = { lines: lstlines, text: lstout }; - if (undefsyms.length && errors.length == 0) { - errors.push({ - line: 0, - msg: "Undefined symbols: " + undefsyms.join(", ") - }); - } - return { - output: objout, - listings, - errors, - symbolmap, - segments - }; - } -} - -// src/common/tokenizer.ts -var CompileError3 = class extends Error { - constructor(msg, loc) { - super(msg); - Object.setPrototypeOf(this, CompileError3.prototype); - this.$loc = loc; - } -}; -function mergeLocs2(a, b) { - return { - line: Math.min(a.line, b.line), - start: Math.min(a.start, b.start), - end: Math.max(a.end, b.end), - label: a.label || b.label, - path: a.path || b.path - }; -} -var TokenType2; -(function(TokenType3) { - TokenType3["EOF"] = "eof"; - TokenType3["EOL"] = "eol"; - TokenType3["Ident"] = "ident"; - TokenType3["Comment"] = "comment"; - TokenType3["Ignore"] = "ignore"; - TokenType3["CatchAll"] = "catch-all"; -})(TokenType2 || (TokenType2 = {})); -var CATCH_ALL_RULES = [ - { type: TokenType2.CatchAll, regex: /.+?/ } -]; -function re_escape(rule) { - return `(${rule.regex.source})`; -} -var TokenizerRuleSet = class { - constructor(rules) { - this.rules = rules.concat(CATCH_ALL_RULES); - var pattern = this.rules.map(re_escape).join("|"); - this.regex = new RegExp(pattern, "gs"); - } -}; -var Tokenizer = class { - constructor() { - this.errorOnCatchAll = false; - this.deferred = []; - this.errors = []; - this.lineno = 0; - this.lineindex = []; - this.tokens = []; - } - setTokenRuleSet(ruleset) { - this.ruleset = ruleset; - } - setTokenRules(rules) { - this.setTokenRuleSet(new TokenizerRuleSet(rules)); - } - tokenizeFile(contents, path4) { - this.path = path4; - let m; - let re = /\n|\r\n?/g; - this.lineindex.push(0); - while (m = re.exec(contents)) { - this.lineindex.push(m.index); - } - this._tokenize(contents); - this.eof = { type: TokenType2.EOF, str: "", eol: true, $loc: { path: this.path, line: this.lineno } }; - this.pushToken(this.eof); - } - _tokenize(text) { - let m; - this.lineno = 0; - while (m = this.ruleset.regex.exec(text)) { - let found = false; - while (m.index >= this.lineindex[this.lineno]) { - this.lineno++; - } - let rules = this.ruleset.rules; - for (let i = 0; i < rules.length; i++) { - let s = m[i + 1]; - if (s != null) { - found = true; - let col = m.index - (this.lineindex[this.lineno - 1] || -1) - 1; - let loc = { path: this.path, line: this.lineno, start: col, end: col + s.length }; - let rule = rules[i]; - switch (rule.type) { - case TokenType2.CatchAll: - if (this.errorOnCatchAll) { - this.compileError(`I didn't expect the character "${m[0]}" here.`, loc); - } - default: - this.pushToken({ str: s, type: rule.type, $loc: loc, eol: false }); - break; - case TokenType2.EOL: - if (this.tokens.length) - this.tokens[this.tokens.length - 1].eol = true; - case TokenType2.Comment: - case TokenType2.Ignore: - break; - } - break; - } - } - if (!found) { - this.compileError(`Could not parse token: <<${m[0]}>>`); - } - } - } - pushToken(token) { - this.tokens.push(token); - } - addError(msg, loc) { - let tok = this.lasttoken || this.peekToken(); - if (!loc) - loc = tok.$loc; - this.errors.push({ path: loc.path, line: loc.line, label: this.curlabel, start: loc.start, end: loc.end, msg }); - } - internalError() { - return this.compileError("Internal error."); - } - notImplementedError() { - return this.compileError("Not yet implemented."); - } - compileError(msg, loc, loc2) { - this.addError(msg, loc); - let e = new CompileError3(msg, loc); - throw e; - return e; - } - peekToken(lookahead) { - let tok = this.tokens[lookahead || 0]; - return tok ? tok : this.eof; - } - consumeToken() { - let tok = this.lasttoken = this.tokens.shift() || this.eof; - return tok; - } - ifToken(match) { - if (this.peekToken().str == match) - return this.consumeToken(); - } - expectToken(str, msg) { - let tok = this.consumeToken(); - let tokstr = tok.str; - if (str != tokstr) { - this.compileError(msg || `There should be a "${str}" here.`); - } - return tok; - } - expectTokens(strlist, msg) { - let tok = this.consumeToken(); - let tokstr = tok.str; - if (!strlist.includes(tokstr)) { - this.compileError(msg || `These keywords are valid here: ${strlist.join(", ")}`); - } - return tok; - } - parseModifiers(modifiers) { - let result = {}; - do { - var tok = this.peekToken(); - if (modifiers.indexOf(tok.str) < 0) - return result; - this.consumeToken(); - result[tok.str] = true; - } while (tok != null); - } - expectIdent(msg) { - let tok = this.consumeToken(); - if (tok.type != TokenType2.Ident) - this.compileError(msg || `There should be an identifier here.`); - return tok; - } - pushbackToken(tok) { - this.tokens.unshift(tok); - } - isEOF() { - return this.tokens.length == 0 || this.peekToken().type == "eof"; - } - expectEOL(msg) { - let tok = this.consumeToken(); - if (tok.type != TokenType2.EOL) - this.compileError(msg || `There's too much stuff on this line.`); - } - skipBlankLines() { - this.skipTokenTypes(["eol"]); - } - skipTokenTypes(types) { - while (types.includes(this.peekToken().type)) - this.consumeToken(); - } - expectTokenTypes(types, msg) { - let tok = this.consumeToken(); - if (!types.includes(tok.type)) - this.compileError(msg || `There should be a ${types.map((s) => `"${s}"`).join(" or ")} here. not a "${tok.type}".`); - return tok; - } - parseList(parseFunc, delim) { - var sep; - var list = []; - do { - var el = parseFunc.bind(this)(); - if (el != null) - list.push(el); - sep = this.consumeToken(); - } while (sep.str == delim); - this.pushbackToken(sep); - return list; - } - runDeferred() { - while (this.deferred.length) { - this.deferred.shift()(); - } - } -}; - -// src/common/ecs/binpack.ts -var debug = false; -var BoxPlacement; -(function(BoxPlacement2) { - BoxPlacement2[BoxPlacement2["TopLeft"] = 0] = "TopLeft"; - BoxPlacement2[BoxPlacement2["TopRight"] = 1] = "TopRight"; - BoxPlacement2[BoxPlacement2["BottomLeft"] = 2] = "BottomLeft"; - BoxPlacement2[BoxPlacement2["BottomRight"] = 3] = "BottomRight"; -})(BoxPlacement || (BoxPlacement = {})); -function boxesIntersect(a, b) { - return !(b.left >= a.right || b.right <= a.left || b.top >= a.bottom || b.bottom <= a.top); -} -function boxesContain(a, b) { - return b.left >= a.left && b.top >= a.top && b.right <= a.right && b.bottom <= a.bottom; -} -var Bin = class { - constructor(binbounds) { - this.binbounds = binbounds; - this.boxes = []; - this.free = []; - this.extents = { left: 0, top: 0, right: 0, bottom: 0 }; - this.free.push(binbounds); - } - getBoxes(bounds, limit, boxes) { - let result = []; - if (!boxes) - boxes = this.boxes; - for (let box of boxes) { - if (boxesIntersect(bounds, box)) { - result.push(box); - if (result.length >= limit) - break; - } - } - return result; - } - fits(b) { - if (!boxesContain(this.binbounds, b)) { - if (debug) - console.log("out of bounds!", b.left, b.top, b.right, b.bottom); - return false; - } - if (this.getBoxes(b, 1).length > 0) { - if (debug) - console.log("intersect!", b.left, b.top, b.right, b.bottom); - return false; - } - return true; - } - bestFit(b) { - let bestscore = 0; - let best = null; - for (let f of this.free) { - if (b.left != null && b.left < f.left) - continue; - if (b.left != null && b.left + b.width > f.right) - continue; - if (b.top != null && b.top < f.top) - continue; - if (b.top != null && b.top + b.height > f.bottom) - continue; - let dx = f.right - f.left - b.width; - let dy = f.bottom - f.top - b.height; - if (dx >= 0 && dy >= 0) { - let score = 1 / (1 + dx + dy + f.left * 1e-3); - if (score > bestscore) { - best = f; - bestscore = score; - if (score == 1) - break; - } - } - } - return best; - } - anyFit(b) { - let bestscore = 0; - let best = null; - for (let f of this.free) { - let box = { - left: b.left != null ? b.left : f.left, - right: f.left + b.width, - top: b.top != null ? b.top : f.top, - bottom: f.top + b.height - }; - if (this.fits(box)) { - let score = 1 / (1 + box.left + box.top); - if (score > bestscore) { - best = f; - if (score == 1) - break; - } - } - } - return best; - } - add(b) { - if (debug) - console.log("add", b.left, b.top, b.right, b.bottom); - if (!this.fits(b)) { - throw new Error(`bad fit ${b.left} ${b.top} ${b.right} ${b.bottom}`); - } - this.boxes.push(b); - this.extents.right = Math.max(this.extents.right, b.right); - this.extents.bottom = Math.max(this.extents.bottom, b.bottom); - for (let p of b.parents) { - let i = this.free.indexOf(p); - if (i < 0) - throw new Error("cannot find parent"); - if (debug) - console.log("removed", p.left, p.top, p.right, p.bottom); - this.free.splice(i, 1); - this.addFree(p.left, p.top, b.left, p.bottom); - this.addFree(b.right, p.top, p.right, p.bottom); - this.addFree(b.left, p.top, b.right, b.top); - this.addFree(b.left, b.bottom, b.right, p.bottom); - } - } - addFree(left, top, right, bottom) { - if (bottom > top && right > left) { - let b = { left, top, right, bottom }; - if (debug) - console.log("free", b.left, b.top, b.right, b.bottom); - this.free.push(b); - } - } -}; -var Packer = class { - constructor() { - this.bins = []; - this.boxes = []; - this.defaultPlacement = 0; - } - pack() { - for (let bc of this.boxes) { - let box = this.bestPlacement(bc); - if (!box) - return false; - box.bin.add(box); - bc.box = box; - } - return true; - } - bestPlacement(b) { - for (let bin of this.bins) { - let parent = bin.bestFit(b); - let approx = false; - if (!parent) { - parent = bin.anyFit(b); - approx = true; - if (debug) - console.log("anyfit", parent?.left, parent?.top); - } - if (parent) { - let place = this.defaultPlacement; - let box = { - left: parent.left, - top: parent.top, - right: parent.left + b.width, - bottom: parent.top + b.height - }; - if (b.left != null) { - box.left = b.left; - box.right = b.left + b.width; - } - if (b.top != null) { - box.top = b.top; - box.bottom = b.top + b.height; - } - if (place == 2 || place == 3) { - let h = box.bottom - box.top; - box.top = parent.bottom - h; - box.bottom = parent.bottom; - } - if (place == 1 || place == 3) { - let w = box.right - box.left; - box.left = parent.right - w; - box.right = parent.right; - } - if (debug) - console.log("place", b.label, box.left, box.top, box.right, box.bottom, parent?.left, parent?.top); - let parents = [parent]; - if (approx) - parents = bin.getBoxes(box, 100, bin.free); - return { parents, place, bin, ...box }; - } - } - if (debug) - console.log("cannot place!", b.left, b.top, b.width, b.height); - return null; - } - toSVG() { - let s = ""; - let r = { width: 100, height: 70 }; - for (let bin of this.bins) { - r.width = Math.max(r.width, bin.binbounds.right); - r.height = Math.max(r.height, bin.binbounds.bottom); - } - s += ``; - for (let bin of this.bins) { - let be = bin.extents; - s += ""; - s += ``; - let textx = be.right + 1; - let texty = 0; - for (let box of this.boxes) { - let b = box.box; - if (b) { - if (b.bin == bin) - s += ``; - if (b.top == texty) - textx += 10; - else - textx = be.right + 1; - texty = b.top; - if (box.label) - s += `${box.label}`; - } - } - s += ""; - } - s += ``; - return s; - } - toSVGUrl() { - return `data:image/svg+xml;base64,${btoa(this.toSVG())}`; - } -}; - -// src/common/ecs/ecs.ts -var ECSError = class extends Error { - constructor(msg, obj) { - super(msg); - this.$sources = []; - Object.setPrototypeOf(this, ECSError.prototype); - if (obj) - this.$loc = obj.$loc || obj; - } -}; -function mksymbol(c, fieldName) { - return c.name + "_" + fieldName; -} -function mkscopesymbol(s, c, fieldName) { - return s.name + "_" + c.name + "_" + fieldName; -} -var SystemStats = class { -}; -var SELECT_TYPE = ["once", "foreach", "join", "with", "if", "select", "unroll"]; -function isLiteral2(arg) { - return arg.value != null; -} -function isLiteralInt(arg) { - return isLiteral2(arg) && arg.valtype.dtype == "int"; -} -function isBinOp2(arg) { - return arg.op != null && arg.left != null && arg.right != null; -} -function isUnOp2(arg) { - return arg.op != null && arg.expr != null; -} -function isBlockStmt(arg) { - return arg.stmts != null; -} -function isInlineCode(arg) { - return arg.code != null; -} -function isQueryExpr(arg) { - return arg.query != null; -} -var Dialect_CA65 = class { - constructor() { - this.ASM_ITERATE_EACH_ASC = ` - ldx #0 -@__each: - {{%code}} - inx - cpx #{{%ecount}} - jne @__each -@__exit: -`; - this.ASM_ITERATE_EACH_DESC = ` - ldx #{{%ecount}}-1 -@__each: - {{%code}} - dex - jpl @__each -@__exit: -`; - this.ASM_ITERATE_JOIN_ASC = ` - ldy #0 -@__each: - ldx {{%joinfield}},y - {{%code}} - iny - cpy #{{%ecount}} - jne @__each -@__exit: -`; - this.ASM_ITERATE_JOIN_DESC = ` - ldy #{{%ecount}}-1 -@__each: - ldx {{%joinfield}},y - {{%code}} - dey - jpl @__each -@__exit: -`; - this.ASM_FILTER_RANGE_LO_X = ` - cpx #{{%xofs}} - jcc @__skipxlo - {{%code}} -@__skipxlo: -`; - this.ASM_FILTER_RANGE_HI_X = ` - cpx #{{%xofs}}+{{%ecount}} - jcs @__skipxhi - {{%code}} -@__skipxhi: -`; - this.ASM_LOOKUP_REF_X = ` - ldx {{%reffield}} - {{%code}} -`; - this.INIT_FROM_ARRAY = ` - ldy #{{%nbytes}} -: lda {{%src}}-1,y - sta {{%dest}}-1,y - dey - bne :- -`; - } - comment(s) { - return ` -;;; ${s} -`; - } - absolute(ident, offset) { - return this.addOffset(ident, offset || 0); - } - addOffset(ident, offset) { - if (offset > 0) - return `${ident}+${offset}`; - if (offset < 0) - return `${ident}-${-offset}`; - return ident; - } - indexed_x(ident, offset) { - return this.addOffset(ident, offset) + ",x"; - } - indexed_y(ident, offset) { - return this.addOffset(ident, offset) + ",y"; - } - fieldsymbol(component, field, bitofs) { - return `${component.name}_${field.name}_b${bitofs}`; - } - datasymbol(component, field, eid, bitofs) { - return `${component.name}_${field.name}_e${eid}_b${bitofs}`; - } - debug_file(path4) { - return `.dbg file, "${path4}", 0, 0`; - } - debug_line(path4, line) { - return `.dbg line, "${path4}", ${line}`; - } - startScope(name) { - return `.scope ${name}`; - } - endScope(name) { - return `.endscope -${this.scopeSymbol(name)} = ${name}::__Start`; - } - scopeSymbol(name) { - return `${name}__Start`; - } - align(value) { - return `.align ${value}`; - } - alignSegmentStart() { - return this.label("__ALIGNORIGIN"); - } - warningIfPageCrossed(startlabel) { - return ` -.assert >(${startlabel}) = >(*), error, "${startlabel} crosses a page boundary!"`; - } - warningIfMoreThan(bytes, startlabel) { - return ` -.assert (* - ${startlabel}) <= ${bytes}, error, .sprintf("${startlabel} does not fit in ${bytes} bytes, it took %d!", (* - ${startlabel}))`; - } - alignIfLessThan(bytes) { - return ` -.if <(* - __ALIGNORIGIN) > 256-${bytes} -.align $100 -.endif`; - } - segment(segtype) { - if (segtype == "bss") { - return `.zeropage`; - } else if (segtype == "rodata") { - return ".rodata"; - } else { - return `.code`; - } - } - label(sym) { - return `${sym}:`; - } - export(sym) { - return `.export _${sym} = ${sym}`; - } - byte(b) { - if (b === void 0) { - return `.res 1`; - } else if (typeof b === "number") { - if (b < 0 || b > 255) - throw new ECSError(`out of range byte ${b}`); - return `.byte ${b}`; - } else { - if (b.bitofs == 0) - return `.byte <${b.symbol}`; - else if (b.bitofs == 8) - return `.byte >${b.symbol}`; - else - return `.byte ((${b.symbol} >> ${b.bitofs})&255)`; - } - } - tempLabel(inst) { - return `${inst.system.name}__${inst.id}__tmp`; - } - equate(symbol, value) { - return `${symbol} = ${value}`; - } - define(symbol, value) { - if (value) - return `.define ${symbol} ${value}`; - else - return `.define ${symbol}`; - } - call(symbol) { - return ` jsr ${symbol}`; - } - jump(symbol) { - return ` jmp ${symbol}`; - } - return() { - return " rts"; - } -}; -var SourceFileExport = class { - constructor() { - this.lines = []; - } - line(s) { - this.text(s); - } - text(s) { - for (let l of s.split("\n")) - this.lines.push(l); - } - toString() { - return this.lines.join("\n"); - } -}; -var CodeSegment = class { - constructor() { - this.codefrags = []; - } - addCodeFragment(code) { - this.codefrags.push(code); - } - dump(file) { - for (let code of this.codefrags) { - file.text(code); - } - } -}; -var DataSegment = class { - constructor() { - this.symbols = {}; - this.equates = {}; - this.ofs2sym = new Map(); - this.fieldranges = {}; - this.size = 0; - this.initdata = []; - } - allocateBytes(name, bytes) { - let ofs = this.symbols[name]; - if (ofs == null) { - ofs = this.size; - this.declareSymbol(name, ofs); - this.size += bytes; - } - return ofs; - } - declareSymbol(name, ofs) { - this.symbols[name] = ofs; - if (!this.ofs2sym.has(ofs)) - this.ofs2sym.set(ofs, []); - this.ofs2sym.get(ofs)?.push(name); - } - findExistingInitData(bytes) { - for (let i = 0; i < this.size - bytes.length; i++) { - for (var j = 0; j < bytes.length; j++) { - if (this.initdata[i + j] !== bytes[j]) - break; - } - if (j == bytes.length) - return i; - } - return -1; - } - allocateInitData(name, bytes) { - let ofs = this.findExistingInitData(bytes); - if (ofs >= 0) { - this.declareSymbol(name, ofs); - } else { - ofs = this.allocateBytes(name, bytes.length); - for (let i = 0; i < bytes.length; i++) { - this.initdata[ofs + i] = bytes[i]; - } - } - } - dump(file, dialect, doExport) { - for (let i = 0; i < this.size; i++) { - let syms = this.ofs2sym.get(i); - if (syms) { - for (let sym of syms) { - if (doExport) - file.line(dialect.export(sym)); - file.line(dialect.label(sym)); - } - } - file.line(dialect.byte(this.initdata[i])); - } - for (let [symbol, value] of Object.entries(this.equates)) { - file.line(dialect.equate(symbol, value)); - } - } - getFieldRange(component, fieldName) { - return this.fieldranges[mksymbol(component, fieldName)]; - } - getByteOffset(range, access, entityID) { - if (entityID < range.elo) - throw new ECSError(`entity ID ${entityID} too low for ${access.symbol}`); - if (entityID > range.ehi) - throw new ECSError(`entity ID ${entityID} too high for ${access.symbol}`); - let ofs = this.symbols[access.symbol]; - if (ofs !== void 0) { - return ofs + entityID - range.elo; - } - throw new ECSError(`cannot find field access for ${access.symbol}`); - } - getOriginSymbol() { - let a = this.ofs2sym.get(0); - if (!a) - throw new ECSError("getOriginSymbol(): no symbol at offset 0"); - return a[0]; - } -}; -var UninitDataSegment = class extends DataSegment { -}; -var ConstDataSegment = class extends DataSegment { -}; -function getFieldBits(f) { - let n = f.hi - f.lo + 1; - return Math.ceil(Math.log2(n)); -} -function getFieldLength(f) { - if (f.dtype == "int") { - return f.hi - f.lo + 1; - } else { - return 1; - } -} -function getPackedFieldSize(f, constValue) { - if (f.dtype == "int") { - return getFieldBits(f); - } - if (f.dtype == "array" && f.index) { - return 0; - } - if (f.dtype == "array" && constValue != null && Array.isArray(constValue)) { - return constValue.length * getPackedFieldSize(f.elem); - } - if (f.dtype == "ref") { - return 8; - } - return 0; -} -var EntitySet = class { - constructor(scope, query, e) { - this.scope = scope; - if (query) { - if (query.entities) { - this.entities = query.entities.slice(0); - } else { - this.atypes = scope.em.archetypesMatching(query); - this.entities = scope.entitiesMatching(this.atypes); - } - if (query.limit) { - this.entities = this.entities.slice(0, query.limit); - } - } else if (e) { - this.entities = e; - } else { - throw new ECSError("invalid EntitySet constructor"); - } - if (!this.atypes) { - let at = new Set(); - for (let e2 of this.entities) - at.add(e2.etype); - this.atypes = Array.from(at.values()); - } - } - contains(c, f, where) { - return this.scope.em.singleComponentWithFieldName(this.atypes, f.name, where); - } - intersection(qr) { - let ents = this.entities.filter((e) => qr.entities.includes(e)); - return new EntitySet(this.scope, void 0, ents); - } - union(qr) { - let ents = this.entities.concat(qr.entities); - let atypes = this.atypes.concat(qr.atypes); - return new EntitySet(this.scope, void 0, ents); - } - isContiguous() { - if (this.entities.length == 0) - return true; - let id = this.entities[0].id; - for (let i = 1; i < this.entities.length; i++) { - if (this.entities[i].id != ++id) - return false; - } - return true; - } -}; -var IndexRegister = class { - constructor(scope, eset) { - this.scope = scope; - this.elo = 0; - this.ehi = scope.entities.length - 1; - this.lo = null; - this.hi = null; - if (eset) { - this.narrowInPlace(eset); - } - } - entityCount() { - return this.ehi - this.elo + 1; - } - clone() { - return Object.assign(new IndexRegister(this.scope), this); - } - narrow(eset, action) { - let i = this.clone(); - return i.narrowInPlace(eset, action) ? i : null; - } - narrowInPlace(eset, action) { - if (this.scope != eset.scope) - throw new ECSError(`scope mismatch`, action); - if (!eset.isContiguous()) - throw new ECSError(`entities are not contiguous`, action); - if (this.eset) { - this.eset = this.eset.intersection(eset); - } else { - this.eset = eset; - } - if (this.eset.entities.length == 0) { - return false; - } - let newelo = this.eset.entities[0].id; - let newehi = this.eset.entities[this.eset.entities.length - 1].id; - if (this.lo === null || this.hi === null) { - this.lo = 0; - this.hi = newehi - newelo; - this.elo = newelo; - this.ehi = newehi; - } else { - this.lo += newelo - this.elo; - this.hi += newehi - this.ehi; - } - return true; - } - offset() { - return this.lo || 0; - } -}; -var ActionCPUState = class { - constructor() { - this.xreg = null; - this.yreg = null; - } -}; -var ActionEval = class { - constructor(scope, instance, action, eventargs) { - this.scope = scope; - this.instance = instance; - this.action = action; - this.eventargs = eventargs; - this.tmplabel = ""; - this.em = scope.em; - this.dialect = scope.em.dialect; - this.tmplabel = this.dialect.tempLabel(this.instance); - this.seq = this.em.seq++; - this.label = `${this.instance.system.name}__${action.event}__${this.seq}`; - } - begin() { - } - end() { - } - codeToString() { - let code = this.exprToCode(this.action.expr); - return code; - } - replaceTags(code, action, props) { - const tag_re = /\{\{(.+?)\}\}/g; - code = code.replace(tag_re, (entire, group) => { - let toks = group.split(/\s+/); - if (toks.length == 0) - throw new ECSError(`empty command`, action); - let cmd = group.charAt(0); - let arg0 = toks[0].substring(1).trim(); - let args = [arg0].concat(toks.slice(1)); - switch (cmd) { - case "!": - return this.__emit(args); - case "$": - return this.__local(args); - case "^": - return this.__use(args); - case "#": - return this.__arg(args); - case "&": - return this.__eid(args); - case "<": - return this.__get([arg0, "0"]); - case ">": - return this.__get([arg0, "8"]); - default: - let value = props[toks[0]]; - if (value) - return value; - let fn = this["__" + toks[0]]; - if (fn) - return fn.bind(this)(toks.slice(1)); - throw new ECSError(`unrecognized command {{${toks[0]}}}`, action); - } - }); - return code; - } - replaceLabels(code) { - const label_re = /@(\w+)\b/g; - let seq = this.em.seq++; - let label = `${this.instance.system.name}__${this.action.event}__${seq}`; - code = code.replace(label_re, (s, a) => `${label}__${a}`); - return code; - } - __get(args) { - return this.getset(args, false); - } - __set(args) { - return this.getset(args, true); - } - getset(args, canwrite) { - let fieldName = args[0]; - let bitofs = parseInt(args[1] || "0"); - return this.generateCodeForField(fieldName, bitofs, canwrite); - } - parseFieldArgs(args) { - let fieldName = args[0]; - let bitofs = parseInt(args[1] || "0"); - let component = this.em.singleComponentWithFieldName(this.scope.state.working.atypes, fieldName, this.action); - let field = component.fields.find((f) => f.name == fieldName); - if (field == null) - throw new ECSError(`no field named "${fieldName}" in component`, this.action); - return { component, field, bitofs }; - } - __base(args) { - let { component, field, bitofs } = this.parseFieldArgs(args); - return this.dialect.fieldsymbol(component, field, bitofs); - } - __data(args) { - let { component, field, bitofs } = this.parseFieldArgs(args); - let entities = this.scope.state.working.entities; - if (entities.length != 1) - throw new ECSError(`data operates on exactly one entity`, this.action); - let eid = entities[0].id; - return this.dialect.datasymbol(component, field, eid, bitofs); - } - __const(args) { - let { component, field, bitofs } = this.parseFieldArgs(args); - let entities = this.scope.state.working.entities; - if (entities.length != 1) - throw new ECSError(`const operates on exactly one entity`, this.action); - let constVal = entities[0].consts[mksymbol(component, field.name)]; - if (constVal === void 0) - throw new ECSError(`field is not constant`, this.action); - if (typeof constVal !== "number") - throw new ECSError(`field is not numeric`, this.action); - return constVal << bitofs; - } - __index(args) { - let ident = args[0]; - let index = parseInt(args[1] || "0"); - let entities = this.scope.state.working.entities; - if (entities.length == 1) { - return this.dialect.absolute(ident); - } else { - return this.dialect.indexed_x(ident, index); - } - } - __eid(args) { - let e = this.scope.getEntityByName(args[0] || "?"); - if (!e) - throw new ECSError(`can't find entity named "${args[0]}"`, this.action); - return e.id.toString(); - } - __use(args) { - return this.scope.includeResource(args[0]); - } - __emit(args) { - let event = args[0]; - let eventargs = args.slice(1); - try { - return this.scope.generateCodeForEvent(event, eventargs); - } catch (e) { - if (e.$sources) - e.$sources.push(this.action); - throw e; - } - } - __local(args) { - let tempinc = parseInt(args[0]); - let tempbytes = this.instance.system.tempbytes; - if (isNaN(tempinc)) - throw new ECSError(`bad temporary offset`, this.action); - if (!tempbytes) - throw new ECSError(`this system has no locals`, this.action); - if (tempinc < 0 || tempinc >= tempbytes) - throw new ECSError(`this system only has ${tempbytes} locals`, this.action); - this.scope.updateTempLiveness(this.instance); - return `${this.tmplabel}+${tempinc}`; - } - __arg(args) { - let argindex = parseInt(args[0] || "0"); - let argvalue = this.eventargs[argindex] || ""; - return argvalue; - } - __start(args) { - let startSymbol = this.dialect.scopeSymbol(args[0]); - return this.dialect.jump(startSymbol); - } - generateCodeForField(fieldName, bitofs, canWrite) { - const action = this.action; - const qr = this.scope.state.working; - var component; - var baseLookup = false; - var entityLookup = false; - let entities; - if (fieldName.indexOf(".") > 0) { - let [entname, fname] = fieldName.split("."); - let ent = this.scope.getEntityByName(entname); - if (ent == null) - throw new ECSError(`no entity named "${entname}" in this scope`, action); - component = this.em.singleComponentWithFieldName([ent.etype], fname, action); - fieldName = fname; - entities = [ent]; - entityLookup = true; - } else if (fieldName.indexOf(":") > 0) { - let [cname, fname] = fieldName.split(":"); - component = this.em.getComponentByName(cname); - if (component == null) - throw new ECSError(`no component named "${cname}"`, action); - entities = this.scope.state.working.entities; - fieldName = fname; - baseLookup = true; - } else { - component = this.em.singleComponentWithFieldName(qr.atypes, fieldName, action); - entities = this.scope.state.working.entities; - } - let field = component.fields.find((f) => f.name == fieldName); - if (field == null) - throw new ECSError(`no field named "${fieldName}" in component`, action); - let ident = this.dialect.fieldsymbol(component, field, bitofs); - let constValues = new Set(); - let isConst = false; - for (let e of entities) { - let constVal = e.consts[mksymbol(component, fieldName)]; - if (constVal !== void 0) - isConst = true; - constValues.add(constVal); - } - if (isConst && canWrite) - throw new ECSError(`can't write to constant field ${fieldName}`, action); - if (constValues.size == 1) { - let value = constValues.values().next().value; - if (typeof value === "number") { - return `#${value >> bitofs & 255}`; - } - } - let range = this.scope.getFieldRange(component, field.name); - if (!range) - throw new ECSError(`couldn't find field for ${component.name}:${fieldName}, maybe no entities?`); - if (baseLookup) { - return this.dialect.absolute(ident); - } else if (entities.length == 1) { - let eidofs = entities[0].id - range.elo; - return this.dialect.absolute(ident, eidofs); - } else { - let ir; - let int; - let eidofs; - let xreg = this.scope.state.xreg; - let yreg = this.scope.state.yreg; - if (xreg && (int = xreg.eset?.intersection(qr))) { - ir = xreg.eset; - eidofs = xreg.elo - range.elo; - } else if (yreg && (int = yreg.eset?.intersection(qr))) { - ir = yreg.eset; - eidofs = yreg.elo - range.elo; - } else { - ir = null; - eidofs = 0; - } - if (!ir) { - throw new ECSError(`no intersection for index register`, action); - } - if (ir.entities.length == 0) - throw new ECSError(`no common entities for index register`, action); - if (!ir.isContiguous()) - throw new ECSError(`entities in query are not contiguous`, action); - if (ir == this.scope.state.xreg?.eset) - return this.dialect.indexed_x(ident, eidofs); - if (ir == this.scope.state.yreg?.eset) - return this.dialect.indexed_y(ident, eidofs); - throw new ECSError(`cannot find "${component.name}:${field.name}" in state`, action); - } - } - getJoinField(action, atypes, jtypes) { - let refs = Array.from(this.scope.iterateArchetypeFields(atypes, (c, f) => f.dtype == "ref")); - if (refs.length == 0) - throw new ECSError(`cannot find join fields`, action); - if (refs.length > 1) - throw new ECSError(`cannot join multiple fields (${refs.map((r) => r.f.name).join(" ")})`, action); - return refs[0]; - } - isSubroutineSized(code) { - if (code.length > 2e4) - return false; - if (code.split("\n ").length >= 4) - return true; - return false; - } - exprToCode(expr) { - if (isQueryExpr(expr)) { - return this.queryExprToCode(expr); - } - if (isBlockStmt(expr)) { - return this.blockStmtToCode(expr); - } - if (isInlineCode(expr)) { - return this.evalInlineCode(expr.code); - } - throw new ECSError(`cannot convert expression to code`, expr); - } - evalInlineCode(code) { - let props = this.scope.state.props || {}; - code = this.replaceLabels(code); - code = this.replaceTags(code, this.action, props); - return code; - } - blockStmtToCode(expr) { - return expr.stmts.map((node) => this.exprToCode(node)).join("\n"); - } - queryExprToCode(qexpr) { - let q = this.startQuery(qexpr); - const allowEmpty = ["if", "foreach", "join"]; - if (q.working.entities.length == 0 && allowEmpty.includes(qexpr.select)) { - this.endQuery(q); - return ""; - } else { - this.scope.state.working = q.working; - this.scope.state.props = q.props; - q.code = this.evalInlineCode(q.code); - let body = this.blockStmtToCode(qexpr); - this.endQuery(q); - body = q.code.replace("%%CODE%%", body); - return body; - } - } - queryWorkingSet(qexpr) { - const scope = this.scope; - const instance = this.instance; - let select = qexpr.select; - let q = qexpr.query; - let qr = new EntitySet(scope, q); - if (!(qexpr.all || q.entities)) { - let ir = qr.intersection(scope.state.working); - if (ir.entities.length || select == "if") { - qr = ir; - } - } - if (instance.params.refEntity && instance.params.refField) { - let rf = instance.params.refField; - if (rf.f.dtype == "ref") { - let rq = rf.f.query; - qr = qr.intersection(new EntitySet(scope, rq)); - } - } else if (instance.params.query) { - qr = qr.intersection(new EntitySet(scope, instance.params.query)); - } - return qr; - } - updateIndexRegisters(qr, jr, select) { - const action = this.action; - const scope = this.scope; - const instance = this.instance; - const state = this.scope.state; - if (qr.entities.length > 1) { - switch (select) { - case "once": - break; - case "foreach": - case "unroll": - if (state.xreg && state.yreg) - throw new ECSError("no more index registers", action); - if (state.xreg) - state.yreg = new IndexRegister(scope, qr); - else - state.xreg = new IndexRegister(scope, qr); - break; - case "join": - if (state.xreg || state.yreg) - throw new ECSError("no free index registers for join", action); - if (jr) - state.xreg = new IndexRegister(scope, jr); - state.yreg = new IndexRegister(scope, qr); - break; - case "if": - case "with": - if (state.xreg && state.xreg.eset) { - state.xreg = state.xreg.narrow(qr, action); - } else if (select == "with") { - if (instance.params.refEntity && instance.params.refField) { - if (state.xreg) - state.xreg.eset = qr; - else - state.xreg = new IndexRegister(scope, qr); - } - } - break; - } - } - } - getCodeAndProps(qexpr, qr, jr, oldState) { - const entities = qr.entities; - const select = qexpr.select; - let code = "%%CODE%%"; - let props = {}; - if (select == "join" && jr) { - if (qr.entities.length) { - let joinfield = this.getJoinField(this.action, qr.atypes, jr.atypes); - code = this.wrapCodeInLoop(code, qexpr, qr.entities, joinfield); - props["%joinfield"] = this.dialect.fieldsymbol(joinfield.c, joinfield.f, 0); - } - } - let fullEntityCount = qr.entities.length; - if (select == "with") { - if (this.instance.params.refEntity && this.instance.params.refField) { - let re = this.instance.params.refEntity; - let rf = this.instance.params.refField; - code = this.wrapCodeInRefLookup(code); - let range = this.scope.getFieldRange(rf.c, rf.f.name); - let eidofs = re.id - range.elo; - props["%reffield"] = `${this.dialect.fieldsymbol(rf.c, rf.f, 0)}+${eidofs}`; - } else { - code = this.wrapCodeInFilter(code, qr, oldState, props); - } - } - if (select == "if") { - code = this.wrapCodeInFilter(code, qr, oldState, props); - } - if (select == "foreach" && entities.length > 1) { - code = this.wrapCodeInLoop(code, qexpr, qr.entities); - } - if (select == "unroll" && entities.length > 1) { - throw new ECSError("unroll is not yet implemented"); - } - if (entities.length) { - props["%elo"] = entities[0].id.toString(); - props["%ehi"] = entities[entities.length - 1].id.toString(); - } - props["%ecount"] = entities.length.toString(); - props["%efullcount"] = fullEntityCount.toString(); - return { code, props }; - } - startQuery(qexpr) { - const scope = this.scope; - const action = this.action; - const select = qexpr.select; - const oldState = this.scope.state; - this.scope.state = Object.assign(new ActionCPUState(), oldState); - const qr = this.queryWorkingSet(qexpr); - const jr = qexpr.join && qr.entities.length ? new EntitySet(scope, qexpr.join) : null; - this.updateIndexRegisters(qr, jr, select); - const { code, props } = this.getCodeAndProps(qexpr, qr, jr, oldState); - let working = jr ? qr.union(jr) : qr; - return { working, oldState, props, code }; - } - endQuery(q) { - this.scope.state = q.oldState; - } - wrapCodeInLoop(code, qexpr, ents, joinfield) { - let dir = qexpr.direction; - let s = dir == "desc" ? this.dialect.ASM_ITERATE_EACH_DESC : this.dialect.ASM_ITERATE_EACH_ASC; - if (joinfield) - s = dir == "desc" ? this.dialect.ASM_ITERATE_JOIN_DESC : this.dialect.ASM_ITERATE_JOIN_ASC; - s = s.replace("{{%code}}", code); - return s; - } - wrapCodeInFilter(code, qr, oldState, props) { - const ents = qr.entities; - const ents2 = oldState.xreg?.eset?.entities; - if (ents && ents.length && ents2) { - let lo = ents[0].id; - let hi = ents[ents.length - 1].id; - let lo2 = ents2[0].id; - let hi2 = ents2[ents2.length - 1].id; - if (lo != lo2) { - code = this.dialect.ASM_FILTER_RANGE_LO_X.replace("{{%code}}", code); - props["%xofs"] = lo - lo2; - } - if (hi != hi2) { - code = this.dialect.ASM_FILTER_RANGE_HI_X.replace("{{%code}}", code); - } - } - return code; - } - wrapCodeInRefLookup(code) { - code = this.dialect.ASM_LOOKUP_REF_X.replace("{{%code}}", code); - return code; - } -}; -var EventCodeStats = class { - constructor(inst, action, eventcode) { - this.inst = inst; - this.action = action; - this.eventcode = eventcode; - this.labels = []; - this.count = 0; - } -}; -var EntityScope = class { - constructor(em, dialect, name, parent) { - this.em = em; - this.dialect = dialect; - this.name = name; - this.parent = parent; - this.childScopes = []; - this.instances = []; - this.entities = []; - this.fieldtypes = {}; - this.sysstats = new Map(); - this.bss = new UninitDataSegment(); - this.rodata = new ConstDataSegment(); - this.code = new CodeSegment(); - this.componentsInScope = new Set(); - this.resources = new Set(); - this.isDemo = false; - this.filePath = ""; - this.inCritical = 0; - parent?.childScopes.push(this); - this.state = new ActionCPUState(); - this.state.working = new EntitySet(this, void 0, this.entities); - } - newEntity(etype, name) { - if (name && this.getEntityByName(name)) - throw new ECSError(`already an entity named "${name}"`); - let id = this.entities.length; - etype = this.em.addArchetype(etype); - let entity = { id, etype, consts: {}, inits: {} }; - for (let c of etype.components) { - this.componentsInScope.add(c.name); - } - entity.name = name; - this.entities.push(entity); - return entity; - } - newSystemInstance(inst) { - if (!inst) - throw new Error(); - inst.id = this.instances.length + 1; - this.instances.push(inst); - this.em.registerSystemEvents(inst.system); - return inst; - } - newSystemInstanceWithDefaults(system) { - return this.newSystemInstance({ system, params: {}, id: 0 }); - } - getSystemInstanceNamed(name) { - return this.instances.find((sys) => sys.system.name == name); - } - getEntityByName(name) { - return this.entities.find((e) => e.name == name); - } - *iterateEntityFields(entities) { - for (let i = 0; i < entities.length; i++) { - let e = entities[i]; - for (let c of e.etype.components) { - for (let f of c.fields) { - yield { i, e, c, f, v: e.consts[mksymbol(c, f.name)] }; - } - } - } - } - *iterateArchetypeFields(arch, filter) { - for (let i = 0; i < arch.length; i++) { - let a = arch[i]; - for (let c of a.components) { - for (let f of c.fields) { - if (!filter || filter(c, f)) - yield { i, c, f }; - } - } - } - } - *iterateChildScopes() { - for (let scope of this.childScopes) { - yield scope; - } - } - entitiesMatching(atypes) { - let result = []; - for (let e of this.entities) { - for (let a of atypes) { - if (e.etype === a) { - result.push(e); - break; - } - } - } - return result; - } - hasComponent(ctype) { - return this.componentsInScope.has(ctype.name); - } - buildSegments() { - let iter = this.iterateEntityFields(this.entities); - for (var o = iter.next(); o.value; o = iter.next()) { - let { i, e, c, f, v } = o.value; - let cfname = mksymbol(c, f.name); - let ftype = this.fieldtypes[cfname]; - let isConst = ftype == "const"; - let segment = isConst ? this.rodata : this.bss; - if (v === void 0 && isConst) - throw new ECSError(`no value for const field ${cfname}`, e); - let array = segment.fieldranges[cfname]; - if (!array) { - array = segment.fieldranges[cfname] = { component: c, field: f, elo: i, ehi: i }; - } else { - array.ehi = i; - if (array.ehi - array.elo + 1 >= 256) - throw new ECSError(`too many entities have field ${cfname}, limit is 256`); - } - if (!isConst) { - if (f.dtype == "int" && f.defvalue !== void 0) { - let ecfname = mkscopesymbol(this, c, f.name); - if (e.inits[ecfname] == null) { - this.setInitValue(e, c, f, f.defvalue); - } - } - } - } - } - allocateSegment(segment, alloc, type) { - let fields = Object.values(segment.fieldranges); - for (let f of fields) { - if (this.fieldtypes[mksymbol(f.component, f.field.name)] == type) { - let rangelen = f.ehi - f.elo + 1; - let bits = getPackedFieldSize(f.field); - if (bits == 0) - bits = 16; - let bytesperelem = Math.ceil(bits / 8); - let access = []; - for (let i = 0; i < bits; i += 8) { - let symbol = this.dialect.fieldsymbol(f.component, f.field, i); - access.push({ symbol, bit: i, width: 8 }); - if (alloc) { - segment.allocateBytes(symbol, rangelen); - } - } - f.access = access; - } - } - } - allocateROData(segment) { - let iter = this.iterateEntityFields(this.entities); - for (var o = iter.next(); o.value; o = iter.next()) { - let { i, e, c, f, v } = o.value; - let cfname = mksymbol(c, f.name); - if (this.fieldtypes[cfname] == "const") { - let range = segment.fieldranges[cfname]; - let entcount = range ? range.ehi - range.elo + 1 : 0; - if (v == null && f.dtype == "int") - v = 0; - if (v == null && f.dtype == "ref") - v = 0; - if (v == null && f.dtype == "array") - throw new ECSError(`no default value for array ${cfname}`, e); - if (v instanceof Uint8Array && f.dtype == "array") { - let ptrlosym = this.dialect.fieldsymbol(c, f, 0); - let ptrhisym = this.dialect.fieldsymbol(c, f, 8); - let loofs = segment.allocateBytes(ptrlosym, entcount); - let hiofs = segment.allocateBytes(ptrhisym, entcount); - let datasym = this.dialect.datasymbol(c, f, e.id, 0); - segment.allocateInitData(datasym, v); - if (f.baseoffset) - datasym = `(${datasym}+${f.baseoffset})`; - segment.initdata[loofs + e.id - range.elo] = { symbol: datasym, bitofs: 0 }; - segment.initdata[hiofs + e.id - range.elo] = { symbol: datasym, bitofs: 8 }; - } else if (typeof v === "number") { - { - if (!range.access) - throw new ECSError(`no access for field ${cfname}`); - for (let a of range.access) { - segment.allocateBytes(a.symbol, entcount); - let ofs = segment.getByteOffset(range, a, e.id); - if (e.id < range.elo) - throw new ECSError("entity out of range " + c.name + " " + f.name, e); - if (segment.initdata[ofs] !== void 0) - throw new ECSError("initdata already set " + ofs), e; - segment.initdata[ofs] = v >> a.bit & 255; - } - } - } else if (v == null && f.dtype == "array" && f.index) { - let datasym = this.dialect.datasymbol(c, f, e.id, 0); - let databytes = getFieldLength(f.index); - let offset = this.bss.allocateBytes(datasym, databytes); - let ptrlosym = this.dialect.fieldsymbol(c, f, 0); - let ptrhisym = this.dialect.fieldsymbol(c, f, 8); - let loofs = segment.allocateBytes(ptrlosym, entcount); - let hiofs = segment.allocateBytes(ptrhisym, entcount); - if (f.baseoffset) - datasym = `(${datasym}+${f.baseoffset})`; - segment.initdata[loofs + e.id - range.elo] = { symbol: datasym, bitofs: 0 }; - segment.initdata[hiofs + e.id - range.elo] = { symbol: datasym, bitofs: 8 }; - } else { - throw new ECSError(`unhandled constant ${e.id}:${cfname} -- ${typeof v}`); - } - } - } - } - allocateInitData(segment) { - if (segment.size == 0) - return ""; - let initbytes = new Uint8Array(segment.size); - let iter = this.iterateEntityFields(this.entities); - for (var o = iter.next(); o.value; o = iter.next()) { - let { i, e, c, f, v } = o.value; - let scfname = mkscopesymbol(this, c, f.name); - let initvalue = e.inits[scfname]; - if (initvalue !== void 0) { - let range = segment.getFieldRange(c, f.name); - if (!range) - throw new ECSError(`no init range for ${scfname}`, e); - if (!range.access) - throw new ECSError(`no init range access for ${scfname}`, e); - if (typeof initvalue === "number") { - for (let a of range.access) { - let offset = segment.getByteOffset(range, a, e.id); - initbytes[offset] = initvalue >> a.bit & (1 << a.width) - 1; - } - } else if (initvalue instanceof Uint8Array) { - let datasym = this.dialect.datasymbol(c, f, e.id, 0); - let ofs = this.bss.symbols[datasym]; - initbytes.set(initvalue, ofs); - } else { - throw new ECSError(`cannot initialize ${scfname} = ${initvalue}`); - } - } - } - let bufsym = this.name + "__INITDATA"; - let bufofs = this.rodata.allocateInitData(bufsym, initbytes); - let code = this.dialect.INIT_FROM_ARRAY; - code = code.replace("{{%nbytes}}", initbytes.length.toString()); - code = code.replace("{{%src}}", bufsym); - code = code.replace("{{%dest}}", segment.getOriginSymbol()); - return code; - } - getFieldRange(c, fn) { - return this.bss.getFieldRange(c, fn) || this.rodata.getFieldRange(c, fn); - } - setConstValue(e, component, field, value) { - this.setConstInitValue(e, component, field, value, "const"); - } - setInitValue(e, component, field, value) { - this.setConstInitValue(e, component, field, value, "init"); - } - setConstInitValue(e, component, field, value, type) { - this.checkFieldValue(field, value); - let fieldName = field.name; - let cfname = mksymbol(component, fieldName); - let ecfname = mkscopesymbol(this, component, fieldName); - if (e.consts[cfname] !== void 0) - throw new ECSError(`"${fieldName}" is already defined as a constant`, e); - if (e.inits[ecfname] !== void 0) - throw new ECSError(`"${fieldName}" is already defined as a variable`, e); - if (type == "const") - e.consts[cfname] = value; - if (type == "init") - e.inits[ecfname] = value; - this.fieldtypes[cfname] = type; - } - isConstOrInit(component, fieldName) { - return this.fieldtypes[mksymbol(component, fieldName)]; - } - getConstValue(entity, fieldName) { - let component = this.em.singleComponentWithFieldName([entity.etype], fieldName, entity); - let cfname = mksymbol(component, fieldName); - return entity.consts[cfname]; - } - checkFieldValue(field, value) { - if (field.dtype == "array") { - if (!(value instanceof Uint8Array)) - throw new ECSError(`This "${field.name}" value should be an array.`); - } else if (typeof value !== "number") { - throw new ECSError(`This "${field.name}" ${field.dtype} value should be an number.`); - } else { - if (field.dtype == "int") { - if (value < field.lo || value > field.hi) - throw new ECSError(`This "${field.name}" value is out of range, should be between ${field.lo} and ${field.hi}.`); - } else if (field.dtype == "ref") { - let eset = new EntitySet(this, field.query); - if (value < 0 || value >= eset.entities.length) - throw new ECSError(`This "${field.name}" value is out of range for this ref type.`); - } - } - } - generateCodeForEvent(event, args, codelabel) { - let systems = this.em.event2systems[event]; - if (!systems || systems.length == 0) { - console.log(`warning: no system responds to "${event}"`); - return ""; - } - this.eventSeq++; - let code = ""; - if (codelabel) { - code += this.dialect.label(codelabel) + "\n"; - } - if (event == "start") { - code += this.allocateInitData(this.bss); - } - let eventCount = 0; - let instances = this.instances.filter((inst) => systems.includes(inst.system)); - for (let inst of instances) { - let sys = inst.system; - for (let action of sys.actions) { - if (action.event == event) { - eventCount++; - let codeeval = new ActionEval(this, inst, action, args || []); - codeeval.begin(); - if (action.critical) - this.inCritical++; - let eventcode = codeeval.codeToString(); - if (action.critical) - this.inCritical--; - if (!this.inCritical && codeeval.isSubroutineSized(eventcode)) { - let normcode = this.normalizeCode(eventcode, action); - let estats = this.eventCodeStats[normcode]; - if (!estats) { - estats = this.eventCodeStats[normcode] = new EventCodeStats(inst, action, eventcode); - } - estats.labels.push(codeeval.label); - estats.count++; - if (action.critical) - estats.count++; - } - let s = ""; - s += this.dialect.comment(`start action ${codeeval.label}`); - s += eventcode; - s += this.dialect.comment(`end action ${codeeval.label}`); - code += s; - codeeval.end(); - } - } - } - if (eventCount == 0) { - console.log(`warning: event ${event} not handled`); - } - return code; - } - normalizeCode(code, action) { - code = code.replace(/\b(\w+__\w+__)(\d+)__(\w+)\b/g, (z, a, b, c) => a + c); - return code; - } - getSystemStats(inst) { - let stats = this.sysstats.get(inst); - if (!stats) { - stats = new SystemStats(); - this.sysstats.set(inst, stats); - } - return stats; - } - updateTempLiveness(inst) { - let stats = this.getSystemStats(inst); - let n = this.eventSeq; - if (stats.tempstartseq && stats.tempendseq) { - stats.tempstartseq = Math.min(stats.tempstartseq, n); - stats.tempendseq = Math.max(stats.tempendseq, n); - } else { - stats.tempstartseq = stats.tempendseq = n; - } - } - includeResource(symbol) { - this.resources.add(symbol); - return symbol; - } - allocateTempVars() { - let pack = new Packer(); - let maxTempBytes = 128 - this.bss.size; - let bssbin = new Bin({ left: 0, top: 0, bottom: this.eventSeq + 1, right: maxTempBytes }); - pack.bins.push(bssbin); - for (let instance of this.instances) { - let stats = this.getSystemStats(instance); - if (instance.system.tempbytes && stats.tempstartseq && stats.tempendseq) { - let v = { - inst: instance, - top: stats.tempstartseq, - bottom: stats.tempendseq + 1, - width: instance.system.tempbytes, - height: stats.tempendseq - stats.tempstartseq + 1, - label: instance.system.name - }; - pack.boxes.push(v); - } - } - if (!pack.pack()) - console.log("cannot pack temporary local vars"); - if (bssbin.extents.right > 0) { - let tempofs = this.bss.allocateBytes("TEMP", bssbin.extents.right); - for (let b of pack.boxes) { - let inst = b.inst; - if (b.box) - this.bss.declareSymbol(this.dialect.tempLabel(inst), tempofs + b.box.left); - } - } - console.log(pack.toSVGUrl()); - } - analyzeEntities() { - this.buildSegments(); - this.allocateSegment(this.bss, true, "init"); - this.allocateSegment(this.bss, true, void 0); - this.allocateSegment(this.rodata, false, "const"); - this.allocateROData(this.rodata); - } - isMainScope() { - return this.parent == null; - } - generateCode() { - this.eventSeq = 0; - this.eventCodeStats = {}; - let start; - let initsys = this.em.getSystemByName("Init"); - if (this.isMainScope() && initsys) { - this.newSystemInstanceWithDefaults(initsys); - start = this.generateCodeForEvent("main_init"); - } else { - start = this.generateCodeForEvent("start"); - } - start = this.replaceSubroutines(start); - this.code.addCodeFragment(start); - for (let sub of Array.from(this.resources.values())) { - if (!this.getSystemInstanceNamed(sub)) { - let sys = this.em.getSystemByName(sub); - if (!sys) - throw new ECSError(`cannot find resource named "${sub}"`); - this.newSystemInstanceWithDefaults(sys); - } - let code = this.generateCodeForEvent(sub, [], sub); - this.code.addCodeFragment(code); - } - } - replaceSubroutines(code) { - let allsubs = []; - for (let stats of Object.values(this.eventCodeStats)) { - if (stats.count > 1) { - if (allsubs.length == 0) { - allsubs = [ - this.dialect.segment("rodata"), - this.dialect.alignSegmentStart() - ]; - } else if (stats.action.fitbytes) { - allsubs.push(this.dialect.alignIfLessThan(stats.action.fitbytes)); - } - let subcall = this.dialect.call(stats.labels[0]); - for (let label of stats.labels) { - let startdelim = this.dialect.comment(`start action ${label}`).trim(); - let enddelim = this.dialect.comment(`end action ${label}`).trim(); - let istart = code.indexOf(startdelim); - let iend = code.indexOf(enddelim, istart); - if (istart >= 0 && iend > istart) { - code = code.substring(0, istart) + subcall + code.substring(iend + enddelim.length); - } - } - let substart = stats.labels[0]; - let sublines = [ - this.dialect.segment("rodata"), - this.dialect.label(substart), - stats.eventcode, - this.dialect.return() - ]; - if (stats.action.critical) { - sublines.push(this.dialect.warningIfPageCrossed(substart)); - } - if (stats.action.fitbytes) { - sublines.push(this.dialect.warningIfMoreThan(stats.action.fitbytes, substart)); - } - allsubs = allsubs.concat(sublines); - } - } - code += allsubs.join("\n"); - return code; - } - showStats() { - for (let inst of this.instances) { - console.log(inst.system.name, this.getSystemStats(inst)); - } - } - dumpCodeTo(file) { - let shouldExport = this.instances.length == 0; - let dialect = this.dialect; - file.line(dialect.startScope(this.name)); - file.line(dialect.segment("bss")); - this.bss.dump(file, dialect, shouldExport); - file.line(dialect.segment("code")); - this.rodata.dump(file, dialect, shouldExport); - file.line(dialect.label("__Start")); - this.code.dump(file); - for (let subscope of this.childScopes) { - subscope.dump(file); - } - file.line(dialect.endScope(this.name)); - } - dump(file) { - this.analyzeEntities(); - this.generateCode(); - this.allocateTempVars(); - this.dumpCodeTo(file); - } -}; -var EntityManager = class { - constructor(dialect) { - this.dialect = dialect; - this.archetypes = {}; - this.components = {}; - this.systems = {}; - this.topScopes = {}; - this.event2systems = {}; - this.name2cfpairs = {}; - this.mainPath = ""; - this.imported = {}; - this.seq = 1; - } - newScope(name, parent) { - let existing = this.topScopes[name]; - if (existing && !existing.isDemo) - throw new ECSError(`scope ${name} already defined`, existing); - let scope = new EntityScope(this, this.dialect, name, parent); - if (!parent) - this.topScopes[name] = scope; - return scope; - } - deferComponent(name) { - this.components[name] = { name, fields: [] }; - } - defineComponent(ctype) { - let existing = this.components[ctype.name]; - if (existing && existing.fields.length > 0) - throw new ECSError(`component ${ctype.name} already defined`, existing); - if (existing) { - existing.fields = ctype.fields; - ctype = existing; - } - for (let field of ctype.fields) { - let list = this.name2cfpairs[field.name]; - if (!list) - list = this.name2cfpairs[field.name] = []; - list.push({ c: ctype, f: field }); - } - this.components[ctype.name] = ctype; - return ctype; - } - defineSystem(system) { - let existing = this.systems[system.name]; - if (existing) - throw new ECSError(`system ${system.name} already defined`, existing); - return this.systems[system.name] = system; - } - registerSystemEvents(system) { - for (let a of system.actions) { - let event = a.event; - let list = this.event2systems[event]; - if (list == null) - list = this.event2systems[event] = []; - if (!list.includes(system)) - list.push(system); - } - } - addArchetype(atype) { - let key = atype.components.map((c) => c.name).join(","); - if (this.archetypes[key]) - return this.archetypes[key]; - else - return this.archetypes[key] = atype; - } - componentsMatching(q, etype) { - let list = []; - for (let c of etype.components) { - if (q.exclude?.includes(c)) { - return []; - } - if (q.include.length == 0 || q.include.includes(c)) { - list.push(c); - } - } - return list.length == q.include.length ? list : []; - } - archetypesMatching(q) { - let result = new Set(); - for (let etype of Object.values(this.archetypes)) { - let cmatch = this.componentsMatching(q, etype); - if (cmatch.length > 0) { - result.add(etype); - } - } - return Array.from(result.values()); - } - componentsWithFieldName(atypes, fieldName) { - let comps = new Set(); - for (let at of atypes) { - for (let c of at.components) { - for (let f of c.fields) { - if (f.name == fieldName) - comps.add(c); - } - } - } - return Array.from(comps); - } - getComponentByName(name) { - return this.components[name]; - } - getSystemByName(name) { - return this.systems[name]; - } - singleComponentWithFieldName(atypes, fieldName, where) { - let cfpairs = this.name2cfpairs[fieldName]; - if (!cfpairs) - throw new ECSError(`cannot find field named "${fieldName}"`, where); - let filtered = cfpairs.filter((cf) => atypes.find((a) => a.components.includes(cf.c))); - if (filtered.length == 0) { - throw new ECSError(`cannot find component with field "${fieldName}" in this context`, where); - } - if (filtered.length > 1) { - throw new ECSError(`ambiguous field name "${fieldName}"`, where); - } - return filtered[0].c; - } - toJSON() { - return JSON.stringify({ - components: this.components, - systems: this.systems - }); - } - exportToFile(file) { - for (let event of Object.keys(this.event2systems)) { - file.line(this.dialect.equate(`EVENT__${event}`, "1")); - } - for (let scope of Object.values(this.topScopes)) { - if (!scope.isDemo || scope.filePath == this.mainPath) { - scope.dump(file); - } - } - } - *iterateScopes() { - for (let scope of Object.values(this.topScopes)) { - yield scope; - scope.iterateChildScopes(); - } - } - getDebugTree() { - let scopes = this.topScopes; - let components = this.components; - let fields = this.name2cfpairs; - let systems = this.systems; - let events = this.event2systems; - let entities = {}; - for (let scope of Array.from(this.iterateScopes())) { - for (let e of scope.entities) - entities[e.name || "#" + e.id.toString()] = e; - } - return { scopes, components, fields, systems, events, entities }; - } - evalExpr(expr, scope) { - if (isLiteral2(expr)) - return expr; - if (isBinOp2(expr) || isUnOp2(expr)) { - var fn = this["evalop__" + expr.op]; - if (!fn) - throw new ECSError(`no eval function for "${expr.op}"`); - } - if (isBinOp2(expr)) { - expr.left = this.evalExpr(expr.left, scope); - expr.right = this.evalExpr(expr.right, scope); - let e = fn(expr.left, expr.right); - return e || expr; - } - if (isUnOp2(expr)) { - expr.expr = this.evalExpr(expr.expr, scope); - let e = fn(expr.expr); - return e || expr; - } - return expr; - } - evalop__neg(arg) { - if (isLiteralInt(arg)) { - let valtype = { - dtype: "int", - lo: -arg.valtype.hi, - hi: arg.valtype.hi - }; - return { valtype, value: -arg.value }; - } - } - evalop__add(left, right) { - if (isLiteralInt(left) && isLiteralInt(right)) { - let valtype = { - dtype: "int", - lo: left.valtype.lo + right.valtype.lo, - hi: left.valtype.hi + right.valtype.hi - }; - return { valtype, value: left.value + right.value }; - } - } - evalop__sub(left, right) { - if (isLiteralInt(left) && isLiteralInt(right)) { - let valtype = { - dtype: "int", - lo: left.valtype.lo - right.valtype.hi, - hi: left.valtype.hi - right.valtype.lo - }; - return { valtype, value: left.value - right.value }; - } - } -}; - -// src/common/ecs/decoder.ts -var LineDecoder = class { - constructor(text) { - this.curline = 0; - this.lines = text.split("\n").map((s) => s.trim()).filter((s) => !!s).map((s) => s.split(/\s+/)); - } - decodeBits(s, n, msbfirst) { - if (s.length != n) - throw new ECSError(`Expected ${n} characters`); - let b = 0; - for (let i = 0; i < n; i++) { - let bit; - let ch = s.charAt(i); - if (ch == "x" || ch == "X" || ch == "1") - bit = 1; - else if (ch == "." || ch == "0") - bit = 0; - else - throw new ECSError("need x or . (or 0 or 1)"); - if (bit) { - if (msbfirst) - b |= 1 << n - 1 - i; - else - b |= 1 << i; - } - } - return b; - } - assertTokens(toks, count) { - if (toks.length != count) - throw new ECSError(`Expected ${count} tokens on line.`); - } - hex(s) { - let v = parseInt(s, 16); - if (isNaN(v)) - throw new ECSError(`Invalid hex value: ${s}`); - return v; - } - getErrorLocation($loc) { - $loc.line += this.curline + 1; - return $loc; - } -}; -var VCSSpriteDecoder = class extends LineDecoder { - parse() { - let height = this.lines.length; - let bitmapdata = new Uint8Array(height); - let colormapdata = new Uint8Array(height); - for (let i = 0; i < height; i++) { - this.curline = height - 1 - i; - let toks = this.lines[this.curline]; - this.assertTokens(toks, 2); - bitmapdata[i] = this.decodeBits(toks[0], 8, true); - colormapdata[i] = this.hex(toks[1]); - } - return { - properties: { - bitmapdata, - colormapdata, - height: height - 1 - } - }; - } -}; -var VCSBitmapDecoder = class extends LineDecoder { - parse() { - let height = this.lines.length; - let bitmapdata = new Uint8Array(height); - for (let i = 0; i < height; i++) { - this.curline = height - 1 - i; - let toks = this.lines[this.curline]; - this.assertTokens(toks, 1); - bitmapdata[i] = this.decodeBits(toks[0], 8, true); - } - return { - properties: { - bitmapdata, - height: height - 1 - } - }; - } -}; -var VCSPlayfieldDecoder = class extends LineDecoder { - parse() { - let height = this.lines.length; - let pf = new Uint32Array(height); - for (let i = 0; i < height; i++) { - this.curline = height - 1 - i; - let toks = this.lines[this.curline]; - this.assertTokens(toks, 1); - let pf0 = this.decodeBits(toks[0].substring(0, 4), 4, false) << 4; - let pf1 = this.decodeBits(toks[0].substring(4, 12), 8, true); - let pf2 = this.decodeBits(toks[0].substring(12, 20), 8, false); - pf[i] = pf0 << 0 | pf1 << 8 | pf2 << 16; - } - return { - properties: { - pf - } - }; - } -}; -var VCSVersatilePlayfieldDecoder = class extends LineDecoder { - parse() { - let height = this.lines.length; - let data = new Uint8Array(height * 2); - data.fill(63); - const regs = [13, 14, 15, 8, 9, 10, 63]; - let prev = [0, 0, 0, 0, 0, 0, 0]; - let cur = [0, 0, 0, 0, 0, 0, 0]; - for (let i = 0; i < height; i++) { - let dataofs = height * 2 - i * 2; - this.curline = i; - let toks = this.lines[this.curline]; - if (toks.length == 2) { - data[dataofs - 1] = this.hex(toks[0]); - data[dataofs - 2] = this.hex(toks[1]); - continue; - } - this.assertTokens(toks, 4); - cur[0] = this.decodeBits(toks[0].substring(0, 4), 4, false) << 4; - cur[1] = this.decodeBits(toks[0].substring(4, 12), 8, true); - cur[2] = this.decodeBits(toks[0].substring(12, 20), 8, false); - if (toks[1] != "..") - cur[3] = this.hex(toks[1]); - if (toks[2] != "..") - cur[4] = this.hex(toks[2]); - if (toks[3] != "..") - cur[5] = this.hex(toks[3]); - let changed = []; - for (let j = 0; j < cur.length; j++) { - if (cur[j] != prev[j]) - changed.push(j); - } - if (changed.length > 1) { - console.log(changed, cur, prev); - throw new ECSError(`More than one register change in line ${i + 1}: [${changed}]`); - } - let chgidx = changed.length ? changed[0] : regs.length - 1; - data[dataofs - 1] = regs[chgidx]; - data[dataofs - 2] = cur[chgidx]; - prev[chgidx] = cur[chgidx]; - } - return { - properties: { - data - } - }; - } -}; -var VCSBitmap48Decoder = class extends LineDecoder { - parse() { - let height = this.lines.length; - let bitmap0 = new Uint8Array(height); - let bitmap1 = new Uint8Array(height); - let bitmap2 = new Uint8Array(height); - let bitmap3 = new Uint8Array(height); - let bitmap4 = new Uint8Array(height); - let bitmap5 = new Uint8Array(height); - for (let i = 0; i < height; i++) { - this.curline = height - 1 - i; - let toks = this.lines[this.curline]; - this.assertTokens(toks, 1); - bitmap0[i] = this.decodeBits(toks[0].slice(0, 8), 8, true); - bitmap1[i] = this.decodeBits(toks[0].slice(8, 16), 8, true); - bitmap2[i] = this.decodeBits(toks[0].slice(16, 24), 8, true); - bitmap3[i] = this.decodeBits(toks[0].slice(24, 32), 8, true); - bitmap4[i] = this.decodeBits(toks[0].slice(32, 40), 8, true); - bitmap5[i] = this.decodeBits(toks[0].slice(40, 48), 8, true); - } - return { - properties: { - bitmap0, - bitmap1, - bitmap2, - bitmap3, - bitmap4, - bitmap5, - height: height - 1 - } - }; - } -}; -function newDecoder(name, text) { - let cons = DECODERS[name]; - if (cons) - return new cons(text); -} -var DECODERS = { - "vcs_sprite": VCSSpriteDecoder, - "vcs_bitmap": VCSBitmapDecoder, - "vcs_playfield": VCSPlayfieldDecoder, - "vcs_versatile": VCSVersatilePlayfieldDecoder, - "vcs_bitmap48": VCSBitmap48Decoder -}; - -// src/common/ecs/compiler.ts -var ECSTokenType; -(function(ECSTokenType2) { - ECSTokenType2["Ellipsis"] = "ellipsis"; - ECSTokenType2["Operator"] = "operator"; - ECSTokenType2["Relational"] = "relational"; - ECSTokenType2["QuotedString"] = "quoted-string"; - ECSTokenType2["Integer"] = "integer"; - ECSTokenType2["CodeFragment"] = "code-fragment"; - ECSTokenType2["Placeholder"] = "placeholder"; -})(ECSTokenType || (ECSTokenType = {})); -var OPERATORS2 = { - "IMP": { f: "bimp", p: 4 }, - "EQV": { f: "beqv", p: 5 }, - "XOR": { f: "bxor", p: 6 }, - "OR": { f: "bor", p: 7 }, - "AND": { f: "band", p: 8 }, - "||": { f: "lor", p: 17 }, - "&&": { f: "land", p: 18 }, - "=": { f: "eq", p: 50 }, - "==": { f: "eq", p: 50 }, - "<>": { f: "ne", p: 50 }, - "><": { f: "ne", p: 50 }, - "!=": { f: "ne", p: 50 }, - "#": { f: "ne", p: 50 }, - "<": { f: "lt", p: 50 }, - ">": { f: "gt", p: 50 }, - "<=": { f: "le", p: 50 }, - ">=": { f: "ge", p: 50 }, - "MIN": { f: "min", p: 75 }, - "MAX": { f: "max", p: 75 }, - "+": { f: "add", p: 100 }, - "-": { f: "sub", p: 100 } -}; -function getOperator2(op) { - return OPERATORS2[op]; -} -function getPrecedence2(tok) { - switch (tok.type) { - case ECSTokenType.Operator: - case ECSTokenType.Relational: - case TokenType2.Ident: - let op = getOperator2(tok.str); - if (op) - return op.p; - } - return -1; -} -var ECSCompiler = class extends Tokenizer { - constructor(em, isMainFile) { - super(); - this.em = em; - this.isMainFile = isMainFile; - this.currentScope = null; - this.currentContext = null; - this.includeDebugInfo = false; - this.setTokenRules([ - { type: ECSTokenType.Ellipsis, regex: /\.\./ }, - { type: ECSTokenType.QuotedString, regex: /".*?"/ }, - { type: ECSTokenType.CodeFragment, regex: /---.*?---/ }, - { type: ECSTokenType.Integer, regex: /0[xX][A-Fa-f0-9]+/ }, - { type: ECSTokenType.Integer, regex: /\$[A-Fa-f0-9]+/ }, - { type: ECSTokenType.Integer, regex: /[%][01]+/ }, - { type: ECSTokenType.Integer, regex: /\d+/ }, - { type: ECSTokenType.Relational, regex: /[=<>][=<>]?/ }, - { type: ECSTokenType.Operator, regex: /[.#,:(){}\[\]\-\+]/ }, - { type: TokenType2.Ident, regex: /[A-Za-z_][A-Za-z0-9_]*/ }, - { type: TokenType2.Ignore, regex: /\/\/.*?[\n\r]/ }, - { type: TokenType2.Ignore, regex: /\/\*.*?\*\// }, - { type: TokenType2.EOL, regex: /[\n\r]+/ }, - { type: TokenType2.Ignore, regex: /\s+/ } - ]); - this.errorOnCatchAll = true; - } - annotate(fn) { - let start = this.peekToken(); - let obj = fn(); - let end = this.lasttoken; - let $loc = end ? mergeLocs2(start.$loc, end.$loc) : start.$loc; - if (obj) - obj.$loc = $loc; - return obj; - } - parseFile(text, path4) { - this.tokenizeFile(text, path4); - while (!this.isEOF()) { - let top = this.parseTopLevel(); - if (top) { - let t = top; - this.annotate(() => t); - } - } - this.runDeferred(); - } - importFile(path4) { - if (!this.em.imported[path4]) { - let text = this.getImportFile && this.getImportFile(path4); - if (!text) - this.compileError(`I can't find the import file "${path4}".`); - this.em.imported[path4] = true; - let comp = new ECSCompiler(this.em, false); - comp.includeDebugInfo = this.includeDebugInfo; - try { - comp.parseFile(text, path4); - } catch (e) { - for (var err of comp.errors) - this.errors.push(err); - throw e; - } - } - } - parseTopLevel() { - let tok = this.expectTokens(["component", "system", "scope", "resource", "import", "demo", "comment"]); - if (tok.str == "component") { - return this.em.defineComponent(this.parseComponentDefinition()); - } - if (tok.str == "system") { - return this.em.defineSystem(this.parseSystem()); - } - if (tok.str == "scope") { - return this.parseScope(); - } - if (tok.str == "resource") { - return this.em.defineSystem(this.parseResource()); - } - if (tok.str == "import") { - let tok2 = this.expectTokenTypes([ECSTokenType.QuotedString]); - let path4 = tok2.str.substring(1, tok2.str.length - 1); - return this.importFile(path4); - } - if (tok.str == "demo") { - if (this.isMainFile) { - let scope = this.parseScope(); - scope.isDemo = true; - this.expectToken("demo"); - return scope; - } else { - this.skipDemo(); - return; - } - } - if (tok.str == "comment") { - this.expectTokenTypes([ECSTokenType.CodeFragment]); - return; - } - this.compileError(`Unexpected top-level keyword: ${tok.str}`); - } - skipDemo() { - var tok; - while ((tok = this.consumeToken()) && !this.isEOF()) { - if (tok.str == "end" && this.peekToken().str == "demo") { - this.consumeToken(); - return; - } - } - throw new ECSError(`Expected "end demo" after a "demo" declaration.`); - } - parseComponentDefinition() { - let name = this.expectIdent().str; - let fields = []; - this.em.deferComponent(name); - while (this.peekToken().str != "end") { - fields.push(this.parseComponentField()); - } - this.expectToken("end"); - return { name, fields }; - } - parseComponentField() { - let name = this.expectIdent(); - this.expectToken(":", 'I expected either a ":" or "end" here.'); - let type = this.parseDataType(); - return { name: name.str, $loc: name.$loc, ...type }; - } - parseDataType() { - if (this.peekToken().type == "integer") { - let lo = this.parseIntegerConstant(); - this.expectToken(".."); - let hi = this.parseIntegerConstant(); - this.checkLowerLimit(lo, -2147483648, "lower int range"); - this.checkUpperLimit(hi, 2147483647, "upper int range"); - this.checkUpperLimit(hi - lo, 4294967295, "int range"); - this.checkLowerLimit(hi, lo, "int range"); - let defvalue; - if (this.ifToken("default")) { - defvalue = this.parseIntegerConstant(); - } - return { dtype: "int", lo, hi, defvalue }; - } - if (this.peekToken().str == "[") { - return { dtype: "ref", query: this.parseQuery() }; - } - if (this.ifToken("array")) { - let index = void 0; - if (this.peekToken().type == ECSTokenType.Integer) { - index = this.parseDataType(); - } - this.expectToken("of"); - let elem = this.parseDataType(); - let baseoffset; - if (this.ifToken("baseoffset")) { - baseoffset = this.parseIntegerConstant(); - this.checkLowerLimit(baseoffset, -32768, "base offset"); - this.checkUpperLimit(baseoffset, 32767, "base offset"); - } - return { dtype: "array", index, elem, baseoffset }; - } - if (this.ifToken("enum")) { - this.expectToken("["); - let enumtoks = this.parseList(this.parseEnumIdent, ","); - this.expectToken("]"); - if (enumtoks.length == 0) - this.compileError(`must define at least one enum`); - let lo = 0; - let hi = enumtoks.length - 1; - this.checkLowerLimit(hi, 0, "enum count"); - this.checkUpperLimit(hi, 255, "enum count"); - let enums = {}; - for (let i = 0; i <= hi; i++) - enums[enumtoks[i].str] = i; - let defvalue; - if (this.ifToken("default")) { - defvalue = this.parseIntegerConstant(); - } - return { dtype: "int", lo, hi, defvalue, enums }; - } - throw this.compileError(`I expected a data type here.`); - } - parseEnumIdent() { - let tok = this.expectTokenTypes([TokenType2.Ident]); - return tok; - } - parseEnumValue(tok, field) { - if (!field.enums) - throw new ECSError(`field is not an enum`); - let value = field.enums[tok.str]; - if (value == null) - throw new ECSError(`unknown enum "${tok.str}"`); - return value; - } - parseDataValue(field) { - let tok = this.peekToken(); - if (tok.type == TokenType2.Ident && field.dtype == "int") { - return this.parseEnumValue(this.consumeToken(), field); - } - if (tok.type == TokenType2.Ident) { - let entity = this.currentScope?.getEntityByName(tok.str); - if (!entity) - this.compileError('no entity named "${tok.str}"'); - else { - this.consumeToken(); - this.expectToken("."); - let fieldName = this.expectIdent().str; - let constValue = this.currentScope?.getConstValue(entity, fieldName); - if (constValue == null) - throw new ECSError(`"${fieldName}" is not defined as a constant`, entity); - else - return constValue; - } - } - if (tok.str == "[") { - return new Uint8Array(this.parseDataArray()); - } - if (tok.str == "#") { - this.consumeToken(); - let reftype = field.dtype == "ref" ? field : void 0; - return this.parseEntityForwardRef(reftype); - } - return this.parseIntegerConstant(); - } - parseEntityForwardRef(reftype) { - let token = this.expectIdent(); - return { reftype, token }; - } - parseDataArray() { - this.expectToken("["); - let arr = this.parseList(this.parseIntegerConstant, ","); - this.expectToken("]"); - return arr; - } - expectInteger() { - let s = this.consumeToken().str; - let i; - if (s.startsWith("$")) - i = parseInt(s.substring(1), 16); - else if (s.startsWith("%")) - i = parseInt(s.substring(1), 2); - else - i = parseInt(s); - if (isNaN(i)) - this.compileError("There should be an integer here."); - return i; - } - parseSystem() { - let name = this.expectIdent().str; - let actions = []; - let system = { name, actions }; - let cmd; - while ((cmd = this.expectTokens(["on", "locals", "end"]).str) != "end") { - if (cmd == "on") { - let action = this.annotate(() => this.parseAction(system)); - actions.push(action); - } else if (cmd == "locals") { - system.tempbytes = this.parseIntegerConstant(); - } else { - this.compileError(`Unexpected system keyword: ${cmd}`); - } - } - return system; - } - parseResource() { - let name = this.expectIdent().str; - let tempbytes; - if (this.peekToken().str == "locals") { - this.consumeToken(); - tempbytes = this.parseIntegerConstant(); - } - let system = { name, tempbytes, actions: [] }; - let expr = this.annotate(() => this.parseBlockStatement()); - let action = { expr, event: name }; - system.actions.push(action); - return system; - } - parseAction(system) { - const event = this.expectIdent().str; - this.expectToken("do"); - let fitbytes = void 0; - let critical = void 0; - if (this.ifToken("critical")) - critical = true; - if (this.ifToken("fit")) - fitbytes = this.parseIntegerConstant(); - let expr = this.annotate(() => this.parseBlockStatement()); - let action = { expr, event, fitbytes, critical }; - return action; - } - parseQuery() { - let q = { include: [] }; - let start = this.expectToken("["); - this.parseList(() => this.parseQueryItem(q), ","); - this.expectToken("]"); - q.$loc = mergeLocs2(start.$loc, this.lasttoken.$loc); - return q; - } - parseQueryItem(q) { - let prefix = this.peekToken(); - if (prefix.type != TokenType2.Ident) { - this.consumeToken(); - } - if (prefix.type == TokenType2.Ident) { - let cref = this.parseComponentRef(); - q.include.push(cref); - } else if (prefix.str == "-") { - let cref = this.parseComponentRef(); - if (!q.exclude) - q.exclude = []; - q.exclude.push(cref); - } else if (prefix.str == "#") { - const scope = this.currentScope; - if (scope == null) { - throw this.compileError("You can only reference specific entities inside of a scope."); - } - let eref = this.parseEntityForwardRef(); - this.deferred.push(() => { - let refvalue = this.resolveEntityRef(scope, eref); - if (!q.entities) - q.entities = []; - q.entities.push(scope.entities[refvalue]); - }); - } else { - this.compileError(`Query components may be preceded only by a '-'.`); - } - } - parseEventName() { - return this.expectIdent().str; - } - parseEventList() { - return this.parseList(this.parseEventName, ","); - } - parseCode() { - let tok = this.expectTokenTypes([ECSTokenType.CodeFragment]); - let code = tok.str.substring(3, tok.str.length - 3); - let lines = code.split("\n"); - if (this.includeDebugInfo) - this.addDebugInfo(lines, tok.$loc.line); - code = lines.join("\n"); - return code; - } - addDebugInfo(lines, startline) { - const re = /^\s*(;|\/\/|$)/; - for (let i = 0; i < lines.length; i++) { - if (!lines[i].match(re)) - lines[i] = this.em.dialect.debug_line(this.path, startline + i) + "\n" + lines[i]; - } - } - parseScope() { - let name = this.expectIdent().str; - let scope = this.em.newScope(name, this.currentScope || void 0); - scope.filePath = this.path; - this.currentScope = scope; - let cmd; - while ((cmd = this.expectTokens(["end", "using", "entity", "scope", "comment", "system"]).str) != "end") { - if (cmd == "using") { - this.parseScopeUsing(); - } - if (cmd == "entity") { - this.annotate(() => this.parseEntity()); - } - if (cmd == "scope") { - this.annotate(() => this.parseScope()); - } - if (cmd == "comment") { - this.expectTokenTypes([ECSTokenType.CodeFragment]); - } - if (cmd == "system") { - let sys = this.annotate(() => this.parseSystem()); - this.em.defineSystem(sys); - this.currentScope.newSystemInstanceWithDefaults(sys); - } - } - this.currentScope = scope.parent || null; - return scope; - } - parseScopeUsing() { - let instlist = this.parseList(this.parseSystemInstanceRef, ","); - let params = {}; - if (this.peekToken().str == "with") { - this.consumeToken(); - params = this.parseSystemInstanceParameters(); - } - for (let inst of instlist) { - inst.params = params; - this.currentScope?.newSystemInstance(inst); - } - } - parseEntity() { - if (!this.currentScope) { - throw this.internalError(); - } - const scope = this.currentScope; - let entname = ""; - if (this.peekToken().type == TokenType2.Ident) { - entname = this.expectIdent().str; - } - let etype = this.parseEntityArchetype(); - let entity = this.currentScope.newEntity(etype, entname); - let cmd2; - while ((cmd2 = this.expectTokens(["const", "init", "var", "decode", "end"]).str) != "end") { - let cmd = cmd2; - if (cmd == "var") - cmd = "init"; - if (cmd == "init" || cmd == "const") { - this.parseInitConst(cmd, scope, entity); - } else if (cmd == "decode") { - this.parseDecode(scope, entity); - } - } - return entity; - } - parseInitConst(cmd, scope, entity) { - let name = this.expectIdent().str; - let { c, f } = this.getEntityField(entity, name); - let symtype = scope.isConstOrInit(c, name); - if (symtype && symtype != cmd) - this.compileError(`I can't mix const and init values for a given field in a scope.`); - this.expectToken("="); - let valueOrRef = this.parseDataValue(f); - if (valueOrRef.token != null) { - this.deferred.push(() => { - this.lasttoken = valueOrRef.token; - let refvalue = this.resolveEntityRef(scope, valueOrRef); - if (cmd == "const") - scope.setConstValue(entity, c, f, refvalue); - if (cmd == "init") - scope.setInitValue(entity, c, f, refvalue); - }); - } else { - if (cmd == "const") - scope.setConstValue(entity, c, f, valueOrRef); - if (cmd == "init") - scope.setInitValue(entity, c, f, valueOrRef); - } - } - parseDecode(scope, entity) { - let decoderid = this.expectIdent().str; - let codetok = this.expectTokenTypes([ECSTokenType.CodeFragment]); - let code = codetok.str; - code = code.substring(3, code.length - 3); - let decoder = newDecoder(decoderid, code); - if (!decoder) { - throw this.compileError(`I can't find a "${decoderid}" decoder.`); - } - let result; - try { - result = decoder.parse(); - } catch (e) { - throw new ECSError(e.message, decoder.getErrorLocation(codetok.$loc)); - } - for (let entry of Object.entries(result.properties)) { - let { c, f } = this.getEntityField(entity, entry[0]); - scope.setConstValue(entity, c, f, entry[1]); - } - } - getEntityField(e, name) { - if (!this.currentScope) { - throw this.internalError(); - } - let comps = this.em.componentsWithFieldName([e.etype], name); - if (comps.length == 0) - this.compileError(`I couldn't find a field named "${name}" for this entity.`); - if (comps.length > 1) - this.compileError(`I found more than one field named "${name}" for this entity.`); - let component = comps[0]; - let field = component.fields.find((f) => f.name == name); - if (!field) { - throw this.internalError(); - } - return { c: component, f: field }; - } - parseEntityArchetype() { - this.expectToken("["); - let components = this.parseList(this.parseComponentRef, ","); - this.expectToken("]"); - return { components }; - } - parseComponentRef() { - let name = this.expectIdent().str; - let cref = this.em.getComponentByName(name); - if (!cref) - this.compileError(`I couldn't find a component named "${name}".`); - return cref; - } - findEntityByName(scope, token) { - let name = token.str; - let eref = scope.entities.find((e) => e.name == name); - if (!eref) { - throw this.compileError(`I couldn't find an entity named "${name}" in this scope.`, token.$loc); - } - return eref; - } - resolveEntityRef(scope, ref) { - let id = this.findEntityByName(scope, ref.token).id; - if (ref.reftype) { - let atypes = this.em.archetypesMatching(ref.reftype.query); - let entities = scope.entitiesMatching(atypes); - if (entities.length == 0) - throw this.compileError(`This entity doesn't seem to fit the reference type.`, ref.token.$loc); - id -= entities[0].id; - } - return id; - } - parseSystemInstanceRef() { - let name = this.expectIdent().str; - let system = this.em.getSystemByName(name); - if (!system) - throw this.compileError(`I couldn't find a system named "${name}".`, this.lasttoken.$loc); - let params = {}; - let inst = { system, params, id: 0 }; - return inst; - } - parseSystemInstanceParameters() { - let scope = this.currentScope; - if (scope == null) - throw this.internalError(); - if (this.peekToken().str == "[") { - return { query: this.parseQuery() }; - } - this.expectToken("#"); - let entname = this.expectIdent(); - this.expectToken("."); - let fieldname = this.expectIdent(); - let entity = this.findEntityByName(scope, entname); - let cf = this.getEntityField(entity, fieldname.str); - return { refEntity: entity, refField: cf }; - } - exportToFile(src) { - this.em.exportToFile(src); - } - export() { - let src = new SourceFileExport(); - src.line(this.em.dialect.debug_file(this.path)); - for (let path4 of Object.keys(this.em.imported)) - src.line(this.em.dialect.debug_file(path4)); - this.exportToFile(src); - return src.toString(); - } - checkUpperLimit(value, upper, what) { - if (value > upper) - this.compileError(`This ${what} is too high; must be ${upper} or less`); - } - checkLowerLimit(value, lower, what) { - if (value < lower) - this.compileError(`This ${what} is too low; must be ${lower} or more`); - } - parseConstant() { - let expr = this.parseExpr(); - expr = this.em.evalExpr(expr, this.currentScope); - if (isLiteral2(expr)) - return expr.value; - throw this.compileError("This expression is not a constant."); - } - parseIntegerConstant() { - let value = this.parseConstant(); - if (typeof value === "number") - return value; - throw this.compileError("This expression is not an integer."); - } - parseExpr() { - var startloc = this.peekToken().$loc; - var expr = this.parseExpr1(this.parsePrimary(), 0); - var endloc = this.lasttoken.$loc; - expr.$loc = mergeLocs2(startloc, endloc); - return expr; - } - parseExpr1(left, minPred) { - let look = this.peekToken(); - while (getPrecedence2(look) >= minPred) { - let op = this.consumeToken(); - let right = this.parsePrimary(); - look = this.peekToken(); - while (getPrecedence2(look) > getPrecedence2(op)) { - right = this.parseExpr1(right, getPrecedence2(look)); - look = this.peekToken(); - } - var opfn = getOperator2(op.str).f; - if (op.str == "and") - opfn = "land"; - if (op.str == "or") - opfn = "lor"; - var valtype = this.exprTypeForOp(opfn, left, right, op); - left = { valtype, op: opfn, left, right }; - } - return left; - } - parsePrimary() { - let tok = this.consumeToken(); - switch (tok.type) { - case ECSTokenType.Integer: - this.pushbackToken(tok); - let value = this.expectInteger(); - let valtype = { dtype: "int", lo: value, hi: value }; - return { valtype, value }; - case TokenType2.Ident: - if (tok.str == "not") { - let expr = this.parsePrimary(); - let valtype2 = { dtype: "int", lo: 0, hi: 1 }; - return { valtype: valtype2, op: "lnot", expr }; - } else { - this.pushbackToken(tok); - return this.parseVarSubscriptOrFunc(); - } - case ECSTokenType.Operator: - if (tok.str == "(") { - let expr = this.parseExpr(); - this.expectToken(")", `There should be another expression or a ")" here.`); - return expr; - } else if (tok.str == "-") { - let expr = this.parsePrimary(); - let valtype2 = expr.valtype; - if (valtype2?.dtype == "int") { - let hi = Math.abs(valtype2.hi); - let negtype = { dtype: "int", lo: -hi, hi }; - return { valtype: negtype, op: "neg", expr }; - } - } else if (tok.str == "+") { - return this.parsePrimary(); - } - default: - throw this.compileError(`The expression is incomplete.`); - } - } - parseVarSubscriptOrFunc() { - var tok = this.consumeToken(); - switch (tok.type) { - case TokenType2.Ident: - if (this.ifToken(":")) { - let ftok = this.consumeToken(); - let component = this.em.getComponentByName(tok.str); - if (!component) - throw this.compileError(`A component named "${tok.str}" has not been defined.`); - let field = component.fields.find((f) => f.name == ftok.str); - if (!field) - throw this.compileError(`There is no "${ftok.str}" field in the ${tok.str} component.`); - if (!this.currentScope) - throw this.compileError(`This operation only works inside of a scope.`); - let atypes = this.em.archetypesMatching({ include: [component] }); - let entities = this.currentScope.entitiesMatching(atypes); - return { entities, field }; - } - if (this.ifToken(".")) { - let ftok = this.consumeToken(); - if (!this.currentScope) - throw this.compileError(`This operation only works inside of a scope.`); - let entity = this.currentScope.getEntityByName(tok.str); - if (!entity) - throw this.compileError(`An entity named "${tok.str}" has not been defined.`); - let component = this.em.singleComponentWithFieldName([entity.etype], ftok.str, ftok); - let field = component.fields.find((f) => f.name == ftok.str); - if (!field) - throw this.compileError(`There is no "${ftok.str}" field in this entity.`); - let entities = [entity]; - return { entities, field }; - } - let args = []; - if (this.ifToken("(")) { - args = this.parseExprList(); - this.expectToken(")", `There should be another expression or a ")" here.`); - } - var loc = mergeLocs2(tok.$loc, this.lasttoken.$loc); - var valtype = this.exprTypeForSubscript(tok.str, args, loc); - return { valtype, name: tok.str, args, $loc: loc }; - default: - throw this.compileError(`There should be a variable name here.`); - } - } - parseLexpr() { - var lexpr = this.parseVarSubscriptOrFunc(); - return lexpr; - } - exprTypeForOp(fnname, left, right, optok) { - return { dtype: "int", lo: 0, hi: 255 }; - } - exprTypeForSubscript(fnname, args, loc) { - return { dtype: "int", lo: 0, hi: 255 }; - } - parseLexprList() { - return this.parseList(this.parseLexpr, ","); - } - parseExprList() { - return this.parseList(this.parseExpr, ","); - } - parseBlockStatement() { - let valtype = { dtype: "int", lo: 0, hi: 0 }; - if (this.peekToken().type == ECSTokenType.CodeFragment) { - return { valtype, code: this.parseCode() }; - } - if (this.ifToken("begin")) { - let stmts = []; - while (this.peekToken().str != "end") { - stmts.push(this.annotate(() => this.parseBlockStatement())); - } - this.expectToken("end"); - return { valtype, stmts }; - } - let cmd = this.peekToken(); - if (SELECT_TYPE.includes(cmd.str)) { - return this.parseQueryStatement(); - } - throw this.compileError(`There should be a statement or "end" here.`, cmd.$loc); - } - parseQueryStatement() { - const select = this.expectTokens(SELECT_TYPE).str; - let all = this.ifToken("all") != null; - let query = void 0; - let join = void 0; - if (select == "once") { - if (this.peekToken().str == "[") - this.compileError(`A "${select}" action can't include a query.`); - } else { - query = this.parseQuery(); - } - if (select == "join") { - this.expectToken("with"); - join = this.parseQuery(); - } - if (this.ifToken("limit")) { - if (!query) { - this.compileError(`A "${select}" query can't include a limit.`); - } else - query.limit = this.parseIntegerConstant(); - } - const all_modifiers = ["asc", "desc"]; - const modifiers = this.parseModifiers(all_modifiers); - let direction = void 0; - if (modifiers["asc"]) - direction = "asc"; - else if (modifiers["desc"]) - direction = "desc"; - let body = this.annotate(() => this.parseBlockStatement()); - return { select, query, join, direction, all, stmts: [body], loop: select == "foreach" }; - } -}; - -// src/worker/tools/ecs.ts -function assembleECS(step) { - let em = new EntityManager(new Dialect_CA65()); - let compiler = new ECSCompiler(em, true); - compiler.getImportFile = (path4) => { - return getWorkFileAsString(path4); - }; - gatherFiles(step, { mainFilePath: "main.ecs" }); - if (step.mainfile) - em.mainPath = step.path; - var destpath = step.prefix + ".ca65"; - if (staleFiles(step, [destpath])) { - let code = getWorkFileAsString(step.path); - fixParamsWithDefines(step.path, step.params); - try { - compiler.includeDebugInfo = true; - compiler.parseFile(code, step.path); - let outtext = compiler.export().toString(); - putWorkFile(destpath, outtext); - var listings = {}; - listings[destpath] = { lines: [], text: outtext }; - var debuginfo = compiler.em.getDebugTree(); - } catch (e) { - if (e instanceof ECSError) { - compiler.addError(e.message, e.$loc); - for (let obj of e.$sources) { - let name = obj.event; - if (name == "start") - break; - compiler.addError(`... ${name}`, obj.$loc); - } - return { errors: compiler.errors }; - } else if (e instanceof CompileError3) { - return { errors: compiler.errors }; - } else { - throw e; - } - } - return { - nexttool: "ca65", - path: destpath, - args: [destpath], - files: [destpath].concat(step.files), - listings, - debuginfo - }; - } -} - -// src/worker/tools/remote.ts -var sessionID = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); -async function buildRemote(step) { - const { REMOTE_URL } = await (await fetch("../../remote.json")).json(); - if (typeof REMOTE_URL !== "string") - throw new Error("No REMOTE_URL in remote.json"); - gatherFiles(step); - var binpath = "a.out"; - if (staleFiles(step, [binpath])) { - let updates = []; - for (var i = 0; i < step.files.length; i++) { - let path4 = step.files[i]; - let entry = store.workfs[path4]; - let data = typeof entry.data === "string" ? entry.data : btoa(byteArrayToString(entry.data)); - updates.push({ path: path4, data }); - } - let cmd = { buildStep: step, updates, sessionID }; - console.log("POST", cmd); - let result = await fetch(REMOTE_URL, { - method: "POST", - mode: "cors", - body: JSON.stringify(cmd), - headers: { - "Content-Type": "application/json" - } - }); - let json = await result.json(); - if (isUnchanged(json)) - return json; - if (isErrorResult(json)) - return json; - if (isOutputResult(json)) { - json.output = stringToByteArray(atob(json.output)); - return json; - } - throw new Error(`Unexpected result from remote build: ${JSON.stringify(json)}`); - } -} - -// src/worker/tools/acme.ts -function parseACMESymbolTable(text) { - var symbolmap = {}; - var lines = text.split("\n"); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i].trim(); - var m = line.match(/(\w+)\s*=\s*[$]([0-9a-f]+)/i); - if (m) { - symbolmap[m[1]] = parseInt(m[2], 16); - } - } - return symbolmap; -} -function parseACMEReportFile(text) { - var listings = {}; - var listing; - var lines = text.split("\n"); - for (var i = 0; i < lines.length; ++i) { - var line = lines[i].trim(); - var m1 = line.match(/^;\s*[*]+\s*Source: (.+)$/); - if (m1) { - var file = m1[1]; - listings[file] = listing = { - lines: [] - }; - continue; - } - var m2 = line.match(/^(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)/i); - if (m2) { - if (listing) { - listing.lines.push({ - line: parseInt(m2[1]), - offset: parseInt(m2[2], 16), - insns: m2[3] - }); - } - } - } - return listings; -} -function assembleACME(step) { - loadNative("acme"); - var errors = []; - gatherFiles(step, { mainFilePath: "main.acme" }); - var binpath = step.prefix + ".bin"; - var lstpath = step.prefix + ".lst"; - var sympath = step.prefix + ".sym"; - if (staleFiles(step, [binpath])) { - var binout, lstout, symout; - var ACME = emglobal.acme({ - instantiateWasm: moduleInstFn("acme"), - noInitialRun: true, - print: print_fn, - printErr: msvcErrorMatcher(errors) - }); - var FS = ACME.FS; - populateFiles(step, FS); - fixParamsWithDefines(step.path, step.params); - var args = ["--msvc", "--initmem", "0", "-o", binpath, "-r", lstpath, "-l", sympath, step.path]; - if (step.params?.acmeargs) { - args.unshift.apply(args, step.params.acmeargs); - } else { - args.unshift.apply(args, ["-f", "plain"]); - } - args.unshift.apply(args, ["-D__8BITWORKSHOP__=1"]); - if (step.mainfile) { - args.unshift.apply(args, ["-D__MAIN__=1"]); - } - execMain(step, ACME, args); - if (errors.length) { - let listings = {}; - return { errors, listings }; - } - binout = FS.readFile(binpath, { encoding: "binary" }); - lstout = FS.readFile(lstpath, { encoding: "utf8" }); - symout = FS.readFile(sympath, { encoding: "utf8" }); - putWorkFile(binpath, binout); - putWorkFile(lstpath, lstout); - putWorkFile(sympath, symout); - return { - output: binout, - listings: parseACMEReportFile(lstout), - errors, - symbolmap: parseACMESymbolTable(symout) - }; - } -} - -// src/common/wasi/wasishim.ts -var use_debug = true; -var debug2 = use_debug ? console.log : () => { -}; -var warning = console.log; -var FDType; -(function(FDType2) { - FDType2[FDType2["UNKNOWN"] = 0] = "UNKNOWN"; - FDType2[FDType2["BLOCK_DEVICE"] = 1] = "BLOCK_DEVICE"; - FDType2[FDType2["CHARACTER_DEVICE"] = 2] = "CHARACTER_DEVICE"; - FDType2[FDType2["DIRECTORY"] = 3] = "DIRECTORY"; - FDType2[FDType2["REGULAR_FILE"] = 4] = "REGULAR_FILE"; - FDType2[FDType2["SOCKET_DGRAM"] = 5] = "SOCKET_DGRAM"; - FDType2[FDType2["SOCKET_STREAM"] = 6] = "SOCKET_STREAM"; - FDType2[FDType2["SYMBOLIC_LINK"] = 7] = "SYMBOLIC_LINK"; -})(FDType || (FDType = {})); -var FDRights; -(function(FDRights2) { - FDRights2[FDRights2["FD_DATASYNC"] = 1] = "FD_DATASYNC"; - FDRights2[FDRights2["FD_READ"] = 2] = "FD_READ"; - FDRights2[FDRights2["FD_SEEK"] = 4] = "FD_SEEK"; - FDRights2[FDRights2["FD_FDSTAT_SET_FLAGS"] = 8] = "FD_FDSTAT_SET_FLAGS"; - FDRights2[FDRights2["FD_SYNC"] = 16] = "FD_SYNC"; - FDRights2[FDRights2["FD_TELL"] = 32] = "FD_TELL"; - FDRights2[FDRights2["FD_WRITE"] = 64] = "FD_WRITE"; - FDRights2[FDRights2["FD_ADVISE"] = 128] = "FD_ADVISE"; - FDRights2[FDRights2["FD_ALLOCATE"] = 256] = "FD_ALLOCATE"; - FDRights2[FDRights2["PATH_CREATE_DIRECTORY"] = 512] = "PATH_CREATE_DIRECTORY"; - FDRights2[FDRights2["PATH_CREATE_FILE"] = 1024] = "PATH_CREATE_FILE"; - FDRights2[FDRights2["PATH_LINK_SOURCE"] = 2048] = "PATH_LINK_SOURCE"; - FDRights2[FDRights2["PATH_LINK_TARGET"] = 4096] = "PATH_LINK_TARGET"; - FDRights2[FDRights2["PATH_OPEN"] = 8192] = "PATH_OPEN"; - FDRights2[FDRights2["FD_READDIR"] = 16384] = "FD_READDIR"; - FDRights2[FDRights2["PATH_READLINK"] = 32768] = "PATH_READLINK"; - FDRights2[FDRights2["PATH_RENAME_SOURCE"] = 65536] = "PATH_RENAME_SOURCE"; - FDRights2[FDRights2["PATH_RENAME_TARGET"] = 131072] = "PATH_RENAME_TARGET"; - FDRights2[FDRights2["PATH_FILESTAT_GET"] = 262144] = "PATH_FILESTAT_GET"; - FDRights2[FDRights2["PATH_FILESTAT_SET_SIZE"] = 524288] = "PATH_FILESTAT_SET_SIZE"; - FDRights2[FDRights2["PATH_FILESTAT_SET_TIMES"] = 1048576] = "PATH_FILESTAT_SET_TIMES"; - FDRights2[FDRights2["FD_FILESTAT_GET"] = 2097152] = "FD_FILESTAT_GET"; - FDRights2[FDRights2["FD_FILESTAT_SET_SIZE"] = 4194304] = "FD_FILESTAT_SET_SIZE"; - FDRights2[FDRights2["FD_FILESTAT_SET_TIMES"] = 8388608] = "FD_FILESTAT_SET_TIMES"; - FDRights2[FDRights2["PATH_SYMLINK"] = 16777216] = "PATH_SYMLINK"; - FDRights2[FDRights2["PATH_REMOVE_DIRECTORY"] = 33554432] = "PATH_REMOVE_DIRECTORY"; - FDRights2[FDRights2["PATH_UNLINK_FILE"] = 67108864] = "PATH_UNLINK_FILE"; - FDRights2[FDRights2["POLL_FD_READWRITE"] = 134217728] = "POLL_FD_READWRITE"; - FDRights2[FDRights2["SOCK_SHUTDOWN"] = 268435456] = "SOCK_SHUTDOWN"; - FDRights2[FDRights2["FD_ALL"] = 536870911] = "FD_ALL"; -})(FDRights || (FDRights = {})); -var FDFlags; -(function(FDFlags2) { - FDFlags2[FDFlags2["APPEND"] = 1] = "APPEND"; - FDFlags2[FDFlags2["DSYNC"] = 2] = "DSYNC"; - FDFlags2[FDFlags2["NONBLOCK"] = 4] = "NONBLOCK"; - FDFlags2[FDFlags2["RSYNC"] = 8] = "RSYNC"; - FDFlags2[FDFlags2["SYNC"] = 16] = "SYNC"; -})(FDFlags || (FDFlags = {})); -var FDOpenFlags; -(function(FDOpenFlags2) { - FDOpenFlags2[FDOpenFlags2["CREAT"] = 1] = "CREAT"; - FDOpenFlags2[FDOpenFlags2["DIRECTORY"] = 2] = "DIRECTORY"; - FDOpenFlags2[FDOpenFlags2["EXCL"] = 4] = "EXCL"; - FDOpenFlags2[FDOpenFlags2["TRUNC"] = 8] = "TRUNC"; -})(FDOpenFlags || (FDOpenFlags = {})); -var WASIErrors; -(function(WASIErrors2) { - WASIErrors2[WASIErrors2["SUCCESS"] = 0] = "SUCCESS"; - WASIErrors2[WASIErrors2["TOOBIG"] = 1] = "TOOBIG"; - WASIErrors2[WASIErrors2["ACCES"] = 2] = "ACCES"; - WASIErrors2[WASIErrors2["ADDRINUSE"] = 3] = "ADDRINUSE"; - WASIErrors2[WASIErrors2["ADDRNOTAVAIL"] = 4] = "ADDRNOTAVAIL"; - WASIErrors2[WASIErrors2["AFNOSUPPORT"] = 5] = "AFNOSUPPORT"; - WASIErrors2[WASIErrors2["AGAIN"] = 6] = "AGAIN"; - WASIErrors2[WASIErrors2["ALREADY"] = 7] = "ALREADY"; - WASIErrors2[WASIErrors2["BADF"] = 8] = "BADF"; - WASIErrors2[WASIErrors2["BADMSG"] = 9] = "BADMSG"; - WASIErrors2[WASIErrors2["BUSY"] = 10] = "BUSY"; - WASIErrors2[WASIErrors2["CANCELED"] = 11] = "CANCELED"; - WASIErrors2[WASIErrors2["CHILD"] = 12] = "CHILD"; - WASIErrors2[WASIErrors2["CONNABORTED"] = 13] = "CONNABORTED"; - WASIErrors2[WASIErrors2["CONNREFUSED"] = 14] = "CONNREFUSED"; - WASIErrors2[WASIErrors2["CONNRESET"] = 15] = "CONNRESET"; - WASIErrors2[WASIErrors2["DEADLK"] = 16] = "DEADLK"; - WASIErrors2[WASIErrors2["DESTADDRREQ"] = 17] = "DESTADDRREQ"; - WASIErrors2[WASIErrors2["DOM"] = 18] = "DOM"; - WASIErrors2[WASIErrors2["DQUOT"] = 19] = "DQUOT"; - WASIErrors2[WASIErrors2["EXIST"] = 20] = "EXIST"; - WASIErrors2[WASIErrors2["FAULT"] = 21] = "FAULT"; - WASIErrors2[WASIErrors2["FBIG"] = 22] = "FBIG"; - WASIErrors2[WASIErrors2["HOSTUNREACH"] = 23] = "HOSTUNREACH"; - WASIErrors2[WASIErrors2["IDRM"] = 24] = "IDRM"; - WASIErrors2[WASIErrors2["ILSEQ"] = 25] = "ILSEQ"; - WASIErrors2[WASIErrors2["INPROGRESS"] = 26] = "INPROGRESS"; - WASIErrors2[WASIErrors2["INTR"] = 27] = "INTR"; - WASIErrors2[WASIErrors2["INVAL"] = 28] = "INVAL"; - WASIErrors2[WASIErrors2["IO"] = 29] = "IO"; - WASIErrors2[WASIErrors2["ISCONN"] = 30] = "ISCONN"; - WASIErrors2[WASIErrors2["ISDIR"] = 31] = "ISDIR"; - WASIErrors2[WASIErrors2["LOOP"] = 32] = "LOOP"; - WASIErrors2[WASIErrors2["MFILE"] = 33] = "MFILE"; - WASIErrors2[WASIErrors2["MLINK"] = 34] = "MLINK"; - WASIErrors2[WASIErrors2["MSGSIZE"] = 35] = "MSGSIZE"; - WASIErrors2[WASIErrors2["MULTIHOP"] = 36] = "MULTIHOP"; - WASIErrors2[WASIErrors2["NAMETOOLONG"] = 37] = "NAMETOOLONG"; - WASIErrors2[WASIErrors2["NETDOWN"] = 38] = "NETDOWN"; - WASIErrors2[WASIErrors2["NETRESET"] = 39] = "NETRESET"; - WASIErrors2[WASIErrors2["NETUNREACH"] = 40] = "NETUNREACH"; - WASIErrors2[WASIErrors2["NFILE"] = 41] = "NFILE"; - WASIErrors2[WASIErrors2["NOBUFS"] = 42] = "NOBUFS"; - WASIErrors2[WASIErrors2["NODEV"] = 43] = "NODEV"; - WASIErrors2[WASIErrors2["NOENT"] = 44] = "NOENT"; - WASIErrors2[WASIErrors2["NOEXEC"] = 45] = "NOEXEC"; - WASIErrors2[WASIErrors2["NOLCK"] = 46] = "NOLCK"; - WASIErrors2[WASIErrors2["NOLINK"] = 47] = "NOLINK"; - WASIErrors2[WASIErrors2["NOMEM"] = 48] = "NOMEM"; - WASIErrors2[WASIErrors2["NOMSG"] = 49] = "NOMSG"; - WASIErrors2[WASIErrors2["NOPROTOOPT"] = 50] = "NOPROTOOPT"; - WASIErrors2[WASIErrors2["NOSPC"] = 51] = "NOSPC"; - WASIErrors2[WASIErrors2["NOSYS"] = 52] = "NOSYS"; - WASIErrors2[WASIErrors2["NOTCONN"] = 53] = "NOTCONN"; - WASIErrors2[WASIErrors2["NOTDIR"] = 54] = "NOTDIR"; - WASIErrors2[WASIErrors2["NOTEMPTY"] = 55] = "NOTEMPTY"; - WASIErrors2[WASIErrors2["NOTRECOVERABLE"] = 56] = "NOTRECOVERABLE"; - WASIErrors2[WASIErrors2["NOTSOCK"] = 57] = "NOTSOCK"; - WASIErrors2[WASIErrors2["NOTSUP"] = 58] = "NOTSUP"; - WASIErrors2[WASIErrors2["NOTTY"] = 59] = "NOTTY"; - WASIErrors2[WASIErrors2["NXIO"] = 60] = "NXIO"; - WASIErrors2[WASIErrors2["OVERFLOW"] = 61] = "OVERFLOW"; - WASIErrors2[WASIErrors2["OWNERDEAD"] = 62] = "OWNERDEAD"; - WASIErrors2[WASIErrors2["PERM"] = 63] = "PERM"; - WASIErrors2[WASIErrors2["PIPE"] = 64] = "PIPE"; - WASIErrors2[WASIErrors2["PROTO"] = 65] = "PROTO"; - WASIErrors2[WASIErrors2["PROTONOSUPPORT"] = 66] = "PROTONOSUPPORT"; - WASIErrors2[WASIErrors2["PROTOTYPE"] = 67] = "PROTOTYPE"; - WASIErrors2[WASIErrors2["RANGE"] = 68] = "RANGE"; - WASIErrors2[WASIErrors2["ROFS"] = 69] = "ROFS"; - WASIErrors2[WASIErrors2["SPIPE"] = 70] = "SPIPE"; - WASIErrors2[WASIErrors2["SRCH"] = 71] = "SRCH"; - WASIErrors2[WASIErrors2["STALE"] = 72] = "STALE"; - WASIErrors2[WASIErrors2["TIMEDOUT"] = 73] = "TIMEDOUT"; - WASIErrors2[WASIErrors2["TXTBSY"] = 74] = "TXTBSY"; - WASIErrors2[WASIErrors2["XDEV"] = 75] = "XDEV"; - WASIErrors2[WASIErrors2["NOTCAPABLE"] = 76] = "NOTCAPABLE"; -})(WASIErrors || (WASIErrors = {})); -var WASIFileDescriptor = class { - constructor(name, type, rights) { - this.name = name; - this.type = type; - this.rights = rights; - this.fdindex = -1; - this.data = new Uint8Array(16); - this.flags = 0; - this.size = 0; - this.offset = 0; - this.rights = -1; - } - ensureCapacity(size) { - if (this.data.byteLength < size) { - const newdata = new Uint8Array(size * 2); - newdata.set(this.data); - this.data = newdata; - } - } - write(chunk) { - this.ensureCapacity(this.offset + chunk.byteLength); - this.data.set(chunk, this.offset); - this.offset += chunk.byteLength; - this.size = Math.max(this.size, this.offset); - } - read(chunk) { - const len = Math.min(chunk.byteLength, this.size - this.offset); - chunk.set(this.data.subarray(this.offset, this.offset + len)); - this.offset += len; - return len; - } - truncate() { - this.size = 0; - this.offset = 0; - } - llseek(offset, whence) { - switch (whence) { - case 0: - this.offset = offset; - break; - case 1: - this.offset += offset; - break; - case 2: - this.offset = this.size + offset; - break; - } - if (this.offset < 0) - this.offset = 0; - if (this.offset > this.size) - this.offset = this.size; - } - getBytes() { - return this.data.subarray(0, this.size); - } - getBytesAsString() { - return new TextDecoder().decode(this.getBytes()); - } - toString() { - return `FD(${this.fdindex} "${this.name}" 0x${this.type.toString(16)} 0x${this.rights.toString(16)} ${this.offset}/${this.size}/${this.data.byteLength})`; - } -}; -var WASIStreamingFileDescriptor = class extends WASIFileDescriptor { - constructor(fdindex, name, type, rights, stream) { - super(name, type, rights); - this.stream = stream; - this.fdindex = fdindex; - } - write(chunk) { - this.stream.write(chunk); - } -}; -var WASIMemoryFilesystem = class { - constructor() { - this.parent = null; - this.files = new Map(); - this.dirs = new Map(); - this.putDirectory("/"); - } - setParent(parent) { - this.parent = parent; - } - putDirectory(name, rights) { - if (!rights) - rights = 8192 | 512 | 1024; - const dir = new WASIFileDescriptor(name, 3, rights); - this.dirs.set(name, dir); - return dir; - } - putFile(name, data, rights) { - if (typeof data === "string") { - data = new TextEncoder().encode(data); - } - if (!rights) - rights = 2 | 64; - const file = new WASIFileDescriptor(name, 4, rights); - file.write(data); - file.offset = 0; - this.files.set(name, file); - return file; - } - getFile(name) { - let file = this.files.get(name); - if (!file) { - file = this.parent?.getFile(name); - } - return file; - } -}; -var _instance, _memarr8, _memarr32, _args, _envvars; -var WASIRunner = class { - constructor() { - __privateAdd(this, _instance, void 0); - __privateAdd(this, _memarr8, void 0); - __privateAdd(this, _memarr32, void 0); - __privateAdd(this, _args, []); - __privateAdd(this, _envvars, []); - this.fds = []; - this.exited = false; - this.errno = -1; - this.fs = new WASIMemoryFilesystem(); - this.createStdioBrowser(); - } - createStdioNode() { - this.stdin = new WASIStreamingFileDescriptor(0, "", 2, 2, process.stdin); - this.stdout = new WASIStreamingFileDescriptor(1, "", 2, 64, process.stdout); - this.stderr = new WASIStreamingFileDescriptor(2, "", 2, 64, process.stderr); - this.fds[0] = this.stdin; - this.fds[1] = this.stdout; - this.fds[2] = this.stderr; - } - createStdioBrowser() { - this.stdin = new WASIFileDescriptor("", 2, 2); - this.stdout = new WASIFileDescriptor("", 2, 64); - this.stderr = new WASIFileDescriptor("", 2, 64); - this.stdin.fdindex = 0; - this.stdout.fdindex = 1; - this.stderr.fdindex = 2; - this.fds[0] = this.stdin; - this.fds[1] = this.stdout; - this.fds[2] = this.stderr; - } - initSync(wasmModule) { - __privateSet(this, _instance, new WebAssembly.Instance(wasmModule, this.getImportObject())); - } - loadSync(wasmSource) { - let wasmModule = new WebAssembly.Module(wasmSource); - this.initSync(wasmModule); - } - async loadAsync(wasmSource) { - let wasmModule = await WebAssembly.compile(wasmSource); - __privateSet(this, _instance, await WebAssembly.instantiate(wasmModule, this.getImportObject())); - } - setArgs(args) { - __privateSet(this, _args, args.map((arg) => new TextEncoder().encode(arg + "\0"))); - } - addPreopenDirectory(name) { - return this.openFile(name, 2 | 1); - } - openFile(path4, o_flags, mode) { - let file = this.fs.getFile(path4); - mode = typeof mode == "undefined" ? 438 : mode; - if (o_flags & 1) { - if (file == null) { - if (o_flags & 2) { - file = this.fs.putDirectory(path4); - } else { - file = this.fs.putFile(path4, new Uint8Array(), 536870911); - } - } else { - if (o_flags & 8) { - file.truncate(); - } else - return 28; - } - } else { - if (file == null) - return 52; - if (o_flags & 2) { - if (file.type !== 3) - return 52; - } - if (o_flags & 4) - return 28; - if (o_flags & 8) { - file.truncate(); - } else { - file.llseek(0, 0); - } - } - file.fdindex = this.fds.length; - this.fds.push(file); - return file; - } - mem8() { - if (!__privateGet(this, _memarr8)?.byteLength) { - __privateSet(this, _memarr8, new Uint8Array(__privateGet(this, _instance).exports.memory.buffer)); - } - return __privateGet(this, _memarr8); - } - mem32() { - if (!__privateGet(this, _memarr32)?.byteLength) { - __privateSet(this, _memarr32, new Int32Array(__privateGet(this, _instance).exports.memory.buffer)); - } - return __privateGet(this, _memarr32); - } - run() { - try { - __privateGet(this, _instance).exports._start(); - if (!this.exited) { - this.exited = true; - this.errno = 0; - } - } catch (err) { - if (!this.exited) - throw err; - } - return this.getErrno(); - } - getImportObject() { - return { - "wasi_snapshot_preview1": this.getWASISnapshotPreview1(), - "env": this.getEnv() - }; - } - peek8(ptr) { - return this.mem8()[ptr]; - } - peek16(ptr) { - return this.mem8()[ptr] | this.mem8()[ptr + 1] << 8; - } - peek32(ptr) { - return this.mem32()[ptr >>> 2]; - } - poke8(ptr, val) { - this.mem8()[ptr] = val; - } - poke16(ptr, val) { - this.mem8()[ptr] = val; - this.mem8()[ptr + 1] = val >> 8; - } - poke32(ptr, val) { - this.mem32()[ptr >>> 2] = val; - } - poke64(ptr, val) { - this.mem32()[ptr >>> 2] = val; - this.mem32()[(ptr >>> 2) + 1] = 0; - } - pokeUTF8(str, ptr, maxlen) { - const enc = new TextEncoder(); - const bytes = enc.encode(str); - const len = Math.min(bytes.length, maxlen); - this.mem8().set(bytes.subarray(0, len), ptr); - } - peekUTF8(ptr, maxlen) { - const bytes = this.mem8().subarray(ptr, ptr + maxlen); - const dec = new TextDecoder(); - return dec.decode(bytes); - } - getErrno() { - return this.errno; - } - poke_str_array_sizes(strs, count_ptr, buf_size_ptr) { - this.poke32(count_ptr, strs.length); - this.poke32(buf_size_ptr, strs.reduce((acc, arg) => acc + arg.length, 0)); - } - poke_str_args(strs, argv_ptr, argv_buf_ptr) { - let argv = argv_ptr; - let argv_buf = argv_buf_ptr; - for (let arg of __privateGet(this, _args)) { - this.poke32(argv, argv_buf); - argv += 4; - for (let i = 0; i < arg.length; i++) { - this.poke8(argv_buf, arg[i]); - argv_buf++; - } - } - } - args_sizes_get(argcount_ptr, argv_buf_size_ptr) { - debug2("args_sizes_get", argcount_ptr, argv_buf_size_ptr); - this.poke_str_array_sizes(__privateGet(this, _args), argcount_ptr, argv_buf_size_ptr); - return 0; - } - args_get(argv_ptr, argv_buf_ptr) { - debug2("args_get", argv_ptr, argv_buf_ptr); - this.poke_str_args(__privateGet(this, _args), argv_ptr, argv_buf_ptr); - return 0; - } - environ_sizes_get(environ_count_ptr, environ_buf_size_ptr) { - debug2("environ_sizes_get", environ_count_ptr, environ_buf_size_ptr); - this.poke_str_array_sizes(__privateGet(this, _envvars), environ_count_ptr, environ_buf_size_ptr); - return 0; - } - environ_get(environ_ptr, environ_buf_ptr) { - debug2("environ_get", environ_ptr, environ_buf_ptr); - this.poke_str_args(__privateGet(this, _envvars), environ_ptr, environ_buf_ptr); - return 0; - } - fd_write(fd, iovs, iovs_len, nwritten_ptr) { - const stream = this.fds[fd]; - const iovecs = this.mem32().subarray(iovs >>> 2, iovs + iovs_len * 8 >>> 2); - let total = 0; - for (let i = 0; i < iovs_len; i++) { - const ptr = iovecs[i * 2]; - const len = iovecs[i * 2 + 1]; - const chunk = this.mem8().subarray(ptr, ptr + len); - total += len; - stream.write(chunk); - } - this.poke32(nwritten_ptr, total); - debug2("fd_write", fd, iovs, iovs_len, "->", total); - return 0; - } - fd_read(fd, iovs, iovs_len, nread_ptr) { - const stream = this.fds[fd]; - const iovecs = this.mem32().subarray(iovs >>> 2, iovs + iovs_len * 8 >>> 2); - let total = 0; - for (let i = 0; i < iovs_len; i++) { - const ptr = iovecs[i * 2]; - const len = iovecs[i * 2 + 1]; - const chunk = this.mem8().subarray(ptr, ptr + len); - total += stream.read(chunk); - } - this.poke32(nread_ptr, total); - debug2("fd_read", fd, iovs, iovs_len, "->", total); - return 0; - } - fd_seek(fd, offset, whence, newoffset_ptr) { - const file = this.fds[fd]; - debug2("fd_seek", fd, offset, whence, file); - if (file != null) { - file.llseek(offset, whence); - this.poke64(newoffset_ptr, file.offset); - return 0; - } - return 8; - } - fd_close(fd) { - debug2("fd_close", fd); - const file = this.fds[fd]; - if (file != null) { - this.fds[fd] = null; - return 0; - } - return 8; - } - proc_exit(errno) { - debug2("proc_exit", errno); - this.errno = errno; - this.exited = true; - } - fd_prestat_get(fd, prestat_ptr) { - const file = this.fds[fd]; - debug2("fd_prestat_get", fd, prestat_ptr, file?.name); - if (file && file.type === 3) { - const enc_name = new TextEncoder().encode(file.name); - this.poke8(prestat_ptr + 0, 0); - this.poke64(prestat_ptr + 8, enc_name.length); - return 0; - } - return 8; - } - fd_fdstat_get(fd, fdstat_ptr) { - const file = this.fds[fd]; - debug2("fd_fdstat_get", fd, fdstat_ptr, file + ""); - if (file != null) { - this.poke16(fdstat_ptr + 0, file.type); - this.poke16(fdstat_ptr + 2, file.flags); - this.poke64(fdstat_ptr + 8, file.rights); - this.poke64(fdstat_ptr + 16, file.rights); - return 0; - } - return 8; - } - fd_prestat_dir_name(fd, path_ptr, path_len) { - const file = this.fds[fd]; - debug2("fd_prestat_dir_name", fd, path_ptr, path_len); - if (file != null) { - this.pokeUTF8(file.name, path_ptr, path_len); - return 0; - } - return 28; - } - path_open(dirfd, dirflags, path_ptr, path_len, o_flags, fs_rights_base, fs_rights_inheriting, fd_flags, fd_ptr) { - const dir = this.fds[dirfd]; - if (dir == null) - return 8; - if (dir.type !== 3) - return 54; - const filename = this.peekUTF8(path_ptr, path_len); - const path4 = dir.name + "/" + filename; - const fd = this.openFile(path4, o_flags, fd_flags); - debug2("path_open", path4, dirfd, dirflags, o_flags, fd_flags, fd_ptr, "->", fd + ""); - if (typeof fd === "number") - return fd; - this.poke32(fd_ptr, fd.fdindex); - return 0; - } - random_get(ptr, len) { - debug2("random_get", ptr, len); - for (let i = 0; i < len; i++) { - this.poke8(ptr + i, Math.floor(Math.random() * 256)); - } - return 0; - } - path_filestat_get(dirfd, dirflags, path_ptr, path_len, filestat_ptr) { - const dir = this.fds[dirfd]; - if (dir == null) - return 8; - if (dir.type !== 3) - return 54; - const filename = this.peekUTF8(path_ptr, path_len); - const path4 = dir.name + "/" + filename; - const fd = this.fs.getFile(path4); - console.log("path_filestat_get", dir + "", path4, filestat_ptr, "->", fd + ""); - if (!fd) - return 44; - this.poke64(filestat_ptr, fd.fdindex); - this.poke64(filestat_ptr + 8, 0); - this.poke8(filestat_ptr + 16, fd.type); - this.poke64(filestat_ptr + 24, 1); - this.poke64(filestat_ptr + 32, fd.size); - this.poke64(filestat_ptr + 40, 0); - this.poke64(filestat_ptr + 48, 0); - this.poke64(filestat_ptr + 56, 0); - } - getWASISnapshotPreview1() { - return { - args_sizes_get: this.args_sizes_get.bind(this), - args_get: this.args_get.bind(this), - environ_sizes_get: this.environ_sizes_get.bind(this), - environ_get: this.environ_get.bind(this), - proc_exit: this.proc_exit.bind(this), - path_open: this.path_open.bind(this), - fd_prestat_get: this.fd_prestat_get.bind(this), - fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this), - fd_fdstat_get: this.fd_fdstat_get.bind(this), - fd_read: this.fd_read.bind(this), - fd_write: this.fd_write.bind(this), - fd_seek: this.fd_seek.bind(this), - fd_close: this.fd_close.bind(this), - path_filestat_get: this.path_filestat_get.bind(this), - random_get: this.random_get.bind(this), - fd_fdstat_set_flags() { - warning("TODO: fd_fdstat_set_flags"); - return 58; - }, - fd_readdir() { - warning("TODO: fd_readdir"); - return 58; - }, - path_unlink_file() { - warning("TODO: path_unlink_file"); - return 58; - }, - clock_time_get() { - warning("TODO: clock_time_get"); - return 58; - } - }; - } - getEnv() { - return { - __syscall_unlinkat() { - warning("TODO: unlink"); - return 0; - } - }; - } -}; -_instance = new WeakMap(); -_memarr8 = new WeakMap(); -_memarr32 = new WeakMap(); -_args = new WeakMap(); -_envvars = new WeakMap(); - -// src/worker/tools/cc7800.ts -var import_jszip = __toModule(require_lib7()); -var cc7800_fs = null; -var wasiModule = null; -function loadBlobSync(path4) { - var xhr = new XMLHttpRequest(); - xhr.responseType = "blob"; - xhr.open("GET", path4, false); - xhr.send(null); - return xhr.response; -} -async function loadWASIFilesystemZip(zippath) { - const jszip = new import_jszip.default(); - const path4 = "../../src/worker/fs/" + zippath; - const zipdata = loadBlobSync(path4); - console.log(zippath, zipdata); - await jszip.loadAsync(zipdata); - let fs3 = new WASIMemoryFilesystem(); - let promises = []; - jszip.forEach(async (relativePath, zipEntry) => { - if (zipEntry.dir) { - fs3.putDirectory(relativePath); - } else { - let path5 = "./" + relativePath; - let prom = zipEntry.async("uint8array").then((data) => { - fs3.putFile(path5, data); - }); - promises.push(prom); - } - }); - await Promise.all(promises); - return fs3; -} -async function compileCC7800(step) { - const errors = []; - gatherFiles(step, { mainFilePath: "main.c" }); - const destpath = "./a.out"; - if (staleFiles(step, [destpath])) { - if (!cc7800_fs) { - cc7800_fs = await loadWASIFilesystemZip("cc7800-fs.zip"); - } - if (!wasiModule) { - wasiModule = new WebAssembly.Module(loadWASMBinary("cc7800")); - } - const wasi = new WASIRunner(); - wasi.initSync(wasiModule); - wasi.fs.setParent(cc7800_fs); - for (let file of step.files) { - wasi.fs.putFile("./" + file, store.getFileData(file)); - } - wasi.addPreopenDirectory("headers"); - wasi.addPreopenDirectory("."); - wasi.setArgs(["cc7800", "-v", "-g", "-S", "-I", "headers", step.path]); - try { - wasi.run(); - } catch (e) { - errors.push(e); - } - let stdout = wasi.fds[1].getBytesAsString(); - let stderr = wasi.fds[2].getBytesAsString(); - console.log("stdout", stdout); - console.log("stderr", stderr); - if (stderr.indexOf("Syntax error:") >= 0) { - const matcher = makeErrorMatcher(errors, /^Syntax error: (.+?) on line (\d+) of (.+)/, 2, 1, step.path, 3); - for (let line of stderr.split("\n")) { - matcher(line); - } - } - if (errors.length) { - return { errors }; - } - const combinedasm = wasi.fs.getFile(destpath).getBytesAsString(); - putWorkFile(destpath, combinedasm); - } - return { - nexttool: "dasm", - path: destpath, - args: [destpath], - files: [destpath] - }; -} - -// src/worker/workermain.ts -var ENVIRONMENT_IS_WEB = typeof window === "object"; -var ENVIRONMENT_IS_WORKER = typeof importScripts === "function"; -var emglobal = ENVIRONMENT_IS_WORKER ? self : ENVIRONMENT_IS_WEB ? window : global; -if (!emglobal["require"]) { - emglobal["require"] = (modpath) => { - if (modpath.endsWith(".js")) - modpath = modpath.slice(-3); - var modname = modpath.split("/").slice(-1)[0]; - var hasNamespace = emglobal[modname] != null; - console.log("@@@ require", modname, modpath, hasNamespace); - if (!hasNamespace) { - exports = {}; - importScripts(`${modpath}.js`); - } - if (emglobal[modname] == null) { - emglobal[modname] = exports; - } - return emglobal[modname]; - }; -} -var _WASM_module_cache = {}; -var CACHE_WASM_MODULES = true; -var wasmMemory; -function getWASMMemory() { - if (wasmMemory == null) { - wasmMemory = new WebAssembly.Memory({ - "initial": 1024, - "maximum": 16384 - }); - } - return wasmMemory; -} -function getWASMModule(module_id) { - var module2 = _WASM_module_cache[module_id]; - if (!module2) { - starttime(); - module2 = new WebAssembly.Module(wasmBlob[module_id]); - if (CACHE_WASM_MODULES) { - _WASM_module_cache[module_id] = module2; - delete wasmBlob[module_id]; - } - endtime("module creation " + module_id); - } - return module2; -} -function moduleInstFn(module_id) { - return function(imports, ri) { - var mod = getWASMModule(module_id); - var inst = new WebAssembly.Instance(mod, imports); - ri(inst); - return inst.exports; - }; -} -var PLATFORM_PARAMS = { - "vcs": { - arch: "6502", - code_start: 4096, - code_size: 61440, - data_start: 128, - data_size: 128, - wiz_rom_ext: ".a26", - wiz_inc_dir: "2600", - cfgfile: "atari2600.cfg", - libargs: ["crt0.o", "atari2600.lib"], - extra_link_files: ["crt0.o", "atari2600.cfg"], - define: ["__ATARI2600__"] - }, - "mw8080bw": { - arch: "z80", - code_start: 0, - rom_size: 8192, - data_start: 8192, - data_size: 1024, - stack_end: 9216 - }, - "vicdual": { - arch: "z80", - code_start: 0, - rom_size: 16416, - data_start: 58368, - data_size: 1024, - stack_end: 59392 - }, - "galaxian": { - arch: "z80", - code_start: 0, - rom_size: 16384, - data_start: 16384, - data_size: 1024, - stack_end: 18432 - }, - "galaxian-scramble": { - arch: "z80", - code_start: 0, - rom_size: 20512, - data_start: 16384, - data_size: 1024, - stack_end: 18432 - }, - "williams": { - arch: "6809", - code_start: 0, - rom_size: 49152, - data_start: 38912, - data_size: 10240, - stack_end: 49152, - set_stack_end: 49152, - extra_link_files: ["williams.scr", "libcmoc-crt-vec.a", "libcmoc-std-vec.a"], - extra_link_args: ["-swilliams.scr", "-lcmoc-crt-vec", "-lcmoc-std-vec"], - extra_compile_files: ["assert.h", "cmoc.h", "stdarg.h", "stdlib.h"] - }, - "williams-defender": { - arch: "6809", - code_start: 0, - rom_size: 49152, - data_start: 38912, - data_size: 10240, - stack_end: 49152 - }, - "williams-z80": { - arch: "z80", - code_start: 0, - rom_size: 38912, - data_start: 38912, - data_size: 10240, - stack_end: 49152 - }, - "vector-z80color": { - arch: "z80", - code_start: 0, - rom_size: 32768, - data_start: 57344, - data_size: 8192, - stack_end: 0 - }, - "vector-ataricolor": { - arch: "6502", - define: ["__VECTOR__"], - cfgfile: "vector-color.cfg", - libargs: ["crt0.o", "none.lib"], - extra_link_files: ["crt0.o", "vector-color.cfg"] - }, - "sound_williams-z80": { - arch: "z80", - code_start: 0, - rom_size: 16384, - data_start: 16384, - data_size: 1024, - stack_end: 32768 - }, - "base_z80": { - arch: "z80", - code_start: 0, - rom_size: 32768, - data_start: 32768, - data_size: 32768, - stack_end: 0 - }, - "coleco": { - arch: "z80", - rom_start: 32768, - code_start: 33024, - rom_size: 32768, - data_start: 28672, - data_size: 1024, - stack_end: 32768, - extra_preproc_args: ["-I", "/share/include/coleco", "-D", "CV_CV"], - extra_link_args: ["-k", "/share/lib/coleco", "-l", "libcv", "-l", "libcvu", "crt0.rel"] - }, - "msx": { - arch: "z80", - rom_start: 16384, - code_start: 16384, - rom_size: 32768, - data_start: 49152, - data_size: 12288, - stack_end: 65535, - extra_link_args: ["crt0-msx.rel"], - extra_link_files: ["crt0-msx.rel", "crt0-msx.lst"], - wiz_sys_type: "z80", - wiz_inc_dir: "msx" - }, - "msx-libcv": { - arch: "z80", - rom_start: 16384, - code_start: 16384, - rom_size: 32768, - data_start: 49152, - data_size: 12288, - stack_end: 65535, - extra_preproc_args: ["-I", ".", "-D", "CV_MSX"], - extra_link_args: ["-k", ".", "-l", "libcv-msx", "-l", "libcvu-msx", "crt0-msx.rel"], - extra_link_files: ["libcv-msx.lib", "libcvu-msx.lib", "crt0-msx.rel", "crt0-msx.lst"], - extra_compile_files: ["cv.h", "cv_graphics.h", "cv_input.h", "cv_sound.h", "cv_support.h", "cvu.h", "cvu_c.h", "cvu_compression.h", "cvu_f.h", "cvu_graphics.h", "cvu_input.h", "cvu_sound.h"] - }, - "sms-sg1000-libcv": { - arch: "z80", - rom_start: 0, - code_start: 256, - rom_size: 49152, - data_start: 49152, - data_size: 1024, - stack_end: 57344, - extra_preproc_args: ["-I", ".", "-D", "CV_SMS"], - extra_link_args: ["-k", ".", "-l", "libcv-sms", "-l", "libcvu-sms", "crt0-sms.rel"], - extra_link_files: ["libcv-sms.lib", "libcvu-sms.lib", "crt0-sms.rel", "crt0-sms.lst"], - extra_compile_files: ["cv.h", "cv_graphics.h", "cv_input.h", "cv_sound.h", "cv_support.h", "cvu.h", "cvu_c.h", "cvu_compression.h", "cvu_f.h", "cvu_graphics.h", "cvu_input.h", "cvu_sound.h"] - }, - "nes": { - arch: "6502", - define: ["__NES__"], - cfgfile: "neslib2.cfg", - libargs: [ - "crt0.o", - "nes.lib", - "neslib2.lib", - "-D", - "NES_MAPPER=0", - "-D", - "NES_PRG_BANKS=2", - "-D", - "NES_CHR_BANKS=1", - "-D", - "NES_MIRRORING=0" - ], - extra_link_files: ["crt0.o", "neslib2.lib", "neslib2.cfg", "nesbanked.cfg"], - wiz_rom_ext: ".nes" - }, - "apple2": { - arch: "6502", - define: ["__APPLE2__"], - cfgfile: "apple2.cfg", - libargs: ["--lib-path", "/share/target/apple2/drv", "apple2.lib"], - __CODE_RUN__: 16384, - code_start: 2051, - acmeargs: ["-f", "apple"] - }, - "apple2-e": { - arch: "6502", - define: ["__APPLE2__"], - cfgfile: "apple2.cfg", - libargs: ["apple2.lib"], - acmeargs: ["-f", "apple"] - }, - "atari8-800xl.disk": { - arch: "6502", - define: ["__ATARI__"], - cfgfile: "atari.cfg", - libargs: ["atari.lib"], - fastbasic_cfgfile: "fastbasic-cart.cfg" - }, - "atari8-800xl": { - arch: "6502", - define: ["__ATARI__"], - cfgfile: "atari-cart.cfg", - libargs: ["atari.lib", "-D", "__CARTFLAGS__=4"], - fastbasic_cfgfile: "fastbasic-cart.cfg" - }, - "atari8-800": { - arch: "6502", - define: ["__ATARI__"], - cfgfile: "atari-cart.cfg", - libargs: ["atari.lib", "-D", "__CARTFLAGS__=4"], - fastbasic_cfgfile: "fastbasic-cart.cfg" - }, - "atari8-5200": { - arch: "6502", - define: ["__ATARI5200__"], - cfgfile: "atari5200.cfg", - libargs: ["atari5200.lib", "-D", "__CARTFLAGS__=255"], - fastbasic_cfgfile: "fastbasic-cart.cfg" - }, - "verilog": { - arch: "verilog", - extra_compile_files: ["8bitworkshop.v"] - }, - "astrocade": { - arch: "z80", - code_start: 8192, - rom_size: 8192, - data_start: 19984, - data_size: 496, - stack_end: 20480 - }, - "astrocade-arcade": { - arch: "z80", - code_start: 0, - rom_size: 16384, - data_start: 32224, - data_size: 544, - stack_end: 32768 - }, - "astrocade-bios": { - arch: "z80", - code_start: 0, - rom_size: 8192, - data_start: 20430, - data_size: 50, - stack_end: 20430 - }, - "atari7800": { - arch: "6502", - define: ["__ATARI7800__"], - cfgfile: "atari7800.cfg", - libargs: ["crt0.o", "none.lib"], - extra_link_files: ["crt0.o", "atari7800.cfg"] - }, - "c64": { - arch: "6502", - define: ["__CBM__", "__C64__"], - cfgfile: "c64.cfg", - libargs: ["c64.lib"], - acmeargs: ["-f", "cbm"] - }, - "vic20": { - arch: "6502", - define: ["__CBM__", "__VIC20__"], - cfgfile: "vic20.cfg", - libargs: ["vic20.lib"], - acmeargs: ["-f", "cbm"] - }, - "kim1": { - arch: "6502" - }, - "vectrex": { - arch: "6809", - code_start: 0, - rom_size: 32768, - data_start: 51328, - data_size: 896, - stack_end: 52224, - extra_compile_files: ["assert.h", "cmoc.h", "stdarg.h", "vectrex.h", "stdlib.h", "bios.h"], - extra_link_files: ["vectrex.scr", "libcmoc-crt-vec.a", "libcmoc-std-vec.a"], - extra_compile_args: ["--vectrex"], - extra_link_args: ["-svectrex.scr", "-lcmoc-crt-vec", "-lcmoc-std-vec"] - }, - "x86": { - arch: "x86" - }, - "zx": { - arch: "z80", - code_start: 23755, - rom_size: 65368 - 23755, - data_start: 61440, - data_size: 65024 - 61440, - stack_end: 65368, - extra_link_args: ["crt0-zx.rel"], - extra_link_files: ["crt0-zx.rel", "crt0-zx.lst"] - }, - "devel-6502": { - arch: "6502", - cfgfile: "devel-6502.cfg", - libargs: ["crt0.o", "none.lib"], - extra_link_files: ["crt0.o", "devel-6502.cfg"] - }, - "cpc.rslib": { - arch: "z80", - code_start: 16384, - rom_size: 45312 - 16384, - data_start: 45312, - data_size: 45312 - 49152, - stack_end: 49152, - extra_compile_files: ["cpcrslib.h"], - extra_link_args: ["crt0-cpc.rel", "cpcrslib.lib"], - extra_link_files: ["crt0-cpc.rel", "crt0-cpc.lst", "cpcrslib.lib", "cpcrslib.lst"] - }, - "cpc": { - arch: "z80", - code_start: 16384, - rom_size: 45312 - 16384, - data_start: 45312, - data_size: 45312 - 49152, - stack_end: 49152, - extra_compile_files: ["cpctelera.h"], - extra_link_args: ["crt0-cpc.rel", "cpctelera.lib"], - extra_link_files: ["crt0-cpc.rel", "crt0-cpc.lst", "cpctelera.lib", "cpctelera.lst"] - }, - "pce": { - arch: "huc6280", - define: ["__PCE__"], - cfgfile: "pce.cfg", - libargs: ["pce.lib", "-D", "__CARTSIZE__=0x8000"] - } -}; -PLATFORM_PARAMS["sms-sms-libcv"] = PLATFORM_PARAMS["sms-sg1000-libcv"]; -PLATFORM_PARAMS["sms-gg-libcv"] = PLATFORM_PARAMS["sms-sms-libcv"]; -var _t1; -function starttime() { - _t1 = new Date(); -} -function endtime(msg) { - var _t2 = new Date(); - console.log(msg, _t2.getTime() - _t1.getTime(), "ms"); -} -var FileWorkingStore = class { - constructor() { - this.workfs = {}; - this.workerseq = 0; - this.reset(); - } - reset() { - this.workfs = {}; - this.newVersion(); - } - currentVersion() { - return this.workerseq; - } - newVersion() { - let ts = new Date().getTime(); - if (ts <= this.workerseq) - ts = ++this.workerseq; - return ts; - } - putFile(path4, data) { - var encoding = typeof data === "string" ? "utf8" : "binary"; - var entry = this.workfs[path4]; - if (!entry || !compareData(entry.data, data) || entry.encoding != encoding) { - this.workfs[path4] = entry = { path: path4, data, encoding, ts: this.newVersion() }; - console.log("+++", entry.path, entry.encoding, entry.data.length, entry.ts); - } - return entry; - } - hasFile(path4) { - return this.workfs[path4] != null; - } - getFileData(path4) { - return this.workfs[path4] && this.workfs[path4].data; - } - getFileAsString(path4) { - let data = this.getFileData(path4); - if (data != null && typeof data !== "string") - throw new Error(`${path4}: expected string`); - return data; - } - getFileEntry(path4) { - return this.workfs[path4]; - } - setItem(key, value) { - this.items[key] = value; - } -}; -var store = new FileWorkingStore(); -function errorResult(msg) { - return { errors: [{ line: 0, msg }] }; -} -var Builder = class { - constructor() { - this.steps = []; - this.startseq = 0; - } - wasChanged(entry) { - return entry.ts > this.startseq; - } - async executeBuildSteps() { - this.startseq = store.currentVersion(); - var linkstep = null; - while (this.steps.length) { - var step = this.steps.shift(); - var platform = step.platform; - var [tool, remoteTool] = step.tool.split(":", 2); - var toolfn = TOOLS[tool]; - if (!toolfn) { - throw Error(`no tool named "${tool}"`); - } - if (remoteTool) { - step.tool = remoteTool; - } - step.params = PLATFORM_PARAMS[getBasePlatform(platform)]; - try { - step.result = await toolfn(step); - } catch (e) { - console.log("EXCEPTION", e, e.stack); - return errorResult(e + ""); - } - if (step.result) { - step.result.params = step.params; - if (step.debuginfo) { - let r = step.result; - if (!r.debuginfo) - r.debuginfo = {}; - Object.assign(r.debuginfo, step.debuginfo); - } - if ("errors" in step.result && step.result.errors.length) { - applyDefaultErrorPath(step.result.errors, step.path); - return step.result; - } - if ("output" in step.result && step.result.output) { - return step.result; - } - if ("linktool" in step.result) { - if (linkstep) { - linkstep.files = linkstep.files.concat(step.result.files); - linkstep.args = linkstep.args.concat(step.result.args); - } else { - linkstep = { - tool: step.result.linktool, - platform, - files: step.result.files, - args: step.result.args - }; - } - linkstep.debuginfo = step.debuginfo; - } - if ("nexttool" in step.result) { - var asmstep = { - tool: step.result.nexttool, - platform, - ...step.result - }; - this.steps.push(asmstep); - } - if (this.steps.length == 0 && linkstep) { - this.steps.push(linkstep); - linkstep = null; - } - } - } - } - async handleMessage(data) { - this.steps = []; - if (data.updates) { - data.updates.forEach((u) => store.putFile(u.path, u.data)); - } - if (data.setitems) { - data.setitems.forEach((i) => store.setItem(i.key, i.value)); - } - if (data.buildsteps) { - this.steps.push.apply(this.steps, data.buildsteps); - } - if (data.code) { - this.steps.push(data); - } - if (this.steps.length) { - var result = await this.executeBuildSteps(); - return result ? result : { unchanged: true }; - } - console.log("Unknown message", data); - } -}; -var builder = new Builder(); -function applyDefaultErrorPath(errors, path4) { - if (!path4) - return; - for (var i = 0; i < errors.length; i++) { - var err = errors[i]; - if (!err.path && err.line) - err.path = path4; - } -} -function compareData(a, b) { - if (a.length != b.length) - return false; - if (typeof a === "string" && typeof b === "string") { - return a == b; - } else { - for (var i = 0; i < a.length; i++) { - if (a[i] != b[i]) - return false; - } - return true; - } -} -function putWorkFile(path4, data) { - return store.putFile(path4, data); -} -function getWorkFileAsString(path4) { - return store.getFileAsString(path4); -} -function populateEntry(fs3, path4, entry, options) { - var data = entry.data; - if (options && options.processFn) { - data = options.processFn(path4, data); - } - var toks = path4.split("/"); - if (toks.length > 1) { - for (var i = 0; i < toks.length - 1; i++) - try { - fs3.mkdir(toks[i]); - } catch (e) { - } - } - fs3.writeFile(path4, data, { encoding: entry.encoding }); - var time = new Date(entry.ts); - fs3.utime(path4, time, time); - console.log("<<<", path4, entry.data.length); -} -function gatherFiles(step, options) { - var maxts = 0; - if (step.files) { - for (var i = 0; i < step.files.length; i++) { - var path4 = step.files[i]; - var entry = store.workfs[path4]; - if (!entry) { - throw new Error("No entry for path '" + path4 + "'"); - } else { - maxts = Math.max(maxts, entry.ts); - } - } - } else if (step.code) { - var path4 = step.path ? step.path : options.mainFilePath; - if (!path4) - throw Error("need path or mainFilePath"); - var code = step.code; - var entry = putWorkFile(path4, code); - step.path = path4; - step.files = [path4]; - maxts = entry.ts; - } else if (step.path) { - var path4 = step.path; - var entry = store.workfs[path4]; - maxts = entry.ts; - step.files = [path4]; - } - if (step.path && !step.prefix) { - step.prefix = getPrefix(step.path); - } - step.maxts = maxts; - return maxts; -} -function getPrefix(s) { - var pos = s.lastIndexOf("."); - return pos > 0 ? s.substring(0, pos) : s; -} -function populateFiles(step, fs3, options) { - gatherFiles(step, options); - if (!step.files) - throw Error("call gatherFiles() first"); - for (var i = 0; i < step.files.length; i++) { - var path4 = step.files[i]; - populateEntry(fs3, path4, store.workfs[path4], options); - } -} -function populateExtraFiles(step, fs3, extrafiles) { - if (extrafiles) { - for (var i = 0; i < extrafiles.length; i++) { - var xfn = extrafiles[i]; - if (store.workfs[xfn]) { - fs3.writeFile(xfn, store.workfs[xfn].data, { encoding: "binary" }); - continue; - } - var xpath = "lib/" + getBasePlatform(step.platform) + "/" + xfn; - var xhr = new XMLHttpRequest(); - xhr.responseType = "arraybuffer"; - xhr.open("GET", PWORKER + xpath, false); - xhr.send(null); - if (xhr.response && xhr.status == 200) { - var data = new Uint8Array(xhr.response); - fs3.writeFile(xfn, data, { encoding: "binary" }); - putWorkFile(xfn, data); - console.log(":::", xfn, data.length); - } else { - throw Error("Could not load extra file " + xpath); - } - } - } -} -function staleFiles(step, targets) { - if (!step.maxts) - throw Error("call populateFiles() first"); - for (var i = 0; i < targets.length; i++) { - var entry = store.workfs[targets[i]]; - if (!entry || step.maxts > entry.ts) - return true; - } - console.log("unchanged", step.maxts, targets); - return false; -} -function anyTargetChanged(step, targets) { - if (!step.maxts) - throw Error("call populateFiles() first"); - for (var i = 0; i < targets.length; i++) { - var entry = store.workfs[targets[i]]; - if (!entry || entry.ts > step.maxts) - return true; - } - console.log("unchanged", step.maxts, targets); - return false; -} -function execMain(step, mod, args) { - starttime(); - var run = mod.callMain || mod.run; - run(args); - endtime(step.tool); -} -var fsMeta = {}; -var fsBlob = {}; -var wasmBlob = {}; -var PSRC = "../../src/"; -var PWORKER = PSRC + "worker/"; -function loadFilesystem(name) { - var xhr = new XMLHttpRequest(); - xhr.responseType = "blob"; - xhr.open("GET", PWORKER + "fs/fs" + name + ".data", false); - xhr.send(null); - fsBlob[name] = xhr.response; - xhr = new XMLHttpRequest(); - xhr.responseType = "json"; - xhr.open("GET", PWORKER + "fs/fs" + name + ".js.metadata", false); - xhr.send(null); - fsMeta[name] = xhr.response; - console.log("Loaded " + name + " filesystem", fsMeta[name].files.length, "files", fsBlob[name].size, "bytes"); -} -var loaded = {}; -function load(modulename, debug3) { - if (!loaded[modulename]) { - importScripts(PWORKER + "asmjs/" + modulename + (debug3 ? "." + debug3 + ".js" : ".js")); - loaded[modulename] = 1; - } -} -function loadWASMBinary(modulename) { - if (!loaded[modulename]) { - var xhr = new XMLHttpRequest(); - xhr.responseType = "arraybuffer"; - xhr.open("GET", PWORKER + "wasm/" + modulename + ".wasm", false); - xhr.send(null); - if (xhr.response) { - wasmBlob[modulename] = new Uint8Array(xhr.response); - console.log("Loaded " + modulename + ".wasm (" + wasmBlob[modulename].length + " bytes)"); - loaded[modulename] = 1; - } else { - throw Error("Could not load WASM file " + modulename + ".wasm"); - } - } - return wasmBlob[modulename]; -} -function loadWASM(modulename, debug3) { - if (!loaded[modulename]) { - importScripts(PWORKER + "wasm/" + modulename + (debug3 ? "." + debug3 + ".js" : ".js")); - loadWASMBinary(modulename); - } -} -function loadNative(modulename) { - if (CACHE_WASM_MODULES && typeof WebAssembly === "object") { - loadWASM(modulename); - } else { - load(modulename); - } -} -function setupFS(FS, name) { - var WORKERFS = FS.filesystems["WORKERFS"]; - if (name === "65-vector") - name = "65-none"; - if (name === "65-atari7800") - name = "65-none"; - if (name === "65-devel") - name = "65-none"; - if (name === "65-vcs") - name = "65-atari2600"; - if (!fsMeta[name]) - throw Error("No filesystem for '" + name + "'"); - FS.mkdir("/share"); - FS.mount(WORKERFS, { - packages: [{ metadata: fsMeta[name], blob: fsBlob[name] }] - }, "/share"); - var reader = WORKERFS.reader; - var blobcache = {}; - WORKERFS.stream_ops.read = function(stream, buffer, offset, length, position) { - if (position >= stream.node.size) - return 0; - var contents = blobcache[stream.path]; - if (!contents) { - var ab = reader.readAsArrayBuffer(stream.node.contents); - contents = blobcache[stream.path] = new Uint8Array(ab); - } - if (position + length > contents.length) - length = contents.length - position; - for (var i = 0; i < length; i++) { - buffer[offset + i] = contents[position + i]; - } - return length; - }; -} -var print_fn = function(s) { - console.log(s); -}; -var re_msvc = /[/]*([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+?):\s*(.*)/; -var re_msvc2 = /\s*(at)\s+(\d+)\s*(:)\s*(.*)/; -function msvcErrorMatcher(errors) { - return function(s) { - var matches = re_msvc.exec(s) || re_msvc2.exec(s); - if (matches) { - var errline = parseInt(matches[2]); - errors.push({ - line: errline, - path: matches[1], - msg: matches[4] - }); - } else { - console.log(s); - } - }; -} -function makeErrorMatcher(errors, regex, iline, imsg, mainpath, ifilename) { - return function(s) { - var matches = regex.exec(s); - if (matches) { - errors.push({ - line: parseInt(matches[iline]) || 1, - msg: matches[imsg], - path: ifilename ? matches[ifilename] : mainpath - }); - } else { - console.log("??? " + s); - } - }; -} -function extractErrors(regex, strings, path4, iline, imsg, ifilename) { - var errors = []; - var matcher = makeErrorMatcher(errors, regex, iline, imsg, path4, ifilename); - for (var i = 0; i < strings.length; i++) { - matcher(strings[i]); - } - return errors; -} -var re_crlf = /\r?\n/; -var re_lineoffset = /\s*(\d+)\s+[%]line\s+(\d+)\+(\d+)\s+(.+)/; -function parseListing(code, lineMatch, iline, ioffset, iinsns, icycles, funcMatch, segMatch) { - var lines = []; - var lineofs = 0; - var segment = ""; - var func = ""; - var funcbase = 0; - code.split(re_crlf).forEach((line, lineindex) => { - let segm = segMatch && segMatch.exec(line); - if (segm) { - segment = segm[1]; - } - let funcm = funcMatch && funcMatch.exec(line); - if (funcm) { - funcbase = parseInt(funcm[1], 16); - func = funcm[2]; - } - var linem = lineMatch.exec(line); - if (linem && linem[1]) { - var linenum = iline < 0 ? lineindex : parseInt(linem[iline]); - var offset = parseInt(linem[ioffset], 16); - var insns = linem[iinsns]; - var cycles = icycles ? parseInt(linem[icycles]) : null; - var iscode = cycles > 0; - if (insns) { - lines.push({ - line: linenum + lineofs, - offset: offset - funcbase, - insns, - cycles, - iscode, - segment, - func - }); - } - } else { - let m = re_lineoffset.exec(line); - if (m) { - lineofs = parseInt(m[2]) - parseInt(m[1]) - parseInt(m[3]); - } - } - }); - return lines; -} -function parseSourceLines(code, lineMatch, offsetMatch, funcMatch, segMatch) { - var lines = []; - var lastlinenum = 0; - var segment = ""; - var func = ""; - var funcbase = 0; - for (var line of code.split(re_crlf)) { - let segm = segMatch && segMatch.exec(line); - if (segm) { - segment = segm[1]; - } - let funcm = funcMatch && funcMatch.exec(line); - if (funcm) { - funcbase = parseInt(funcm[1], 16); - func = funcm[2]; - } - var linem = lineMatch.exec(line); - if (linem && linem[1]) { - lastlinenum = parseInt(linem[1]); - } else if (lastlinenum) { - var linem = offsetMatch.exec(line); - if (linem && linem[1]) { - var offset = parseInt(linem[1], 16); - lines.push({ - line: lastlinenum, - offset: offset - funcbase, - segment, - func - }); - lastlinenum = 0; - } - } - } - return lines; -} -function setupStdin(fs3, code) { - var i = 0; - fs3.init(function() { - return i < code.length ? code.charCodeAt(i++) : null; - }); -} -function fixParamsWithDefines(path4, params) { - var libargs = params.libargs; - if (path4 && libargs) { - var code = getWorkFileAsString(path4); - if (code) { - var oldcfgfile = params.cfgfile; - var ident2index = {}; - for (var i = 0; i < libargs.length; i++) { - var toks = libargs[i].split("="); - if (toks.length == 2) { - ident2index[toks[0]] = i; - } - } - var re = /^[;]?#define\s+(\w+)\s+(\S+)/gmi; - var m; - while (m = re.exec(code)) { - var ident = m[1]; - var value = m[2]; - var index = ident2index[ident]; - if (index >= 0) { - libargs[index] = ident + "=" + value; - console.log("Using libargs", index, libargs[index]); - if (ident == "NES_MAPPER" && value == "4") { - params.cfgfile = "nesbanked.cfg"; - console.log("using config file", params.cfgfile); - } - } else if (ident == "CFGFILE" && value) { - params.cfgfile = value; - } else if (ident == "LIBARGS" && value) { - params.libargs = value.split(",").filter((s) => { - return s != ""; - }); - console.log("Using libargs", params.libargs); - } else if (ident == "CC65_FLAGS" && value) { - params.extra_compiler_args = value.split(",").filter((s) => { - return s != ""; - }); - console.log("Using compiler flags", params.extra_compiler_args); - } - } - } - } -} -function makeCPPSafe(s) { - return s.replace(/[^A-Za-z0-9_]/g, "_"); -} -function preprocessMCPP(step, filesys) { - load("mcpp"); - var platform = step.platform; - var params = PLATFORM_PARAMS[getBasePlatform(platform)]; - if (!params) - throw Error("Platform not supported: " + platform); - var errors = []; - var match_fn = makeErrorMatcher(errors, /:(\d+): (.+)/, 1, 2, step.path); - var MCPP = emglobal.mcpp({ - noInitialRun: true, - noFSInit: true, - print: print_fn, - printErr: match_fn - }); - var FS = MCPP.FS; - if (filesys) - setupFS(FS, filesys); - populateFiles(step, FS); - populateExtraFiles(step, FS, params.extra_compile_files); - var args = [ - "-D", - "__8BITWORKSHOP__", - "-D", - "__SDCC_z80", - "-D", - makeCPPSafe(platform.toUpperCase()), - "-I", - "/share/include", - "-Q", - step.path, - "main.i" - ]; - if (step.mainfile) { - args.unshift.apply(args, ["-D", "__MAIN__"]); - } - let platform_def = platform.toUpperCase().replaceAll(/[^a-zA-Z0-9]/g, "_"); - args.unshift.apply(args, ["-D", `__PLATFORM_${platform_def}__`]); - if (params.extra_preproc_args) { - args.push.apply(args, params.extra_preproc_args); - } - execMain(step, MCPP, args); - if (errors.length) - return { errors }; - var iout = FS.readFile("main.i", { encoding: "utf8" }); - iout = iout.replace(/^#line /gm, "\n# "); - try { - var errout = FS.readFile("mcpp.err", { encoding: "utf8" }); - if (errout.length) { - var errors = extractErrors(/([^:]+):(\d+): (.+)/, errout.split("\n"), step.path, 2, 3, 1); - if (errors.length == 0) { - errors = errorResult(errout).errors; - } - return { errors }; - } - } catch (e) { - } - return { code: iout }; -} -function setupRequireFunction() { - var exports2 = {}; - exports2["jsdom"] = { - JSDOM: function(a, b) { - this.window = {}; - } - }; - emglobal["require"] = (modname) => { - console.log("require", modname, exports2[modname] != null); - return exports2[modname]; - }; -} -var TOOLS = { - "dasm": assembleDASM, - "acme": assembleACME, - "cc65": compileCC65, - "ca65": assembleCA65, - "ld65": linkLD65, - "sdasz80": assembleSDASZ80, - "sdldz80": linkSDLDZ80, - "sdcc": compileSDCC, - "xasm6809": assembleXASM6809, - "cmoc": compileCMOC, - "lwasm": assembleLWASM, - "lwlink": linkLWLINK, - "verilator": compileVerilator, - "yosys": compileYosys, - "jsasm": compileJSASMStep, - "zmac": assembleZMAC, - "nesasm": assembleNESASM, - "smlrc": compileSmallerC, - "yasm": assembleYASM, - "bataribasic": compileBatariBasic, - "markdown": translateShowdown, - "inform6": compileInform6, - "merlin32": assembleMerlin32, - "fastbasic": compileFastBasic, - "basic": compileBASIC, - "silice": compileSilice, - "wiz": compileWiz, - "armips": assembleARMIPS, - "vasmarm": assembleVASMARM, - "ecs": assembleECS, - "remote": buildRemote, - "cc7800": compileCC7800 -}; -var TOOL_PRELOADFS = { - "cc65-apple2": "65-apple2", - "ca65-apple2": "65-apple2", - "cc65-c64": "65-c64", - "ca65-c64": "65-c64", - "cc65-vic20": "65-vic20", - "ca65-vic20": "65-vic20", - "cc65-nes": "65-nes", - "ca65-nes": "65-nes", - "cc65-atari8": "65-atari8", - "ca65-atari8": "65-atari8", - "cc65-vector": "65-none", - "ca65-vector": "65-none", - "cc65-atari7800": "65-none", - "ca65-atari7800": "65-none", - "cc65-devel": "65-none", - "ca65-devel": "65-none", - "cc65-vcs": "65-atari2600", - "ca65-vcs": "65-atari2600", - "cc65-pce": "65-pce", - "ca65-pce": "65-pce", - "sdasz80": "sdcc", - "sdcc": "sdcc", - "sccz80": "sccz80", - "bataribasic": "2600basic", - "inform6": "inform", - "fastbasic": "65-atari8", - "silice": "Silice", - "wiz": "wiz", - "ecs-vcs": "65-atari2600", - "ecs-nes": "65-nes", - "ecs-c64": "65-c64" -}; -async function handleMessage(data) { - if (data.preload) { - var fs3 = TOOL_PRELOADFS[data.preload]; - if (!fs3 && data.platform) - fs3 = TOOL_PRELOADFS[data.preload + "-" + getBasePlatform(data.platform)]; - if (!fs3 && data.platform) - fs3 = TOOL_PRELOADFS[data.preload + "-" + getRootBasePlatform(data.platform)]; - if (fs3 && !fsMeta[fs3]) - loadFilesystem(fs3); - return; - } - if (data.reset) { - store.reset(); - return; - } - return builder.handleMessage(data); -} -if (ENVIRONMENT_IS_WORKER) { - lastpromise = null; - onmessage = async function(e) { - await lastpromise; - lastpromise = handleMessage(e.data); - var result = await lastpromise; - lastpromise = null; - if (result) { - try { - postMessage(result); - } catch (e2) { - console.log(e2); - postMessage(errorResult(`${e2}`)); - } - } - }; -} -var lastpromise; - // src/worker/server/clang.ts var import_path = __toModule(require("path")); function parseObjDump(lst) { @@ -46635,6 +26869,22 @@ function parseObjDump(lst) { return { listings, symbolmap, segments }; } +// src/worker/listingutils.ts +function makeErrorMatcher(errors, regex, iline, imsg, mainpath, ifilename) { + return function(s) { + var matches = regex.exec(s); + if (matches) { + errors.push({ + line: parseInt(matches[iline]) || 1, + msg: matches[imsg], + path: ifilename ? matches[ifilename] : mainpath + }); + } else { + console.log("??? " + s); + } + }; +} + // src/worker/server/buildenv.ts var LLVM_MOS_TOOL = { name: "llvm-mos", @@ -46675,25 +26925,25 @@ function findBestTool(step) { if (!step?.tool) throw new Error("No tool specified"); const [name, version] = step.tool.split("@"); - for (let tool of TOOLS2) { + for (let tool of TOOLS) { if (tool.name === name && (!version || version === "latest" || tool.version === version)) { return tool; } } throw new Error(`Tool not found: ${step.tool}`); } -var TOOLS2 = [ +var TOOLS = [ Object.assign({}, LLVM_MOS_TOOL, { version: "latest" }) ]; var ServerBuildEnv = class { - constructor(rootdir, sessionID2, tool) { + constructor(rootdir, sessionID, tool) { this.rootdir = import_path2.default.resolve(rootdir); - this.sessionID = sessionID2; + this.sessionID = sessionID; this.tool = tool; - if (!sessionID2.match(/^[a-zA-Z0-9_-]+$/)) { - throw new Error(`Invalid sessionID: ${sessionID2}`); + if (!sessionID.match(/^[a-zA-Z0-9_-]+$/)) { + throw new Error(`Invalid sessionID: ${sessionID}`); } - this.sessionDir = import_path2.default.join(this.rootdir, "sessions", sessionID2); + this.sessionDir = import_path2.default.join(this.rootdir, "sessions", sessionID); if (!import_fs.default.existsSync(this.sessionDir)) { import_fs.default.mkdirSync(this.sessionDir); } @@ -46769,13 +27019,13 @@ var ServerBuildEnv = class { errorData = replaceAll(errorData, this.sessionDir, ""); errorData = replaceAll(errorData, this.rootdir, ""); errorData = errorData.replace(/(\/var\/folders\/.+?\/).+?:/g, ""); - let errorResult2 = await this.processErrors(step, errorData); - if (errorResult2.errors.length === 0) { - errorResult2.errors.push({ line: 0, msg: `Build failed. + let errorResult = await this.processErrors(step, errorData); + if (errorResult.errors.length === 0) { + errorResult.errors.push({ line: 0, msg: `Build failed. ${errorData}` }); } - resolve(errorResult2); + resolve(errorResult); } }); }); @@ -46824,13 +27074,13 @@ var app = (0, import_express.default)(); app.use((0, import_cors.default)()); app.use(import_express.default.json({ limit: 1024 * 1024 })); app.get("/info", (req, res) => { - res.json({ tools: TOOLS2 }); + res.json({ tools: TOOLS }); }); app.get("/test", async (req, res, next) => { try { const updates = [{ path: "test.c", data: "int main() { return 0; }" }]; const buildStep = { tool: "llvm-mos", platform: "c64", files: ["test.c"] }; - const env = new ServerBuildEnv(SERVER_ROOT, "test", TOOLS2[0]); + const env = new ServerBuildEnv(SERVER_ROOT, "test", TOOLS[0]); const result = await env.compileAndLink(buildStep, updates); res.json(result); } catch (err) { @@ -46841,9 +27091,9 @@ app.post("/build", async (req, res, next) => { try { const updates = req.body.updates; const buildStep = req.body.buildStep; - const sessionID2 = req.body.sessionID; + const sessionID = req.body.sessionID; const bestTool = findBestTool(buildStep); - const env = new ServerBuildEnv(SERVER_ROOT, sessionID2, bestTool); + const env = new ServerBuildEnv(SERVER_ROOT, sessionID, bestTool); const result = await env.compileAndLink(buildStep, updates); res.json(result); } catch (err) { diff --git a/gen/server/server.js.map b/gen/server/server.js.map index ef2fb9ec..28226c9f 100644 --- a/gen/server/server.js.map +++ b/gen/server/server.js.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../../node_modules/depd/index.js", "../../node_modules/bytes/index.js", "../../node_modules/content-type/index.js", "../../node_modules/setprototypeof/index.js", "../../node_modules/statuses/index.js", "../../node_modules/inherits/inherits_browser.js", "../../node_modules/inherits/inherits.js", "../../node_modules/toidentifier/index.js", "../../node_modules/http-errors/index.js", "../../node_modules/body-parser/node_modules/ms/index.js", "../../node_modules/body-parser/node_modules/debug/src/debug.js", "../../node_modules/body-parser/node_modules/debug/src/browser.js", "../../node_modules/body-parser/node_modules/debug/src/node.js", "../../node_modules/body-parser/node_modules/debug/src/index.js", "../../node_modules/destroy/index.js", "../../node_modules/safer-buffer/safer.js", "../../node_modules/raw-body/node_modules/iconv-lite/lib/bom-handling.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/internal.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/utf16.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/utf7.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/sbcs-codec.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/sbcs-data.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/sbcs-data-generated.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/dbcs-codec.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/dbcs-data.js", "../../node_modules/raw-body/node_modules/iconv-lite/encodings/index.js", "../../node_modules/raw-body/node_modules/iconv-lite/lib/streams.js", "../../node_modules/raw-body/node_modules/iconv-lite/lib/extend-node.js", "../../node_modules/raw-body/node_modules/iconv-lite/lib/index.js", "../../node_modules/unpipe/index.js", "../../node_modules/raw-body/index.js", "../../node_modules/body-parser/node_modules/iconv-lite/lib/bom-handling.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/internal.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/utf16.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/utf7.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-codec.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-data.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/sbcs-data-generated.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/dbcs-codec.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/dbcs-data.js", "../../node_modules/body-parser/node_modules/iconv-lite/encodings/index.js", "../../node_modules/body-parser/node_modules/iconv-lite/lib/streams.js", "../../node_modules/body-parser/node_modules/iconv-lite/lib/extend-node.js", "../../node_modules/body-parser/node_modules/iconv-lite/lib/index.js", "../../node_modules/ee-first/index.js", "../../node_modules/on-finished/index.js", "../../node_modules/body-parser/lib/read.js", "../../node_modules/media-typer/index.js", "../../node_modules/mime-db/index.js", "../../node_modules/mime-types/index.js", "../../node_modules/type-is/index.js", "../../node_modules/body-parser/lib/types/json.js", "../../node_modules/body-parser/lib/types/raw.js", "../../node_modules/body-parser/lib/types/text.js", "../../node_modules/has-symbols/shams.js", "../../node_modules/has-symbols/index.js", "../../node_modules/has-proto/index.js", "../../node_modules/function-bind/implementation.js", "../../node_modules/function-bind/index.js", "../../node_modules/hasown/index.js", "../../node_modules/get-intrinsic/index.js", "../../node_modules/has-property-descriptors/index.js", "../../node_modules/gopd/index.js", "../../node_modules/define-data-property/index.js", "../../node_modules/set-function-length/index.js", "../../node_modules/call-bind/index.js", "../../node_modules/call-bind/callBound.js", "../../node_modules/object-inspect/util.inspect.js", "../../node_modules/object-inspect/index.js", "../../node_modules/side-channel/index.js", "../../node_modules/qs/lib/formats.js", "../../node_modules/qs/lib/utils.js", "../../node_modules/qs/lib/stringify.js", "../../node_modules/qs/lib/parse.js", "../../node_modules/qs/lib/index.js", "../../node_modules/body-parser/lib/types/urlencoded.js", "../../node_modules/body-parser/index.js", "../../node_modules/merge-descriptors/index.js", "../../node_modules/finalhandler/node_modules/ms/index.js", "../../node_modules/finalhandler/node_modules/debug/src/debug.js", "../../node_modules/finalhandler/node_modules/debug/src/browser.js", "../../node_modules/finalhandler/node_modules/debug/src/node.js", "../../node_modules/finalhandler/node_modules/debug/src/index.js", "../../node_modules/encodeurl/index.js", "../../node_modules/escape-html/index.js", "../../node_modules/parseurl/index.js", "../../node_modules/finalhandler/index.js", "../../node_modules/express/node_modules/ms/index.js", "../../node_modules/express/node_modules/debug/src/debug.js", "../../node_modules/express/node_modules/debug/src/browser.js", "../../node_modules/express/node_modules/debug/src/node.js", "../../node_modules/express/node_modules/debug/src/index.js", "../../node_modules/array-flatten/array-flatten.js", "../../node_modules/path-to-regexp/index.js", "../../node_modules/express/lib/router/layer.js", "../../node_modules/methods/index.js", "../../node_modules/express/lib/router/route.js", "../../node_modules/utils-merge/index.js", "../../node_modules/express/lib/router/index.js", "../../node_modules/express/lib/middleware/init.js", "../../node_modules/express/lib/middleware/query.js", "../../node_modules/express/lib/view.js", "../../node_modules/safe-buffer/index.js", "../../node_modules/content-disposition/index.js", "../../node_modules/send/node_modules/debug/node_modules/ms/index.js", "../../node_modules/send/node_modules/debug/src/debug.js", "../../node_modules/send/node_modules/debug/src/browser.js", "../../node_modules/send/node_modules/debug/src/node.js", "../../node_modules/send/node_modules/debug/src/index.js", "../../node_modules/etag/index.js", "../../node_modules/fresh/index.js", "../../node_modules/mime/mime.js", "../../node_modules/send/node_modules/ms/index.js", "../../node_modules/range-parser/index.js", "../../node_modules/send/index.js", "../../node_modules/forwarded/index.js", "../../node_modules/ipaddr.js/lib/ipaddr.js", "../../node_modules/proxy-addr/index.js", "../../node_modules/express/lib/utils.js", "../../node_modules/express/lib/application.js", "../../node_modules/negotiator/lib/charset.js", "../../node_modules/negotiator/lib/encoding.js", "../../node_modules/negotiator/lib/language.js", "../../node_modules/negotiator/lib/mediaType.js", "../../node_modules/negotiator/index.js", "../../node_modules/accepts/index.js", "../../node_modules/express/lib/request.js", "../../node_modules/cookie-signature/index.js", "../../node_modules/cookie/index.js", "../../node_modules/vary/index.js", "../../node_modules/express/lib/response.js", "../../node_modules/serve-static/index.js", "../../node_modules/express/lib/express.js", "../../node_modules/express/index.js", "../../node_modules/object-assign/index.js", "../../node_modules/cors/lib/index.js", "../../node_modules/process-nextick-args/index.js", "../../node_modules/isarray/index.js", "../../node_modules/readable-stream/lib/internal/streams/stream.js", "../../node_modules/readable-stream/node_modules/safe-buffer/index.js", "../../node_modules/core-util-is/lib/util.js", "../../node_modules/readable-stream/lib/internal/streams/BufferList.js", "../../node_modules/readable-stream/lib/internal/streams/destroy.js", "../../node_modules/util-deprecate/node.js", "../../node_modules/readable-stream/lib/_stream_writable.js", "../../node_modules/readable-stream/lib/_stream_duplex.js", "../../node_modules/readable-stream/lib/_stream_readable.js", "../../node_modules/readable-stream/lib/_stream_transform.js", "../../node_modules/readable-stream/lib/_stream_passthrough.js", "../../node_modules/readable-stream/readable.js", "../../node_modules/jszip/lib/support.js", "../../node_modules/jszip/lib/base64.js", "../../node_modules/jszip/lib/nodejsUtils.js", "../../node_modules/immediate/lib/index.js", "../../node_modules/lie/lib/index.js", "../../node_modules/jszip/lib/external.js", "../../node_modules/setimmediate/setImmediate.js", "../../node_modules/jszip/lib/utils.js", "../../node_modules/jszip/lib/stream/GenericWorker.js", "../../node_modules/jszip/lib/utf8.js", "../../node_modules/jszip/lib/stream/ConvertWorker.js", "../../node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js", "../../node_modules/jszip/lib/stream/StreamHelper.js", "../../node_modules/jszip/lib/defaults.js", "../../node_modules/jszip/lib/stream/DataWorker.js", "../../node_modules/jszip/lib/crc32.js", "../../node_modules/jszip/lib/stream/Crc32Probe.js", "../../node_modules/jszip/lib/stream/DataLengthProbe.js", "../../node_modules/jszip/lib/compressedObject.js", "../../node_modules/jszip/lib/zipObject.js", "../../node_modules/pako/lib/utils/common.js", "../../node_modules/pako/lib/zlib/trees.js", "../../node_modules/pako/lib/zlib/adler32.js", "../../node_modules/pako/lib/zlib/crc32.js", "../../node_modules/pako/lib/zlib/messages.js", "../../node_modules/pako/lib/zlib/deflate.js", "../../node_modules/pako/lib/utils/strings.js", "../../node_modules/pako/lib/zlib/zstream.js", "../../node_modules/pako/lib/deflate.js", "../../node_modules/pako/lib/zlib/inffast.js", "../../node_modules/pako/lib/zlib/inftrees.js", "../../node_modules/pako/lib/zlib/inflate.js", "../../node_modules/pako/lib/zlib/constants.js", "../../node_modules/pako/lib/zlib/gzheader.js", "../../node_modules/pako/lib/inflate.js", "../../node_modules/pako/index.js", "../../node_modules/jszip/lib/flate.js", "../../node_modules/jszip/lib/compressions.js", "../../node_modules/jszip/lib/signature.js", "../../node_modules/jszip/lib/generate/ZipFileWorker.js", "../../node_modules/jszip/lib/generate/index.js", "../../node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js", "../../node_modules/jszip/lib/object.js", "../../node_modules/jszip/lib/reader/DataReader.js", "../../node_modules/jszip/lib/reader/ArrayReader.js", "../../node_modules/jszip/lib/reader/StringReader.js", "../../node_modules/jszip/lib/reader/Uint8ArrayReader.js", "../../node_modules/jszip/lib/reader/NodeBufferReader.js", "../../node_modules/jszip/lib/reader/readerFor.js", "../../node_modules/jszip/lib/zipEntry.js", "../../node_modules/jszip/lib/zipEntries.js", "../../node_modules/jszip/lib/load.js", "../../node_modules/jszip/lib/index.js", "../../src/worker/server/server.ts", "../../src/worker/server/buildenv.ts", "../../src/common/workertypes.ts", "../../src/common/util.ts", "../../src/common/basic/compiler.ts", "../../src/worker/tools/misc.ts", "../../src/worker/tools/cc65.ts", "../../src/worker/tools/dasm.ts", "../../src/worker/tools/sdcc.ts", "../../src/worker/assembler.ts", "../../src/common/hdl/hdltypes.ts", "../../src/common/hdl/vxmlparser.ts", "../../src/worker/tools/verilog.ts", "../../src/worker/tools/m6809.ts", "../../src/worker/tools/m6502.ts", "../../src/worker/tools/z80.ts", "../../src/worker/tools/x86.ts", "../../src/worker/tools/arm.ts", "../../src/common/tokenizer.ts", "../../src/common/ecs/binpack.ts", "../../src/common/ecs/ecs.ts", "../../src/common/ecs/decoder.ts", "../../src/common/ecs/compiler.ts", "../../src/worker/tools/ecs.ts", "../../src/worker/tools/remote.ts", "../../src/worker/tools/acme.ts", "../../src/common/wasi/wasishim.ts", "../../src/worker/tools/cc7800.ts", "../../src/worker/workermain.ts", "../../src/worker/server/clang.ts"], - "sourcesContent": ["/*!\n * depd\n * Copyright(c) 2014-2018 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\n\nvar relative = require('path').relative\n\n/**\n * Module exports.\n */\n\nmodule.exports = depd\n\n/**\n * Get the path to base files on.\n */\n\nvar basePath = process.cwd()\n\n/**\n * Determine if namespace is contained in the string.\n */\n\nfunction containsNamespace (str, namespace) {\n var vals = str.split(/[ ,]+/)\n var ns = String(namespace).toLowerCase()\n\n for (var i = 0; i < vals.length; i++) {\n var val = vals[i]\n\n // namespace contained\n if (val && (val === '*' || val.toLowerCase() === ns)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Convert a data descriptor to accessor descriptor.\n */\n\nfunction convertDataDescriptorToAccessor (obj, prop, message) {\n var descriptor = Object.getOwnPropertyDescriptor(obj, prop)\n var value = descriptor.value\n\n descriptor.get = function getter () { return value }\n\n if (descriptor.writable) {\n descriptor.set = function setter (val) { return (value = val) }\n }\n\n delete descriptor.value\n delete descriptor.writable\n\n Object.defineProperty(obj, prop, descriptor)\n\n return descriptor\n}\n\n/**\n * Create arguments string to keep arity.\n */\n\nfunction createArgumentsString (arity) {\n var str = ''\n\n for (var i = 0; i < arity; i++) {\n str += ', arg' + i\n }\n\n return str.substr(2)\n}\n\n/**\n * Create stack string from stack.\n */\n\nfunction createStackString (stack) {\n var str = this.name + ': ' + this.namespace\n\n if (this.message) {\n str += ' deprecated ' + this.message\n }\n\n for (var i = 0; i < stack.length; i++) {\n str += '\\n at ' + stack[i].toString()\n }\n\n return str\n}\n\n/**\n * Create deprecate for namespace in caller.\n */\n\nfunction depd (namespace) {\n if (!namespace) {\n throw new TypeError('argument namespace is required')\n }\n\n var stack = getStack()\n var site = callSiteLocation(stack[1])\n var file = site[0]\n\n function deprecate (message) {\n // call to self as log\n log.call(deprecate, message)\n }\n\n deprecate._file = file\n deprecate._ignored = isignored(namespace)\n deprecate._namespace = namespace\n deprecate._traced = istraced(namespace)\n deprecate._warned = Object.create(null)\n\n deprecate.function = wrapfunction\n deprecate.property = wrapproperty\n\n return deprecate\n}\n\n/**\n * Determine if event emitter has listeners of a given type.\n *\n * The way to do this check is done three different ways in Node.js >= 0.8\n * so this consolidates them into a minimal set using instance methods.\n *\n * @param {EventEmitter} emitter\n * @param {string} type\n * @returns {boolean}\n * @private\n */\n\nfunction eehaslisteners (emitter, type) {\n var count = typeof emitter.listenerCount !== 'function'\n ? emitter.listeners(type).length\n : emitter.listenerCount(type)\n\n return count > 0\n}\n\n/**\n * Determine if namespace is ignored.\n */\n\nfunction isignored (namespace) {\n if (process.noDeprecation) {\n // --no-deprecation support\n return true\n }\n\n var str = process.env.NO_DEPRECATION || ''\n\n // namespace ignored\n return containsNamespace(str, namespace)\n}\n\n/**\n * Determine if namespace is traced.\n */\n\nfunction istraced (namespace) {\n if (process.traceDeprecation) {\n // --trace-deprecation support\n return true\n }\n\n var str = process.env.TRACE_DEPRECATION || ''\n\n // namespace traced\n return containsNamespace(str, namespace)\n}\n\n/**\n * Display deprecation message.\n */\n\nfunction log (message, site) {\n var haslisteners = eehaslisteners(process, 'deprecation')\n\n // abort early if no destination\n if (!haslisteners && this._ignored) {\n return\n }\n\n var caller\n var callFile\n var callSite\n var depSite\n var i = 0\n var seen = false\n var stack = getStack()\n var file = this._file\n\n if (site) {\n // provided site\n depSite = site\n callSite = callSiteLocation(stack[1])\n callSite.name = depSite.name\n file = callSite[0]\n } else {\n // get call site\n i = 2\n depSite = callSiteLocation(stack[i])\n callSite = depSite\n }\n\n // get caller of deprecated thing in relation to file\n for (; i < stack.length; i++) {\n caller = callSiteLocation(stack[i])\n callFile = caller[0]\n\n if (callFile === file) {\n seen = true\n } else if (callFile === this._file) {\n file = this._file\n } else if (seen) {\n break\n }\n }\n\n var key = caller\n ? depSite.join(':') + '__' + caller.join(':')\n : undefined\n\n if (key !== undefined && key in this._warned) {\n // already warned\n return\n }\n\n this._warned[key] = true\n\n // generate automatic message from call site\n var msg = message\n if (!msg) {\n msg = callSite === depSite || !callSite.name\n ? defaultMessage(depSite)\n : defaultMessage(callSite)\n }\n\n // emit deprecation if listeners exist\n if (haslisteners) {\n var err = DeprecationError(this._namespace, msg, stack.slice(i))\n process.emit('deprecation', err)\n return\n }\n\n // format and write message\n var format = process.stderr.isTTY\n ? formatColor\n : formatPlain\n var output = format.call(this, msg, caller, stack.slice(i))\n process.stderr.write(output + '\\n', 'utf8')\n}\n\n/**\n * Get call site location as array.\n */\n\nfunction callSiteLocation (callSite) {\n var file = callSite.getFileName() || ''\n var line = callSite.getLineNumber()\n var colm = callSite.getColumnNumber()\n\n if (callSite.isEval()) {\n file = callSite.getEvalOrigin() + ', ' + file\n }\n\n var site = [file, line, colm]\n\n site.callSite = callSite\n site.name = callSite.getFunctionName()\n\n return site\n}\n\n/**\n * Generate a default message from the site.\n */\n\nfunction defaultMessage (site) {\n var callSite = site.callSite\n var funcName = site.name\n\n // make useful anonymous name\n if (!funcName) {\n funcName = ''\n }\n\n var context = callSite.getThis()\n var typeName = context && callSite.getTypeName()\n\n // ignore useless type name\n if (typeName === 'Object') {\n typeName = undefined\n }\n\n // make useful type name\n if (typeName === 'Function') {\n typeName = context.name || typeName\n }\n\n return typeName && callSite.getMethodName()\n ? typeName + '.' + funcName\n : funcName\n}\n\n/**\n * Format deprecation message without color.\n */\n\nfunction formatPlain (msg, caller, stack) {\n var timestamp = new Date().toUTCString()\n\n var formatted = timestamp +\n ' ' + this._namespace +\n ' deprecated ' + msg\n\n // add stack trace\n if (this._traced) {\n for (var i = 0; i < stack.length; i++) {\n formatted += '\\n at ' + stack[i].toString()\n }\n\n return formatted\n }\n\n if (caller) {\n formatted += ' at ' + formatLocation(caller)\n }\n\n return formatted\n}\n\n/**\n * Format deprecation message with color.\n */\n\nfunction formatColor (msg, caller, stack) {\n var formatted = '\\x1b[36;1m' + this._namespace + '\\x1b[22;39m' + // bold cyan\n ' \\x1b[33;1mdeprecated\\x1b[22;39m' + // bold yellow\n ' \\x1b[0m' + msg + '\\x1b[39m' // reset\n\n // add stack trace\n if (this._traced) {\n for (var i = 0; i < stack.length; i++) {\n formatted += '\\n \\x1b[36mat ' + stack[i].toString() + '\\x1b[39m' // cyan\n }\n\n return formatted\n }\n\n if (caller) {\n formatted += ' \\x1b[36m' + formatLocation(caller) + '\\x1b[39m' // cyan\n }\n\n return formatted\n}\n\n/**\n * Format call site location.\n */\n\nfunction formatLocation (callSite) {\n return relative(basePath, callSite[0]) +\n ':' + callSite[1] +\n ':' + callSite[2]\n}\n\n/**\n * Get the stack as array of call sites.\n */\n\nfunction getStack () {\n var limit = Error.stackTraceLimit\n var obj = {}\n var prep = Error.prepareStackTrace\n\n Error.prepareStackTrace = prepareObjectStackTrace\n Error.stackTraceLimit = Math.max(10, limit)\n\n // capture the stack\n Error.captureStackTrace(obj)\n\n // slice this function off the top\n var stack = obj.stack.slice(1)\n\n Error.prepareStackTrace = prep\n Error.stackTraceLimit = limit\n\n return stack\n}\n\n/**\n * Capture call site stack from v8.\n */\n\nfunction prepareObjectStackTrace (obj, stack) {\n return stack\n}\n\n/**\n * Return a wrapped function in a deprecation message.\n */\n\nfunction wrapfunction (fn, message) {\n if (typeof fn !== 'function') {\n throw new TypeError('argument fn must be a function')\n }\n\n var args = createArgumentsString(fn.length)\n var stack = getStack()\n var site = callSiteLocation(stack[1])\n\n site.name = fn.name\n\n // eslint-disable-next-line no-new-func\n var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site',\n '\"use strict\"\\n' +\n 'return function (' + args + ') {' +\n 'log.call(deprecate, message, site)\\n' +\n 'return fn.apply(this, arguments)\\n' +\n '}')(fn, log, this, message, site)\n\n return deprecatedfn\n}\n\n/**\n * Wrap property in a deprecation message.\n */\n\nfunction wrapproperty (obj, prop, message) {\n if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {\n throw new TypeError('argument obj must be object')\n }\n\n var descriptor = Object.getOwnPropertyDescriptor(obj, prop)\n\n if (!descriptor) {\n throw new TypeError('must call property on owner object')\n }\n\n if (!descriptor.configurable) {\n throw new TypeError('property must be configurable')\n }\n\n var deprecate = this\n var stack = getStack()\n var site = callSiteLocation(stack[1])\n\n // set site name\n site.name = prop\n\n // convert data descriptor\n if ('value' in descriptor) {\n descriptor = convertDataDescriptorToAccessor(obj, prop, message)\n }\n\n var get = descriptor.get\n var set = descriptor.set\n\n // wrap getter\n if (typeof get === 'function') {\n descriptor.get = function getter () {\n log.call(deprecate, message, site)\n return get.apply(this, arguments)\n }\n }\n\n // wrap setter\n if (typeof set === 'function') {\n descriptor.set = function setter () {\n log.call(deprecate, message, site)\n return set.apply(this, arguments)\n }\n }\n\n Object.defineProperty(obj, prop, descriptor)\n}\n\n/**\n * Create DeprecationError for deprecation\n */\n\nfunction DeprecationError (namespace, message, stack) {\n var error = new Error()\n var stackString\n\n Object.defineProperty(error, 'constructor', {\n value: DeprecationError\n })\n\n Object.defineProperty(error, 'message', {\n configurable: true,\n enumerable: false,\n value: message,\n writable: true\n })\n\n Object.defineProperty(error, 'name', {\n enumerable: false,\n configurable: true,\n value: 'DeprecationError',\n writable: true\n })\n\n Object.defineProperty(error, 'namespace', {\n configurable: true,\n enumerable: false,\n value: namespace,\n writable: true\n })\n\n Object.defineProperty(error, 'stack', {\n configurable: true,\n enumerable: false,\n get: function () {\n if (stackString !== undefined) {\n return stackString\n }\n\n // prepare stack trace\n return (stackString = createStackString.call(this, stack))\n },\n set: function setter (val) {\n stackString = val\n }\n })\n\n return error\n}\n", "/*!\n * bytes\n * Copyright(c) 2012-2014 TJ Holowaychuk\n * Copyright(c) 2015 Jed Watson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = bytes;\nmodule.exports.format = format;\nmodule.exports.parse = parse;\n\n/**\n * Module variables.\n * @private\n */\n\nvar formatThousandsRegExp = /\\B(?=(\\d{3})+(?!\\d))/g;\n\nvar formatDecimalsRegExp = /(?:\\.0*|(\\.[^0]+)0+)$/;\n\nvar map = {\n b: 1,\n kb: 1 << 10,\n mb: 1 << 20,\n gb: 1 << 30,\n tb: Math.pow(1024, 4),\n pb: Math.pow(1024, 5),\n};\n\nvar parseRegExp = /^((-|\\+)?(\\d+(?:\\.\\d+)?)) *(kb|mb|gb|tb|pb)$/i;\n\n/**\n * Convert the given value in bytes into a string or parse to string to an integer in bytes.\n *\n * @param {string|number} value\n * @param {{\n * case: [string],\n * decimalPlaces: [number]\n * fixedDecimals: [boolean]\n * thousandsSeparator: [string]\n * unitSeparator: [string]\n * }} [options] bytes options.\n *\n * @returns {string|number|null}\n */\n\nfunction bytes(value, options) {\n if (typeof value === 'string') {\n return parse(value);\n }\n\n if (typeof value === 'number') {\n return format(value, options);\n }\n\n return null;\n}\n\n/**\n * Format the given value in bytes into a string.\n *\n * If the value is negative, it is kept as such. If it is a float,\n * it is rounded.\n *\n * @param {number} value\n * @param {object} [options]\n * @param {number} [options.decimalPlaces=2]\n * @param {number} [options.fixedDecimals=false]\n * @param {string} [options.thousandsSeparator=]\n * @param {string} [options.unit=]\n * @param {string} [options.unitSeparator=]\n *\n * @returns {string|null}\n * @public\n */\n\nfunction format(value, options) {\n if (!Number.isFinite(value)) {\n return null;\n }\n\n var mag = Math.abs(value);\n var thousandsSeparator = (options && options.thousandsSeparator) || '';\n var unitSeparator = (options && options.unitSeparator) || '';\n var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;\n var fixedDecimals = Boolean(options && options.fixedDecimals);\n var unit = (options && options.unit) || '';\n\n if (!unit || !map[unit.toLowerCase()]) {\n if (mag >= map.pb) {\n unit = 'PB';\n } else if (mag >= map.tb) {\n unit = 'TB';\n } else if (mag >= map.gb) {\n unit = 'GB';\n } else if (mag >= map.mb) {\n unit = 'MB';\n } else if (mag >= map.kb) {\n unit = 'KB';\n } else {\n unit = 'B';\n }\n }\n\n var val = value / map[unit.toLowerCase()];\n var str = val.toFixed(decimalPlaces);\n\n if (!fixedDecimals) {\n str = str.replace(formatDecimalsRegExp, '$1');\n }\n\n if (thousandsSeparator) {\n str = str.split('.').map(function (s, i) {\n return i === 0\n ? s.replace(formatThousandsRegExp, thousandsSeparator)\n : s\n }).join('.');\n }\n\n return str + unitSeparator + unit;\n}\n\n/**\n * Parse the string value into an integer in bytes.\n *\n * If no unit is given, it is assumed the value is in bytes.\n *\n * @param {number|string} val\n *\n * @returns {number|null}\n * @public\n */\n\nfunction parse(val) {\n if (typeof val === 'number' && !isNaN(val)) {\n return val;\n }\n\n if (typeof val !== 'string') {\n return null;\n }\n\n // Test if the string passed is valid\n var results = parseRegExp.exec(val);\n var floatValue;\n var unit = 'b';\n\n if (!results) {\n // Nothing could be extracted from the given string\n floatValue = parseInt(val, 10);\n unit = 'b'\n } else {\n // Retrieve the value and the unit\n floatValue = parseFloat(results[1]);\n unit = results[4].toLowerCase();\n }\n\n if (isNaN(floatValue)) {\n return null;\n }\n\n return Math.floor(map[unit] * floatValue);\n}\n", "/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * RegExp to match *( \";\" parameter ) in RFC 7231 sec 3.1.1.1\n *\n * parameter = token \"=\" ( token / quoted-string )\n * token = 1*tchar\n * tchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\"\n * / \"+\" / \"-\" / \".\" / \"^\" / \"_\" / \"`\" / \"|\" / \"~\"\n * / DIGIT / ALPHA\n * ; any VCHAR, except delimiters\n * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE\n * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text\n * obs-text = %x80-FF\n * quoted-pair = \"\\\" ( HTAB / SP / VCHAR / obs-text )\n */\nvar PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *(\"(?:[\\u000b\\u0020\\u0021\\u0023-\\u005b\\u005d-\\u007e\\u0080-\\u00ff]|\\\\[\\u000b\\u0020-\\u00ff])*\"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g // eslint-disable-line no-control-regex\nvar TEXT_REGEXP = /^[\\u000b\\u0020-\\u007e\\u0080-\\u00ff]+$/ // eslint-disable-line no-control-regex\nvar TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/\n\n/**\n * RegExp to match quoted-pair in RFC 7230 sec 3.2.6\n *\n * quoted-pair = \"\\\" ( HTAB / SP / VCHAR / obs-text )\n * obs-text = %x80-FF\n */\nvar QESC_REGEXP = /\\\\([\\u000b\\u0020-\\u00ff])/g // eslint-disable-line no-control-regex\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6\n */\nvar QUOTE_REGEXP = /([\\\\\"])/g\n\n/**\n * RegExp to match type in RFC 7231 sec 3.1.1.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nvar TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/\n\n/**\n * Module exports.\n * @public\n */\n\nexports.format = format\nexports.parse = parse\n\n/**\n * Format object to media type.\n *\n * @param {object} obj\n * @return {string}\n * @public\n */\n\nfunction format (obj) {\n if (!obj || typeof obj !== 'object') {\n throw new TypeError('argument obj is required')\n }\n\n var parameters = obj.parameters\n var type = obj.type\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError('invalid type')\n }\n\n var string = type\n\n // append parameters\n if (parameters && typeof parameters === 'object') {\n var param\n var params = Object.keys(parameters).sort()\n\n for (var i = 0; i < params.length; i++) {\n param = params[i]\n\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError('invalid parameter name')\n }\n\n string += '; ' + param + '=' + qstring(parameters[param])\n }\n }\n\n return string\n}\n\n/**\n * Parse media type to object.\n *\n * @param {string|object} string\n * @return {Object}\n * @public\n */\n\nfunction parse (string) {\n if (!string) {\n throw new TypeError('argument string is required')\n }\n\n // support req/res-like objects as argument\n var header = typeof string === 'object'\n ? getcontenttype(string)\n : string\n\n if (typeof header !== 'string') {\n throw new TypeError('argument string is required to be a string')\n }\n\n var index = header.indexOf(';')\n var type = index !== -1\n ? header.slice(0, index).trim()\n : header.trim()\n\n if (!TYPE_REGEXP.test(type)) {\n throw new TypeError('invalid media type')\n }\n\n var obj = new ContentType(type.toLowerCase())\n\n // parse parameters\n if (index !== -1) {\n var key\n var match\n var value\n\n PARAM_REGEXP.lastIndex = index\n\n while ((match = PARAM_REGEXP.exec(header))) {\n if (match.index !== index) {\n throw new TypeError('invalid parameter format')\n }\n\n index += match[0].length\n key = match[1].toLowerCase()\n value = match[2]\n\n if (value.charCodeAt(0) === 0x22 /* \" */) {\n // remove quotes\n value = value.slice(1, -1)\n\n // remove escapes\n if (value.indexOf('\\\\') !== -1) {\n value = value.replace(QESC_REGEXP, '$1')\n }\n }\n\n obj.parameters[key] = value\n }\n\n if (index !== header.length) {\n throw new TypeError('invalid parameter format')\n }\n }\n\n return obj\n}\n\n/**\n * Get content-type from req/res objects.\n *\n * @param {object}\n * @return {Object}\n * @private\n */\n\nfunction getcontenttype (obj) {\n var header\n\n if (typeof obj.getHeader === 'function') {\n // res-like\n header = obj.getHeader('content-type')\n } else if (typeof obj.headers === 'object') {\n // req-like\n header = obj.headers && obj.headers['content-type']\n }\n\n if (typeof header !== 'string') {\n throw new TypeError('content-type header is missing from object')\n }\n\n return header\n}\n\n/**\n * Quote a string if necessary.\n *\n * @param {string} val\n * @return {string}\n * @private\n */\n\nfunction qstring (val) {\n var str = String(val)\n\n // no need to quote tokens\n if (TOKEN_REGEXP.test(str)) {\n return str\n }\n\n if (str.length > 0 && !TEXT_REGEXP.test(str)) {\n throw new TypeError('invalid parameter value')\n }\n\n return '\"' + str.replace(QUOTE_REGEXP, '\\\\$1') + '\"'\n}\n\n/**\n * Class to represent a content type.\n * @private\n */\nfunction ContentType (type) {\n this.parameters = Object.create(null)\n this.type = type\n}\n", "'use strict'\n/* eslint no-proto: 0 */\nmodule.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties)\n\nfunction setProtoOf (obj, proto) {\n obj.__proto__ = proto\n return obj\n}\n\nfunction mixinProperties (obj, proto) {\n for (var prop in proto) {\n if (!Object.prototype.hasOwnProperty.call(obj, prop)) {\n obj[prop] = proto[prop]\n }\n }\n return obj\n}\n", "/*!\n * statuses\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar codes = require('./codes.json')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = status\n\n// status code to message map\nstatus.message = codes\n\n// status message (lower-case) to code map\nstatus.code = createMessageToStatusCodeMap(codes)\n\n// array of status codes\nstatus.codes = createStatusCodeList(codes)\n\n// status codes for redirects\nstatus.redirect = {\n 300: true,\n 301: true,\n 302: true,\n 303: true,\n 305: true,\n 307: true,\n 308: true\n}\n\n// status codes for empty bodies\nstatus.empty = {\n 204: true,\n 205: true,\n 304: true\n}\n\n// status codes for when you should retry the request\nstatus.retry = {\n 502: true,\n 503: true,\n 504: true\n}\n\n/**\n * Create a map of message to status code.\n * @private\n */\n\nfunction createMessageToStatusCodeMap (codes) {\n var map = {}\n\n Object.keys(codes).forEach(function forEachCode (code) {\n var message = codes[code]\n var status = Number(code)\n\n // populate map\n map[message.toLowerCase()] = status\n })\n\n return map\n}\n\n/**\n * Create a list of all status codes.\n * @private\n */\n\nfunction createStatusCodeList (codes) {\n return Object.keys(codes).map(function mapCode (code) {\n return Number(code)\n })\n}\n\n/**\n * Get the status code for given message.\n * @private\n */\n\nfunction getStatusCode (message) {\n var msg = message.toLowerCase()\n\n if (!Object.prototype.hasOwnProperty.call(status.code, msg)) {\n throw new Error('invalid status message: \"' + message + '\"')\n }\n\n return status.code[msg]\n}\n\n/**\n * Get the status message for given code.\n * @private\n */\n\nfunction getStatusMessage (code) {\n if (!Object.prototype.hasOwnProperty.call(status.message, code)) {\n throw new Error('invalid status code: ' + code)\n }\n\n return status.message[code]\n}\n\n/**\n * Get the status code.\n *\n * Given a number, this will throw if it is not a known status\n * code, otherwise the code will be returned. Given a string,\n * the string will be parsed for a number and return the code\n * if valid, otherwise will lookup the code assuming this is\n * the status message.\n *\n * @param {string|number} code\n * @returns {number}\n * @public\n */\n\nfunction status (code) {\n if (typeof code === 'number') {\n return getStatusMessage(code)\n }\n\n if (typeof code !== 'string') {\n throw new TypeError('code must be a number or string')\n }\n\n // '403'\n var n = parseInt(code, 10)\n if (!isNaN(n)) {\n return getStatusMessage(n)\n }\n\n return getStatusCode(code)\n}\n", "if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n if (superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n }\n}\n", "try {\n var util = require('util');\n /* istanbul ignore next */\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n /* istanbul ignore next */\n module.exports = require('./inherits_browser.js');\n}\n", "/*!\n * toidentifier\n * Copyright(c) 2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = toIdentifier\n\n/**\n * Trasform the given string into a JavaScript identifier\n *\n * @param {string} str\n * @returns {string}\n * @public\n */\n\nfunction toIdentifier (str) {\n return str\n .split(' ')\n .map(function (token) {\n return token.slice(0, 1).toUpperCase() + token.slice(1)\n })\n .join('')\n .replace(/[^ _0-9a-z]/gi, '')\n}\n", "/*!\n * http-errors\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar deprecate = require('depd')('http-errors')\nvar setPrototypeOf = require('setprototypeof')\nvar statuses = require('statuses')\nvar inherits = require('inherits')\nvar toIdentifier = require('toidentifier')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = createError\nmodule.exports.HttpError = createHttpErrorConstructor()\nmodule.exports.isHttpError = createIsHttpErrorFunction(module.exports.HttpError)\n\n// Populate exports for all constructors\npopulateConstructorExports(module.exports, statuses.codes, module.exports.HttpError)\n\n/**\n * Get the code class of a status code.\n * @private\n */\n\nfunction codeClass (status) {\n return Number(String(status).charAt(0) + '00')\n}\n\n/**\n * Create a new HTTP Error.\n *\n * @returns {Error}\n * @public\n */\n\nfunction createError () {\n // so much arity going on ~_~\n var err\n var msg\n var status = 500\n var props = {}\n for (var i = 0; i < arguments.length; i++) {\n var arg = arguments[i]\n var type = typeof arg\n if (type === 'object' && arg instanceof Error) {\n err = arg\n status = err.status || err.statusCode || status\n } else if (type === 'number' && i === 0) {\n status = arg\n } else if (type === 'string') {\n msg = arg\n } else if (type === 'object') {\n props = arg\n } else {\n throw new TypeError('argument #' + (i + 1) + ' unsupported type ' + type)\n }\n }\n\n if (typeof status === 'number' && (status < 400 || status >= 600)) {\n deprecate('non-error status code; use only 4xx or 5xx status codes')\n }\n\n if (typeof status !== 'number' ||\n (!statuses.message[status] && (status < 400 || status >= 600))) {\n status = 500\n }\n\n // constructor\n var HttpError = createError[status] || createError[codeClass(status)]\n\n if (!err) {\n // create error\n err = HttpError\n ? new HttpError(msg)\n : new Error(msg || statuses.message[status])\n Error.captureStackTrace(err, createError)\n }\n\n if (!HttpError || !(err instanceof HttpError) || err.status !== status) {\n // add properties to generic error\n err.expose = status < 500\n err.status = err.statusCode = status\n }\n\n for (var key in props) {\n if (key !== 'status' && key !== 'statusCode') {\n err[key] = props[key]\n }\n }\n\n return err\n}\n\n/**\n * Create HTTP error abstract base class.\n * @private\n */\n\nfunction createHttpErrorConstructor () {\n function HttpError () {\n throw new TypeError('cannot construct abstract class')\n }\n\n inherits(HttpError, Error)\n\n return HttpError\n}\n\n/**\n * Create a constructor for a client error.\n * @private\n */\n\nfunction createClientErrorConstructor (HttpError, name, code) {\n var className = toClassName(name)\n\n function ClientError (message) {\n // create the error object\n var msg = message != null ? message : statuses.message[code]\n var err = new Error(msg)\n\n // capture a stack trace to the construction point\n Error.captureStackTrace(err, ClientError)\n\n // adjust the [[Prototype]]\n setPrototypeOf(err, ClientError.prototype)\n\n // redefine the error message\n Object.defineProperty(err, 'message', {\n enumerable: true,\n configurable: true,\n value: msg,\n writable: true\n })\n\n // redefine the error name\n Object.defineProperty(err, 'name', {\n enumerable: false,\n configurable: true,\n value: className,\n writable: true\n })\n\n return err\n }\n\n inherits(ClientError, HttpError)\n nameFunc(ClientError, className)\n\n ClientError.prototype.status = code\n ClientError.prototype.statusCode = code\n ClientError.prototype.expose = true\n\n return ClientError\n}\n\n/**\n * Create function to test is a value is a HttpError.\n * @private\n */\n\nfunction createIsHttpErrorFunction (HttpError) {\n return function isHttpError (val) {\n if (!val || typeof val !== 'object') {\n return false\n }\n\n if (val instanceof HttpError) {\n return true\n }\n\n return val instanceof Error &&\n typeof val.expose === 'boolean' &&\n typeof val.statusCode === 'number' && val.status === val.statusCode\n }\n}\n\n/**\n * Create a constructor for a server error.\n * @private\n */\n\nfunction createServerErrorConstructor (HttpError, name, code) {\n var className = toClassName(name)\n\n function ServerError (message) {\n // create the error object\n var msg = message != null ? message : statuses.message[code]\n var err = new Error(msg)\n\n // capture a stack trace to the construction point\n Error.captureStackTrace(err, ServerError)\n\n // adjust the [[Prototype]]\n setPrototypeOf(err, ServerError.prototype)\n\n // redefine the error message\n Object.defineProperty(err, 'message', {\n enumerable: true,\n configurable: true,\n value: msg,\n writable: true\n })\n\n // redefine the error name\n Object.defineProperty(err, 'name', {\n enumerable: false,\n configurable: true,\n value: className,\n writable: true\n })\n\n return err\n }\n\n inherits(ServerError, HttpError)\n nameFunc(ServerError, className)\n\n ServerError.prototype.status = code\n ServerError.prototype.statusCode = code\n ServerError.prototype.expose = false\n\n return ServerError\n}\n\n/**\n * Set the name of a function, if possible.\n * @private\n */\n\nfunction nameFunc (func, name) {\n var desc = Object.getOwnPropertyDescriptor(func, 'name')\n\n if (desc && desc.configurable) {\n desc.value = name\n Object.defineProperty(func, 'name', desc)\n }\n}\n\n/**\n * Populate the exports object with constructors for every error class.\n * @private\n */\n\nfunction populateConstructorExports (exports, codes, HttpError) {\n codes.forEach(function forEachCode (code) {\n var CodeError\n var name = toIdentifier(statuses.message[code])\n\n switch (codeClass(code)) {\n case 400:\n CodeError = createClientErrorConstructor(HttpError, name, code)\n break\n case 500:\n CodeError = createServerErrorConstructor(HttpError, name, code)\n break\n }\n\n if (CodeError) {\n // export the constructor\n exports[code] = CodeError\n exports[name] = CodeError\n }\n })\n}\n\n/**\n * Get a class name from a name identifier.\n * @private\n */\n\nfunction toClassName (name) {\n return name.substr(-5) !== 'Error'\n ? name + 'Error'\n : name\n}\n", "/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isNaN(val) === false) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n if (ms >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (ms >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (ms >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (ms >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n return plural(ms, d, 'day') ||\n plural(ms, h, 'hour') ||\n plural(ms, m, 'minute') ||\n plural(ms, s, 'second') ||\n ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) {\n return;\n }\n if (ms < n * 1.5) {\n return Math.floor(ms / n) + ' ' + name;\n }\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n", "\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = createDebug.debug = createDebug['default'] = createDebug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n */\n\nexports.formatters = {};\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n * @param {String} namespace\n * @return {Number}\n * @api private\n */\n\nfunction selectColor(namespace) {\n var hash = 0, i;\n\n for (i in namespace) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n hash |= 0; // Convert to 32bit integer\n }\n\n return exports.colors[Math.abs(hash) % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction createDebug(namespace) {\n\n function debug() {\n // disabled?\n if (!debug.enabled) return;\n\n var self = debug;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // turn the `arguments` into a proper Array\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %O\n args.unshift('%O');\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n // apply env-specific formatting (colors, etc.)\n exports.formatArgs.call(self, args);\n\n var logFn = debug.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n\n debug.namespace = namespace;\n debug.enabled = exports.enabled(namespace);\n debug.useColors = exports.useColors();\n debug.color = selectColor(namespace);\n\n // env-specific initialization logic for debug instances\n if ('function' === typeof exports.init) {\n exports.init(debug);\n }\n\n return debug;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n exports.names = [];\n exports.skips = [];\n\n var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n", "/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n && 'undefined' != typeof chrome.storage\n ? chrome.storage.local\n : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // NB: In an Electron preload script, document will be defined but not fully\n // initialized. Since we know we're in Chrome, we'll just detect this case\n // explicitly\n if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {\n return true;\n }\n\n // is webkit? http://stackoverflow.com/a/16459606/376773\n // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n // double check webkit in userAgent just in case we are in a worker\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n try {\n return JSON.stringify(v);\n } catch (err) {\n return '[UnexpectedJSONParseError]: ' + err.message;\n }\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return;\n\n var c = 'color: ' + this.color;\n args.splice(1, 0, c, 'color: inherit')\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-zA-Z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n exports.storage.removeItem('debug');\n } else {\n exports.storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = exports.storage.debug;\n } catch(e) {}\n\n // If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n if (!r && typeof process !== 'undefined' && 'env' in process) {\n r = process.env.DEBUG;\n }\n\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n try {\n return window.localStorage;\n } catch (e) {}\n}\n", "/**\n * Module dependencies.\n */\n\nvar tty = require('tty');\nvar util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(function (key) {\n return /^debug_/i.test(key);\n}).reduce(function (obj, key) {\n // camel-case\n var prop = key\n .substring(6)\n .toLowerCase()\n .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });\n\n // coerce string value into JS value\n var val = process.env[key];\n if (/^(yes|on|true|enabled)$/i.test(val)) val = true;\n else if (/^(no|off|false|disabled)$/i.test(val)) val = false;\n else if (val === 'null') val = null;\n else val = Number(val);\n\n obj[prop] = val;\n return obj;\n}, {});\n\n/**\n * The file descriptor to write the `debug()` calls to.\n * Set the `DEBUG_FD` env variable to override with another value. i.e.:\n *\n * $ DEBUG_FD=3 node script.js 3>debug.log\n */\n\nvar fd = parseInt(process.env.DEBUG_FD, 10) || 2;\n\nif (1 !== fd && 2 !== fd) {\n util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')()\n}\n\nvar stream = 1 === fd ? process.stdout :\n 2 === fd ? process.stderr :\n createWritableStdioStream(fd);\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n return 'colors' in exports.inspectOpts\n ? Boolean(exports.inspectOpts.colors)\n : tty.isatty(fd);\n}\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nexports.formatters.o = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts)\n .split('\\n').map(function(str) {\n return str.trim()\n }).join(' ');\n};\n\n/**\n * Map %o to `util.inspect()`, allowing multiple lines if needed.\n */\n\nexports.formatters.O = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts);\n};\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var name = this.namespace;\n var useColors = this.useColors;\n\n if (useColors) {\n var c = this.color;\n var prefix = ' \\u001b[3' + c + ';1m' + name + ' ' + '\\u001b[0m';\n\n args[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n args.push('\\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\\u001b[0m');\n } else {\n args[0] = new Date().toUTCString()\n + ' ' + name + ' ' + args[0];\n }\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to `stream`.\n */\n\nfunction log() {\n return stream.write(util.format.apply(util, arguments) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n if (null == namespaces) {\n // If you set a process.env field to null or undefined, it gets cast to the\n // string 'null' or 'undefined'. Just delete instead.\n delete process.env.DEBUG;\n } else {\n process.env.DEBUG = namespaces;\n }\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n return process.env.DEBUG;\n}\n\n/**\n * Copied from `node/src/node.js`.\n *\n * XXX: It's lame that node doesn't expose this API out-of-the-box. It also\n * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.\n */\n\nfunction createWritableStdioStream (fd) {\n var stream;\n var tty_wrap = process.binding('tty_wrap');\n\n // Note stream._type is used for test-module-load-list.js\n\n switch (tty_wrap.guessHandleType(fd)) {\n case 'TTY':\n stream = new tty.WriteStream(fd);\n stream._type = 'tty';\n\n // Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n case 'FILE':\n var fs = require('fs');\n stream = new fs.SyncWriteStream(fd, { autoClose: false });\n stream._type = 'fs';\n break;\n\n case 'PIPE':\n case 'TCP':\n var net = require('net');\n stream = new net.Socket({\n fd: fd,\n readable: false,\n writable: true\n });\n\n // FIXME Should probably have an option in net.Socket to create a\n // stream from an existing fd which is writable only. But for now\n // we'll just add this hack and set the `readable` member to false.\n // Test: ./node test/fixtures/echo.js < /etc/passwd\n stream.readable = false;\n stream.read = null;\n stream._type = 'pipe';\n\n // FIXME Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n default:\n // Probably an error on in uv_guess_handle()\n throw new Error('Implement me. Unknown stream file type!');\n }\n\n // For supporting legacy API we put the FD here.\n stream.fd = fd;\n\n stream._isStdio = true;\n\n return stream;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init (debug) {\n debug.inspectOpts = {};\n\n var keys = Object.keys(exports.inspectOpts);\n for (var i = 0; i < keys.length; i++) {\n debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n }\n}\n\n/**\n * Enable namespaces listed in `process.env.DEBUG` initially.\n */\n\nexports.enable(load());\n", "/**\n * Detect Electron renderer process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process !== 'undefined' && process.type === 'renderer') {\n module.exports = require('./browser.js');\n} else {\n module.exports = require('./node.js');\n}\n", "/*!\n * destroy\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2015-2022 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar EventEmitter = require('events').EventEmitter\nvar ReadStream = require('fs').ReadStream\nvar Stream = require('stream')\nvar Zlib = require('zlib')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = destroy\n\n/**\n * Destroy the given stream, and optionally suppress any future `error` events.\n *\n * @param {object} stream\n * @param {boolean} suppress\n * @public\n */\n\nfunction destroy (stream, suppress) {\n if (isFsReadStream(stream)) {\n destroyReadStream(stream)\n } else if (isZlibStream(stream)) {\n destroyZlibStream(stream)\n } else if (hasDestroy(stream)) {\n stream.destroy()\n }\n\n if (isEventEmitter(stream) && suppress) {\n stream.removeAllListeners('error')\n stream.addListener('error', noop)\n }\n\n return stream\n}\n\n/**\n * Destroy a ReadStream.\n *\n * @param {object} stream\n * @private\n */\n\nfunction destroyReadStream (stream) {\n stream.destroy()\n\n if (typeof stream.close === 'function') {\n // node.js core bug work-around\n stream.on('open', onOpenClose)\n }\n}\n\n/**\n * Close a Zlib stream.\n *\n * Zlib streams below Node.js 4.5.5 have a buggy implementation\n * of .close() when zlib encountered an error.\n *\n * @param {object} stream\n * @private\n */\n\nfunction closeZlibStream (stream) {\n if (stream._hadError === true) {\n var prop = stream._binding === null\n ? '_binding'\n : '_handle'\n\n stream[prop] = {\n close: function () { this[prop] = null }\n }\n }\n\n stream.close()\n}\n\n/**\n * Destroy a Zlib stream.\n *\n * Zlib streams don't have a destroy function in Node.js 6. On top of that\n * simply calling destroy on a zlib stream in Node.js 8+ will result in a\n * memory leak. So until that is fixed, we need to call both close AND destroy.\n *\n * PR to fix memory leak: https://github.com/nodejs/node/pull/23734\n *\n * In Node.js 6+8, it's important that destroy is called before close as the\n * stream would otherwise emit the error 'zlib binding closed'.\n *\n * @param {object} stream\n * @private\n */\n\nfunction destroyZlibStream (stream) {\n if (typeof stream.destroy === 'function') {\n // node.js core bug work-around\n // istanbul ignore if: node.js 0.8\n if (stream._binding) {\n // node.js < 0.10.0\n stream.destroy()\n if (stream._processing) {\n stream._needDrain = true\n stream.once('drain', onDrainClearBinding)\n } else {\n stream._binding.clear()\n }\n } else if (stream._destroy && stream._destroy !== Stream.Transform.prototype._destroy) {\n // node.js >= 12, ^11.1.0, ^10.15.1\n stream.destroy()\n } else if (stream._destroy && typeof stream.close === 'function') {\n // node.js 7, 8\n stream.destroyed = true\n stream.close()\n } else {\n // fallback\n // istanbul ignore next\n stream.destroy()\n }\n } else if (typeof stream.close === 'function') {\n // node.js < 8 fallback\n closeZlibStream(stream)\n }\n}\n\n/**\n * Determine if stream has destroy.\n * @private\n */\n\nfunction hasDestroy (stream) {\n return stream instanceof Stream &&\n typeof stream.destroy === 'function'\n}\n\n/**\n * Determine if val is EventEmitter.\n * @private\n */\n\nfunction isEventEmitter (val) {\n return val instanceof EventEmitter\n}\n\n/**\n * Determine if stream is fs.ReadStream stream.\n * @private\n */\n\nfunction isFsReadStream (stream) {\n return stream instanceof ReadStream\n}\n\n/**\n * Determine if stream is Zlib stream.\n * @private\n */\n\nfunction isZlibStream (stream) {\n return stream instanceof Zlib.Gzip ||\n stream instanceof Zlib.Gunzip ||\n stream instanceof Zlib.Deflate ||\n stream instanceof Zlib.DeflateRaw ||\n stream instanceof Zlib.Inflate ||\n stream instanceof Zlib.InflateRaw ||\n stream instanceof Zlib.Unzip\n}\n\n/**\n * No-op function.\n * @private\n */\n\nfunction noop () {}\n\n/**\n * On drain handler to clear binding.\n * @private\n */\n\n// istanbul ignore next: node.js 0.8\nfunction onDrainClearBinding () {\n this._binding.clear()\n}\n\n/**\n * On open handler to close stream.\n * @private\n */\n\nfunction onOpenClose () {\n if (typeof this.fd === 'number') {\n // actually close down the fd\n this.close()\n }\n}\n", "/* eslint-disable node/no-deprecated-api */\n\n'use strict'\n\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\nvar safer = {}\n\nvar key\n\nfor (key in buffer) {\n if (!buffer.hasOwnProperty(key)) continue\n if (key === 'SlowBuffer' || key === 'Buffer') continue\n safer[key] = buffer[key]\n}\n\nvar Safer = safer.Buffer = {}\nfor (key in Buffer) {\n if (!Buffer.hasOwnProperty(key)) continue\n if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue\n Safer[key] = Buffer[key]\n}\n\nsafer.Buffer.prototype = Buffer.prototype\n\nif (!Safer.from || Safer.from === Uint8Array.from) {\n Safer.from = function (value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('The \"value\" argument must not be of type number. Received type ' + typeof value)\n }\n if (value && typeof value.length === 'undefined') {\n throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)\n }\n return Buffer(value, encodingOrOffset, length)\n }\n}\n\nif (!Safer.alloc) {\n Safer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('The \"size\" argument must be of type number. Received type ' + typeof size)\n }\n if (size < 0 || size >= 2 * (1 << 30)) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n var buf = Buffer(size)\n if (!fill || fill.length === 0) {\n buf.fill(0)\n } else if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n return buf\n }\n}\n\nif (!safer.kStringMaxLength) {\n try {\n safer.kStringMaxLength = process.binding('buffer').kStringMaxLength\n } catch (e) {\n // we can't determine kStringMaxLength in environments where process.binding\n // is unsupported, so let's not set it\n }\n}\n\nif (!safer.constants) {\n safer.constants = {\n MAX_LENGTH: safer.kMaxLength\n }\n if (safer.kStringMaxLength) {\n safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength\n }\n}\n\nmodule.exports = safer\n", "\"use strict\";\n\nvar BOMChar = '\\uFEFF';\n\nexports.PrependBOM = PrependBOMWrapper\nfunction PrependBOMWrapper(encoder, options) {\n this.encoder = encoder;\n this.addBOM = true;\n}\n\nPrependBOMWrapper.prototype.write = function(str) {\n if (this.addBOM) {\n str = BOMChar + str;\n this.addBOM = false;\n }\n\n return this.encoder.write(str);\n}\n\nPrependBOMWrapper.prototype.end = function() {\n return this.encoder.end();\n}\n\n\n//------------------------------------------------------------------------------\n\nexports.StripBOM = StripBOMWrapper;\nfunction StripBOMWrapper(decoder, options) {\n this.decoder = decoder;\n this.pass = false;\n this.options = options || {};\n}\n\nStripBOMWrapper.prototype.write = function(buf) {\n var res = this.decoder.write(buf);\n if (this.pass || !res)\n return res;\n\n if (res[0] === BOMChar) {\n res = res.slice(1);\n if (typeof this.options.stripBOM === 'function')\n this.options.stripBOM();\n }\n\n this.pass = true;\n return res;\n}\n\nStripBOMWrapper.prototype.end = function() {\n return this.decoder.end();\n}\n\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Export Node.js internal encodings.\n\nmodule.exports = {\n // Encodings\n utf8: { type: \"_internal\", bomAware: true},\n cesu8: { type: \"_internal\", bomAware: true},\n unicode11utf8: \"utf8\",\n\n ucs2: { type: \"_internal\", bomAware: true},\n utf16le: \"ucs2\",\n\n binary: { type: \"_internal\" },\n base64: { type: \"_internal\" },\n hex: { type: \"_internal\" },\n\n // Codec.\n _internal: InternalCodec,\n};\n\n//------------------------------------------------------------------------------\n\nfunction InternalCodec(codecOptions, iconv) {\n this.enc = codecOptions.encodingName;\n this.bomAware = codecOptions.bomAware;\n\n if (this.enc === \"base64\")\n this.encoder = InternalEncoderBase64;\n else if (this.enc === \"cesu8\") {\n this.enc = \"utf8\"; // Use utf8 for decoding.\n this.encoder = InternalEncoderCesu8;\n\n // Add decoder for versions of Node not supporting CESU-8\n if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '\uD83D\uDCA9') {\n this.decoder = InternalDecoderCesu8;\n this.defaultCharUnicode = iconv.defaultCharUnicode;\n }\n }\n}\n\nInternalCodec.prototype.encoder = InternalEncoder;\nInternalCodec.prototype.decoder = InternalDecoder;\n\n//------------------------------------------------------------------------------\n\n// We use node.js internal decoder. Its signature is the same as ours.\nvar StringDecoder = require('string_decoder').StringDecoder;\n\nif (!StringDecoder.prototype.end) // Node v0.8 doesn't have this method.\n StringDecoder.prototype.end = function() {};\n\n\nfunction InternalDecoder(options, codec) {\n StringDecoder.call(this, codec.enc);\n}\n\nInternalDecoder.prototype = StringDecoder.prototype;\n\n\n//------------------------------------------------------------------------------\n// Encoder is mostly trivial\n\nfunction InternalEncoder(options, codec) {\n this.enc = codec.enc;\n}\n\nInternalEncoder.prototype.write = function(str) {\n return Buffer.from(str, this.enc);\n}\n\nInternalEncoder.prototype.end = function() {\n}\n\n\n//------------------------------------------------------------------------------\n// Except base64 encoder, which must keep its state.\n\nfunction InternalEncoderBase64(options, codec) {\n this.prevStr = '';\n}\n\nInternalEncoderBase64.prototype.write = function(str) {\n str = this.prevStr + str;\n var completeQuads = str.length - (str.length % 4);\n this.prevStr = str.slice(completeQuads);\n str = str.slice(0, completeQuads);\n\n return Buffer.from(str, \"base64\");\n}\n\nInternalEncoderBase64.prototype.end = function() {\n return Buffer.from(this.prevStr, \"base64\");\n}\n\n\n//------------------------------------------------------------------------------\n// CESU-8 encoder is also special.\n\nfunction InternalEncoderCesu8(options, codec) {\n}\n\nInternalEncoderCesu8.prototype.write = function(str) {\n var buf = Buffer.alloc(str.length * 3), bufIdx = 0;\n for (var i = 0; i < str.length; i++) {\n var charCode = str.charCodeAt(i);\n // Naive implementation, but it works because CESU-8 is especially easy\n // to convert from UTF-16 (which all JS strings are encoded in).\n if (charCode < 0x80)\n buf[bufIdx++] = charCode;\n else if (charCode < 0x800) {\n buf[bufIdx++] = 0xC0 + (charCode >>> 6);\n buf[bufIdx++] = 0x80 + (charCode & 0x3f);\n }\n else { // charCode will always be < 0x10000 in javascript.\n buf[bufIdx++] = 0xE0 + (charCode >>> 12);\n buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f);\n buf[bufIdx++] = 0x80 + (charCode & 0x3f);\n }\n }\n return buf.slice(0, bufIdx);\n}\n\nInternalEncoderCesu8.prototype.end = function() {\n}\n\n//------------------------------------------------------------------------------\n// CESU-8 decoder is not implemented in Node v4.0+\n\nfunction InternalDecoderCesu8(options, codec) {\n this.acc = 0;\n this.contBytes = 0;\n this.accBytes = 0;\n this.defaultCharUnicode = codec.defaultCharUnicode;\n}\n\nInternalDecoderCesu8.prototype.write = function(buf) {\n var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, \n res = '';\n for (var i = 0; i < buf.length; i++) {\n var curByte = buf[i];\n if ((curByte & 0xC0) !== 0x80) { // Leading byte\n if (contBytes > 0) { // Previous code is invalid\n res += this.defaultCharUnicode;\n contBytes = 0;\n }\n\n if (curByte < 0x80) { // Single-byte code\n res += String.fromCharCode(curByte);\n } else if (curByte < 0xE0) { // Two-byte code\n acc = curByte & 0x1F;\n contBytes = 1; accBytes = 1;\n } else if (curByte < 0xF0) { // Three-byte code\n acc = curByte & 0x0F;\n contBytes = 2; accBytes = 1;\n } else { // Four or more are not supported for CESU-8.\n res += this.defaultCharUnicode;\n }\n } else { // Continuation byte\n if (contBytes > 0) { // We're waiting for it.\n acc = (acc << 6) | (curByte & 0x3f);\n contBytes--; accBytes++;\n if (contBytes === 0) {\n // Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80)\n if (accBytes === 2 && acc < 0x80 && acc > 0)\n res += this.defaultCharUnicode;\n else if (accBytes === 3 && acc < 0x800)\n res += this.defaultCharUnicode;\n else\n // Actually add character.\n res += String.fromCharCode(acc);\n }\n } else { // Unexpected continuation byte\n res += this.defaultCharUnicode;\n }\n }\n }\n this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes;\n return res;\n}\n\nInternalDecoderCesu8.prototype.end = function() {\n var res = 0;\n if (this.contBytes > 0)\n res += this.defaultCharUnicode;\n return res;\n}\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js\n\n// == UTF16-BE codec. ==========================================================\n\nexports.utf16be = Utf16BECodec;\nfunction Utf16BECodec() {\n}\n\nUtf16BECodec.prototype.encoder = Utf16BEEncoder;\nUtf16BECodec.prototype.decoder = Utf16BEDecoder;\nUtf16BECodec.prototype.bomAware = true;\n\n\n// -- Encoding\n\nfunction Utf16BEEncoder() {\n}\n\nUtf16BEEncoder.prototype.write = function(str) {\n var buf = Buffer.from(str, 'ucs2');\n for (var i = 0; i < buf.length; i += 2) {\n var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp;\n }\n return buf;\n}\n\nUtf16BEEncoder.prototype.end = function() {\n}\n\n\n// -- Decoding\n\nfunction Utf16BEDecoder() {\n this.overflowByte = -1;\n}\n\nUtf16BEDecoder.prototype.write = function(buf) {\n if (buf.length == 0)\n return '';\n\n var buf2 = Buffer.alloc(buf.length + 1),\n i = 0, j = 0;\n\n if (this.overflowByte !== -1) {\n buf2[0] = buf[0];\n buf2[1] = this.overflowByte;\n i = 1; j = 2;\n }\n\n for (; i < buf.length-1; i += 2, j+= 2) {\n buf2[j] = buf[i+1];\n buf2[j+1] = buf[i];\n }\n\n this.overflowByte = (i == buf.length-1) ? buf[buf.length-1] : -1;\n\n return buf2.slice(0, j).toString('ucs2');\n}\n\nUtf16BEDecoder.prototype.end = function() {\n}\n\n\n// == UTF-16 codec =============================================================\n// Decoder chooses automatically from UTF-16LE and UTF-16BE using BOM and space-based heuristic.\n// Defaults to UTF-16LE, as it's prevalent and default in Node.\n// http://en.wikipedia.org/wiki/UTF-16 and http://encoding.spec.whatwg.org/#utf-16le\n// Decoder default can be changed: iconv.decode(buf, 'utf16', {defaultEncoding: 'utf-16be'});\n\n// Encoder uses UTF-16LE and prepends BOM (which can be overridden with addBOM: false).\n\nexports.utf16 = Utf16Codec;\nfunction Utf16Codec(codecOptions, iconv) {\n this.iconv = iconv;\n}\n\nUtf16Codec.prototype.encoder = Utf16Encoder;\nUtf16Codec.prototype.decoder = Utf16Decoder;\n\n\n// -- Encoding (pass-through)\n\nfunction Utf16Encoder(options, codec) {\n options = options || {};\n if (options.addBOM === undefined)\n options.addBOM = true;\n this.encoder = codec.iconv.getEncoder('utf-16le', options);\n}\n\nUtf16Encoder.prototype.write = function(str) {\n return this.encoder.write(str);\n}\n\nUtf16Encoder.prototype.end = function() {\n return this.encoder.end();\n}\n\n\n// -- Decoding\n\nfunction Utf16Decoder(options, codec) {\n this.decoder = null;\n this.initialBytes = [];\n this.initialBytesLen = 0;\n\n this.options = options || {};\n this.iconv = codec.iconv;\n}\n\nUtf16Decoder.prototype.write = function(buf) {\n if (!this.decoder) {\n // Codec is not chosen yet. Accumulate initial bytes.\n this.initialBytes.push(buf);\n this.initialBytesLen += buf.length;\n \n if (this.initialBytesLen < 16) // We need more bytes to use space heuristic (see below)\n return '';\n\n // We have enough bytes -> detect endianness.\n var buf = Buffer.concat(this.initialBytes),\n encoding = detectEncoding(buf, this.options.defaultEncoding);\n this.decoder = this.iconv.getDecoder(encoding, this.options);\n this.initialBytes.length = this.initialBytesLen = 0;\n }\n\n return this.decoder.write(buf);\n}\n\nUtf16Decoder.prototype.end = function() {\n if (!this.decoder) {\n var buf = Buffer.concat(this.initialBytes),\n encoding = detectEncoding(buf, this.options.defaultEncoding);\n this.decoder = this.iconv.getDecoder(encoding, this.options);\n\n var res = this.decoder.write(buf),\n trail = this.decoder.end();\n\n return trail ? (res + trail) : res;\n }\n return this.decoder.end();\n}\n\nfunction detectEncoding(buf, defaultEncoding) {\n var enc = defaultEncoding || 'utf-16le';\n\n if (buf.length >= 2) {\n // Check BOM.\n if (buf[0] == 0xFE && buf[1] == 0xFF) // UTF-16BE BOM\n enc = 'utf-16be';\n else if (buf[0] == 0xFF && buf[1] == 0xFE) // UTF-16LE BOM\n enc = 'utf-16le';\n else {\n // No BOM found. Try to deduce encoding from initial content.\n // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon.\n // So, we count ASCII as if it was LE or BE, and decide from that.\n var asciiCharsLE = 0, asciiCharsBE = 0, // Counts of chars in both positions\n _len = Math.min(buf.length - (buf.length % 2), 64); // Len is always even.\n\n for (var i = 0; i < _len; i += 2) {\n if (buf[i] === 0 && buf[i+1] !== 0) asciiCharsBE++;\n if (buf[i] !== 0 && buf[i+1] === 0) asciiCharsLE++;\n }\n\n if (asciiCharsBE > asciiCharsLE)\n enc = 'utf-16be';\n else if (asciiCharsBE < asciiCharsLE)\n enc = 'utf-16le';\n }\n }\n\n return enc;\n}\n\n\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// UTF-7 codec, according to https://tools.ietf.org/html/rfc2152\n// See also below a UTF-7-IMAP codec, according to http://tools.ietf.org/html/rfc3501#section-5.1.3\n\nexports.utf7 = Utf7Codec;\nexports.unicode11utf7 = 'utf7'; // Alias UNICODE-1-1-UTF-7\nfunction Utf7Codec(codecOptions, iconv) {\n this.iconv = iconv;\n};\n\nUtf7Codec.prototype.encoder = Utf7Encoder;\nUtf7Codec.prototype.decoder = Utf7Decoder;\nUtf7Codec.prototype.bomAware = true;\n\n\n// -- Encoding\n\nvar nonDirectChars = /[^A-Za-z0-9'\\(\\),-\\.\\/:\\? \\n\\r\\t]+/g;\n\nfunction Utf7Encoder(options, codec) {\n this.iconv = codec.iconv;\n}\n\nUtf7Encoder.prototype.write = function(str) {\n // Naive implementation.\n // Non-direct chars are encoded as \"+-\"; single \"+\" char is encoded as \"+-\".\n return Buffer.from(str.replace(nonDirectChars, function(chunk) {\n return \"+\" + (chunk === '+' ? '' : \n this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) \n + \"-\";\n }.bind(this)));\n}\n\nUtf7Encoder.prototype.end = function() {\n}\n\n\n// -- Decoding\n\nfunction Utf7Decoder(options, codec) {\n this.iconv = codec.iconv;\n this.inBase64 = false;\n this.base64Accum = '';\n}\n\nvar base64Regex = /[A-Za-z0-9\\/+]/;\nvar base64Chars = [];\nfor (var i = 0; i < 256; i++)\n base64Chars[i] = base64Regex.test(String.fromCharCode(i));\n\nvar plusChar = '+'.charCodeAt(0), \n minusChar = '-'.charCodeAt(0),\n andChar = '&'.charCodeAt(0);\n\nUtf7Decoder.prototype.write = function(buf) {\n var res = \"\", lastI = 0,\n inBase64 = this.inBase64,\n base64Accum = this.base64Accum;\n\n // The decoder is more involved as we must handle chunks in stream.\n\n for (var i = 0; i < buf.length; i++) {\n if (!inBase64) { // We're in direct mode.\n // Write direct chars until '+'\n if (buf[i] == plusChar) {\n res += this.iconv.decode(buf.slice(lastI, i), \"ascii\"); // Write direct chars.\n lastI = i+1;\n inBase64 = true;\n }\n } else { // We decode base64.\n if (!base64Chars[buf[i]]) { // Base64 ended.\n if (i == lastI && buf[i] == minusChar) {// \"+-\" -> \"+\"\n res += \"+\";\n } else {\n var b64str = base64Accum + buf.slice(lastI, i).toString();\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n if (buf[i] != minusChar) // Minus is absorbed after base64.\n i--;\n\n lastI = i+1;\n inBase64 = false;\n base64Accum = '';\n }\n }\n }\n\n if (!inBase64) {\n res += this.iconv.decode(buf.slice(lastI), \"ascii\"); // Write direct chars.\n } else {\n var b64str = base64Accum + buf.slice(lastI).toString();\n\n var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars.\n base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.\n b64str = b64str.slice(0, canBeDecoded);\n\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n this.inBase64 = inBase64;\n this.base64Accum = base64Accum;\n\n return res;\n}\n\nUtf7Decoder.prototype.end = function() {\n var res = \"\";\n if (this.inBase64 && this.base64Accum.length > 0)\n res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), \"utf16-be\");\n\n this.inBase64 = false;\n this.base64Accum = '';\n return res;\n}\n\n\n// UTF-7-IMAP codec.\n// RFC3501 Sec. 5.1.3 Modified UTF-7 (http://tools.ietf.org/html/rfc3501#section-5.1.3)\n// Differences:\n// * Base64 part is started by \"&\" instead of \"+\"\n// * Direct characters are 0x20-0x7E, except \"&\" (0x26)\n// * In Base64, \",\" is used instead of \"/\"\n// * Base64 must not be used to represent direct characters.\n// * No implicit shift back from Base64 (should always end with '-')\n// * String must end in non-shifted position.\n// * \"-&\" while in base64 is not allowed.\n\n\nexports.utf7imap = Utf7IMAPCodec;\nfunction Utf7IMAPCodec(codecOptions, iconv) {\n this.iconv = iconv;\n};\n\nUtf7IMAPCodec.prototype.encoder = Utf7IMAPEncoder;\nUtf7IMAPCodec.prototype.decoder = Utf7IMAPDecoder;\nUtf7IMAPCodec.prototype.bomAware = true;\n\n\n// -- Encoding\n\nfunction Utf7IMAPEncoder(options, codec) {\n this.iconv = codec.iconv;\n this.inBase64 = false;\n this.base64Accum = Buffer.alloc(6);\n this.base64AccumIdx = 0;\n}\n\nUtf7IMAPEncoder.prototype.write = function(str) {\n var inBase64 = this.inBase64,\n base64Accum = this.base64Accum,\n base64AccumIdx = this.base64AccumIdx,\n buf = Buffer.alloc(str.length*5 + 10), bufIdx = 0;\n\n for (var i = 0; i < str.length; i++) {\n var uChar = str.charCodeAt(i);\n if (0x20 <= uChar && uChar <= 0x7E) { // Direct character or '&'.\n if (inBase64) {\n if (base64AccumIdx > 0) {\n bufIdx += buf.write(base64Accum.slice(0, base64AccumIdx).toString('base64').replace(/\\//g, ',').replace(/=+$/, ''), bufIdx);\n base64AccumIdx = 0;\n }\n\n buf[bufIdx++] = minusChar; // Write '-', then go to direct mode.\n inBase64 = false;\n }\n\n if (!inBase64) {\n buf[bufIdx++] = uChar; // Write direct character\n\n if (uChar === andChar) // Ampersand -> '&-'\n buf[bufIdx++] = minusChar;\n }\n\n } else { // Non-direct character\n if (!inBase64) {\n buf[bufIdx++] = andChar; // Write '&', then go to base64 mode.\n inBase64 = true;\n }\n if (inBase64) {\n base64Accum[base64AccumIdx++] = uChar >> 8;\n base64Accum[base64AccumIdx++] = uChar & 0xFF;\n\n if (base64AccumIdx == base64Accum.length) {\n bufIdx += buf.write(base64Accum.toString('base64').replace(/\\//g, ','), bufIdx);\n base64AccumIdx = 0;\n }\n }\n }\n }\n\n this.inBase64 = inBase64;\n this.base64AccumIdx = base64AccumIdx;\n\n return buf.slice(0, bufIdx);\n}\n\nUtf7IMAPEncoder.prototype.end = function() {\n var buf = Buffer.alloc(10), bufIdx = 0;\n if (this.inBase64) {\n if (this.base64AccumIdx > 0) {\n bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString('base64').replace(/\\//g, ',').replace(/=+$/, ''), bufIdx);\n this.base64AccumIdx = 0;\n }\n\n buf[bufIdx++] = minusChar; // Write '-', then go to direct mode.\n this.inBase64 = false;\n }\n\n return buf.slice(0, bufIdx);\n}\n\n\n// -- Decoding\n\nfunction Utf7IMAPDecoder(options, codec) {\n this.iconv = codec.iconv;\n this.inBase64 = false;\n this.base64Accum = '';\n}\n\nvar base64IMAPChars = base64Chars.slice();\nbase64IMAPChars[','.charCodeAt(0)] = true;\n\nUtf7IMAPDecoder.prototype.write = function(buf) {\n var res = \"\", lastI = 0,\n inBase64 = this.inBase64,\n base64Accum = this.base64Accum;\n\n // The decoder is more involved as we must handle chunks in stream.\n // It is forgiving, closer to standard UTF-7 (for example, '-' is optional at the end).\n\n for (var i = 0; i < buf.length; i++) {\n if (!inBase64) { // We're in direct mode.\n // Write direct chars until '&'\n if (buf[i] == andChar) {\n res += this.iconv.decode(buf.slice(lastI, i), \"ascii\"); // Write direct chars.\n lastI = i+1;\n inBase64 = true;\n }\n } else { // We decode base64.\n if (!base64IMAPChars[buf[i]]) { // Base64 ended.\n if (i == lastI && buf[i] == minusChar) { // \"&-\" -> \"&\"\n res += \"&\";\n } else {\n var b64str = base64Accum + buf.slice(lastI, i).toString().replace(/,/g, '/');\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n if (buf[i] != minusChar) // Minus may be absorbed after base64.\n i--;\n\n lastI = i+1;\n inBase64 = false;\n base64Accum = '';\n }\n }\n }\n\n if (!inBase64) {\n res += this.iconv.decode(buf.slice(lastI), \"ascii\"); // Write direct chars.\n } else {\n var b64str = base64Accum + buf.slice(lastI).toString().replace(/,/g, '/');\n\n var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars.\n base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.\n b64str = b64str.slice(0, canBeDecoded);\n\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n this.inBase64 = inBase64;\n this.base64Accum = base64Accum;\n\n return res;\n}\n\nUtf7IMAPDecoder.prototype.end = function() {\n var res = \"\";\n if (this.inBase64 && this.base64Accum.length > 0)\n res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), \"utf16-be\");\n\n this.inBase64 = false;\n this.base64Accum = '';\n return res;\n}\n\n\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that\n// correspond to encoded bytes (if 128 - then lower half is ASCII). \n\nexports._sbcs = SBCSCodec;\nfunction SBCSCodec(codecOptions, iconv) {\n if (!codecOptions)\n throw new Error(\"SBCS codec is called without the data.\")\n \n // Prepare char buffer for decoding.\n if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256))\n throw new Error(\"Encoding '\"+codecOptions.type+\"' has incorrect 'chars' (must be of len 128 or 256)\");\n \n if (codecOptions.chars.length === 128) {\n var asciiString = \"\";\n for (var i = 0; i < 128; i++)\n asciiString += String.fromCharCode(i);\n codecOptions.chars = asciiString + codecOptions.chars;\n }\n\n this.decodeBuf = Buffer.from(codecOptions.chars, 'ucs2');\n \n // Encoding buffer.\n var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));\n\n for (var i = 0; i < codecOptions.chars.length; i++)\n encodeBuf[codecOptions.chars.charCodeAt(i)] = i;\n\n this.encodeBuf = encodeBuf;\n}\n\nSBCSCodec.prototype.encoder = SBCSEncoder;\nSBCSCodec.prototype.decoder = SBCSDecoder;\n\n\nfunction SBCSEncoder(options, codec) {\n this.encodeBuf = codec.encodeBuf;\n}\n\nSBCSEncoder.prototype.write = function(str) {\n var buf = Buffer.alloc(str.length);\n for (var i = 0; i < str.length; i++)\n buf[i] = this.encodeBuf[str.charCodeAt(i)];\n \n return buf;\n}\n\nSBCSEncoder.prototype.end = function() {\n}\n\n\nfunction SBCSDecoder(options, codec) {\n this.decodeBuf = codec.decodeBuf;\n}\n\nSBCSDecoder.prototype.write = function(buf) {\n // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.\n var decodeBuf = this.decodeBuf;\n var newBuf = Buffer.alloc(buf.length*2);\n var idx1 = 0, idx2 = 0;\n for (var i = 0; i < buf.length; i++) {\n idx1 = buf[i]*2; idx2 = i*2;\n newBuf[idx2] = decodeBuf[idx1];\n newBuf[idx2+1] = decodeBuf[idx1+1];\n }\n return newBuf.toString('ucs2');\n}\n\nSBCSDecoder.prototype.end = function() {\n}\n", "\"use strict\";\n\n// Manually added data to be used by sbcs codec in addition to generated one.\n\nmodule.exports = {\n // Not supported by iconv, not sure why.\n \"10029\": \"maccenteuro\",\n \"maccenteuro\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u0100\u0101\u00C9\u0104\u00D6\u00DC\u00E1\u0105\u010C\u00E4\u010D\u0106\u0107\u00E9\u0179\u017A\u010E\u00ED\u010F\u0112\u0113\u0116\u00F3\u0117\u00F4\u00F6\u00F5\u00FA\u011A\u011B\u00FC\u2020\u00B0\u0118\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u0119\u00A8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\u00AC\u221A\u0144\u0147\u2206\u00AB\u00BB\u2026\u00A0\u0148\u0150\u00D5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\u00C1\u0164\u0165\u00CD\u017D\u017E\u016A\u00D3\u00D4\u016B\u016E\u00DA\u016F\u0170\u0171\u0172\u0173\u00DD\u00FD\u0137\u017B\u0141\u017C\u0122\u02C7\"\n },\n\n \"808\": \"cp808\",\n \"ibm808\": \"cp808\",\n \"cp808\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E\u00B0\u2219\u00B7\u221A\u2116\u20AC\u25A0\u00A0\"\n },\n\n \"mik\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u2514\u2534\u252C\u251C\u2500\u253C\u2563\u2551\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2510\u2591\u2592\u2593\u2502\u2524\u2116\u00A7\u2557\u255D\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n\n // Aliases of generated encodings.\n \"ascii8bit\": \"ascii\",\n \"usascii\": \"ascii\",\n \"ansix34\": \"ascii\",\n \"ansix341968\": \"ascii\",\n \"ansix341986\": \"ascii\",\n \"csascii\": \"ascii\",\n \"cp367\": \"ascii\",\n \"ibm367\": \"ascii\",\n \"isoir6\": \"ascii\",\n \"iso646us\": \"ascii\",\n \"iso646irv\": \"ascii\",\n \"us\": \"ascii\",\n\n \"latin1\": \"iso88591\",\n \"latin2\": \"iso88592\",\n \"latin3\": \"iso88593\",\n \"latin4\": \"iso88594\",\n \"latin5\": \"iso88599\",\n \"latin6\": \"iso885910\",\n \"latin7\": \"iso885913\",\n \"latin8\": \"iso885914\",\n \"latin9\": \"iso885915\",\n \"latin10\": \"iso885916\",\n\n \"csisolatin1\": \"iso88591\",\n \"csisolatin2\": \"iso88592\",\n \"csisolatin3\": \"iso88593\",\n \"csisolatin4\": \"iso88594\",\n \"csisolatincyrillic\": \"iso88595\",\n \"csisolatinarabic\": \"iso88596\",\n \"csisolatingreek\" : \"iso88597\",\n \"csisolatinhebrew\": \"iso88598\",\n \"csisolatin5\": \"iso88599\",\n \"csisolatin6\": \"iso885910\",\n\n \"l1\": \"iso88591\",\n \"l2\": \"iso88592\",\n \"l3\": \"iso88593\",\n \"l4\": \"iso88594\",\n \"l5\": \"iso88599\",\n \"l6\": \"iso885910\",\n \"l7\": \"iso885913\",\n \"l8\": \"iso885914\",\n \"l9\": \"iso885915\",\n \"l10\": \"iso885916\",\n\n \"isoir14\": \"iso646jp\",\n \"isoir57\": \"iso646cn\",\n \"isoir100\": \"iso88591\",\n \"isoir101\": \"iso88592\",\n \"isoir109\": \"iso88593\",\n \"isoir110\": \"iso88594\",\n \"isoir144\": \"iso88595\",\n \"isoir127\": \"iso88596\",\n \"isoir126\": \"iso88597\",\n \"isoir138\": \"iso88598\",\n \"isoir148\": \"iso88599\",\n \"isoir157\": \"iso885910\",\n \"isoir166\": \"tis620\",\n \"isoir179\": \"iso885913\",\n \"isoir199\": \"iso885914\",\n \"isoir203\": \"iso885915\",\n \"isoir226\": \"iso885916\",\n\n \"cp819\": \"iso88591\",\n \"ibm819\": \"iso88591\",\n\n \"cyrillic\": \"iso88595\",\n\n \"arabic\": \"iso88596\",\n \"arabic8\": \"iso88596\",\n \"ecma114\": \"iso88596\",\n \"asmo708\": \"iso88596\",\n\n \"greek\" : \"iso88597\",\n \"greek8\" : \"iso88597\",\n \"ecma118\" : \"iso88597\",\n \"elot928\" : \"iso88597\",\n\n \"hebrew\": \"iso88598\",\n \"hebrew8\": \"iso88598\",\n\n \"turkish\": \"iso88599\",\n \"turkish8\": \"iso88599\",\n\n \"thai\": \"iso885911\",\n \"thai8\": \"iso885911\",\n\n \"celtic\": \"iso885914\",\n \"celtic8\": \"iso885914\",\n \"isoceltic\": \"iso885914\",\n\n \"tis6200\": \"tis620\",\n \"tis62025291\": \"tis620\",\n \"tis62025330\": \"tis620\",\n\n \"10000\": \"macroman\",\n \"10006\": \"macgreek\",\n \"10007\": \"maccyrillic\",\n \"10079\": \"maciceland\",\n \"10081\": \"macturkish\",\n\n \"cspc8codepage437\": \"cp437\",\n \"cspc775baltic\": \"cp775\",\n \"cspc850multilingual\": \"cp850\",\n \"cspcp852\": \"cp852\",\n \"cspc862latinhebrew\": \"cp862\",\n \"cpgr\": \"cp869\",\n\n \"msee\": \"cp1250\",\n \"mscyrl\": \"cp1251\",\n \"msansi\": \"cp1252\",\n \"msgreek\": \"cp1253\",\n \"msturk\": \"cp1254\",\n \"mshebr\": \"cp1255\",\n \"msarab\": \"cp1256\",\n \"winbaltrim\": \"cp1257\",\n\n \"cp20866\": \"koi8r\",\n \"20866\": \"koi8r\",\n \"ibm878\": \"koi8r\",\n \"cskoi8r\": \"koi8r\",\n\n \"cp21866\": \"koi8u\",\n \"21866\": \"koi8u\",\n \"ibm1168\": \"koi8u\",\n\n \"strk10482002\": \"rk1048\",\n\n \"tcvn5712\": \"tcvn\",\n \"tcvn57121\": \"tcvn\",\n\n \"gb198880\": \"iso646cn\",\n \"cn\": \"iso646cn\",\n\n \"csiso14jisc6220ro\": \"iso646jp\",\n \"jisc62201969ro\": \"iso646jp\",\n \"jp\": \"iso646jp\",\n\n \"cshproman8\": \"hproman8\",\n \"r8\": \"hproman8\",\n \"roman8\": \"hproman8\",\n \"xroman8\": \"hproman8\",\n \"ibm1051\": \"hproman8\",\n\n \"mac\": \"macintosh\",\n \"csmacintosh\": \"macintosh\",\n};\n\n", "\"use strict\";\n\n// Generated data for sbcs codec. Don't edit manually. Regenerate using generation/gen-sbcs.js script.\nmodule.exports = {\n \"437\": \"cp437\",\n \"737\": \"cp737\",\n \"775\": \"cp775\",\n \"850\": \"cp850\",\n \"852\": \"cp852\",\n \"855\": \"cp855\",\n \"856\": \"cp856\",\n \"857\": \"cp857\",\n \"858\": \"cp858\",\n \"860\": \"cp860\",\n \"861\": \"cp861\",\n \"862\": \"cp862\",\n \"863\": \"cp863\",\n \"864\": \"cp864\",\n \"865\": \"cp865\",\n \"866\": \"cp866\",\n \"869\": \"cp869\",\n \"874\": \"windows874\",\n \"922\": \"cp922\",\n \"1046\": \"cp1046\",\n \"1124\": \"cp1124\",\n \"1125\": \"cp1125\",\n \"1129\": \"cp1129\",\n \"1133\": \"cp1133\",\n \"1161\": \"cp1161\",\n \"1162\": \"cp1162\",\n \"1163\": \"cp1163\",\n \"1250\": \"windows1250\",\n \"1251\": \"windows1251\",\n \"1252\": \"windows1252\",\n \"1253\": \"windows1253\",\n \"1254\": \"windows1254\",\n \"1255\": \"windows1255\",\n \"1256\": \"windows1256\",\n \"1257\": \"windows1257\",\n \"1258\": \"windows1258\",\n \"28591\": \"iso88591\",\n \"28592\": \"iso88592\",\n \"28593\": \"iso88593\",\n \"28594\": \"iso88594\",\n \"28595\": \"iso88595\",\n \"28596\": \"iso88596\",\n \"28597\": \"iso88597\",\n \"28598\": \"iso88598\",\n \"28599\": \"iso88599\",\n \"28600\": \"iso885910\",\n \"28601\": \"iso885911\",\n \"28603\": \"iso885913\",\n \"28604\": \"iso885914\",\n \"28605\": \"iso885915\",\n \"28606\": \"iso885916\",\n \"windows874\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\uFFFD\uFFFD\uFFFD\u2026\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"win874\": \"windows874\",\n \"cp874\": \"windows874\",\n \"windows1250\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\uFFFD\u201E\u2026\u2020\u2021\uFFFD\u2030\u0160\u2039\u015A\u0164\u017D\u0179\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0161\u203A\u015B\u0165\u017E\u017A\u00A0\u02C7\u02D8\u0141\u00A4\u0104\u00A6\u00A7\u00A8\u00A9\u015E\u00AB\u00AC\u00AD\u00AE\u017B\u00B0\u00B1\u02DB\u0142\u00B4\u00B5\u00B6\u00B7\u00B8\u0105\u015F\u00BB\u013D\u02DD\u013E\u017C\u0154\u00C1\u00C2\u0102\u00C4\u0139\u0106\u00C7\u010C\u00C9\u0118\u00CB\u011A\u00CD\u00CE\u010E\u0110\u0143\u0147\u00D3\u00D4\u0150\u00D6\u00D7\u0158\u016E\u00DA\u0170\u00DC\u00DD\u0162\u00DF\u0155\u00E1\u00E2\u0103\u00E4\u013A\u0107\u00E7\u010D\u00E9\u0119\u00EB\u011B\u00ED\u00EE\u010F\u0111\u0144\u0148\u00F3\u00F4\u0151\u00F6\u00F7\u0159\u016F\u00FA\u0171\u00FC\u00FD\u0163\u02D9\"\n },\n \"win1250\": \"windows1250\",\n \"cp1250\": \"windows1250\",\n \"windows1251\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0402\u0403\u201A\u0453\u201E\u2026\u2020\u2021\u20AC\u2030\u0409\u2039\u040A\u040C\u040B\u040F\u0452\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0459\u203A\u045A\u045C\u045B\u045F\u00A0\u040E\u045E\u0408\u00A4\u0490\u00A6\u00A7\u0401\u00A9\u0404\u00AB\u00AC\u00AD\u00AE\u0407\u00B0\u00B1\u0406\u0456\u0491\u00B5\u00B6\u00B7\u0451\u2116\u0454\u00BB\u0458\u0405\u0455\u0457\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\"\n },\n \"win1251\": \"windows1251\",\n \"cp1251\": \"windows1251\",\n \"windows1252\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\uFFFD\u017D\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\uFFFD\u017E\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"win1252\": \"windows1252\",\n \"cp1252\": \"windows1252\",\n \"windows1253\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\uFFFD\u2030\uFFFD\u2039\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD\u00A0\u0385\u0386\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\uFFFD\u00AB\u00AC\u00AD\u00AE\u2015\u00B0\u00B1\u00B2\u00B3\u0384\u00B5\u00B6\u00B7\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD\"\n },\n \"win1253\": \"windows1253\",\n \"cp1253\": \"windows1253\",\n \"windows1254\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\uFFFD\uFFFD\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u011E\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u0130\u015E\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u011F\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u0131\u015F\u00FF\"\n },\n \"win1254\": \"windows1254\",\n \"cp1254\": \"windows1254\",\n \"windows1255\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\uFFFD\u2039\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD\u00A0\u00A1\u00A2\u00A3\u20AA\u00A5\u00A6\u00A7\u00A8\u00A9\u00D7\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00F7\u00BB\u00BC\u00BD\u00BE\u00BF\u05B0\u05B1\u05B2\u05B3\u05B4\u05B5\u05B6\u05B7\u05B8\u05B9\u05BA\u05BB\u05BC\u05BD\u05BE\u05BF\u05C0\u05C1\u05C2\u05C3\u05F0\u05F1\u05F2\u05F3\u05F4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\uFFFD\uFFFD\u200E\u200F\uFFFD\"\n },\n \"win1255\": \"windows1255\",\n \"cp1255\": \"windows1255\",\n \"windows1256\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\u067E\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0679\u2039\u0152\u0686\u0698\u0688\u06AF\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u06A9\u2122\u0691\u203A\u0153\u200C\u200D\u06BA\u00A0\u060C\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u06BE\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u061B\u00BB\u00BC\u00BD\u00BE\u061F\u06C1\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u00D7\u0637\u0638\u0639\u063A\u0640\u0641\u0642\u0643\u00E0\u0644\u00E2\u0645\u0646\u0647\u0648\u00E7\u00E8\u00E9\u00EA\u00EB\u0649\u064A\u00EE\u00EF\u064B\u064C\u064D\u064E\u00F4\u064F\u0650\u00F7\u0651\u00F9\u0652\u00FB\u00FC\u200E\u200F\u06D2\"\n },\n \"win1256\": \"windows1256\",\n \"cp1256\": \"windows1256\",\n \"windows1257\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\uFFFD\u201E\u2026\u2020\u2021\uFFFD\u2030\uFFFD\u2039\uFFFD\u00A8\u02C7\u00B8\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\uFFFD\u203A\uFFFD\u00AF\u02DB\uFFFD\u00A0\uFFFD\u00A2\u00A3\u00A4\uFFFD\u00A6\u00A7\u00D8\u00A9\u0156\u00AB\u00AC\u00AD\u00AE\u00C6\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00F8\u00B9\u0157\u00BB\u00BC\u00BD\u00BE\u00E6\u0104\u012E\u0100\u0106\u00C4\u00C5\u0118\u0112\u010C\u00C9\u0179\u0116\u0122\u0136\u012A\u013B\u0160\u0143\u0145\u00D3\u014C\u00D5\u00D6\u00D7\u0172\u0141\u015A\u016A\u00DC\u017B\u017D\u00DF\u0105\u012F\u0101\u0107\u00E4\u00E5\u0119\u0113\u010D\u00E9\u017A\u0117\u0123\u0137\u012B\u013C\u0161\u0144\u0146\u00F3\u014D\u00F5\u00F6\u00F7\u0173\u0142\u015B\u016B\u00FC\u017C\u017E\u02D9\"\n },\n \"win1257\": \"windows1257\",\n \"cp1257\": \"windows1257\",\n \"windows1258\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\uFFFD\u2039\u0152\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\uFFFD\u203A\u0153\uFFFD\uFFFD\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u0102\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u0300\u00CD\u00CE\u00CF\u0110\u00D1\u0309\u00D3\u00D4\u01A0\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u01AF\u0303\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u0301\u00ED\u00EE\u00EF\u0111\u00F1\u0323\u00F3\u00F4\u01A1\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u01B0\u20AB\u00FF\"\n },\n \"win1258\": \"windows1258\",\n \"cp1258\": \"windows1258\",\n \"iso88591\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"cp28591\": \"iso88591\",\n \"iso88592\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u02D8\u0141\u00A4\u013D\u015A\u00A7\u00A8\u0160\u015E\u0164\u0179\u00AD\u017D\u017B\u00B0\u0105\u02DB\u0142\u00B4\u013E\u015B\u02C7\u00B8\u0161\u015F\u0165\u017A\u02DD\u017E\u017C\u0154\u00C1\u00C2\u0102\u00C4\u0139\u0106\u00C7\u010C\u00C9\u0118\u00CB\u011A\u00CD\u00CE\u010E\u0110\u0143\u0147\u00D3\u00D4\u0150\u00D6\u00D7\u0158\u016E\u00DA\u0170\u00DC\u00DD\u0162\u00DF\u0155\u00E1\u00E2\u0103\u00E4\u013A\u0107\u00E7\u010D\u00E9\u0119\u00EB\u011B\u00ED\u00EE\u010F\u0111\u0144\u0148\u00F3\u00F4\u0151\u00F6\u00F7\u0159\u016F\u00FA\u0171\u00FC\u00FD\u0163\u02D9\"\n },\n \"cp28592\": \"iso88592\",\n \"iso88593\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0126\u02D8\u00A3\u00A4\uFFFD\u0124\u00A7\u00A8\u0130\u015E\u011E\u0134\u00AD\uFFFD\u017B\u00B0\u0127\u00B2\u00B3\u00B4\u00B5\u0125\u00B7\u00B8\u0131\u015F\u011F\u0135\u00BD\uFFFD\u017C\u00C0\u00C1\u00C2\uFFFD\u00C4\u010A\u0108\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\uFFFD\u00D1\u00D2\u00D3\u00D4\u0120\u00D6\u00D7\u011C\u00D9\u00DA\u00DB\u00DC\u016C\u015C\u00DF\u00E0\u00E1\u00E2\uFFFD\u00E4\u010B\u0109\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\uFFFD\u00F1\u00F2\u00F3\u00F4\u0121\u00F6\u00F7\u011D\u00F9\u00FA\u00FB\u00FC\u016D\u015D\u02D9\"\n },\n \"cp28593\": \"iso88593\",\n \"iso88594\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u0138\u0156\u00A4\u0128\u013B\u00A7\u00A8\u0160\u0112\u0122\u0166\u00AD\u017D\u00AF\u00B0\u0105\u02DB\u0157\u00B4\u0129\u013C\u02C7\u00B8\u0161\u0113\u0123\u0167\u014A\u017E\u014B\u0100\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u012E\u010C\u00C9\u0118\u00CB\u0116\u00CD\u00CE\u012A\u0110\u0145\u014C\u0136\u00D4\u00D5\u00D6\u00D7\u00D8\u0172\u00DA\u00DB\u00DC\u0168\u016A\u00DF\u0101\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u012F\u010D\u00E9\u0119\u00EB\u0117\u00ED\u00EE\u012B\u0111\u0146\u014D\u0137\u00F4\u00F5\u00F6\u00F7\u00F8\u0173\u00FA\u00FB\u00FC\u0169\u016B\u02D9\"\n },\n \"cp28594\": \"iso88594\",\n \"iso88595\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0401\u0402\u0403\u0404\u0405\u0406\u0407\u0408\u0409\u040A\u040B\u040C\u00AD\u040E\u040F\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u2116\u0451\u0452\u0453\u0454\u0455\u0456\u0457\u0458\u0459\u045A\u045B\u045C\u00A7\u045E\u045F\"\n },\n \"cp28595\": \"iso88595\",\n \"iso88596\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\uFFFD\uFFFD\uFFFD\u00A4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u060C\u00AD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u061B\uFFFD\uFFFD\uFFFD\u061F\uFFFD\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637\u0638\u0639\u063A\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0640\u0641\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"cp28596\": \"iso88596\",\n \"iso88597\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u2018\u2019\u00A3\u20AC\u20AF\u00A6\u00A7\u00A8\u00A9\u037A\u00AB\u00AC\u00AD\uFFFD\u2015\u00B0\u00B1\u00B2\u00B3\u0384\u0385\u0386\u00B7\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD\"\n },\n \"cp28597\": \"iso88597\",\n \"iso88598\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\uFFFD\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00D7\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00F7\u00BB\u00BC\u00BD\u00BE\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2017\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\uFFFD\uFFFD\u200E\u200F\uFFFD\"\n },\n \"cp28598\": \"iso88598\",\n \"iso88599\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u011E\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u0130\u015E\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u011F\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u0131\u015F\u00FF\"\n },\n \"cp28599\": \"iso88599\",\n \"iso885910\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u0112\u0122\u012A\u0128\u0136\u00A7\u013B\u0110\u0160\u0166\u017D\u00AD\u016A\u014A\u00B0\u0105\u0113\u0123\u012B\u0129\u0137\u00B7\u013C\u0111\u0161\u0167\u017E\u2015\u016B\u014B\u0100\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u012E\u010C\u00C9\u0118\u00CB\u0116\u00CD\u00CE\u00CF\u00D0\u0145\u014C\u00D3\u00D4\u00D5\u00D6\u0168\u00D8\u0172\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u0101\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u012F\u010D\u00E9\u0119\u00EB\u0117\u00ED\u00EE\u00EF\u00F0\u0146\u014D\u00F3\u00F4\u00F5\u00F6\u0169\u00F8\u0173\u00FA\u00FB\u00FC\u00FD\u00FE\u0138\"\n },\n \"cp28600\": \"iso885910\",\n \"iso885911\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"cp28601\": \"iso885911\",\n \"iso885913\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u201D\u00A2\u00A3\u00A4\u201E\u00A6\u00A7\u00D8\u00A9\u0156\u00AB\u00AC\u00AD\u00AE\u00C6\u00B0\u00B1\u00B2\u00B3\u201C\u00B5\u00B6\u00B7\u00F8\u00B9\u0157\u00BB\u00BC\u00BD\u00BE\u00E6\u0104\u012E\u0100\u0106\u00C4\u00C5\u0118\u0112\u010C\u00C9\u0179\u0116\u0122\u0136\u012A\u013B\u0160\u0143\u0145\u00D3\u014C\u00D5\u00D6\u00D7\u0172\u0141\u015A\u016A\u00DC\u017B\u017D\u00DF\u0105\u012F\u0101\u0107\u00E4\u00E5\u0119\u0113\u010D\u00E9\u017A\u0117\u0123\u0137\u012B\u013C\u0161\u0144\u0146\u00F3\u014D\u00F5\u00F6\u00F7\u0173\u0142\u015B\u016B\u00FC\u017C\u017E\u2019\"\n },\n \"cp28603\": \"iso885913\",\n \"iso885914\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u1E02\u1E03\u00A3\u010A\u010B\u1E0A\u00A7\u1E80\u00A9\u1E82\u1E0B\u1EF2\u00AD\u00AE\u0178\u1E1E\u1E1F\u0120\u0121\u1E40\u1E41\u00B6\u1E56\u1E81\u1E57\u1E83\u1E60\u1EF3\u1E84\u1E85\u1E61\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u0174\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u1E6A\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u0176\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u0175\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u1E6B\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u0177\u00FF\"\n },\n \"cp28604\": \"iso885914\",\n \"iso885915\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u20AC\u00A5\u0160\u00A7\u0161\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u017D\u00B5\u00B6\u00B7\u017E\u00B9\u00BA\u00BB\u0152\u0153\u0178\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"cp28605\": \"iso885915\",\n \"iso885916\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u0105\u0141\u20AC\u201E\u0160\u00A7\u0161\u00A9\u0218\u00AB\u0179\u00AD\u017A\u017B\u00B0\u00B1\u010C\u0142\u017D\u201D\u00B6\u00B7\u017E\u010D\u0219\u00BB\u0152\u0153\u0178\u017C\u00C0\u00C1\u00C2\u0102\u00C4\u0106\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u0110\u0143\u00D2\u00D3\u00D4\u0150\u00D6\u015A\u0170\u00D9\u00DA\u00DB\u00DC\u0118\u021A\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u0107\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u0111\u0144\u00F2\u00F3\u00F4\u0151\u00F6\u015B\u0171\u00F9\u00FA\u00FB\u00FC\u0119\u021B\u00FF\"\n },\n \"cp28606\": \"iso885916\",\n \"cp437\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm437\": \"cp437\",\n \"csibm437\": \"cp437\",\n \"cp737\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u03C5\u03C6\u03C7\u03C8\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03C9\u03AC\u03AD\u03AE\u03CA\u03AF\u03CC\u03CD\u03CB\u03CE\u0386\u0388\u0389\u038A\u038C\u038E\u038F\u00B1\u2265\u2264\u03AA\u03AB\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm737\": \"cp737\",\n \"csibm737\": \"cp737\",\n \"cp775\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0106\u00FC\u00E9\u0101\u00E4\u0123\u00E5\u0107\u0142\u0113\u0156\u0157\u012B\u0179\u00C4\u00C5\u00C9\u00E6\u00C6\u014D\u00F6\u0122\u00A2\u015A\u015B\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u00A4\u0100\u012A\u00F3\u017B\u017C\u017A\u201D\u00A6\u00A9\u00AE\u00AC\u00BD\u00BC\u0141\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u0104\u010C\u0118\u0116\u2563\u2551\u2557\u255D\u012E\u0160\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0172\u016A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u017D\u0105\u010D\u0119\u0117\u012F\u0161\u0173\u016B\u017E\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u00D3\u00DF\u014C\u0143\u00F5\u00D5\u00B5\u0144\u0136\u0137\u013B\u013C\u0146\u0112\u0145\u2019\u00AD\u00B1\u201C\u00BE\u00B6\u00A7\u00F7\u201E\u00B0\u2219\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm775\": \"cp775\",\n \"csibm775\": \"cp775\",\n \"cp850\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u00F0\u00D0\u00CA\u00CB\u00C8\u0131\u00CD\u00CE\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\u00FE\u00DE\u00DA\u00DB\u00D9\u00FD\u00DD\u00AF\u00B4\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm850\": \"cp850\",\n \"csibm850\": \"cp850\",\n \"cp852\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u016F\u0107\u00E7\u0142\u00EB\u0150\u0151\u00EE\u0179\u00C4\u0106\u00C9\u0139\u013A\u00F4\u00F6\u013D\u013E\u015A\u015B\u00D6\u00DC\u0164\u0165\u0141\u00D7\u010D\u00E1\u00ED\u00F3\u00FA\u0104\u0105\u017D\u017E\u0118\u0119\u00AC\u017A\u010C\u015F\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u011A\u015E\u2563\u2551\u2557\u255D\u017B\u017C\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0102\u0103\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u0111\u0110\u010E\u00CB\u010F\u0147\u00CD\u00CE\u011B\u2518\u250C\u2588\u2584\u0162\u016E\u2580\u00D3\u00DF\u00D4\u0143\u0144\u0148\u0160\u0161\u0154\u00DA\u0155\u0170\u00FD\u00DD\u0163\u00B4\u00AD\u02DD\u02DB\u02C7\u02D8\u00A7\u00F7\u00B8\u00B0\u00A8\u02D9\u0171\u0158\u0159\u25A0\u00A0\"\n },\n \"ibm852\": \"cp852\",\n \"csibm852\": \"cp852\",\n \"cp855\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0452\u0402\u0453\u0403\u0451\u0401\u0454\u0404\u0455\u0405\u0456\u0406\u0457\u0407\u0458\u0408\u0459\u0409\u045A\u040A\u045B\u040B\u045C\u040C\u045E\u040E\u045F\u040F\u044E\u042E\u044A\u042A\u0430\u0410\u0431\u0411\u0446\u0426\u0434\u0414\u0435\u0415\u0444\u0424\u0433\u0413\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u0445\u0425\u0438\u0418\u2563\u2551\u2557\u255D\u0439\u0419\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u043A\u041A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u043B\u041B\u043C\u041C\u043D\u041D\u043E\u041E\u043F\u2518\u250C\u2588\u2584\u041F\u044F\u2580\u042F\u0440\u0420\u0441\u0421\u0442\u0422\u0443\u0423\u0436\u0416\u0432\u0412\u044C\u042C\u2116\u00AD\u044B\u042B\u0437\u0417\u0448\u0428\u044D\u042D\u0449\u0429\u0447\u0427\u00A7\u25A0\u00A0\"\n },\n \"ibm855\": \"cp855\",\n \"csibm855\": \"cp855\",\n \"cp856\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\uFFFD\u00A3\uFFFD\u00D7\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00AE\u00AC\u00BD\u00BC\uFFFD\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\uFFFD\uFFFD\uFFFD\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\uFFFD\uFFFD\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2518\u250C\u2588\u2584\u00A6\uFFFD\u2580\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00B5\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00AF\u00B4\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm856\": \"cp856\",\n \"csibm856\": \"cp856\",\n \"cp857\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u0131\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u0130\u00D6\u00DC\u00F8\u00A3\u00D8\u015E\u015F\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u011E\u011F\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u00BA\u00AA\u00CA\u00CB\u00C8\uFFFD\u00CD\u00CE\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\uFFFD\u00D7\u00DA\u00DB\u00D9\u00EC\u00FF\u00AF\u00B4\u00AD\u00B1\uFFFD\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm857\": \"cp857\",\n \"csibm857\": \"cp857\",\n \"cp858\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u00F0\u00D0\u00CA\u00CB\u00C8\u20AC\u00CD\u00CE\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\u00FE\u00DE\u00DA\u00DB\u00D9\u00FD\u00DD\u00AF\u00B4\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm858\": \"cp858\",\n \"csibm858\": \"cp858\",\n \"cp860\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E3\u00E0\u00C1\u00E7\u00EA\u00CA\u00E8\u00CD\u00D4\u00EC\u00C3\u00C2\u00C9\u00C0\u00C8\u00F4\u00F5\u00F2\u00DA\u00F9\u00CC\u00D5\u00DC\u00A2\u00A3\u00D9\u20A7\u00D3\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00D2\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm860\": \"cp860\",\n \"csibm860\": \"cp860\",\n \"cp861\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00D0\u00F0\u00DE\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00FE\u00FB\u00DD\u00FD\u00D6\u00DC\u00F8\u00A3\u00D8\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00C1\u00CD\u00D3\u00DA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm861\": \"cp861\",\n \"csibm861\": \"cp861\",\n \"cp862\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm862\": \"cp862\",\n \"csibm862\": \"cp862\",\n \"cp863\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00C2\u00E0\u00B6\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u2017\u00C0\u00A7\u00C9\u00C8\u00CA\u00F4\u00CB\u00CF\u00FB\u00F9\u00A4\u00D4\u00DC\u00A2\u00A3\u00D9\u00DB\u0192\u00A6\u00B4\u00F3\u00FA\u00A8\u00B8\u00B3\u00AF\u00CE\u2310\u00AC\u00BD\u00BC\u00BE\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm863\": \"cp863\",\n \"csibm863\": \"cp863\",\n \"cp864\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#$\u066A&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007F\u00B0\u00B7\u2219\u221A\u2592\u2500\u2502\u253C\u2524\u252C\u251C\u2534\u2510\u250C\u2514\u2518\u03B2\u221E\u03C6\u00B1\u00BD\u00BC\u2248\u00AB\u00BB\uFEF7\uFEF8\uFFFD\uFFFD\uFEFB\uFEFC\uFFFD\u00A0\u00AD\uFE82\u00A3\u00A4\uFE84\uFFFD\uFFFD\uFE8E\uFE8F\uFE95\uFE99\u060C\uFE9D\uFEA1\uFEA5\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\uFED1\u061B\uFEB1\uFEB5\uFEB9\u061F\u00A2\uFE80\uFE81\uFE83\uFE85\uFECA\uFE8B\uFE8D\uFE91\uFE93\uFE97\uFE9B\uFE9F\uFEA3\uFEA7\uFEA9\uFEAB\uFEAD\uFEAF\uFEB3\uFEB7\uFEBB\uFEBF\uFEC1\uFEC5\uFECB\uFECF\u00A6\u00AC\u00F7\u00D7\uFEC9\u0640\uFED3\uFED7\uFEDB\uFEDF\uFEE3\uFEE7\uFEEB\uFEED\uFEEF\uFEF3\uFEBD\uFECC\uFECE\uFECD\uFEE1\uFE7D\u0651\uFEE5\uFEE9\uFEEC\uFEF0\uFEF2\uFED0\uFED5\uFEF5\uFEF6\uFEDD\uFED9\uFEF1\u25A0\uFFFD\"\n },\n \"ibm864\": \"cp864\",\n \"csibm864\": \"cp864\",\n \"cp865\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00A4\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm865\": \"cp865\",\n \"csibm865\": \"cp865\",\n \"cp866\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E\u00B0\u2219\u00B7\u221A\u2116\u00A4\u25A0\u00A0\"\n },\n \"ibm866\": \"cp866\",\n \"csibm866\": \"cp866\",\n \"cp869\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0386\uFFFD\u00B7\u00AC\u00A6\u2018\u2019\u0388\u2015\u0389\u038A\u03AA\u038C\uFFFD\uFFFD\u038E\u03AB\u00A9\u038F\u00B2\u00B3\u03AC\u00A3\u03AD\u03AE\u03AF\u03CA\u0390\u03CC\u03CD\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u00BD\u0398\u0399\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u039A\u039B\u039C\u039D\u2563\u2551\u2557\u255D\u039E\u039F\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u03A0\u03A1\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u2518\u250C\u2588\u2584\u03B4\u03B5\u2580\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u0384\u00AD\u00B1\u03C5\u03C6\u03C7\u00A7\u03C8\u0385\u00B0\u00A8\u03C9\u03CB\u03B0\u03CE\u25A0\u00A0\"\n },\n \"ibm869\": \"cp869\",\n \"csibm869\": \"cp869\",\n \"cp922\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u203E\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u0160\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u017D\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u0161\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u017E\u00FF\"\n },\n \"ibm922\": \"cp922\",\n \"csibm922\": \"cp922\",\n \"cp1046\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFE88\u00D7\u00F7\uF8F6\uF8F5\uF8F4\uF8F7\uFE71\u0088\u25A0\u2502\u2500\u2510\u250C\u2514\u2518\uFE79\uFE7B\uFE7D\uFE7F\uFE77\uFE8A\uFEF0\uFEF3\uFEF2\uFECE\uFECF\uFED0\uFEF6\uFEF8\uFEFA\uFEFC\u00A0\uF8FA\uF8F9\uF8F8\u00A4\uF8FB\uFE8B\uFE91\uFE97\uFE9B\uFE9F\uFEA3\u060C\u00AD\uFEA7\uFEB3\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\uFEB7\u061B\uFEBB\uFEBF\uFECA\u061F\uFECB\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637\uFEC7\u0639\u063A\uFECC\uFE82\uFE84\uFE8E\uFED3\u0640\u0641\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\uFED7\uFEDB\uFEDF\uF8FC\uFEF5\uFEF7\uFEF9\uFEFB\uFEE3\uFEE7\uFEEC\uFEE9\uFFFD\"\n },\n \"ibm1046\": \"cp1046\",\n \"csibm1046\": \"cp1046\",\n \"cp1124\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0401\u0402\u0490\u0404\u0405\u0406\u0407\u0408\u0409\u040A\u040B\u040C\u00AD\u040E\u040F\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u2116\u0451\u0452\u0491\u0454\u0455\u0456\u0457\u0458\u0459\u045A\u045B\u045C\u00A7\u045E\u045F\"\n },\n \"ibm1124\": \"cp1124\",\n \"csibm1124\": \"cp1124\",\n \"cp1125\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0490\u0491\u0404\u0454\u0406\u0456\u0407\u0457\u00B7\u221A\u2116\u00A4\u25A0\u00A0\"\n },\n \"ibm1125\": \"cp1125\",\n \"csibm1125\": \"cp1125\",\n \"cp1129\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u0153\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u0178\u00B5\u00B6\u00B7\u0152\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u0102\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u0300\u00CD\u00CE\u00CF\u0110\u00D1\u0309\u00D3\u00D4\u01A0\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u01AF\u0303\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u0301\u00ED\u00EE\u00EF\u0111\u00F1\u0323\u00F3\u00F4\u01A1\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u01B0\u20AB\u00FF\"\n },\n \"ibm1129\": \"cp1129\",\n \"csibm1129\": \"cp1129\",\n \"cp1133\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0E81\u0E82\u0E84\u0E87\u0E88\u0EAA\u0E8A\u0E8D\u0E94\u0E95\u0E96\u0E97\u0E99\u0E9A\u0E9B\u0E9C\u0E9D\u0E9E\u0E9F\u0EA1\u0EA2\u0EA3\u0EA5\u0EA7\u0EAB\u0EAD\u0EAE\uFFFD\uFFFD\uFFFD\u0EAF\u0EB0\u0EB2\u0EB3\u0EB4\u0EB5\u0EB6\u0EB7\u0EB8\u0EB9\u0EBC\u0EB1\u0EBB\u0EBD\uFFFD\uFFFD\uFFFD\u0EC0\u0EC1\u0EC2\u0EC3\u0EC4\u0EC8\u0EC9\u0ECA\u0ECB\u0ECC\u0ECD\u0EC6\uFFFD\u0EDC\u0EDD\u20AD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0ED0\u0ED1\u0ED2\u0ED3\u0ED4\u0ED5\u0ED6\u0ED7\u0ED8\u0ED9\uFFFD\uFFFD\u00A2\u00AC\u00A6\uFFFD\"\n },\n \"ibm1133\": \"cp1133\",\n \"csibm1133\": \"cp1133\",\n \"cp1161\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0E48\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\u0E49\u0E4A\u0E4B\u20AC\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\u00A2\u00AC\u00A6\u00A0\"\n },\n \"ibm1161\": \"cp1161\",\n \"csibm1161\": \"cp1161\",\n \"cp1162\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\u0081\u0082\u0083\u0084\u2026\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"ibm1162\": \"cp1162\",\n \"csibm1162\": \"cp1162\",\n \"cp1163\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u20AC\u00A5\u00A6\u00A7\u0153\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u0178\u00B5\u00B6\u00B7\u0152\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u0102\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u0300\u00CD\u00CE\u00CF\u0110\u00D1\u0309\u00D3\u00D4\u01A0\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u01AF\u0303\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u0301\u00ED\u00EE\u00EF\u0111\u00F1\u0323\u00F3\u00F4\u01A1\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u01B0\u20AB\u00FF\"\n },\n \"ibm1163\": \"cp1163\",\n \"csibm1163\": \"cp1163\",\n \"maccroatian\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u0160\u2122\u00B4\u00A8\u2260\u017D\u00D8\u221E\u00B1\u2264\u2265\u2206\u00B5\u2202\u2211\u220F\u0161\u222B\u00AA\u00BA\u2126\u017E\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u0106\u00AB\u010C\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\uFFFD\u00A9\u2044\u00A4\u2039\u203A\u00C6\u00BB\u2013\u00B7\u201A\u201E\u2030\u00C2\u0107\u00C1\u010D\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\u0111\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u03C0\u00CB\u02DA\u00B8\u00CA\u00E6\u02C7\"\n },\n \"maccyrillic\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u0406\u00AE\u00A9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\u00B1\u2264\u2265\u0456\u00B5\u2202\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u00A4\"\n },\n \"macgreek\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00B9\u00B2\u00C9\u00B3\u00D6\u00DC\u0385\u00E0\u00E2\u00E4\u0384\u00A8\u00E7\u00E9\u00E8\u00EA\u00EB\u00A3\u2122\u00EE\u00EF\u2022\u00BD\u2030\u00F4\u00F6\u00A6\u00AD\u00F9\u00FB\u00FC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\u00DF\u00AE\u00A9\u03A3\u03AA\u00A7\u2260\u00B0\u0387\u0391\u00B1\u2264\u2265\u00A5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\u00AC\u039F\u03A1\u2248\u03A4\u00AB\u00BB\u2026\u00A0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\u00F7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\uFFFD\"\n },\n \"maciceland\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u00DD\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u00D0\u00F0\u00DE\u00FE\u00FD\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macroman\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u2039\u203A\uFB01\uFB02\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macromania\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u0102\u015E\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u0103\u015F\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u2039\u203A\u0162\u0163\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macthai\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00AB\u00BB\u2026\uF88C\uF88F\uF892\uF895\uF898\uF88B\uF88E\uF891\uF894\uF897\u201C\u201D\uF899\uFFFD\u2022\uF884\uF889\uF885\uF886\uF887\uF888\uF88A\uF88D\uF890\uF893\uF896\u2018\u2019\uFFFD\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFEFF\u200B\u2013\u2014\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u2122\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u00AE\u00A9\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"macturkish\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\uFFFD\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macukraine\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\u00B0\u0490\u00A3\u00A7\u2022\u00B6\u0406\u00AE\u00A9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\u00B1\u2264\u2265\u0456\u00B5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u00A4\"\n },\n \"koi8r\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u2553\u2554\u2555\u2556\u2557\u2558\u2559\u255A\u255B\u255C\u255D\u255E\u255F\u2560\u2561\u0401\u2562\u2563\u2564\u2565\u2566\u2567\u2568\u2569\u256A\u256B\u256C\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"koi8u\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u0454\u2554\u0456\u0457\u2557\u2558\u2559\u255A\u255B\u0491\u255D\u255E\u255F\u2560\u2561\u0401\u0404\u2563\u0406\u0407\u2566\u2567\u2568\u2569\u256A\u0490\u256C\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"koi8ru\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u0454\u2554\u0456\u0457\u2557\u2558\u2559\u255A\u255B\u0491\u045E\u255E\u255F\u2560\u2561\u0401\u0404\u2563\u0406\u0407\u2566\u2567\u2568\u2569\u256A\u0490\u040E\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"koi8t\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u049B\u0493\u201A\u0492\u201E\u2026\u2020\u2021\uFFFD\u2030\u04B3\u2039\u04B2\u04B7\u04B6\uFFFD\u049A\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u04EF\u04EE\u0451\u00A4\u04E3\u00A6\u00A7\uFFFD\uFFFD\uFFFD\u00AB\u00AC\u00AD\u00AE\uFFFD\u00B0\u00B1\u00B2\u0401\uFFFD\u04E2\u00B6\u00B7\uFFFD\u2116\uFFFD\u00BB\uFFFD\uFFFD\uFFFD\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"armscii8\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\uFFFD\u0587\u0589)(\u00BB\u00AB\u2014.\u055D,-\u058A\u2026\u055C\u055B\u055E\u0531\u0561\u0532\u0562\u0533\u0563\u0534\u0564\u0535\u0565\u0536\u0566\u0537\u0567\u0538\u0568\u0539\u0569\u053A\u056A\u053B\u056B\u053C\u056C\u053D\u056D\u053E\u056E\u053F\u056F\u0540\u0570\u0541\u0571\u0542\u0572\u0543\u0573\u0544\u0574\u0545\u0575\u0546\u0576\u0547\u0577\u0548\u0578\u0549\u0579\u054A\u057A\u054B\u057B\u054C\u057C\u054D\u057D\u054E\u057E\u054F\u057F\u0550\u0580\u0551\u0581\u0552\u0582\u0553\u0583\u0554\u0584\u0555\u0585\u0556\u0586\u055A\uFFFD\"\n },\n \"rk1048\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0402\u0403\u201A\u0453\u201E\u2026\u2020\u2021\u20AC\u2030\u0409\u2039\u040A\u049A\u04BA\u040F\u0452\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0459\u203A\u045A\u049B\u04BB\u045F\u00A0\u04B0\u04B1\u04D8\u00A4\u04E8\u00A6\u00A7\u0401\u00A9\u0492\u00AB\u00AC\u00AD\u00AE\u04AE\u00B0\u00B1\u0406\u0456\u04E9\u00B5\u00B6\u00B7\u0451\u2116\u0493\u00BB\u04D9\u04A2\u04A3\u04AF\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\"\n },\n \"tcvn\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\u00DA\u1EE4\\u0003\u1EEA\u1EEC\u1EEE\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\u1EE8\u1EF0\u1EF2\u1EF6\u1EF8\u00DD\u1EF4\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007F\u00C0\u1EA2\u00C3\u00C1\u1EA0\u1EB6\u1EAC\u00C8\u1EBA\u1EBC\u00C9\u1EB8\u1EC6\u00CC\u1EC8\u0128\u00CD\u1ECA\u00D2\u1ECE\u00D5\u00D3\u1ECC\u1ED8\u1EDC\u1EDE\u1EE0\u1EDA\u1EE2\u00D9\u1EE6\u0168\u00A0\u0102\u00C2\u00CA\u00D4\u01A0\u01AF\u0110\u0103\u00E2\u00EA\u00F4\u01A1\u01B0\u0111\u1EB0\u0300\u0309\u0303\u0301\u0323\u00E0\u1EA3\u00E3\u00E1\u1EA1\u1EB2\u1EB1\u1EB3\u1EB5\u1EAF\u1EB4\u1EAE\u1EA6\u1EA8\u1EAA\u1EA4\u1EC0\u1EB7\u1EA7\u1EA9\u1EAB\u1EA5\u1EAD\u00E8\u1EC2\u1EBB\u1EBD\u00E9\u1EB9\u1EC1\u1EC3\u1EC5\u1EBF\u1EC7\u00EC\u1EC9\u1EC4\u1EBE\u1ED2\u0129\u00ED\u1ECB\u00F2\u1ED4\u1ECF\u00F5\u00F3\u1ECD\u1ED3\u1ED5\u1ED7\u1ED1\u1ED9\u1EDD\u1EDF\u1EE1\u1EDB\u1EE3\u00F9\u1ED6\u1EE7\u0169\u00FA\u1EE5\u1EEB\u1EED\u1EEF\u1EE9\u1EF1\u1EF3\u1EF7\u1EF9\u00FD\u1EF5\u1ED0\"\n },\n \"georgianacademy\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u008D\u008E\u008F\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u009D\u009E\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u10D0\u10D1\u10D2\u10D3\u10D4\u10D5\u10D6\u10D7\u10D8\u10D9\u10DA\u10DB\u10DC\u10DD\u10DE\u10DF\u10E0\u10E1\u10E2\u10E3\u10E4\u10E5\u10E6\u10E7\u10E8\u10E9\u10EA\u10EB\u10EC\u10ED\u10EE\u10EF\u10F0\u10F1\u10F2\u10F3\u10F4\u10F5\u10F6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"georgianps\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u008D\u008E\u008F\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u009D\u009E\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u10D0\u10D1\u10D2\u10D3\u10D4\u10D5\u10D6\u10F1\u10D7\u10D8\u10D9\u10DA\u10DB\u10DC\u10F2\u10DD\u10DE\u10DF\u10E0\u10E1\u10E2\u10F3\u10E3\u10E4\u10E5\u10E6\u10E7\u10E8\u10E9\u10EA\u10EB\u10EC\u10ED\u10EE\u10F4\u10EF\u10F0\u10F5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"pt154\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0496\u0492\u04EE\u0493\u201E\u2026\u04B6\u04AE\u04B2\u04AF\u04A0\u04E2\u04A2\u049A\u04BA\u04B8\u0497\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u04B3\u04B7\u04A1\u04E3\u04A3\u049B\u04BB\u04B9\u00A0\u040E\u045E\u0408\u04E8\u0498\u04B0\u00A7\u0401\u00A9\u04D8\u00AB\u00AC\u04EF\u00AE\u049C\u00B0\u04B1\u0406\u0456\u0499\u04E9\u00B6\u00B7\u0451\u2116\u04D9\u00BB\u0458\u04AA\u04AB\u049D\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\"\n },\n \"viscii\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\u1EB2\\u0003\\u0004\u1EB4\u1EAA\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\u1EF6\\u0015\\u0016\\u0017\\u0018\u1EF8\\u001a\\u001b\\u001c\\u001d\u1EF4\\u001f !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007F\u1EA0\u1EAE\u1EB0\u1EB6\u1EA4\u1EA6\u1EA8\u1EAC\u1EBC\u1EB8\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EE2\u1EDA\u1EDC\u1EDE\u1ECA\u1ECE\u1ECC\u1EC8\u1EE6\u0168\u1EE4\u1EF2\u00D5\u1EAF\u1EB1\u1EB7\u1EA5\u1EA7\u1EA9\u1EAD\u1EBD\u1EB9\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1ED1\u1ED3\u1ED5\u1ED7\u1EE0\u01A0\u1ED9\u1EDD\u1EDF\u1ECB\u1EF0\u1EE8\u1EEA\u1EEC\u01A1\u1EDB\u01AF\u00C0\u00C1\u00C2\u00C3\u1EA2\u0102\u1EB3\u1EB5\u00C8\u00C9\u00CA\u1EBA\u00CC\u00CD\u0128\u1EF3\u0110\u1EE9\u00D2\u00D3\u00D4\u1EA1\u1EF7\u1EEB\u1EED\u00D9\u00DA\u1EF9\u1EF5\u00DD\u1EE1\u01B0\u00E0\u00E1\u00E2\u00E3\u1EA3\u0103\u1EEF\u1EAB\u00E8\u00E9\u00EA\u1EBB\u00EC\u00ED\u0129\u1EC9\u0111\u1EF1\u00F2\u00F3\u00F4\u00F5\u1ECF\u1ECD\u1EE5\u00F9\u00FA\u0169\u1EE7\u00FD\u1EE3\u1EEE\"\n },\n \"iso646cn\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#\u00A5%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}\u203E\u007F\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"iso646jp\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\u00A5]^_`abcdefghijklmnopqrstuvwxyz{|}\u203E\u007F\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"hproman8\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00C0\u00C2\u00C8\u00CA\u00CB\u00CE\u00CF\u00B4\u02CB\u02C6\u00A8\u02DC\u00D9\u00DB\u20A4\u00AF\u00DD\u00FD\u00B0\u00C7\u00E7\u00D1\u00F1\u00A1\u00BF\u00A4\u00A3\u00A5\u00A7\u0192\u00A2\u00E2\u00EA\u00F4\u00FB\u00E1\u00E9\u00F3\u00FA\u00E0\u00E8\u00F2\u00F9\u00E4\u00EB\u00F6\u00FC\u00C5\u00EE\u00D8\u00C6\u00E5\u00ED\u00F8\u00E6\u00C4\u00EC\u00D6\u00DC\u00C9\u00EF\u00DF\u00D4\u00C1\u00C3\u00E3\u00D0\u00F0\u00CD\u00CC\u00D3\u00D2\u00D5\u00F5\u0160\u0161\u00DA\u0178\u00FF\u00DE\u00FE\u00B7\u00B5\u00B6\u00BE\u2014\u00BC\u00BD\u00AA\u00BA\u00AB\u25A0\u00BB\u00B1\uFFFD\"\n },\n \"macintosh\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u2039\u203A\uFB01\uFB02\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"ascii\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"tis620\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n }\n}", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Multibyte codec. In this scheme, a character is represented by 1 or more bytes.\n// Our codec supports UTF-16 surrogates, extensions for GB18030 and unicode sequences.\n// To save memory and loading time, we read table files only when requested.\n\nexports._dbcs = DBCSCodec;\n\nvar UNASSIGNED = -1,\n GB18030_CODE = -2,\n SEQ_START = -10,\n NODE_START = -1000,\n UNASSIGNED_NODE = new Array(0x100),\n DEF_CHAR = -1;\n\nfor (var i = 0; i < 0x100; i++)\n UNASSIGNED_NODE[i] = UNASSIGNED;\n\n\n// Class DBCSCodec reads and initializes mapping tables.\nfunction DBCSCodec(codecOptions, iconv) {\n this.encodingName = codecOptions.encodingName;\n if (!codecOptions)\n throw new Error(\"DBCS codec is called without the data.\")\n if (!codecOptions.table)\n throw new Error(\"Encoding '\" + this.encodingName + \"' has no data.\");\n\n // Load tables.\n var mappingTable = codecOptions.table();\n\n\n // Decode tables: MBCS -> Unicode.\n\n // decodeTables is a trie, encoded as an array of arrays of integers. Internal arrays are trie nodes and all have len = 256.\n // Trie root is decodeTables[0].\n // Values: >= 0 -> unicode character code. can be > 0xFFFF\n // == UNASSIGNED -> unknown/unassigned sequence.\n // == GB18030_CODE -> this is the end of a GB18030 4-byte sequence.\n // <= NODE_START -> index of the next node in our trie to process next byte.\n // <= SEQ_START -> index of the start of a character code sequence, in decodeTableSeq.\n this.decodeTables = [];\n this.decodeTables[0] = UNASSIGNED_NODE.slice(0); // Create root node.\n\n // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here. \n this.decodeTableSeq = [];\n\n // Actual mapping tables consist of chunks. Use them to fill up decode tables.\n for (var i = 0; i < mappingTable.length; i++)\n this._addDecodeChunk(mappingTable[i]);\n\n this.defaultCharUnicode = iconv.defaultCharUnicode;\n\n \n // Encode tables: Unicode -> DBCS.\n\n // `encodeTable` is array mapping from unicode char to encoded char. All its values are integers for performance.\n // Because it can be sparse, it is represented as array of buckets by 256 chars each. Bucket can be null.\n // Values: >= 0 -> it is a normal char. Write the value (if <=256 then 1 byte, if <=65536 then 2 bytes, etc.).\n // == UNASSIGNED -> no conversion found. Output a default char.\n // <= SEQ_START -> it's an index in encodeTableSeq, see below. The character starts a sequence.\n this.encodeTable = [];\n \n // `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of\n // objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key\n // means end of sequence (needed when one sequence is a strict subsequence of another).\n // Objects are kept separately from encodeTable to increase performance.\n this.encodeTableSeq = [];\n\n // Some chars can be decoded, but need not be encoded.\n var skipEncodeChars = {};\n if (codecOptions.encodeSkipVals)\n for (var i = 0; i < codecOptions.encodeSkipVals.length; i++) {\n var val = codecOptions.encodeSkipVals[i];\n if (typeof val === 'number')\n skipEncodeChars[val] = true;\n else\n for (var j = val.from; j <= val.to; j++)\n skipEncodeChars[j] = true;\n }\n \n // Use decode trie to recursively fill out encode tables.\n this._fillEncodeTable(0, 0, skipEncodeChars);\n\n // Add more encoding pairs when needed.\n if (codecOptions.encodeAdd) {\n for (var uChar in codecOptions.encodeAdd)\n if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar))\n this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]);\n }\n\n this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)];\n if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0]['?'];\n if (this.defCharSB === UNASSIGNED) this.defCharSB = \"?\".charCodeAt(0);\n\n\n // Load & create GB18030 tables when needed.\n if (typeof codecOptions.gb18030 === 'function') {\n this.gb18030 = codecOptions.gb18030(); // Load GB18030 ranges.\n\n // Add GB18030 decode tables.\n var thirdByteNodeIdx = this.decodeTables.length;\n var thirdByteNode = this.decodeTables[thirdByteNodeIdx] = UNASSIGNED_NODE.slice(0);\n\n var fourthByteNodeIdx = this.decodeTables.length;\n var fourthByteNode = this.decodeTables[fourthByteNodeIdx] = UNASSIGNED_NODE.slice(0);\n\n for (var i = 0x81; i <= 0xFE; i++) {\n var secondByteNodeIdx = NODE_START - this.decodeTables[0][i];\n var secondByteNode = this.decodeTables[secondByteNodeIdx];\n for (var j = 0x30; j <= 0x39; j++)\n secondByteNode[j] = NODE_START - thirdByteNodeIdx;\n }\n for (var i = 0x81; i <= 0xFE; i++)\n thirdByteNode[i] = NODE_START - fourthByteNodeIdx;\n for (var i = 0x30; i <= 0x39; i++)\n fourthByteNode[i] = GB18030_CODE\n } \n}\n\nDBCSCodec.prototype.encoder = DBCSEncoder;\nDBCSCodec.prototype.decoder = DBCSDecoder;\n\n// Decoder helpers\nDBCSCodec.prototype._getDecodeTrieNode = function(addr) {\n var bytes = [];\n for (; addr > 0; addr >>= 8)\n bytes.push(addr & 0xFF);\n if (bytes.length == 0)\n bytes.push(0);\n\n var node = this.decodeTables[0];\n for (var i = bytes.length-1; i > 0; i--) { // Traverse nodes deeper into the trie.\n var val = node[bytes[i]];\n\n if (val == UNASSIGNED) { // Create new node.\n node[bytes[i]] = NODE_START - this.decodeTables.length;\n this.decodeTables.push(node = UNASSIGNED_NODE.slice(0));\n }\n else if (val <= NODE_START) { // Existing node.\n node = this.decodeTables[NODE_START - val];\n }\n else\n throw new Error(\"Overwrite byte in \" + this.encodingName + \", addr: \" + addr.toString(16));\n }\n return node;\n}\n\n\nDBCSCodec.prototype._addDecodeChunk = function(chunk) {\n // First element of chunk is the hex mbcs code where we start.\n var curAddr = parseInt(chunk[0], 16);\n\n // Choose the decoding node where we'll write our chars.\n var writeTable = this._getDecodeTrieNode(curAddr);\n curAddr = curAddr & 0xFF;\n\n // Write all other elements of the chunk to the table.\n for (var k = 1; k < chunk.length; k++) {\n var part = chunk[k];\n if (typeof part === \"string\") { // String, write as-is.\n for (var l = 0; l < part.length;) {\n var code = part.charCodeAt(l++);\n if (0xD800 <= code && code < 0xDC00) { // Decode surrogate\n var codeTrail = part.charCodeAt(l++);\n if (0xDC00 <= codeTrail && codeTrail < 0xE000)\n writeTable[curAddr++] = 0x10000 + (code - 0xD800) * 0x400 + (codeTrail - 0xDC00);\n else\n throw new Error(\"Incorrect surrogate pair in \" + this.encodingName + \" at chunk \" + chunk[0]);\n }\n else if (0x0FF0 < code && code <= 0x0FFF) { // Character sequence (our own encoding used)\n var len = 0xFFF - code + 2;\n var seq = [];\n for (var m = 0; m < len; m++)\n seq.push(part.charCodeAt(l++)); // Simple variation: don't support surrogates or subsequences in seq.\n\n writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;\n this.decodeTableSeq.push(seq);\n }\n else\n writeTable[curAddr++] = code; // Basic char\n }\n } \n else if (typeof part === \"number\") { // Integer, meaning increasing sequence starting with prev character.\n var charCode = writeTable[curAddr - 1] + 1;\n for (var l = 0; l < part; l++)\n writeTable[curAddr++] = charCode++;\n }\n else\n throw new Error(\"Incorrect type '\" + typeof part + \"' given in \" + this.encodingName + \" at chunk \" + chunk[0]);\n }\n if (curAddr > 0xFF)\n throw new Error(\"Incorrect chunk in \" + this.encodingName + \" at addr \" + chunk[0] + \": too long\" + curAddr);\n}\n\n// Encoder helpers\nDBCSCodec.prototype._getEncodeBucket = function(uCode) {\n var high = uCode >> 8; // This could be > 0xFF because of astral characters.\n if (this.encodeTable[high] === undefined)\n this.encodeTable[high] = UNASSIGNED_NODE.slice(0); // Create bucket on demand.\n return this.encodeTable[high];\n}\n\nDBCSCodec.prototype._setEncodeChar = function(uCode, dbcsCode) {\n var bucket = this._getEncodeBucket(uCode);\n var low = uCode & 0xFF;\n if (bucket[low] <= SEQ_START)\n this.encodeTableSeq[SEQ_START-bucket[low]][DEF_CHAR] = dbcsCode; // There's already a sequence, set a single-char subsequence of it.\n else if (bucket[low] == UNASSIGNED)\n bucket[low] = dbcsCode;\n}\n\nDBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) {\n \n // Get the root of character tree according to first character of the sequence.\n var uCode = seq[0];\n var bucket = this._getEncodeBucket(uCode);\n var low = uCode & 0xFF;\n\n var node;\n if (bucket[low] <= SEQ_START) {\n // There's already a sequence with - use it.\n node = this.encodeTableSeq[SEQ_START-bucket[low]];\n }\n else {\n // There was no sequence object - allocate a new one.\n node = {};\n if (bucket[low] !== UNASSIGNED) node[DEF_CHAR] = bucket[low]; // If a char was set before - make it a single-char subsequence.\n bucket[low] = SEQ_START - this.encodeTableSeq.length;\n this.encodeTableSeq.push(node);\n }\n\n // Traverse the character tree, allocating new nodes as needed.\n for (var j = 1; j < seq.length-1; j++) {\n var oldVal = node[uCode];\n if (typeof oldVal === 'object')\n node = oldVal;\n else {\n node = node[uCode] = {}\n if (oldVal !== undefined)\n node[DEF_CHAR] = oldVal\n }\n }\n\n // Set the leaf to given dbcsCode.\n uCode = seq[seq.length-1];\n node[uCode] = dbcsCode;\n}\n\nDBCSCodec.prototype._fillEncodeTable = function(nodeIdx, prefix, skipEncodeChars) {\n var node = this.decodeTables[nodeIdx];\n for (var i = 0; i < 0x100; i++) {\n var uCode = node[i];\n var mbCode = prefix + i;\n if (skipEncodeChars[mbCode])\n continue;\n\n if (uCode >= 0)\n this._setEncodeChar(uCode, mbCode);\n else if (uCode <= NODE_START)\n this._fillEncodeTable(NODE_START - uCode, mbCode << 8, skipEncodeChars);\n else if (uCode <= SEQ_START)\n this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode);\n }\n}\n\n\n\n// == Encoder ==================================================================\n\nfunction DBCSEncoder(options, codec) {\n // Encoder state\n this.leadSurrogate = -1;\n this.seqObj = undefined;\n \n // Static data\n this.encodeTable = codec.encodeTable;\n this.encodeTableSeq = codec.encodeTableSeq;\n this.defaultCharSingleByte = codec.defCharSB;\n this.gb18030 = codec.gb18030;\n}\n\nDBCSEncoder.prototype.write = function(str) {\n var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3)),\n leadSurrogate = this.leadSurrogate,\n seqObj = this.seqObj, nextChar = -1,\n i = 0, j = 0;\n\n while (true) {\n // 0. Get next character.\n if (nextChar === -1) {\n if (i == str.length) break;\n var uCode = str.charCodeAt(i++);\n }\n else {\n var uCode = nextChar;\n nextChar = -1; \n }\n\n // 1. Handle surrogates.\n if (0xD800 <= uCode && uCode < 0xE000) { // Char is one of surrogates.\n if (uCode < 0xDC00) { // We've got lead surrogate.\n if (leadSurrogate === -1) {\n leadSurrogate = uCode;\n continue;\n } else {\n leadSurrogate = uCode;\n // Double lead surrogate found.\n uCode = UNASSIGNED;\n }\n } else { // We've got trail surrogate.\n if (leadSurrogate !== -1) {\n uCode = 0x10000 + (leadSurrogate - 0xD800) * 0x400 + (uCode - 0xDC00);\n leadSurrogate = -1;\n } else {\n // Incomplete surrogate pair - only trail surrogate found.\n uCode = UNASSIGNED;\n }\n \n }\n }\n else if (leadSurrogate !== -1) {\n // Incomplete surrogate pair - only lead surrogate found.\n nextChar = uCode; uCode = UNASSIGNED; // Write an error, then current char.\n leadSurrogate = -1;\n }\n\n // 2. Convert uCode character.\n var dbcsCode = UNASSIGNED;\n if (seqObj !== undefined && uCode != UNASSIGNED) { // We are in the middle of the sequence\n var resCode = seqObj[uCode];\n if (typeof resCode === 'object') { // Sequence continues.\n seqObj = resCode;\n continue;\n\n } else if (typeof resCode == 'number') { // Sequence finished. Write it.\n dbcsCode = resCode;\n\n } else if (resCode == undefined) { // Current character is not part of the sequence.\n\n // Try default character for this sequence\n resCode = seqObj[DEF_CHAR];\n if (resCode !== undefined) {\n dbcsCode = resCode; // Found. Write it.\n nextChar = uCode; // Current character will be written too in the next iteration.\n\n } else {\n // TODO: What if we have no default? (resCode == undefined)\n // Then, we should write first char of the sequence as-is and try the rest recursively.\n // Didn't do it for now because no encoding has this situation yet.\n // Currently, just skip the sequence and write current char.\n }\n }\n seqObj = undefined;\n }\n else if (uCode >= 0) { // Regular character\n var subtable = this.encodeTable[uCode >> 8];\n if (subtable !== undefined)\n dbcsCode = subtable[uCode & 0xFF];\n \n if (dbcsCode <= SEQ_START) { // Sequence start\n seqObj = this.encodeTableSeq[SEQ_START-dbcsCode];\n continue;\n }\n\n if (dbcsCode == UNASSIGNED && this.gb18030) {\n // Use GB18030 algorithm to find character(s) to write.\n var idx = findIdx(this.gb18030.uChars, uCode);\n if (idx != -1) {\n var dbcsCode = this.gb18030.gbChars[idx] + (uCode - this.gb18030.uChars[idx]);\n newBuf[j++] = 0x81 + Math.floor(dbcsCode / 12600); dbcsCode = dbcsCode % 12600;\n newBuf[j++] = 0x30 + Math.floor(dbcsCode / 1260); dbcsCode = dbcsCode % 1260;\n newBuf[j++] = 0x81 + Math.floor(dbcsCode / 10); dbcsCode = dbcsCode % 10;\n newBuf[j++] = 0x30 + dbcsCode;\n continue;\n }\n }\n }\n\n // 3. Write dbcsCode character.\n if (dbcsCode === UNASSIGNED)\n dbcsCode = this.defaultCharSingleByte;\n \n if (dbcsCode < 0x100) {\n newBuf[j++] = dbcsCode;\n }\n else if (dbcsCode < 0x10000) {\n newBuf[j++] = dbcsCode >> 8; // high byte\n newBuf[j++] = dbcsCode & 0xFF; // low byte\n }\n else {\n newBuf[j++] = dbcsCode >> 16;\n newBuf[j++] = (dbcsCode >> 8) & 0xFF;\n newBuf[j++] = dbcsCode & 0xFF;\n }\n }\n\n this.seqObj = seqObj;\n this.leadSurrogate = leadSurrogate;\n return newBuf.slice(0, j);\n}\n\nDBCSEncoder.prototype.end = function() {\n if (this.leadSurrogate === -1 && this.seqObj === undefined)\n return; // All clean. Most often case.\n\n var newBuf = Buffer.alloc(10), j = 0;\n\n if (this.seqObj) { // We're in the sequence.\n var dbcsCode = this.seqObj[DEF_CHAR];\n if (dbcsCode !== undefined) { // Write beginning of the sequence.\n if (dbcsCode < 0x100) {\n newBuf[j++] = dbcsCode;\n }\n else {\n newBuf[j++] = dbcsCode >> 8; // high byte\n newBuf[j++] = dbcsCode & 0xFF; // low byte\n }\n } else {\n // See todo above.\n }\n this.seqObj = undefined;\n }\n\n if (this.leadSurrogate !== -1) {\n // Incomplete surrogate pair - only lead surrogate found.\n newBuf[j++] = this.defaultCharSingleByte;\n this.leadSurrogate = -1;\n }\n \n return newBuf.slice(0, j);\n}\n\n// Export for testing\nDBCSEncoder.prototype.findIdx = findIdx;\n\n\n// == Decoder ==================================================================\n\nfunction DBCSDecoder(options, codec) {\n // Decoder state\n this.nodeIdx = 0;\n this.prevBuf = Buffer.alloc(0);\n\n // Static data\n this.decodeTables = codec.decodeTables;\n this.decodeTableSeq = codec.decodeTableSeq;\n this.defaultCharUnicode = codec.defaultCharUnicode;\n this.gb18030 = codec.gb18030;\n}\n\nDBCSDecoder.prototype.write = function(buf) {\n var newBuf = Buffer.alloc(buf.length*2),\n nodeIdx = this.nodeIdx, \n prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length,\n seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence.\n uCode;\n\n if (prevBufOffset > 0) // Make prev buf overlap a little to make it easier to slice later.\n prevBuf = Buffer.concat([prevBuf, buf.slice(0, 10)]);\n \n for (var i = 0, j = 0; i < buf.length; i++) {\n var curByte = (i >= 0) ? buf[i] : prevBuf[i + prevBufOffset];\n\n // Lookup in current trie node.\n var uCode = this.decodeTables[nodeIdx][curByte];\n\n if (uCode >= 0) { \n // Normal character, just use it.\n }\n else if (uCode === UNASSIGNED) { // Unknown char.\n // TODO: Callback with seq.\n //var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);\n i = seqStart; // Try to parse again, after skipping first byte of the sequence ('i' will be incremented by 'for' cycle).\n uCode = this.defaultCharUnicode.charCodeAt(0);\n }\n else if (uCode === GB18030_CODE) {\n var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);\n var ptr = (curSeq[0]-0x81)*12600 + (curSeq[1]-0x30)*1260 + (curSeq[2]-0x81)*10 + (curSeq[3]-0x30);\n var idx = findIdx(this.gb18030.gbChars, ptr);\n uCode = this.gb18030.uChars[idx] + ptr - this.gb18030.gbChars[idx];\n }\n else if (uCode <= NODE_START) { // Go to next trie node.\n nodeIdx = NODE_START - uCode;\n continue;\n }\n else if (uCode <= SEQ_START) { // Output a sequence of chars.\n var seq = this.decodeTableSeq[SEQ_START - uCode];\n for (var k = 0; k < seq.length - 1; k++) {\n uCode = seq[k];\n newBuf[j++] = uCode & 0xFF;\n newBuf[j++] = uCode >> 8;\n }\n uCode = seq[seq.length-1];\n }\n else\n throw new Error(\"iconv-lite internal error: invalid decoding table value \" + uCode + \" at \" + nodeIdx + \"/\" + curByte);\n\n // Write the character to buffer, handling higher planes using surrogate pair.\n if (uCode > 0xFFFF) { \n uCode -= 0x10000;\n var uCodeLead = 0xD800 + Math.floor(uCode / 0x400);\n newBuf[j++] = uCodeLead & 0xFF;\n newBuf[j++] = uCodeLead >> 8;\n\n uCode = 0xDC00 + uCode % 0x400;\n }\n newBuf[j++] = uCode & 0xFF;\n newBuf[j++] = uCode >> 8;\n\n // Reset trie node.\n nodeIdx = 0; seqStart = i+1;\n }\n\n this.nodeIdx = nodeIdx;\n this.prevBuf = (seqStart >= 0) ? buf.slice(seqStart) : prevBuf.slice(seqStart + prevBufOffset);\n return newBuf.slice(0, j).toString('ucs2');\n}\n\nDBCSDecoder.prototype.end = function() {\n var ret = '';\n\n // Try to parse all remaining chars.\n while (this.prevBuf.length > 0) {\n // Skip 1 character in the buffer.\n ret += this.defaultCharUnicode;\n var buf = this.prevBuf.slice(1);\n\n // Parse remaining as usual.\n this.prevBuf = Buffer.alloc(0);\n this.nodeIdx = 0;\n if (buf.length > 0)\n ret += this.write(buf);\n }\n\n this.nodeIdx = 0;\n return ret;\n}\n\n// Binary search for GB18030. Returns largest i such that table[i] <= val.\nfunction findIdx(table, val) {\n if (table[0] > val)\n return -1;\n\n var l = 0, r = table.length;\n while (l < r-1) { // always table[l] <= val < table[r]\n var mid = l + Math.floor((r-l+1)/2);\n if (table[mid] <= val)\n l = mid;\n else\n r = mid;\n }\n return l;\n}\n\n", "\"use strict\";\n\n// Description of supported double byte encodings and aliases.\n// Tables are not require()-d until they are needed to speed up library load.\n// require()-s are direct to support Browserify.\n\nmodule.exports = {\n \n // == Japanese/ShiftJIS ====================================================\n // All japanese encodings are based on JIS X set of standards:\n // JIS X 0201 - Single-byte encoding of ASCII + \u00A5 + Kana chars at 0xA1-0xDF.\n // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. \n // Has several variations in 1978, 1983, 1990 and 1997.\n // JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead.\n // JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233.\n // 2 planes, first is superset of 0208, second - revised 0212.\n // Introduced in 2000, revised 2004. Some characters are in Unicode Plane 2 (0x2xxxx)\n\n // Byte encodings are:\n // * Shift_JIS: Compatible with 0201, uses not defined chars in top half as lead bytes for double-byte\n // encoding of 0208. Lead byte ranges: 0x81-0x9F, 0xE0-0xEF; Trail byte ranges: 0x40-0x7E, 0x80-0x9E, 0x9F-0xFC.\n // Windows CP932 is a superset of Shift_JIS. Some companies added more chars, notably KDDI.\n // * EUC-JP: Up to 3 bytes per character. Used mostly on *nixes.\n // 0x00-0x7F - lower part of 0201\n // 0x8E, 0xA1-0xDF - upper part of 0201\n // (0xA1-0xFE)x2 - 0208 plane (94x94).\n // 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94).\n // * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon.\n // Used as-is in ISO2022 family.\n // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, \n // 0201-1976 Roman, 0208-1978, 0208-1983.\n // * ISO2022-JP-1: Adds esc seq for 0212-1990.\n // * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7.\n // * ISO2022-JP-3: Adds esc seq for 0201-1976 Kana set, 0213-2000 Planes 1, 2.\n // * ISO2022-JP-2004: Adds 0213-2004 Plane 1.\n //\n // After JIS X 0213 appeared, Shift_JIS-2004, EUC-JISX0213 and ISO2022-JP-2004 followed, with just changing the planes.\n //\n // Overall, it seems that it's a mess :( http://www8.plala.or.jp/tkubota1/unicode-symbols-map2.html\n\n 'shiftjis': {\n type: '_dbcs',\n table: function() { return require('./tables/shiftjis.json') },\n encodeAdd: {'\\u00a5': 0x5C, '\\u203E': 0x7E},\n encodeSkipVals: [{from: 0xED40, to: 0xF940}],\n },\n 'csshiftjis': 'shiftjis',\n 'mskanji': 'shiftjis',\n 'sjis': 'shiftjis',\n 'windows31j': 'shiftjis',\n 'ms31j': 'shiftjis',\n 'xsjis': 'shiftjis',\n 'windows932': 'shiftjis',\n 'ms932': 'shiftjis',\n '932': 'shiftjis',\n 'cp932': 'shiftjis',\n\n 'eucjp': {\n type: '_dbcs',\n table: function() { return require('./tables/eucjp.json') },\n encodeAdd: {'\\u00a5': 0x5C, '\\u203E': 0x7E},\n },\n\n // TODO: KDDI extension to Shift_JIS\n // TODO: IBM CCSID 942 = CP932, but F0-F9 custom chars and other char changes.\n // TODO: IBM CCSID 943 = Shift_JIS = CP932 with original Shift_JIS lower 128 chars.\n\n\n // == Chinese/GBK ==========================================================\n // http://en.wikipedia.org/wiki/GBK\n // We mostly implement W3C recommendation: https://www.w3.org/TR/encoding/#gbk-encoder\n\n // Oldest GB2312 (1981, ~7600 chars) is a subset of CP936\n 'gb2312': 'cp936',\n 'gb231280': 'cp936',\n 'gb23121980': 'cp936',\n 'csgb2312': 'cp936',\n 'csiso58gb231280': 'cp936',\n 'euccn': 'cp936',\n\n // Microsoft's CP936 is a subset and approximation of GBK.\n 'windows936': 'cp936',\n 'ms936': 'cp936',\n '936': 'cp936',\n 'cp936': {\n type: '_dbcs',\n table: function() { return require('./tables/cp936.json') },\n },\n\n // GBK (~22000 chars) is an extension of CP936 that added user-mapped chars and some other.\n 'gbk': {\n type: '_dbcs',\n table: function() { return require('./tables/cp936.json').concat(require('./tables/gbk-added.json')) },\n },\n 'xgbk': 'gbk',\n 'isoir58': 'gbk',\n\n // GB18030 is an algorithmic extension of GBK.\n // Main source: https://www.w3.org/TR/encoding/#gbk-encoder\n // http://icu-project.org/docs/papers/gb18030.html\n // http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml\n // http://www.khngai.com/chinese/charmap/tblgbk.php?page=0\n 'gb18030': {\n type: '_dbcs',\n table: function() { return require('./tables/cp936.json').concat(require('./tables/gbk-added.json')) },\n gb18030: function() { return require('./tables/gb18030-ranges.json') },\n encodeSkipVals: [0x80],\n encodeAdd: {'\u20AC': 0xA2E3},\n },\n\n 'chinese': 'gb18030',\n\n\n // == Korean ===============================================================\n // EUC-KR, KS_C_5601 and KS X 1001 are exactly the same.\n 'windows949': 'cp949',\n 'ms949': 'cp949',\n '949': 'cp949',\n 'cp949': {\n type: '_dbcs',\n table: function() { return require('./tables/cp949.json') },\n },\n\n 'cseuckr': 'cp949',\n 'csksc56011987': 'cp949',\n 'euckr': 'cp949',\n 'isoir149': 'cp949',\n 'korean': 'cp949',\n 'ksc56011987': 'cp949',\n 'ksc56011989': 'cp949',\n 'ksc5601': 'cp949',\n\n\n // == Big5/Taiwan/Hong Kong ================================================\n // There are lots of tables for Big5 and cp950. Please see the following links for history:\n // http://moztw.org/docs/big5/ http://www.haible.de/bruno/charsets/conversion-tables/Big5.html\n // Variations, in roughly number of defined chars:\n // * Windows CP 950: Microsoft variant of Big5. Canonical: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT\n // * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/\n // * Big5-2003 (Taiwan standard) almost superset of cp950.\n // * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers.\n // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. \n // many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years.\n // Plus, it has 4 combining sequences.\n // Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299\n // because big5-hkscs is the only encoding to include astral characters in non-algorithmic way.\n // Implementations are not consistent within browsers; sometimes labeled as just big5.\n // MS Internet Explorer switches from big5 to big5-hkscs when a patch applied.\n // Great discussion & recap of what's going on https://bugzilla.mozilla.org/show_bug.cgi?id=912470#c31\n // In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s.\n // Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt\n // http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt\n // \n // Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder\n // Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong.\n\n 'windows950': 'cp950',\n 'ms950': 'cp950',\n '950': 'cp950',\n 'cp950': {\n type: '_dbcs',\n table: function() { return require('./tables/cp950.json') },\n },\n\n // Big5 has many variations and is an extension of cp950. We use Encoding Standard's as a consensus.\n 'big5': 'big5hkscs',\n 'big5hkscs': {\n type: '_dbcs',\n table: function() { return require('./tables/cp950.json').concat(require('./tables/big5-added.json')) },\n encodeSkipVals: [0xa2cc],\n },\n\n 'cnbig5': 'big5hkscs',\n 'csbig5': 'big5hkscs',\n 'xxbig5': 'big5hkscs',\n};\n", "\"use strict\";\n\n// Update this array if you add/rename/remove files in this directory.\n// We support Browserify by skipping automatic module discovery and requiring modules directly.\nvar modules = [\n require(\"./internal\"),\n require(\"./utf16\"),\n require(\"./utf7\"),\n require(\"./sbcs-codec\"),\n require(\"./sbcs-data\"),\n require(\"./sbcs-data-generated\"),\n require(\"./dbcs-codec\"),\n require(\"./dbcs-data\"),\n];\n\n// Put all encoding/alias/codec definitions to single object and export it. \nfor (var i = 0; i < modules.length; i++) {\n var module = modules[i];\n for (var enc in module)\n if (Object.prototype.hasOwnProperty.call(module, enc))\n exports[enc] = module[enc];\n}\n", "\"use strict\";\n\nvar Buffer = require(\"buffer\").Buffer,\n Transform = require(\"stream\").Transform;\n\n\n// == Exports ==================================================================\nmodule.exports = function(iconv) {\n \n // Additional Public API.\n iconv.encodeStream = function encodeStream(encoding, options) {\n return new IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options);\n }\n\n iconv.decodeStream = function decodeStream(encoding, options) {\n return new IconvLiteDecoderStream(iconv.getDecoder(encoding, options), options);\n }\n\n iconv.supportsStreams = true;\n\n\n // Not published yet.\n iconv.IconvLiteEncoderStream = IconvLiteEncoderStream;\n iconv.IconvLiteDecoderStream = IconvLiteDecoderStream;\n iconv._collect = IconvLiteDecoderStream.prototype.collect;\n};\n\n\n// == Encoder stream =======================================================\nfunction IconvLiteEncoderStream(conv, options) {\n this.conv = conv;\n options = options || {};\n options.decodeStrings = false; // We accept only strings, so we don't need to decode them.\n Transform.call(this, options);\n}\n\nIconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {\n constructor: { value: IconvLiteEncoderStream }\n});\n\nIconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {\n if (typeof chunk != 'string')\n return done(new Error(\"Iconv encoding stream needs strings as its input.\"));\n try {\n var res = this.conv.write(chunk);\n if (res && res.length) this.push(res);\n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteEncoderStream.prototype._flush = function(done) {\n try {\n var res = this.conv.end();\n if (res && res.length) this.push(res);\n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteEncoderStream.prototype.collect = function(cb) {\n var chunks = [];\n this.on('error', cb);\n this.on('data', function(chunk) { chunks.push(chunk); });\n this.on('end', function() {\n cb(null, Buffer.concat(chunks));\n });\n return this;\n}\n\n\n// == Decoder stream =======================================================\nfunction IconvLiteDecoderStream(conv, options) {\n this.conv = conv;\n options = options || {};\n options.encoding = this.encoding = 'utf8'; // We output strings.\n Transform.call(this, options);\n}\n\nIconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {\n constructor: { value: IconvLiteDecoderStream }\n});\n\nIconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {\n if (!Buffer.isBuffer(chunk))\n return done(new Error(\"Iconv decoding stream needs buffers as its input.\"));\n try {\n var res = this.conv.write(chunk);\n if (res && res.length) this.push(res, this.encoding);\n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteDecoderStream.prototype._flush = function(done) {\n try {\n var res = this.conv.end();\n if (res && res.length) this.push(res, this.encoding); \n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteDecoderStream.prototype.collect = function(cb) {\n var res = '';\n this.on('error', cb);\n this.on('data', function(chunk) { res += chunk; });\n this.on('end', function() {\n cb(null, res);\n });\n return this;\n}\n\n", "\"use strict\";\nvar Buffer = require(\"buffer\").Buffer;\n// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer\n\n// == Extend Node primitives to use iconv-lite =================================\n\nmodule.exports = function (iconv) {\n var original = undefined; // Place to keep original methods.\n\n // Node authors rewrote Buffer internals to make it compatible with\n // Uint8Array and we cannot patch key functions since then.\n // Note: this does use older Buffer API on a purpose\n iconv.supportsNodeEncodingsExtension = !(Buffer.from || new Buffer(0) instanceof Uint8Array);\n\n iconv.extendNodeEncodings = function extendNodeEncodings() {\n if (original) return;\n original = {};\n\n if (!iconv.supportsNodeEncodingsExtension) {\n console.error(\"ACTION NEEDED: require('iconv-lite').extendNodeEncodings() is not supported in your version of Node\");\n console.error(\"See more info at https://github.com/ashtuchkin/iconv-lite/wiki/Node-v4-compatibility\");\n return;\n }\n\n var nodeNativeEncodings = {\n 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, \n 'base64': true, 'ucs2': true, 'ucs-2': true, 'utf16le': true, 'utf-16le': true,\n };\n\n Buffer.isNativeEncoding = function(enc) {\n return enc && nodeNativeEncodings[enc.toLowerCase()];\n }\n\n // -- SlowBuffer -----------------------------------------------------------\n var SlowBuffer = require('buffer').SlowBuffer;\n\n original.SlowBufferToString = SlowBuffer.prototype.toString;\n SlowBuffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.SlowBufferToString.call(this, encoding, start, end);\n\n // Otherwise, use our decoding method.\n if (typeof start == 'undefined') start = 0;\n if (typeof end == 'undefined') end = this.length;\n return iconv.decode(this.slice(start, end), encoding);\n }\n\n original.SlowBufferWrite = SlowBuffer.prototype.write;\n SlowBuffer.prototype.write = function(string, offset, length, encoding) {\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.SlowBufferWrite.call(this, string, offset, length, encoding);\n\n if (string.length > 0 && (length < 0 || offset < 0))\n throw new RangeError('attempt to write beyond buffer bounds');\n\n // Otherwise, use our encoding method.\n var buf = iconv.encode(string, encoding);\n if (buf.length < length) length = buf.length;\n buf.copy(this, offset, 0, length);\n return length;\n }\n\n // -- Buffer ---------------------------------------------------------------\n\n original.BufferIsEncoding = Buffer.isEncoding;\n Buffer.isEncoding = function(encoding) {\n return Buffer.isNativeEncoding(encoding) || iconv.encodingExists(encoding);\n }\n\n original.BufferByteLength = Buffer.byteLength;\n Buffer.byteLength = SlowBuffer.byteLength = function(str, encoding) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.BufferByteLength.call(this, str, encoding);\n\n // Slow, I know, but we don't have a better way yet.\n return iconv.encode(str, encoding).length;\n }\n\n original.BufferToString = Buffer.prototype.toString;\n Buffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.BufferToString.call(this, encoding, start, end);\n\n // Otherwise, use our decoding method.\n if (typeof start == 'undefined') start = 0;\n if (typeof end == 'undefined') end = this.length;\n return iconv.decode(this.slice(start, end), encoding);\n }\n\n original.BufferWrite = Buffer.prototype.write;\n Buffer.prototype.write = function(string, offset, length, encoding) {\n var _offset = offset, _length = length, _encoding = encoding;\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.BufferWrite.call(this, string, _offset, _length, _encoding);\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n\n if (string.length > 0 && (length < 0 || offset < 0))\n throw new RangeError('attempt to write beyond buffer bounds');\n\n // Otherwise, use our encoding method.\n var buf = iconv.encode(string, encoding);\n if (buf.length < length) length = buf.length;\n buf.copy(this, offset, 0, length);\n return length;\n\n // TODO: Set _charsWritten.\n }\n\n\n // -- Readable -------------------------------------------------------------\n if (iconv.supportsStreams) {\n var Readable = require('stream').Readable;\n\n original.ReadableSetEncoding = Readable.prototype.setEncoding;\n Readable.prototype.setEncoding = function setEncoding(enc, options) {\n // Use our own decoder, it has the same interface.\n // We cannot use original function as it doesn't handle BOM-s.\n this._readableState.decoder = iconv.getDecoder(enc, options);\n this._readableState.encoding = enc;\n }\n\n Readable.prototype.collect = iconv._collect;\n }\n }\n\n // Remove iconv-lite Node primitive extensions.\n iconv.undoExtendNodeEncodings = function undoExtendNodeEncodings() {\n if (!iconv.supportsNodeEncodingsExtension)\n return;\n if (!original)\n throw new Error(\"require('iconv-lite').undoExtendNodeEncodings(): Nothing to undo; extendNodeEncodings() is not called.\")\n\n delete Buffer.isNativeEncoding;\n\n var SlowBuffer = require('buffer').SlowBuffer;\n\n SlowBuffer.prototype.toString = original.SlowBufferToString;\n SlowBuffer.prototype.write = original.SlowBufferWrite;\n\n Buffer.isEncoding = original.BufferIsEncoding;\n Buffer.byteLength = original.BufferByteLength;\n Buffer.prototype.toString = original.BufferToString;\n Buffer.prototype.write = original.BufferWrite;\n\n if (iconv.supportsStreams) {\n var Readable = require('stream').Readable;\n\n Readable.prototype.setEncoding = original.ReadableSetEncoding;\n delete Readable.prototype.collect;\n }\n\n original = undefined;\n }\n}\n", "\"use strict\";\n\n// Some environments don't have global Buffer (e.g. React Native).\n// Solution would be installing npm modules \"buffer\" and \"stream\" explicitly.\nvar Buffer = require(\"safer-buffer\").Buffer;\n\nvar bomHandling = require(\"./bom-handling\"),\n iconv = module.exports;\n\n// All codecs and aliases are kept here, keyed by encoding name/alias.\n// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`.\niconv.encodings = null;\n\n// Characters emitted in case of error.\niconv.defaultCharUnicode = '\uFFFD';\niconv.defaultCharSingleByte = '?';\n\n// Public API.\niconv.encode = function encode(str, encoding, options) {\n str = \"\" + (str || \"\"); // Ensure string.\n\n var encoder = iconv.getEncoder(encoding, options);\n\n var res = encoder.write(str);\n var trail = encoder.end();\n \n return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res;\n}\n\niconv.decode = function decode(buf, encoding, options) {\n if (typeof buf === 'string') {\n if (!iconv.skipDecodeWarning) {\n console.error('Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding');\n iconv.skipDecodeWarning = true;\n }\n\n buf = Buffer.from(\"\" + (buf || \"\"), \"binary\"); // Ensure buffer.\n }\n\n var decoder = iconv.getDecoder(encoding, options);\n\n var res = decoder.write(buf);\n var trail = decoder.end();\n\n return trail ? (res + trail) : res;\n}\n\niconv.encodingExists = function encodingExists(enc) {\n try {\n iconv.getCodec(enc);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n// Legacy aliases to convert functions\niconv.toEncoding = iconv.encode;\niconv.fromEncoding = iconv.decode;\n\n// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache.\niconv._codecDataCache = {};\niconv.getCodec = function getCodec(encoding) {\n if (!iconv.encodings)\n iconv.encodings = require(\"../encodings\"); // Lazy load all encoding definitions.\n \n // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.\n var enc = iconv._canonicalizeEncoding(encoding);\n\n // Traverse iconv.encodings to find actual codec.\n var codecOptions = {};\n while (true) {\n var codec = iconv._codecDataCache[enc];\n if (codec)\n return codec;\n\n var codecDef = iconv.encodings[enc];\n\n switch (typeof codecDef) {\n case \"string\": // Direct alias to other encoding.\n enc = codecDef;\n break;\n\n case \"object\": // Alias with options. Can be layered.\n for (var key in codecDef)\n codecOptions[key] = codecDef[key];\n\n if (!codecOptions.encodingName)\n codecOptions.encodingName = enc;\n \n enc = codecDef.type;\n break;\n\n case \"function\": // Codec itself.\n if (!codecOptions.encodingName)\n codecOptions.encodingName = enc;\n\n // The codec function must load all tables and return object with .encoder and .decoder methods.\n // It'll be called only once (for each different options object).\n codec = new codecDef(codecOptions, iconv);\n\n iconv._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later.\n return codec;\n\n default:\n throw new Error(\"Encoding not recognized: '\" + encoding + \"' (searched as: '\"+enc+\"')\");\n }\n }\n}\n\niconv._canonicalizeEncoding = function(encoding) {\n // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.\n return (''+encoding).toLowerCase().replace(/:\\d{4}$|[^0-9a-z]/g, \"\");\n}\n\niconv.getEncoder = function getEncoder(encoding, options) {\n var codec = iconv.getCodec(encoding),\n encoder = new codec.encoder(options, codec);\n\n if (codec.bomAware && options && options.addBOM)\n encoder = new bomHandling.PrependBOM(encoder, options);\n\n return encoder;\n}\n\niconv.getDecoder = function getDecoder(encoding, options) {\n var codec = iconv.getCodec(encoding),\n decoder = new codec.decoder(options, codec);\n\n if (codec.bomAware && !(options && options.stripBOM === false))\n decoder = new bomHandling.StripBOM(decoder, options);\n\n return decoder;\n}\n\n\n// Load extensions in Node. All of them are omitted in Browserify build via 'browser' field in package.json.\nvar nodeVer = typeof process !== 'undefined' && process.versions && process.versions.node;\nif (nodeVer) {\n\n // Load streaming support in Node v0.10+\n var nodeVerArr = nodeVer.split(\".\").map(Number);\n if (nodeVerArr[0] > 0 || nodeVerArr[1] >= 10) {\n require(\"./streams\")(iconv);\n }\n\n // Load Node primitive extensions.\n require(\"./extend-node\")(iconv);\n}\n\nif (\"\u0100\" != \"\\u0100\") {\n console.error(\"iconv-lite warning: javascript files use encoding different from utf-8. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info.\");\n}\n", "/*!\n * unpipe\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = unpipe\n\n/**\n * Determine if there are Node.js pipe-like data listeners.\n * @private\n */\n\nfunction hasPipeDataListeners(stream) {\n var listeners = stream.listeners('data')\n\n for (var i = 0; i < listeners.length; i++) {\n if (listeners[i].name === 'ondata') {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Unpipe a stream from all destinations.\n *\n * @param {object} stream\n * @public\n */\n\nfunction unpipe(stream) {\n if (!stream) {\n throw new TypeError('argument stream is required')\n }\n\n if (typeof stream.unpipe === 'function') {\n // new-style\n stream.unpipe()\n return\n }\n\n // Node.js 0.8 hack\n if (!hasPipeDataListeners(stream)) {\n return\n }\n\n var listener\n var listeners = stream.listeners('close')\n\n for (var i = 0; i < listeners.length; i++) {\n listener = listeners[i]\n\n if (listener.name !== 'cleanup' && listener.name !== 'onclose') {\n continue\n }\n\n // invoke the listener\n listener.call(stream)\n }\n}\n", "/*!\n * raw-body\n * Copyright(c) 2013-2014 Jonathan Ong\n * Copyright(c) 2014-2022 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar asyncHooks = tryRequireAsyncHooks()\nvar bytes = require('bytes')\nvar createError = require('http-errors')\nvar iconv = require('iconv-lite')\nvar unpipe = require('unpipe')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = getRawBody\n\n/**\n * Module variables.\n * @private\n */\n\nvar ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: /\n\n/**\n * Get the decoder for a given encoding.\n *\n * @param {string} encoding\n * @private\n */\n\nfunction getDecoder (encoding) {\n if (!encoding) return null\n\n try {\n return iconv.getDecoder(encoding)\n } catch (e) {\n // error getting decoder\n if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e\n\n // the encoding was not found\n throw createError(415, 'specified encoding unsupported', {\n encoding: encoding,\n type: 'encoding.unsupported'\n })\n }\n}\n\n/**\n * Get the raw body of a stream (typically HTTP).\n *\n * @param {object} stream\n * @param {object|string|function} [options]\n * @param {function} [callback]\n * @public\n */\n\nfunction getRawBody (stream, options, callback) {\n var done = callback\n var opts = options || {}\n\n if (options === true || typeof options === 'string') {\n // short cut for encoding\n opts = {\n encoding: options\n }\n }\n\n if (typeof options === 'function') {\n done = options\n opts = {}\n }\n\n // validate callback is a function, if provided\n if (done !== undefined && typeof done !== 'function') {\n throw new TypeError('argument callback must be a function')\n }\n\n // require the callback without promises\n if (!done && !global.Promise) {\n throw new TypeError('argument callback is required')\n }\n\n // get encoding\n var encoding = opts.encoding !== true\n ? opts.encoding\n : 'utf-8'\n\n // convert the limit to an integer\n var limit = bytes.parse(opts.limit)\n\n // convert the expected length to an integer\n var length = opts.length != null && !isNaN(opts.length)\n ? parseInt(opts.length, 10)\n : null\n\n if (done) {\n // classic callback style\n return readStream(stream, encoding, length, limit, wrap(done))\n }\n\n return new Promise(function executor (resolve, reject) {\n readStream(stream, encoding, length, limit, function onRead (err, buf) {\n if (err) return reject(err)\n resolve(buf)\n })\n })\n}\n\n/**\n * Halt a stream.\n *\n * @param {Object} stream\n * @private\n */\n\nfunction halt (stream) {\n // unpipe everything from the stream\n unpipe(stream)\n\n // pause stream\n if (typeof stream.pause === 'function') {\n stream.pause()\n }\n}\n\n/**\n * Read the data from the stream.\n *\n * @param {object} stream\n * @param {string} encoding\n * @param {number} length\n * @param {number} limit\n * @param {function} callback\n * @public\n */\n\nfunction readStream (stream, encoding, length, limit, callback) {\n var complete = false\n var sync = true\n\n // check the length and limit options.\n // note: we intentionally leave the stream paused,\n // so users should handle the stream themselves.\n if (limit !== null && length !== null && length > limit) {\n return done(createError(413, 'request entity too large', {\n expected: length,\n length: length,\n limit: limit,\n type: 'entity.too.large'\n }))\n }\n\n // streams1: assert request encoding is buffer.\n // streams2+: assert the stream encoding is buffer.\n // stream._decoder: streams1\n // state.encoding: streams2\n // state.decoder: streams2, specifically < 0.10.6\n var state = stream._readableState\n if (stream._decoder || (state && (state.encoding || state.decoder))) {\n // developer error\n return done(createError(500, 'stream encoding should not be set', {\n type: 'stream.encoding.set'\n }))\n }\n\n if (typeof stream.readable !== 'undefined' && !stream.readable) {\n return done(createError(500, 'stream is not readable', {\n type: 'stream.not.readable'\n }))\n }\n\n var received = 0\n var decoder\n\n try {\n decoder = getDecoder(encoding)\n } catch (err) {\n return done(err)\n }\n\n var buffer = decoder\n ? ''\n : []\n\n // attach listeners\n stream.on('aborted', onAborted)\n stream.on('close', cleanup)\n stream.on('data', onData)\n stream.on('end', onEnd)\n stream.on('error', onEnd)\n\n // mark sync section complete\n sync = false\n\n function done () {\n var args = new Array(arguments.length)\n\n // copy arguments\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n\n // mark complete\n complete = true\n\n if (sync) {\n process.nextTick(invokeCallback)\n } else {\n invokeCallback()\n }\n\n function invokeCallback () {\n cleanup()\n\n if (args[0]) {\n // halt the stream on error\n halt(stream)\n }\n\n callback.apply(null, args)\n }\n }\n\n function onAborted () {\n if (complete) return\n\n done(createError(400, 'request aborted', {\n code: 'ECONNABORTED',\n expected: length,\n length: length,\n received: received,\n type: 'request.aborted'\n }))\n }\n\n function onData (chunk) {\n if (complete) return\n\n received += chunk.length\n\n if (limit !== null && received > limit) {\n done(createError(413, 'request entity too large', {\n limit: limit,\n received: received,\n type: 'entity.too.large'\n }))\n } else if (decoder) {\n buffer += decoder.write(chunk)\n } else {\n buffer.push(chunk)\n }\n }\n\n function onEnd (err) {\n if (complete) return\n if (err) return done(err)\n\n if (length !== null && received !== length) {\n done(createError(400, 'request size did not match content length', {\n expected: length,\n length: length,\n received: received,\n type: 'request.size.invalid'\n }))\n } else {\n var string = decoder\n ? buffer + (decoder.end() || '')\n : Buffer.concat(buffer)\n done(null, string)\n }\n }\n\n function cleanup () {\n buffer = null\n\n stream.removeListener('aborted', onAborted)\n stream.removeListener('data', onData)\n stream.removeListener('end', onEnd)\n stream.removeListener('error', onEnd)\n stream.removeListener('close', cleanup)\n }\n}\n\n/**\n * Try to require async_hooks\n * @private\n */\n\nfunction tryRequireAsyncHooks () {\n try {\n return require('async_hooks')\n } catch (e) {\n return {}\n }\n}\n\n/**\n * Wrap function with async resource, if possible.\n * AsyncResource.bind static method backported.\n * @private\n */\n\nfunction wrap (fn) {\n var res\n\n // create anonymous resource\n if (asyncHooks.AsyncResource) {\n res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')\n }\n\n // incompatible node.js\n if (!res || !res.runInAsyncScope) {\n return fn\n }\n\n // return bound function\n return res.runInAsyncScope.bind(res, fn, null)\n}\n", "\"use strict\";\n\nvar BOMChar = '\\uFEFF';\n\nexports.PrependBOM = PrependBOMWrapper\nfunction PrependBOMWrapper(encoder, options) {\n this.encoder = encoder;\n this.addBOM = true;\n}\n\nPrependBOMWrapper.prototype.write = function(str) {\n if (this.addBOM) {\n str = BOMChar + str;\n this.addBOM = false;\n }\n\n return this.encoder.write(str);\n}\n\nPrependBOMWrapper.prototype.end = function() {\n return this.encoder.end();\n}\n\n\n//------------------------------------------------------------------------------\n\nexports.StripBOM = StripBOMWrapper;\nfunction StripBOMWrapper(decoder, options) {\n this.decoder = decoder;\n this.pass = false;\n this.options = options || {};\n}\n\nStripBOMWrapper.prototype.write = function(buf) {\n var res = this.decoder.write(buf);\n if (this.pass || !res)\n return res;\n\n if (res[0] === BOMChar) {\n res = res.slice(1);\n if (typeof this.options.stripBOM === 'function')\n this.options.stripBOM();\n }\n\n this.pass = true;\n return res;\n}\n\nStripBOMWrapper.prototype.end = function() {\n return this.decoder.end();\n}\n\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Export Node.js internal encodings.\n\nmodule.exports = {\n // Encodings\n utf8: { type: \"_internal\", bomAware: true},\n cesu8: { type: \"_internal\", bomAware: true},\n unicode11utf8: \"utf8\",\n\n ucs2: { type: \"_internal\", bomAware: true},\n utf16le: \"ucs2\",\n\n binary: { type: \"_internal\" },\n base64: { type: \"_internal\" },\n hex: { type: \"_internal\" },\n\n // Codec.\n _internal: InternalCodec,\n};\n\n//------------------------------------------------------------------------------\n\nfunction InternalCodec(codecOptions, iconv) {\n this.enc = codecOptions.encodingName;\n this.bomAware = codecOptions.bomAware;\n\n if (this.enc === \"base64\")\n this.encoder = InternalEncoderBase64;\n else if (this.enc === \"cesu8\") {\n this.enc = \"utf8\"; // Use utf8 for decoding.\n this.encoder = InternalEncoderCesu8;\n\n // Add decoder for versions of Node not supporting CESU-8\n if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '\uD83D\uDCA9') {\n this.decoder = InternalDecoderCesu8;\n this.defaultCharUnicode = iconv.defaultCharUnicode;\n }\n }\n}\n\nInternalCodec.prototype.encoder = InternalEncoder;\nInternalCodec.prototype.decoder = InternalDecoder;\n\n//------------------------------------------------------------------------------\n\n// We use node.js internal decoder. Its signature is the same as ours.\nvar StringDecoder = require('string_decoder').StringDecoder;\n\nif (!StringDecoder.prototype.end) // Node v0.8 doesn't have this method.\n StringDecoder.prototype.end = function() {};\n\n\nfunction InternalDecoder(options, codec) {\n StringDecoder.call(this, codec.enc);\n}\n\nInternalDecoder.prototype = StringDecoder.prototype;\n\n\n//------------------------------------------------------------------------------\n// Encoder is mostly trivial\n\nfunction InternalEncoder(options, codec) {\n this.enc = codec.enc;\n}\n\nInternalEncoder.prototype.write = function(str) {\n return Buffer.from(str, this.enc);\n}\n\nInternalEncoder.prototype.end = function() {\n}\n\n\n//------------------------------------------------------------------------------\n// Except base64 encoder, which must keep its state.\n\nfunction InternalEncoderBase64(options, codec) {\n this.prevStr = '';\n}\n\nInternalEncoderBase64.prototype.write = function(str) {\n str = this.prevStr + str;\n var completeQuads = str.length - (str.length % 4);\n this.prevStr = str.slice(completeQuads);\n str = str.slice(0, completeQuads);\n\n return Buffer.from(str, \"base64\");\n}\n\nInternalEncoderBase64.prototype.end = function() {\n return Buffer.from(this.prevStr, \"base64\");\n}\n\n\n//------------------------------------------------------------------------------\n// CESU-8 encoder is also special.\n\nfunction InternalEncoderCesu8(options, codec) {\n}\n\nInternalEncoderCesu8.prototype.write = function(str) {\n var buf = Buffer.alloc(str.length * 3), bufIdx = 0;\n for (var i = 0; i < str.length; i++) {\n var charCode = str.charCodeAt(i);\n // Naive implementation, but it works because CESU-8 is especially easy\n // to convert from UTF-16 (which all JS strings are encoded in).\n if (charCode < 0x80)\n buf[bufIdx++] = charCode;\n else if (charCode < 0x800) {\n buf[bufIdx++] = 0xC0 + (charCode >>> 6);\n buf[bufIdx++] = 0x80 + (charCode & 0x3f);\n }\n else { // charCode will always be < 0x10000 in javascript.\n buf[bufIdx++] = 0xE0 + (charCode >>> 12);\n buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f);\n buf[bufIdx++] = 0x80 + (charCode & 0x3f);\n }\n }\n return buf.slice(0, bufIdx);\n}\n\nInternalEncoderCesu8.prototype.end = function() {\n}\n\n//------------------------------------------------------------------------------\n// CESU-8 decoder is not implemented in Node v4.0+\n\nfunction InternalDecoderCesu8(options, codec) {\n this.acc = 0;\n this.contBytes = 0;\n this.accBytes = 0;\n this.defaultCharUnicode = codec.defaultCharUnicode;\n}\n\nInternalDecoderCesu8.prototype.write = function(buf) {\n var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, \n res = '';\n for (var i = 0; i < buf.length; i++) {\n var curByte = buf[i];\n if ((curByte & 0xC0) !== 0x80) { // Leading byte\n if (contBytes > 0) { // Previous code is invalid\n res += this.defaultCharUnicode;\n contBytes = 0;\n }\n\n if (curByte < 0x80) { // Single-byte code\n res += String.fromCharCode(curByte);\n } else if (curByte < 0xE0) { // Two-byte code\n acc = curByte & 0x1F;\n contBytes = 1; accBytes = 1;\n } else if (curByte < 0xF0) { // Three-byte code\n acc = curByte & 0x0F;\n contBytes = 2; accBytes = 1;\n } else { // Four or more are not supported for CESU-8.\n res += this.defaultCharUnicode;\n }\n } else { // Continuation byte\n if (contBytes > 0) { // We're waiting for it.\n acc = (acc << 6) | (curByte & 0x3f);\n contBytes--; accBytes++;\n if (contBytes === 0) {\n // Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80)\n if (accBytes === 2 && acc < 0x80 && acc > 0)\n res += this.defaultCharUnicode;\n else if (accBytes === 3 && acc < 0x800)\n res += this.defaultCharUnicode;\n else\n // Actually add character.\n res += String.fromCharCode(acc);\n }\n } else { // Unexpected continuation byte\n res += this.defaultCharUnicode;\n }\n }\n }\n this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes;\n return res;\n}\n\nInternalDecoderCesu8.prototype.end = function() {\n var res = 0;\n if (this.contBytes > 0)\n res += this.defaultCharUnicode;\n return res;\n}\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js\n\n// == UTF16-BE codec. ==========================================================\n\nexports.utf16be = Utf16BECodec;\nfunction Utf16BECodec() {\n}\n\nUtf16BECodec.prototype.encoder = Utf16BEEncoder;\nUtf16BECodec.prototype.decoder = Utf16BEDecoder;\nUtf16BECodec.prototype.bomAware = true;\n\n\n// -- Encoding\n\nfunction Utf16BEEncoder() {\n}\n\nUtf16BEEncoder.prototype.write = function(str) {\n var buf = Buffer.from(str, 'ucs2');\n for (var i = 0; i < buf.length; i += 2) {\n var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp;\n }\n return buf;\n}\n\nUtf16BEEncoder.prototype.end = function() {\n}\n\n\n// -- Decoding\n\nfunction Utf16BEDecoder() {\n this.overflowByte = -1;\n}\n\nUtf16BEDecoder.prototype.write = function(buf) {\n if (buf.length == 0)\n return '';\n\n var buf2 = Buffer.alloc(buf.length + 1),\n i = 0, j = 0;\n\n if (this.overflowByte !== -1) {\n buf2[0] = buf[0];\n buf2[1] = this.overflowByte;\n i = 1; j = 2;\n }\n\n for (; i < buf.length-1; i += 2, j+= 2) {\n buf2[j] = buf[i+1];\n buf2[j+1] = buf[i];\n }\n\n this.overflowByte = (i == buf.length-1) ? buf[buf.length-1] : -1;\n\n return buf2.slice(0, j).toString('ucs2');\n}\n\nUtf16BEDecoder.prototype.end = function() {\n}\n\n\n// == UTF-16 codec =============================================================\n// Decoder chooses automatically from UTF-16LE and UTF-16BE using BOM and space-based heuristic.\n// Defaults to UTF-16LE, as it's prevalent and default in Node.\n// http://en.wikipedia.org/wiki/UTF-16 and http://encoding.spec.whatwg.org/#utf-16le\n// Decoder default can be changed: iconv.decode(buf, 'utf16', {defaultEncoding: 'utf-16be'});\n\n// Encoder uses UTF-16LE and prepends BOM (which can be overridden with addBOM: false).\n\nexports.utf16 = Utf16Codec;\nfunction Utf16Codec(codecOptions, iconv) {\n this.iconv = iconv;\n}\n\nUtf16Codec.prototype.encoder = Utf16Encoder;\nUtf16Codec.prototype.decoder = Utf16Decoder;\n\n\n// -- Encoding (pass-through)\n\nfunction Utf16Encoder(options, codec) {\n options = options || {};\n if (options.addBOM === undefined)\n options.addBOM = true;\n this.encoder = codec.iconv.getEncoder('utf-16le', options);\n}\n\nUtf16Encoder.prototype.write = function(str) {\n return this.encoder.write(str);\n}\n\nUtf16Encoder.prototype.end = function() {\n return this.encoder.end();\n}\n\n\n// -- Decoding\n\nfunction Utf16Decoder(options, codec) {\n this.decoder = null;\n this.initialBytes = [];\n this.initialBytesLen = 0;\n\n this.options = options || {};\n this.iconv = codec.iconv;\n}\n\nUtf16Decoder.prototype.write = function(buf) {\n if (!this.decoder) {\n // Codec is not chosen yet. Accumulate initial bytes.\n this.initialBytes.push(buf);\n this.initialBytesLen += buf.length;\n \n if (this.initialBytesLen < 16) // We need more bytes to use space heuristic (see below)\n return '';\n\n // We have enough bytes -> detect endianness.\n var buf = Buffer.concat(this.initialBytes),\n encoding = detectEncoding(buf, this.options.defaultEncoding);\n this.decoder = this.iconv.getDecoder(encoding, this.options);\n this.initialBytes.length = this.initialBytesLen = 0;\n }\n\n return this.decoder.write(buf);\n}\n\nUtf16Decoder.prototype.end = function() {\n if (!this.decoder) {\n var buf = Buffer.concat(this.initialBytes),\n encoding = detectEncoding(buf, this.options.defaultEncoding);\n this.decoder = this.iconv.getDecoder(encoding, this.options);\n\n var res = this.decoder.write(buf),\n trail = this.decoder.end();\n\n return trail ? (res + trail) : res;\n }\n return this.decoder.end();\n}\n\nfunction detectEncoding(buf, defaultEncoding) {\n var enc = defaultEncoding || 'utf-16le';\n\n if (buf.length >= 2) {\n // Check BOM.\n if (buf[0] == 0xFE && buf[1] == 0xFF) // UTF-16BE BOM\n enc = 'utf-16be';\n else if (buf[0] == 0xFF && buf[1] == 0xFE) // UTF-16LE BOM\n enc = 'utf-16le';\n else {\n // No BOM found. Try to deduce encoding from initial content.\n // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon.\n // So, we count ASCII as if it was LE or BE, and decide from that.\n var asciiCharsLE = 0, asciiCharsBE = 0, // Counts of chars in both positions\n _len = Math.min(buf.length - (buf.length % 2), 64); // Len is always even.\n\n for (var i = 0; i < _len; i += 2) {\n if (buf[i] === 0 && buf[i+1] !== 0) asciiCharsBE++;\n if (buf[i] !== 0 && buf[i+1] === 0) asciiCharsLE++;\n }\n\n if (asciiCharsBE > asciiCharsLE)\n enc = 'utf-16be';\n else if (asciiCharsBE < asciiCharsLE)\n enc = 'utf-16le';\n }\n }\n\n return enc;\n}\n\n\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// UTF-7 codec, according to https://tools.ietf.org/html/rfc2152\n// See also below a UTF-7-IMAP codec, according to http://tools.ietf.org/html/rfc3501#section-5.1.3\n\nexports.utf7 = Utf7Codec;\nexports.unicode11utf7 = 'utf7'; // Alias UNICODE-1-1-UTF-7\nfunction Utf7Codec(codecOptions, iconv) {\n this.iconv = iconv;\n};\n\nUtf7Codec.prototype.encoder = Utf7Encoder;\nUtf7Codec.prototype.decoder = Utf7Decoder;\nUtf7Codec.prototype.bomAware = true;\n\n\n// -- Encoding\n\nvar nonDirectChars = /[^A-Za-z0-9'\\(\\),-\\.\\/:\\? \\n\\r\\t]+/g;\n\nfunction Utf7Encoder(options, codec) {\n this.iconv = codec.iconv;\n}\n\nUtf7Encoder.prototype.write = function(str) {\n // Naive implementation.\n // Non-direct chars are encoded as \"+-\"; single \"+\" char is encoded as \"+-\".\n return Buffer.from(str.replace(nonDirectChars, function(chunk) {\n return \"+\" + (chunk === '+' ? '' : \n this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) \n + \"-\";\n }.bind(this)));\n}\n\nUtf7Encoder.prototype.end = function() {\n}\n\n\n// -- Decoding\n\nfunction Utf7Decoder(options, codec) {\n this.iconv = codec.iconv;\n this.inBase64 = false;\n this.base64Accum = '';\n}\n\nvar base64Regex = /[A-Za-z0-9\\/+]/;\nvar base64Chars = [];\nfor (var i = 0; i < 256; i++)\n base64Chars[i] = base64Regex.test(String.fromCharCode(i));\n\nvar plusChar = '+'.charCodeAt(0), \n minusChar = '-'.charCodeAt(0),\n andChar = '&'.charCodeAt(0);\n\nUtf7Decoder.prototype.write = function(buf) {\n var res = \"\", lastI = 0,\n inBase64 = this.inBase64,\n base64Accum = this.base64Accum;\n\n // The decoder is more involved as we must handle chunks in stream.\n\n for (var i = 0; i < buf.length; i++) {\n if (!inBase64) { // We're in direct mode.\n // Write direct chars until '+'\n if (buf[i] == plusChar) {\n res += this.iconv.decode(buf.slice(lastI, i), \"ascii\"); // Write direct chars.\n lastI = i+1;\n inBase64 = true;\n }\n } else { // We decode base64.\n if (!base64Chars[buf[i]]) { // Base64 ended.\n if (i == lastI && buf[i] == minusChar) {// \"+-\" -> \"+\"\n res += \"+\";\n } else {\n var b64str = base64Accum + buf.slice(lastI, i).toString();\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n if (buf[i] != minusChar) // Minus is absorbed after base64.\n i--;\n\n lastI = i+1;\n inBase64 = false;\n base64Accum = '';\n }\n }\n }\n\n if (!inBase64) {\n res += this.iconv.decode(buf.slice(lastI), \"ascii\"); // Write direct chars.\n } else {\n var b64str = base64Accum + buf.slice(lastI).toString();\n\n var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars.\n base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.\n b64str = b64str.slice(0, canBeDecoded);\n\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n this.inBase64 = inBase64;\n this.base64Accum = base64Accum;\n\n return res;\n}\n\nUtf7Decoder.prototype.end = function() {\n var res = \"\";\n if (this.inBase64 && this.base64Accum.length > 0)\n res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), \"utf16-be\");\n\n this.inBase64 = false;\n this.base64Accum = '';\n return res;\n}\n\n\n// UTF-7-IMAP codec.\n// RFC3501 Sec. 5.1.3 Modified UTF-7 (http://tools.ietf.org/html/rfc3501#section-5.1.3)\n// Differences:\n// * Base64 part is started by \"&\" instead of \"+\"\n// * Direct characters are 0x20-0x7E, except \"&\" (0x26)\n// * In Base64, \",\" is used instead of \"/\"\n// * Base64 must not be used to represent direct characters.\n// * No implicit shift back from Base64 (should always end with '-')\n// * String must end in non-shifted position.\n// * \"-&\" while in base64 is not allowed.\n\n\nexports.utf7imap = Utf7IMAPCodec;\nfunction Utf7IMAPCodec(codecOptions, iconv) {\n this.iconv = iconv;\n};\n\nUtf7IMAPCodec.prototype.encoder = Utf7IMAPEncoder;\nUtf7IMAPCodec.prototype.decoder = Utf7IMAPDecoder;\nUtf7IMAPCodec.prototype.bomAware = true;\n\n\n// -- Encoding\n\nfunction Utf7IMAPEncoder(options, codec) {\n this.iconv = codec.iconv;\n this.inBase64 = false;\n this.base64Accum = Buffer.alloc(6);\n this.base64AccumIdx = 0;\n}\n\nUtf7IMAPEncoder.prototype.write = function(str) {\n var inBase64 = this.inBase64,\n base64Accum = this.base64Accum,\n base64AccumIdx = this.base64AccumIdx,\n buf = Buffer.alloc(str.length*5 + 10), bufIdx = 0;\n\n for (var i = 0; i < str.length; i++) {\n var uChar = str.charCodeAt(i);\n if (0x20 <= uChar && uChar <= 0x7E) { // Direct character or '&'.\n if (inBase64) {\n if (base64AccumIdx > 0) {\n bufIdx += buf.write(base64Accum.slice(0, base64AccumIdx).toString('base64').replace(/\\//g, ',').replace(/=+$/, ''), bufIdx);\n base64AccumIdx = 0;\n }\n\n buf[bufIdx++] = minusChar; // Write '-', then go to direct mode.\n inBase64 = false;\n }\n\n if (!inBase64) {\n buf[bufIdx++] = uChar; // Write direct character\n\n if (uChar === andChar) // Ampersand -> '&-'\n buf[bufIdx++] = minusChar;\n }\n\n } else { // Non-direct character\n if (!inBase64) {\n buf[bufIdx++] = andChar; // Write '&', then go to base64 mode.\n inBase64 = true;\n }\n if (inBase64) {\n base64Accum[base64AccumIdx++] = uChar >> 8;\n base64Accum[base64AccumIdx++] = uChar & 0xFF;\n\n if (base64AccumIdx == base64Accum.length) {\n bufIdx += buf.write(base64Accum.toString('base64').replace(/\\//g, ','), bufIdx);\n base64AccumIdx = 0;\n }\n }\n }\n }\n\n this.inBase64 = inBase64;\n this.base64AccumIdx = base64AccumIdx;\n\n return buf.slice(0, bufIdx);\n}\n\nUtf7IMAPEncoder.prototype.end = function() {\n var buf = Buffer.alloc(10), bufIdx = 0;\n if (this.inBase64) {\n if (this.base64AccumIdx > 0) {\n bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString('base64').replace(/\\//g, ',').replace(/=+$/, ''), bufIdx);\n this.base64AccumIdx = 0;\n }\n\n buf[bufIdx++] = minusChar; // Write '-', then go to direct mode.\n this.inBase64 = false;\n }\n\n return buf.slice(0, bufIdx);\n}\n\n\n// -- Decoding\n\nfunction Utf7IMAPDecoder(options, codec) {\n this.iconv = codec.iconv;\n this.inBase64 = false;\n this.base64Accum = '';\n}\n\nvar base64IMAPChars = base64Chars.slice();\nbase64IMAPChars[','.charCodeAt(0)] = true;\n\nUtf7IMAPDecoder.prototype.write = function(buf) {\n var res = \"\", lastI = 0,\n inBase64 = this.inBase64,\n base64Accum = this.base64Accum;\n\n // The decoder is more involved as we must handle chunks in stream.\n // It is forgiving, closer to standard UTF-7 (for example, '-' is optional at the end).\n\n for (var i = 0; i < buf.length; i++) {\n if (!inBase64) { // We're in direct mode.\n // Write direct chars until '&'\n if (buf[i] == andChar) {\n res += this.iconv.decode(buf.slice(lastI, i), \"ascii\"); // Write direct chars.\n lastI = i+1;\n inBase64 = true;\n }\n } else { // We decode base64.\n if (!base64IMAPChars[buf[i]]) { // Base64 ended.\n if (i == lastI && buf[i] == minusChar) { // \"&-\" -> \"&\"\n res += \"&\";\n } else {\n var b64str = base64Accum + buf.slice(lastI, i).toString().replace(/,/g, '/');\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n if (buf[i] != minusChar) // Minus may be absorbed after base64.\n i--;\n\n lastI = i+1;\n inBase64 = false;\n base64Accum = '';\n }\n }\n }\n\n if (!inBase64) {\n res += this.iconv.decode(buf.slice(lastI), \"ascii\"); // Write direct chars.\n } else {\n var b64str = base64Accum + buf.slice(lastI).toString().replace(/,/g, '/');\n\n var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars.\n base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.\n b64str = b64str.slice(0, canBeDecoded);\n\n res += this.iconv.decode(Buffer.from(b64str, 'base64'), \"utf16-be\");\n }\n\n this.inBase64 = inBase64;\n this.base64Accum = base64Accum;\n\n return res;\n}\n\nUtf7IMAPDecoder.prototype.end = function() {\n var res = \"\";\n if (this.inBase64 && this.base64Accum.length > 0)\n res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), \"utf16-be\");\n\n this.inBase64 = false;\n this.base64Accum = '';\n return res;\n}\n\n\n", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that\n// correspond to encoded bytes (if 128 - then lower half is ASCII). \n\nexports._sbcs = SBCSCodec;\nfunction SBCSCodec(codecOptions, iconv) {\n if (!codecOptions)\n throw new Error(\"SBCS codec is called without the data.\")\n \n // Prepare char buffer for decoding.\n if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256))\n throw new Error(\"Encoding '\"+codecOptions.type+\"' has incorrect 'chars' (must be of len 128 or 256)\");\n \n if (codecOptions.chars.length === 128) {\n var asciiString = \"\";\n for (var i = 0; i < 128; i++)\n asciiString += String.fromCharCode(i);\n codecOptions.chars = asciiString + codecOptions.chars;\n }\n\n this.decodeBuf = Buffer.from(codecOptions.chars, 'ucs2');\n \n // Encoding buffer.\n var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));\n\n for (var i = 0; i < codecOptions.chars.length; i++)\n encodeBuf[codecOptions.chars.charCodeAt(i)] = i;\n\n this.encodeBuf = encodeBuf;\n}\n\nSBCSCodec.prototype.encoder = SBCSEncoder;\nSBCSCodec.prototype.decoder = SBCSDecoder;\n\n\nfunction SBCSEncoder(options, codec) {\n this.encodeBuf = codec.encodeBuf;\n}\n\nSBCSEncoder.prototype.write = function(str) {\n var buf = Buffer.alloc(str.length);\n for (var i = 0; i < str.length; i++)\n buf[i] = this.encodeBuf[str.charCodeAt(i)];\n \n return buf;\n}\n\nSBCSEncoder.prototype.end = function() {\n}\n\n\nfunction SBCSDecoder(options, codec) {\n this.decodeBuf = codec.decodeBuf;\n}\n\nSBCSDecoder.prototype.write = function(buf) {\n // Strings are immutable in JS -> we use ucs2 buffer to speed up computations.\n var decodeBuf = this.decodeBuf;\n var newBuf = Buffer.alloc(buf.length*2);\n var idx1 = 0, idx2 = 0;\n for (var i = 0; i < buf.length; i++) {\n idx1 = buf[i]*2; idx2 = i*2;\n newBuf[idx2] = decodeBuf[idx1];\n newBuf[idx2+1] = decodeBuf[idx1+1];\n }\n return newBuf.toString('ucs2');\n}\n\nSBCSDecoder.prototype.end = function() {\n}\n", "\"use strict\";\n\n// Manually added data to be used by sbcs codec in addition to generated one.\n\nmodule.exports = {\n // Not supported by iconv, not sure why.\n \"10029\": \"maccenteuro\",\n \"maccenteuro\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u0100\u0101\u00C9\u0104\u00D6\u00DC\u00E1\u0105\u010C\u00E4\u010D\u0106\u0107\u00E9\u0179\u017A\u010E\u00ED\u010F\u0112\u0113\u0116\u00F3\u0117\u00F4\u00F6\u00F5\u00FA\u011A\u011B\u00FC\u2020\u00B0\u0118\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u0119\u00A8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\u00AC\u221A\u0144\u0147\u2206\u00AB\u00BB\u2026\u00A0\u0148\u0150\u00D5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\u00C1\u0164\u0165\u00CD\u017D\u017E\u016A\u00D3\u00D4\u016B\u016E\u00DA\u016F\u0170\u0171\u0172\u0173\u00DD\u00FD\u0137\u017B\u0141\u017C\u0122\u02C7\"\n },\n\n \"808\": \"cp808\",\n \"ibm808\": \"cp808\",\n \"cp808\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E\u00B0\u2219\u00B7\u221A\u2116\u20AC\u25A0\u00A0\"\n },\n\n \"mik\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u2514\u2534\u252C\u251C\u2500\u253C\u2563\u2551\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2510\u2591\u2592\u2593\u2502\u2524\u2116\u00A7\u2557\u255D\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n\n // Aliases of generated encodings.\n \"ascii8bit\": \"ascii\",\n \"usascii\": \"ascii\",\n \"ansix34\": \"ascii\",\n \"ansix341968\": \"ascii\",\n \"ansix341986\": \"ascii\",\n \"csascii\": \"ascii\",\n \"cp367\": \"ascii\",\n \"ibm367\": \"ascii\",\n \"isoir6\": \"ascii\",\n \"iso646us\": \"ascii\",\n \"iso646irv\": \"ascii\",\n \"us\": \"ascii\",\n\n \"latin1\": \"iso88591\",\n \"latin2\": \"iso88592\",\n \"latin3\": \"iso88593\",\n \"latin4\": \"iso88594\",\n \"latin5\": \"iso88599\",\n \"latin6\": \"iso885910\",\n \"latin7\": \"iso885913\",\n \"latin8\": \"iso885914\",\n \"latin9\": \"iso885915\",\n \"latin10\": \"iso885916\",\n\n \"csisolatin1\": \"iso88591\",\n \"csisolatin2\": \"iso88592\",\n \"csisolatin3\": \"iso88593\",\n \"csisolatin4\": \"iso88594\",\n \"csisolatincyrillic\": \"iso88595\",\n \"csisolatinarabic\": \"iso88596\",\n \"csisolatingreek\" : \"iso88597\",\n \"csisolatinhebrew\": \"iso88598\",\n \"csisolatin5\": \"iso88599\",\n \"csisolatin6\": \"iso885910\",\n\n \"l1\": \"iso88591\",\n \"l2\": \"iso88592\",\n \"l3\": \"iso88593\",\n \"l4\": \"iso88594\",\n \"l5\": \"iso88599\",\n \"l6\": \"iso885910\",\n \"l7\": \"iso885913\",\n \"l8\": \"iso885914\",\n \"l9\": \"iso885915\",\n \"l10\": \"iso885916\",\n\n \"isoir14\": \"iso646jp\",\n \"isoir57\": \"iso646cn\",\n \"isoir100\": \"iso88591\",\n \"isoir101\": \"iso88592\",\n \"isoir109\": \"iso88593\",\n \"isoir110\": \"iso88594\",\n \"isoir144\": \"iso88595\",\n \"isoir127\": \"iso88596\",\n \"isoir126\": \"iso88597\",\n \"isoir138\": \"iso88598\",\n \"isoir148\": \"iso88599\",\n \"isoir157\": \"iso885910\",\n \"isoir166\": \"tis620\",\n \"isoir179\": \"iso885913\",\n \"isoir199\": \"iso885914\",\n \"isoir203\": \"iso885915\",\n \"isoir226\": \"iso885916\",\n\n \"cp819\": \"iso88591\",\n \"ibm819\": \"iso88591\",\n\n \"cyrillic\": \"iso88595\",\n\n \"arabic\": \"iso88596\",\n \"arabic8\": \"iso88596\",\n \"ecma114\": \"iso88596\",\n \"asmo708\": \"iso88596\",\n\n \"greek\" : \"iso88597\",\n \"greek8\" : \"iso88597\",\n \"ecma118\" : \"iso88597\",\n \"elot928\" : \"iso88597\",\n\n \"hebrew\": \"iso88598\",\n \"hebrew8\": \"iso88598\",\n\n \"turkish\": \"iso88599\",\n \"turkish8\": \"iso88599\",\n\n \"thai\": \"iso885911\",\n \"thai8\": \"iso885911\",\n\n \"celtic\": \"iso885914\",\n \"celtic8\": \"iso885914\",\n \"isoceltic\": \"iso885914\",\n\n \"tis6200\": \"tis620\",\n \"tis62025291\": \"tis620\",\n \"tis62025330\": \"tis620\",\n\n \"10000\": \"macroman\",\n \"10006\": \"macgreek\",\n \"10007\": \"maccyrillic\",\n \"10079\": \"maciceland\",\n \"10081\": \"macturkish\",\n\n \"cspc8codepage437\": \"cp437\",\n \"cspc775baltic\": \"cp775\",\n \"cspc850multilingual\": \"cp850\",\n \"cspcp852\": \"cp852\",\n \"cspc862latinhebrew\": \"cp862\",\n \"cpgr\": \"cp869\",\n\n \"msee\": \"cp1250\",\n \"mscyrl\": \"cp1251\",\n \"msansi\": \"cp1252\",\n \"msgreek\": \"cp1253\",\n \"msturk\": \"cp1254\",\n \"mshebr\": \"cp1255\",\n \"msarab\": \"cp1256\",\n \"winbaltrim\": \"cp1257\",\n\n \"cp20866\": \"koi8r\",\n \"20866\": \"koi8r\",\n \"ibm878\": \"koi8r\",\n \"cskoi8r\": \"koi8r\",\n\n \"cp21866\": \"koi8u\",\n \"21866\": \"koi8u\",\n \"ibm1168\": \"koi8u\",\n\n \"strk10482002\": \"rk1048\",\n\n \"tcvn5712\": \"tcvn\",\n \"tcvn57121\": \"tcvn\",\n\n \"gb198880\": \"iso646cn\",\n \"cn\": \"iso646cn\",\n\n \"csiso14jisc6220ro\": \"iso646jp\",\n \"jisc62201969ro\": \"iso646jp\",\n \"jp\": \"iso646jp\",\n\n \"cshproman8\": \"hproman8\",\n \"r8\": \"hproman8\",\n \"roman8\": \"hproman8\",\n \"xroman8\": \"hproman8\",\n \"ibm1051\": \"hproman8\",\n\n \"mac\": \"macintosh\",\n \"csmacintosh\": \"macintosh\",\n};\n\n", "\"use strict\";\n\n// Generated data for sbcs codec. Don't edit manually. Regenerate using generation/gen-sbcs.js script.\nmodule.exports = {\n \"437\": \"cp437\",\n \"737\": \"cp737\",\n \"775\": \"cp775\",\n \"850\": \"cp850\",\n \"852\": \"cp852\",\n \"855\": \"cp855\",\n \"856\": \"cp856\",\n \"857\": \"cp857\",\n \"858\": \"cp858\",\n \"860\": \"cp860\",\n \"861\": \"cp861\",\n \"862\": \"cp862\",\n \"863\": \"cp863\",\n \"864\": \"cp864\",\n \"865\": \"cp865\",\n \"866\": \"cp866\",\n \"869\": \"cp869\",\n \"874\": \"windows874\",\n \"922\": \"cp922\",\n \"1046\": \"cp1046\",\n \"1124\": \"cp1124\",\n \"1125\": \"cp1125\",\n \"1129\": \"cp1129\",\n \"1133\": \"cp1133\",\n \"1161\": \"cp1161\",\n \"1162\": \"cp1162\",\n \"1163\": \"cp1163\",\n \"1250\": \"windows1250\",\n \"1251\": \"windows1251\",\n \"1252\": \"windows1252\",\n \"1253\": \"windows1253\",\n \"1254\": \"windows1254\",\n \"1255\": \"windows1255\",\n \"1256\": \"windows1256\",\n \"1257\": \"windows1257\",\n \"1258\": \"windows1258\",\n \"28591\": \"iso88591\",\n \"28592\": \"iso88592\",\n \"28593\": \"iso88593\",\n \"28594\": \"iso88594\",\n \"28595\": \"iso88595\",\n \"28596\": \"iso88596\",\n \"28597\": \"iso88597\",\n \"28598\": \"iso88598\",\n \"28599\": \"iso88599\",\n \"28600\": \"iso885910\",\n \"28601\": \"iso885911\",\n \"28603\": \"iso885913\",\n \"28604\": \"iso885914\",\n \"28605\": \"iso885915\",\n \"28606\": \"iso885916\",\n \"windows874\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\uFFFD\uFFFD\uFFFD\u2026\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"win874\": \"windows874\",\n \"cp874\": \"windows874\",\n \"windows1250\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\uFFFD\u201E\u2026\u2020\u2021\uFFFD\u2030\u0160\u2039\u015A\u0164\u017D\u0179\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0161\u203A\u015B\u0165\u017E\u017A\u00A0\u02C7\u02D8\u0141\u00A4\u0104\u00A6\u00A7\u00A8\u00A9\u015E\u00AB\u00AC\u00AD\u00AE\u017B\u00B0\u00B1\u02DB\u0142\u00B4\u00B5\u00B6\u00B7\u00B8\u0105\u015F\u00BB\u013D\u02DD\u013E\u017C\u0154\u00C1\u00C2\u0102\u00C4\u0139\u0106\u00C7\u010C\u00C9\u0118\u00CB\u011A\u00CD\u00CE\u010E\u0110\u0143\u0147\u00D3\u00D4\u0150\u00D6\u00D7\u0158\u016E\u00DA\u0170\u00DC\u00DD\u0162\u00DF\u0155\u00E1\u00E2\u0103\u00E4\u013A\u0107\u00E7\u010D\u00E9\u0119\u00EB\u011B\u00ED\u00EE\u010F\u0111\u0144\u0148\u00F3\u00F4\u0151\u00F6\u00F7\u0159\u016F\u00FA\u0171\u00FC\u00FD\u0163\u02D9\"\n },\n \"win1250\": \"windows1250\",\n \"cp1250\": \"windows1250\",\n \"windows1251\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0402\u0403\u201A\u0453\u201E\u2026\u2020\u2021\u20AC\u2030\u0409\u2039\u040A\u040C\u040B\u040F\u0452\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0459\u203A\u045A\u045C\u045B\u045F\u00A0\u040E\u045E\u0408\u00A4\u0490\u00A6\u00A7\u0401\u00A9\u0404\u00AB\u00AC\u00AD\u00AE\u0407\u00B0\u00B1\u0406\u0456\u0491\u00B5\u00B6\u00B7\u0451\u2116\u0454\u00BB\u0458\u0405\u0455\u0457\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\"\n },\n \"win1251\": \"windows1251\",\n \"cp1251\": \"windows1251\",\n \"windows1252\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\uFFFD\u017D\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\uFFFD\u017E\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"win1252\": \"windows1252\",\n \"cp1252\": \"windows1252\",\n \"windows1253\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\uFFFD\u2030\uFFFD\u2039\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD\u00A0\u0385\u0386\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\uFFFD\u00AB\u00AC\u00AD\u00AE\u2015\u00B0\u00B1\u00B2\u00B3\u0384\u00B5\u00B6\u00B7\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD\"\n },\n \"win1253\": \"windows1253\",\n \"cp1253\": \"windows1253\",\n \"windows1254\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\uFFFD\uFFFD\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u011E\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u0130\u015E\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u011F\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u0131\u015F\u00FF\"\n },\n \"win1254\": \"windows1254\",\n \"cp1254\": \"windows1254\",\n \"windows1255\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\uFFFD\u2039\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD\u00A0\u00A1\u00A2\u00A3\u20AA\u00A5\u00A6\u00A7\u00A8\u00A9\u00D7\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00F7\u00BB\u00BC\u00BD\u00BE\u00BF\u05B0\u05B1\u05B2\u05B3\u05B4\u05B5\u05B6\u05B7\u05B8\u05B9\u05BA\u05BB\u05BC\u05BD\u05BE\u05BF\u05C0\u05C1\u05C2\u05C3\u05F0\u05F1\u05F2\u05F3\u05F4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\uFFFD\uFFFD\u200E\u200F\uFFFD\"\n },\n \"win1255\": \"windows1255\",\n \"cp1255\": \"windows1255\",\n \"windows1256\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\u067E\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0679\u2039\u0152\u0686\u0698\u0688\u06AF\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u06A9\u2122\u0691\u203A\u0153\u200C\u200D\u06BA\u00A0\u060C\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u06BE\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u061B\u00BB\u00BC\u00BD\u00BE\u061F\u06C1\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u00D7\u0637\u0638\u0639\u063A\u0640\u0641\u0642\u0643\u00E0\u0644\u00E2\u0645\u0646\u0647\u0648\u00E7\u00E8\u00E9\u00EA\u00EB\u0649\u064A\u00EE\u00EF\u064B\u064C\u064D\u064E\u00F4\u064F\u0650\u00F7\u0651\u00F9\u0652\u00FB\u00FC\u200E\u200F\u06D2\"\n },\n \"win1256\": \"windows1256\",\n \"cp1256\": \"windows1256\",\n \"windows1257\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\uFFFD\u201E\u2026\u2020\u2021\uFFFD\u2030\uFFFD\u2039\uFFFD\u00A8\u02C7\u00B8\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\uFFFD\u203A\uFFFD\u00AF\u02DB\uFFFD\u00A0\uFFFD\u00A2\u00A3\u00A4\uFFFD\u00A6\u00A7\u00D8\u00A9\u0156\u00AB\u00AC\u00AD\u00AE\u00C6\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00F8\u00B9\u0157\u00BB\u00BC\u00BD\u00BE\u00E6\u0104\u012E\u0100\u0106\u00C4\u00C5\u0118\u0112\u010C\u00C9\u0179\u0116\u0122\u0136\u012A\u013B\u0160\u0143\u0145\u00D3\u014C\u00D5\u00D6\u00D7\u0172\u0141\u015A\u016A\u00DC\u017B\u017D\u00DF\u0105\u012F\u0101\u0107\u00E4\u00E5\u0119\u0113\u010D\u00E9\u017A\u0117\u0123\u0137\u012B\u013C\u0161\u0144\u0146\u00F3\u014D\u00F5\u00F6\u00F7\u0173\u0142\u015B\u016B\u00FC\u017C\u017E\u02D9\"\n },\n \"win1257\": \"windows1257\",\n \"cp1257\": \"windows1257\",\n \"windows1258\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\uFFFD\u2039\u0152\uFFFD\uFFFD\uFFFD\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\uFFFD\u203A\u0153\uFFFD\uFFFD\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u0102\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u0300\u00CD\u00CE\u00CF\u0110\u00D1\u0309\u00D3\u00D4\u01A0\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u01AF\u0303\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u0301\u00ED\u00EE\u00EF\u0111\u00F1\u0323\u00F3\u00F4\u01A1\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u01B0\u20AB\u00FF\"\n },\n \"win1258\": \"windows1258\",\n \"cp1258\": \"windows1258\",\n \"iso88591\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"cp28591\": \"iso88591\",\n \"iso88592\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u02D8\u0141\u00A4\u013D\u015A\u00A7\u00A8\u0160\u015E\u0164\u0179\u00AD\u017D\u017B\u00B0\u0105\u02DB\u0142\u00B4\u013E\u015B\u02C7\u00B8\u0161\u015F\u0165\u017A\u02DD\u017E\u017C\u0154\u00C1\u00C2\u0102\u00C4\u0139\u0106\u00C7\u010C\u00C9\u0118\u00CB\u011A\u00CD\u00CE\u010E\u0110\u0143\u0147\u00D3\u00D4\u0150\u00D6\u00D7\u0158\u016E\u00DA\u0170\u00DC\u00DD\u0162\u00DF\u0155\u00E1\u00E2\u0103\u00E4\u013A\u0107\u00E7\u010D\u00E9\u0119\u00EB\u011B\u00ED\u00EE\u010F\u0111\u0144\u0148\u00F3\u00F4\u0151\u00F6\u00F7\u0159\u016F\u00FA\u0171\u00FC\u00FD\u0163\u02D9\"\n },\n \"cp28592\": \"iso88592\",\n \"iso88593\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0126\u02D8\u00A3\u00A4\uFFFD\u0124\u00A7\u00A8\u0130\u015E\u011E\u0134\u00AD\uFFFD\u017B\u00B0\u0127\u00B2\u00B3\u00B4\u00B5\u0125\u00B7\u00B8\u0131\u015F\u011F\u0135\u00BD\uFFFD\u017C\u00C0\u00C1\u00C2\uFFFD\u00C4\u010A\u0108\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\uFFFD\u00D1\u00D2\u00D3\u00D4\u0120\u00D6\u00D7\u011C\u00D9\u00DA\u00DB\u00DC\u016C\u015C\u00DF\u00E0\u00E1\u00E2\uFFFD\u00E4\u010B\u0109\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\uFFFD\u00F1\u00F2\u00F3\u00F4\u0121\u00F6\u00F7\u011D\u00F9\u00FA\u00FB\u00FC\u016D\u015D\u02D9\"\n },\n \"cp28593\": \"iso88593\",\n \"iso88594\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u0138\u0156\u00A4\u0128\u013B\u00A7\u00A8\u0160\u0112\u0122\u0166\u00AD\u017D\u00AF\u00B0\u0105\u02DB\u0157\u00B4\u0129\u013C\u02C7\u00B8\u0161\u0113\u0123\u0167\u014A\u017E\u014B\u0100\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u012E\u010C\u00C9\u0118\u00CB\u0116\u00CD\u00CE\u012A\u0110\u0145\u014C\u0136\u00D4\u00D5\u00D6\u00D7\u00D8\u0172\u00DA\u00DB\u00DC\u0168\u016A\u00DF\u0101\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u012F\u010D\u00E9\u0119\u00EB\u0117\u00ED\u00EE\u012B\u0111\u0146\u014D\u0137\u00F4\u00F5\u00F6\u00F7\u00F8\u0173\u00FA\u00FB\u00FC\u0169\u016B\u02D9\"\n },\n \"cp28594\": \"iso88594\",\n \"iso88595\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0401\u0402\u0403\u0404\u0405\u0406\u0407\u0408\u0409\u040A\u040B\u040C\u00AD\u040E\u040F\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u2116\u0451\u0452\u0453\u0454\u0455\u0456\u0457\u0458\u0459\u045A\u045B\u045C\u00A7\u045E\u045F\"\n },\n \"cp28595\": \"iso88595\",\n \"iso88596\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\uFFFD\uFFFD\uFFFD\u00A4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u060C\u00AD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u061B\uFFFD\uFFFD\uFFFD\u061F\uFFFD\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637\u0638\u0639\u063A\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0640\u0641\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"cp28596\": \"iso88596\",\n \"iso88597\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u2018\u2019\u00A3\u20AC\u20AF\u00A6\u00A7\u00A8\u00A9\u037A\u00AB\u00AC\u00AD\uFFFD\u2015\u00B0\u00B1\u00B2\u00B3\u0384\u0385\u0386\u00B7\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD\"\n },\n \"cp28597\": \"iso88597\",\n \"iso88598\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\uFFFD\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00D7\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00F7\u00BB\u00BC\u00BD\u00BE\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2017\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\uFFFD\uFFFD\u200E\u200F\uFFFD\"\n },\n \"cp28598\": \"iso88598\",\n \"iso88599\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u011E\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u0130\u015E\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u011F\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u0131\u015F\u00FF\"\n },\n \"cp28599\": \"iso88599\",\n \"iso885910\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u0112\u0122\u012A\u0128\u0136\u00A7\u013B\u0110\u0160\u0166\u017D\u00AD\u016A\u014A\u00B0\u0105\u0113\u0123\u012B\u0129\u0137\u00B7\u013C\u0111\u0161\u0167\u017E\u2015\u016B\u014B\u0100\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u012E\u010C\u00C9\u0118\u00CB\u0116\u00CD\u00CE\u00CF\u00D0\u0145\u014C\u00D3\u00D4\u00D5\u00D6\u0168\u00D8\u0172\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u0101\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u012F\u010D\u00E9\u0119\u00EB\u0117\u00ED\u00EE\u00EF\u00F0\u0146\u014D\u00F3\u00F4\u00F5\u00F6\u0169\u00F8\u0173\u00FA\u00FB\u00FC\u00FD\u00FE\u0138\"\n },\n \"cp28600\": \"iso885910\",\n \"iso885911\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"cp28601\": \"iso885911\",\n \"iso885913\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u201D\u00A2\u00A3\u00A4\u201E\u00A6\u00A7\u00D8\u00A9\u0156\u00AB\u00AC\u00AD\u00AE\u00C6\u00B0\u00B1\u00B2\u00B3\u201C\u00B5\u00B6\u00B7\u00F8\u00B9\u0157\u00BB\u00BC\u00BD\u00BE\u00E6\u0104\u012E\u0100\u0106\u00C4\u00C5\u0118\u0112\u010C\u00C9\u0179\u0116\u0122\u0136\u012A\u013B\u0160\u0143\u0145\u00D3\u014C\u00D5\u00D6\u00D7\u0172\u0141\u015A\u016A\u00DC\u017B\u017D\u00DF\u0105\u012F\u0101\u0107\u00E4\u00E5\u0119\u0113\u010D\u00E9\u017A\u0117\u0123\u0137\u012B\u013C\u0161\u0144\u0146\u00F3\u014D\u00F5\u00F6\u00F7\u0173\u0142\u015B\u016B\u00FC\u017C\u017E\u2019\"\n },\n \"cp28603\": \"iso885913\",\n \"iso885914\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u1E02\u1E03\u00A3\u010A\u010B\u1E0A\u00A7\u1E80\u00A9\u1E82\u1E0B\u1EF2\u00AD\u00AE\u0178\u1E1E\u1E1F\u0120\u0121\u1E40\u1E41\u00B6\u1E56\u1E81\u1E57\u1E83\u1E60\u1EF3\u1E84\u1E85\u1E61\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u0174\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u1E6A\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u0176\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u0175\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u1E6B\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u0177\u00FF\"\n },\n \"cp28604\": \"iso885914\",\n \"iso885915\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u20AC\u00A5\u0160\u00A7\u0161\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u017D\u00B5\u00B6\u00B7\u017E\u00B9\u00BA\u00BB\u0152\u0153\u0178\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"cp28605\": \"iso885915\",\n \"iso885916\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0104\u0105\u0141\u20AC\u201E\u0160\u00A7\u0161\u00A9\u0218\u00AB\u0179\u00AD\u017A\u017B\u00B0\u00B1\u010C\u0142\u017D\u201D\u00B6\u00B7\u017E\u010D\u0219\u00BB\u0152\u0153\u0178\u017C\u00C0\u00C1\u00C2\u0102\u00C4\u0106\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u0110\u0143\u00D2\u00D3\u00D4\u0150\u00D6\u015A\u0170\u00D9\u00DA\u00DB\u00DC\u0118\u021A\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u0107\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u0111\u0144\u00F2\u00F3\u00F4\u0151\u00F6\u015B\u0171\u00F9\u00FA\u00FB\u00FC\u0119\u021B\u00FF\"\n },\n \"cp28606\": \"iso885916\",\n \"cp437\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm437\": \"cp437\",\n \"csibm437\": \"cp437\",\n \"cp737\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u03C5\u03C6\u03C7\u03C8\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03C9\u03AC\u03AD\u03AE\u03CA\u03AF\u03CC\u03CD\u03CB\u03CE\u0386\u0388\u0389\u038A\u038C\u038E\u038F\u00B1\u2265\u2264\u03AA\u03AB\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm737\": \"cp737\",\n \"csibm737\": \"cp737\",\n \"cp775\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0106\u00FC\u00E9\u0101\u00E4\u0123\u00E5\u0107\u0142\u0113\u0156\u0157\u012B\u0179\u00C4\u00C5\u00C9\u00E6\u00C6\u014D\u00F6\u0122\u00A2\u015A\u015B\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u00A4\u0100\u012A\u00F3\u017B\u017C\u017A\u201D\u00A6\u00A9\u00AE\u00AC\u00BD\u00BC\u0141\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u0104\u010C\u0118\u0116\u2563\u2551\u2557\u255D\u012E\u0160\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0172\u016A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u017D\u0105\u010D\u0119\u0117\u012F\u0161\u0173\u016B\u017E\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u00D3\u00DF\u014C\u0143\u00F5\u00D5\u00B5\u0144\u0136\u0137\u013B\u013C\u0146\u0112\u0145\u2019\u00AD\u00B1\u201C\u00BE\u00B6\u00A7\u00F7\u201E\u00B0\u2219\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm775\": \"cp775\",\n \"csibm775\": \"cp775\",\n \"cp850\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u00F0\u00D0\u00CA\u00CB\u00C8\u0131\u00CD\u00CE\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\u00FE\u00DE\u00DA\u00DB\u00D9\u00FD\u00DD\u00AF\u00B4\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm850\": \"cp850\",\n \"csibm850\": \"cp850\",\n \"cp852\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u016F\u0107\u00E7\u0142\u00EB\u0150\u0151\u00EE\u0179\u00C4\u0106\u00C9\u0139\u013A\u00F4\u00F6\u013D\u013E\u015A\u015B\u00D6\u00DC\u0164\u0165\u0141\u00D7\u010D\u00E1\u00ED\u00F3\u00FA\u0104\u0105\u017D\u017E\u0118\u0119\u00AC\u017A\u010C\u015F\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u011A\u015E\u2563\u2551\u2557\u255D\u017B\u017C\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0102\u0103\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u0111\u0110\u010E\u00CB\u010F\u0147\u00CD\u00CE\u011B\u2518\u250C\u2588\u2584\u0162\u016E\u2580\u00D3\u00DF\u00D4\u0143\u0144\u0148\u0160\u0161\u0154\u00DA\u0155\u0170\u00FD\u00DD\u0163\u00B4\u00AD\u02DD\u02DB\u02C7\u02D8\u00A7\u00F7\u00B8\u00B0\u00A8\u02D9\u0171\u0158\u0159\u25A0\u00A0\"\n },\n \"ibm852\": \"cp852\",\n \"csibm852\": \"cp852\",\n \"cp855\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0452\u0402\u0453\u0403\u0451\u0401\u0454\u0404\u0455\u0405\u0456\u0406\u0457\u0407\u0458\u0408\u0459\u0409\u045A\u040A\u045B\u040B\u045C\u040C\u045E\u040E\u045F\u040F\u044E\u042E\u044A\u042A\u0430\u0410\u0431\u0411\u0446\u0426\u0434\u0414\u0435\u0415\u0444\u0424\u0433\u0413\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u0445\u0425\u0438\u0418\u2563\u2551\u2557\u255D\u0439\u0419\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u043A\u041A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u043B\u041B\u043C\u041C\u043D\u041D\u043E\u041E\u043F\u2518\u250C\u2588\u2584\u041F\u044F\u2580\u042F\u0440\u0420\u0441\u0421\u0442\u0422\u0443\u0423\u0436\u0416\u0432\u0412\u044C\u042C\u2116\u00AD\u044B\u042B\u0437\u0417\u0448\u0428\u044D\u042D\u0449\u0429\u0447\u0427\u00A7\u25A0\u00A0\"\n },\n \"ibm855\": \"cp855\",\n \"csibm855\": \"cp855\",\n \"cp856\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\uFFFD\u00A3\uFFFD\u00D7\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00AE\u00AC\u00BD\u00BC\uFFFD\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\uFFFD\uFFFD\uFFFD\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\uFFFD\uFFFD\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u2518\u250C\u2588\u2584\u00A6\uFFFD\u2580\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00B5\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u00AF\u00B4\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm856\": \"cp856\",\n \"csibm856\": \"cp856\",\n \"cp857\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u0131\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u0130\u00D6\u00DC\u00F8\u00A3\u00D8\u015E\u015F\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u011E\u011F\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u00BA\u00AA\u00CA\u00CB\u00C8\uFFFD\u00CD\u00CE\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\uFFFD\u00D7\u00DA\u00DB\u00D9\u00EC\u00FF\u00AF\u00B4\u00AD\u00B1\uFFFD\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm857\": \"cp857\",\n \"csibm857\": \"cp857\",\n \"cp858\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4\u00F0\u00D0\u00CA\u00CB\u00C8\u20AC\u00CD\u00CE\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\u00FE\u00DE\u00DA\u00DB\u00D9\u00FD\u00DD\u00AF\u00B4\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0\"\n },\n \"ibm858\": \"cp858\",\n \"csibm858\": \"cp858\",\n \"cp860\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E3\u00E0\u00C1\u00E7\u00EA\u00CA\u00E8\u00CD\u00D4\u00EC\u00C3\u00C2\u00C9\u00C0\u00C8\u00F4\u00F5\u00F2\u00DA\u00F9\u00CC\u00D5\u00DC\u00A2\u00A3\u00D9\u20A7\u00D3\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u00D2\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm860\": \"cp860\",\n \"csibm860\": \"cp860\",\n \"cp861\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00D0\u00F0\u00DE\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00FE\u00FB\u00DD\u00FD\u00D6\u00DC\u00F8\u00A3\u00D8\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00C1\u00CD\u00D3\u00DA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm861\": \"cp861\",\n \"csibm861\": \"cp861\",\n \"cp862\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm862\": \"cp862\",\n \"csibm862\": \"cp862\",\n \"cp863\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00C2\u00E0\u00B6\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u2017\u00C0\u00A7\u00C9\u00C8\u00CA\u00F4\u00CB\u00CF\u00FB\u00F9\u00A4\u00D4\u00DC\u00A2\u00A3\u00D9\u00DB\u0192\u00A6\u00B4\u00F3\u00FA\u00A8\u00B8\u00B3\u00AF\u00CE\u2310\u00AC\u00BD\u00BC\u00BE\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm863\": \"cp863\",\n \"csibm863\": \"cp863\",\n \"cp864\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#$\u066A&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007F\u00B0\u00B7\u2219\u221A\u2592\u2500\u2502\u253C\u2524\u252C\u251C\u2534\u2510\u250C\u2514\u2518\u03B2\u221E\u03C6\u00B1\u00BD\u00BC\u2248\u00AB\u00BB\uFEF7\uFEF8\uFFFD\uFFFD\uFEFB\uFEFC\uFFFD\u00A0\u00AD\uFE82\u00A3\u00A4\uFE84\uFFFD\uFFFD\uFE8E\uFE8F\uFE95\uFE99\u060C\uFE9D\uFEA1\uFEA5\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\uFED1\u061B\uFEB1\uFEB5\uFEB9\u061F\u00A2\uFE80\uFE81\uFE83\uFE85\uFECA\uFE8B\uFE8D\uFE91\uFE93\uFE97\uFE9B\uFE9F\uFEA3\uFEA7\uFEA9\uFEAB\uFEAD\uFEAF\uFEB3\uFEB7\uFEBB\uFEBF\uFEC1\uFEC5\uFECB\uFECF\u00A6\u00AC\u00F7\u00D7\uFEC9\u0640\uFED3\uFED7\uFEDB\uFEDF\uFEE3\uFEE7\uFEEB\uFEED\uFEEF\uFEF3\uFEBD\uFECC\uFECE\uFECD\uFEE1\uFE7D\u0651\uFEE5\uFEE9\uFEEC\uFEF0\uFEF2\uFED0\uFED5\uFEF5\uFEF6\uFEDD\uFED9\uFEF1\u25A0\uFFFD\"\n },\n \"ibm864\": \"cp864\",\n \"csibm864\": \"cp864\",\n \"cp865\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00A4\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0\"\n },\n \"ibm865\": \"cp865\",\n \"csibm865\": \"cp865\",\n \"cp866\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E\u00B0\u2219\u00B7\u221A\u2116\u00A4\u25A0\u00A0\"\n },\n \"ibm866\": \"cp866\",\n \"csibm866\": \"cp866\",\n \"cp869\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0386\uFFFD\u00B7\u00AC\u00A6\u2018\u2019\u0388\u2015\u0389\u038A\u03AA\u038C\uFFFD\uFFFD\u038E\u03AB\u00A9\u038F\u00B2\u00B3\u03AC\u00A3\u03AD\u03AE\u03AF\u03CA\u0390\u03CC\u03CD\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u00BD\u0398\u0399\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u039A\u039B\u039C\u039D\u2563\u2551\u2557\u255D\u039E\u039F\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u03A0\u03A1\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u2518\u250C\u2588\u2584\u03B4\u03B5\u2580\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u0384\u00AD\u00B1\u03C5\u03C6\u03C7\u00A7\u03C8\u0385\u00B0\u00A8\u03C9\u03CB\u03B0\u03CE\u25A0\u00A0\"\n },\n \"ibm869\": \"cp869\",\n \"csibm869\": \"cp869\",\n \"cp922\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u203E\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u0160\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u017D\u00DF\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u0161\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u017E\u00FF\"\n },\n \"ibm922\": \"cp922\",\n \"csibm922\": \"cp922\",\n \"cp1046\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFE88\u00D7\u00F7\uF8F6\uF8F5\uF8F4\uF8F7\uFE71\u0088\u25A0\u2502\u2500\u2510\u250C\u2514\u2518\uFE79\uFE7B\uFE7D\uFE7F\uFE77\uFE8A\uFEF0\uFEF3\uFEF2\uFECE\uFECF\uFED0\uFEF6\uFEF8\uFEFA\uFEFC\u00A0\uF8FA\uF8F9\uF8F8\u00A4\uF8FB\uFE8B\uFE91\uFE97\uFE9B\uFE9F\uFEA3\u060C\u00AD\uFEA7\uFEB3\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\uFEB7\u061B\uFEBB\uFEBF\uFECA\u061F\uFECB\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637\uFEC7\u0639\u063A\uFECC\uFE82\uFE84\uFE8E\uFED3\u0640\u0641\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\uFED7\uFEDB\uFEDF\uF8FC\uFEF5\uFEF7\uFEF9\uFEFB\uFEE3\uFEE7\uFEEC\uFEE9\uFFFD\"\n },\n \"ibm1046\": \"cp1046\",\n \"csibm1046\": \"cp1046\",\n \"cp1124\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0401\u0402\u0490\u0404\u0405\u0406\u0407\u0408\u0409\u040A\u040B\u040C\u00AD\u040E\u040F\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u2116\u0451\u0452\u0491\u0454\u0455\u0456\u0457\u0458\u0459\u045A\u045B\u045C\u00A7\u045E\u045F\"\n },\n \"ibm1124\": \"cp1124\",\n \"csibm1124\": \"cp1124\",\n \"cp1125\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0490\u0491\u0404\u0454\u0406\u0456\u0407\u0457\u00B7\u221A\u2116\u00A4\u25A0\u00A0\"\n },\n \"ibm1125\": \"cp1125\",\n \"csibm1125\": \"cp1125\",\n \"cp1129\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u0153\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u0178\u00B5\u00B6\u00B7\u0152\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u0102\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u0300\u00CD\u00CE\u00CF\u0110\u00D1\u0309\u00D3\u00D4\u01A0\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u01AF\u0303\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u0301\u00ED\u00EE\u00EF\u0111\u00F1\u0323\u00F3\u00F4\u01A1\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u01B0\u20AB\u00FF\"\n },\n \"ibm1129\": \"cp1129\",\n \"csibm1129\": \"cp1129\",\n \"cp1133\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0E81\u0E82\u0E84\u0E87\u0E88\u0EAA\u0E8A\u0E8D\u0E94\u0E95\u0E96\u0E97\u0E99\u0E9A\u0E9B\u0E9C\u0E9D\u0E9E\u0E9F\u0EA1\u0EA2\u0EA3\u0EA5\u0EA7\u0EAB\u0EAD\u0EAE\uFFFD\uFFFD\uFFFD\u0EAF\u0EB0\u0EB2\u0EB3\u0EB4\u0EB5\u0EB6\u0EB7\u0EB8\u0EB9\u0EBC\u0EB1\u0EBB\u0EBD\uFFFD\uFFFD\uFFFD\u0EC0\u0EC1\u0EC2\u0EC3\u0EC4\u0EC8\u0EC9\u0ECA\u0ECB\u0ECC\u0ECD\u0EC6\uFFFD\u0EDC\u0EDD\u20AD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0ED0\u0ED1\u0ED2\u0ED3\u0ED4\u0ED5\u0ED6\u0ED7\u0ED8\u0ED9\uFFFD\uFFFD\u00A2\u00AC\u00A6\uFFFD\"\n },\n \"ibm1133\": \"cp1133\",\n \"csibm1133\": \"cp1133\",\n \"cp1161\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0E48\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\u0E49\u0E4A\u0E4B\u20AC\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\u00A2\u00AC\u00A6\u00A0\"\n },\n \"ibm1161\": \"cp1161\",\n \"csibm1161\": \"cp1161\",\n \"cp1162\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u20AC\u0081\u0082\u0083\u0084\u2026\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"ibm1162\": \"cp1162\",\n \"csibm1162\": \"cp1162\",\n \"cp1163\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00A1\u00A2\u00A3\u20AC\u00A5\u00A6\u00A7\u0153\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u0178\u00B5\u00B6\u00B7\u0152\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0\u00C1\u00C2\u0102\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u0300\u00CD\u00CE\u00CF\u0110\u00D1\u0309\u00D3\u00D4\u01A0\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB\u00DC\u01AF\u0303\u00DF\u00E0\u00E1\u00E2\u0103\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u0301\u00ED\u00EE\u00EF\u0111\u00F1\u0323\u00F3\u00F4\u01A1\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u01B0\u20AB\u00FF\"\n },\n \"ibm1163\": \"cp1163\",\n \"csibm1163\": \"cp1163\",\n \"maccroatian\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u0160\u2122\u00B4\u00A8\u2260\u017D\u00D8\u221E\u00B1\u2264\u2265\u2206\u00B5\u2202\u2211\u220F\u0161\u222B\u00AA\u00BA\u2126\u017E\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u0106\u00AB\u010C\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\uFFFD\u00A9\u2044\u00A4\u2039\u203A\u00C6\u00BB\u2013\u00B7\u201A\u201E\u2030\u00C2\u0107\u00C1\u010D\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\u0111\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u03C0\u00CB\u02DA\u00B8\u00CA\u00E6\u02C7\"\n },\n \"maccyrillic\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u0406\u00AE\u00A9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\u00B1\u2264\u2265\u0456\u00B5\u2202\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u00A4\"\n },\n \"macgreek\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00B9\u00B2\u00C9\u00B3\u00D6\u00DC\u0385\u00E0\u00E2\u00E4\u0384\u00A8\u00E7\u00E9\u00E8\u00EA\u00EB\u00A3\u2122\u00EE\u00EF\u2022\u00BD\u2030\u00F4\u00F6\u00A6\u00AD\u00F9\u00FB\u00FC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\u00DF\u00AE\u00A9\u03A3\u03AA\u00A7\u2260\u00B0\u0387\u0391\u00B1\u2264\u2265\u00A5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\u00AC\u039F\u03A1\u2248\u03A4\u00AB\u00BB\u2026\u00A0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\u00F7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\uFFFD\"\n },\n \"maciceland\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u00DD\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u00D0\u00F0\u00DE\u00FE\u00FD\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macroman\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u2039\u203A\uFB01\uFB02\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macromania\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u0102\u015E\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u0103\u015F\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u2039\u203A\u0162\u0163\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macthai\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00AB\u00BB\u2026\uF88C\uF88F\uF892\uF895\uF898\uF88B\uF88E\uF891\uF894\uF897\u201C\u201D\uF899\uFFFD\u2022\uF884\uF889\uF885\uF886\uF887\uF888\uF88A\uF88D\uF890\uF893\uF896\u2018\u2019\uFFFD\u00A0\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFEFF\u200B\u2013\u2014\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u2122\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u00AE\u00A9\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"macturkish\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\uFFFD\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"macukraine\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\u00B0\u0490\u00A3\u00A7\u2022\u00B6\u0406\u00AE\u00A9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\u00B1\u2264\u2265\u0456\u00B5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u00A4\"\n },\n \"koi8r\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u2553\u2554\u2555\u2556\u2557\u2558\u2559\u255A\u255B\u255C\u255D\u255E\u255F\u2560\u2561\u0401\u2562\u2563\u2564\u2565\u2566\u2567\u2568\u2569\u256A\u256B\u256C\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"koi8u\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u0454\u2554\u0456\u0457\u2557\u2558\u2559\u255A\u255B\u0491\u255D\u255E\u255F\u2560\u2561\u0401\u0404\u2563\u0406\u0407\u2566\u2567\u2568\u2569\u256A\u0490\u256C\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"koi8ru\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u0454\u2554\u0456\u0457\u2557\u2558\u2559\u255A\u255B\u0491\u045E\u255E\u255F\u2560\u2561\u0401\u0404\u2563\u0406\u0407\u2566\u2567\u2568\u2569\u256A\u0490\u040E\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"koi8t\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u049B\u0493\u201A\u0492\u201E\u2026\u2020\u2021\uFFFD\u2030\u04B3\u2039\u04B2\u04B7\u04B6\uFFFD\u049A\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u04EF\u04EE\u0451\u00A4\u04E3\u00A6\u00A7\uFFFD\uFFFD\uFFFD\u00AB\u00AC\u00AD\u00AE\uFFFD\u00B0\u00B1\u00B2\u0401\uFFFD\u04E2\u00B6\u00B7\uFFFD\u2116\uFFFD\u00BB\uFFFD\uFFFD\uFFFD\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A\"\n },\n \"armscii8\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\uFFFD\u0587\u0589)(\u00BB\u00AB\u2014.\u055D,-\u058A\u2026\u055C\u055B\u055E\u0531\u0561\u0532\u0562\u0533\u0563\u0534\u0564\u0535\u0565\u0536\u0566\u0537\u0567\u0538\u0568\u0539\u0569\u053A\u056A\u053B\u056B\u053C\u056C\u053D\u056D\u053E\u056E\u053F\u056F\u0540\u0570\u0541\u0571\u0542\u0572\u0543\u0573\u0544\u0574\u0545\u0575\u0546\u0576\u0547\u0577\u0548\u0578\u0549\u0579\u054A\u057A\u054B\u057B\u054C\u057C\u054D\u057D\u054E\u057E\u054F\u057F\u0550\u0580\u0551\u0581\u0552\u0582\u0553\u0583\u0554\u0584\u0555\u0585\u0556\u0586\u055A\uFFFD\"\n },\n \"rk1048\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0402\u0403\u201A\u0453\u201E\u2026\u2020\u2021\u20AC\u2030\u0409\u2039\u040A\u049A\u04BA\u040F\u0452\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0459\u203A\u045A\u049B\u04BB\u045F\u00A0\u04B0\u04B1\u04D8\u00A4\u04E8\u00A6\u00A7\u0401\u00A9\u0492\u00AB\u00AC\u00AD\u00AE\u04AE\u00B0\u00B1\u0406\u0456\u04E9\u00B5\u00B6\u00B7\u0451\u2116\u0493\u00BB\u04D9\u04A2\u04A3\u04AF\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\"\n },\n \"tcvn\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\u00DA\u1EE4\\u0003\u1EEA\u1EEC\u1EEE\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\u1EE8\u1EF0\u1EF2\u1EF6\u1EF8\u00DD\u1EF4\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007F\u00C0\u1EA2\u00C3\u00C1\u1EA0\u1EB6\u1EAC\u00C8\u1EBA\u1EBC\u00C9\u1EB8\u1EC6\u00CC\u1EC8\u0128\u00CD\u1ECA\u00D2\u1ECE\u00D5\u00D3\u1ECC\u1ED8\u1EDC\u1EDE\u1EE0\u1EDA\u1EE2\u00D9\u1EE6\u0168\u00A0\u0102\u00C2\u00CA\u00D4\u01A0\u01AF\u0110\u0103\u00E2\u00EA\u00F4\u01A1\u01B0\u0111\u1EB0\u0300\u0309\u0303\u0301\u0323\u00E0\u1EA3\u00E3\u00E1\u1EA1\u1EB2\u1EB1\u1EB3\u1EB5\u1EAF\u1EB4\u1EAE\u1EA6\u1EA8\u1EAA\u1EA4\u1EC0\u1EB7\u1EA7\u1EA9\u1EAB\u1EA5\u1EAD\u00E8\u1EC2\u1EBB\u1EBD\u00E9\u1EB9\u1EC1\u1EC3\u1EC5\u1EBF\u1EC7\u00EC\u1EC9\u1EC4\u1EBE\u1ED2\u0129\u00ED\u1ECB\u00F2\u1ED4\u1ECF\u00F5\u00F3\u1ECD\u1ED3\u1ED5\u1ED7\u1ED1\u1ED9\u1EDD\u1EDF\u1EE1\u1EDB\u1EE3\u00F9\u1ED6\u1EE7\u0169\u00FA\u1EE5\u1EEB\u1EED\u1EEF\u1EE9\u1EF1\u1EF3\u1EF7\u1EF9\u00FD\u1EF5\u1ED0\"\n },\n \"georgianacademy\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u008D\u008E\u008F\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u009D\u009E\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u10D0\u10D1\u10D2\u10D3\u10D4\u10D5\u10D6\u10D7\u10D8\u10D9\u10DA\u10DB\u10DC\u10DD\u10DE\u10DF\u10E0\u10E1\u10E2\u10E3\u10E4\u10E5\u10E6\u10E7\u10E8\u10E9\u10EA\u10EB\u10EC\u10ED\u10EE\u10EF\u10F0\u10F1\u10F2\u10F3\u10F4\u10F5\u10F6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"georgianps\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u008D\u008E\u008F\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u009D\u009E\u0178\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u10D0\u10D1\u10D2\u10D3\u10D4\u10D5\u10D6\u10F1\u10D7\u10D8\u10D9\u10DA\u10DB\u10DC\u10F2\u10DD\u10DE\u10DF\u10E0\u10E1\u10E2\u10F3\u10E3\u10E4\u10E5\u10E6\u10E7\u10E8\u10E9\u10EA\u10EB\u10EC\u10ED\u10EE\u10F4\u10EF\u10F0\u10F5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF\"\n },\n \"pt154\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0496\u0492\u04EE\u0493\u201E\u2026\u04B6\u04AE\u04B2\u04AF\u04A0\u04E2\u04A2\u049A\u04BA\u04B8\u0497\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u04B3\u04B7\u04A1\u04E3\u04A3\u049B\u04BB\u04B9\u00A0\u040E\u045E\u0408\u04E8\u0498\u04B0\u00A7\u0401\u00A9\u04D8\u00AB\u00AC\u04EF\u00AE\u049C\u00B0\u04B1\u0406\u0456\u0499\u04E9\u00B6\u00B7\u0451\u2116\u04D9\u00BB\u0458\u04AA\u04AB\u049D\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\"\n },\n \"viscii\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\u1EB2\\u0003\\u0004\u1EB4\u1EAA\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\u1EF6\\u0015\\u0016\\u0017\\u0018\u1EF8\\u001a\\u001b\\u001c\\u001d\u1EF4\\u001f !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u007F\u1EA0\u1EAE\u1EB0\u1EB6\u1EA4\u1EA6\u1EA8\u1EAC\u1EBC\u1EB8\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EE2\u1EDA\u1EDC\u1EDE\u1ECA\u1ECE\u1ECC\u1EC8\u1EE6\u0168\u1EE4\u1EF2\u00D5\u1EAF\u1EB1\u1EB7\u1EA5\u1EA7\u1EA9\u1EAD\u1EBD\u1EB9\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1ED1\u1ED3\u1ED5\u1ED7\u1EE0\u01A0\u1ED9\u1EDD\u1EDF\u1ECB\u1EF0\u1EE8\u1EEA\u1EEC\u01A1\u1EDB\u01AF\u00C0\u00C1\u00C2\u00C3\u1EA2\u0102\u1EB3\u1EB5\u00C8\u00C9\u00CA\u1EBA\u00CC\u00CD\u0128\u1EF3\u0110\u1EE9\u00D2\u00D3\u00D4\u1EA1\u1EF7\u1EEB\u1EED\u00D9\u00DA\u1EF9\u1EF5\u00DD\u1EE1\u01B0\u00E0\u00E1\u00E2\u00E3\u1EA3\u0103\u1EEF\u1EAB\u00E8\u00E9\u00EA\u1EBB\u00EC\u00ED\u0129\u1EC9\u0111\u1EF1\u00F2\u00F3\u00F4\u00F5\u1ECF\u1ECD\u1EE5\u00F9\u00FA\u0169\u1EE7\u00FD\u1EE3\u1EEE\"\n },\n \"iso646cn\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#\u00A5%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}\u203E\u007F\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"iso646jp\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\u00A5]^_`abcdefghijklmnopqrstuvwxyz{|}\u203E\u007F\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"hproman8\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F\u00A0\u00C0\u00C2\u00C8\u00CA\u00CB\u00CE\u00CF\u00B4\u02CB\u02C6\u00A8\u02DC\u00D9\u00DB\u20A4\u00AF\u00DD\u00FD\u00B0\u00C7\u00E7\u00D1\u00F1\u00A1\u00BF\u00A4\u00A3\u00A5\u00A7\u0192\u00A2\u00E2\u00EA\u00F4\u00FB\u00E1\u00E9\u00F3\u00FA\u00E0\u00E8\u00F2\u00F9\u00E4\u00EB\u00F6\u00FC\u00C5\u00EE\u00D8\u00C6\u00E5\u00ED\u00F8\u00E6\u00C4\u00EC\u00D6\u00DC\u00C9\u00EF\u00DF\u00D4\u00C1\u00C3\u00E3\u00D0\u00F0\u00CD\u00CC\u00D3\u00D2\u00D5\u00F5\u0160\u0161\u00DA\u0178\u00FF\u00DE\u00FE\u00B7\u00B5\u00B6\u00BE\u2014\u00BC\u00BD\u00AA\u00BA\u00AB\u25A0\u00BB\u00B1\uFFFD\"\n },\n \"macintosh\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\u00C4\u00C5\u00C7\u00C9\u00D1\u00D6\u00DC\u00E1\u00E0\u00E2\u00E4\u00E3\u00E5\u00E7\u00E9\u00E8\u00EA\u00EB\u00ED\u00EC\u00EE\u00EF\u00F1\u00F3\u00F2\u00F4\u00F6\u00F5\u00FA\u00F9\u00FB\u00FC\u2020\u00B0\u00A2\u00A3\u00A7\u2022\u00B6\u00DF\u00AE\u00A9\u2122\u00B4\u00A8\u2260\u00C6\u00D8\u221E\u00B1\u2264\u2265\u00A5\u00B5\u2202\u2211\u220F\u03C0\u222B\u00AA\u00BA\u2126\u00E6\u00F8\u00BF\u00A1\u00AC\u221A\u0192\u2248\u2206\u00AB\u00BB\u2026\u00A0\u00C0\u00C3\u00D5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u00F7\u25CA\u00FF\u0178\u2044\u00A4\u2039\u203A\uFB01\uFB02\u2021\u00B7\u201A\u201E\u2030\u00C2\u00CA\u00C1\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00D3\u00D4\uFFFD\u00D2\u00DA\u00DB\u00D9\u0131\u02C6\u02DC\u00AF\u02D8\u02D9\u02DA\u00B8\u02DD\u02DB\u02C7\"\n },\n \"ascii\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\"\n },\n \"tis620\": {\n \"type\": \"_sbcs\",\n \"chars\": \"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37\u0E38\u0E39\u0E3A\uFFFD\uFFFD\uFFFD\uFFFD\u0E3F\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57\u0E58\u0E59\u0E5A\u0E5B\uFFFD\uFFFD\uFFFD\uFFFD\"\n }\n}", "\"use strict\";\nvar Buffer = require(\"safer-buffer\").Buffer;\n\n// Multibyte codec. In this scheme, a character is represented by 1 or more bytes.\n// Our codec supports UTF-16 surrogates, extensions for GB18030 and unicode sequences.\n// To save memory and loading time, we read table files only when requested.\n\nexports._dbcs = DBCSCodec;\n\nvar UNASSIGNED = -1,\n GB18030_CODE = -2,\n SEQ_START = -10,\n NODE_START = -1000,\n UNASSIGNED_NODE = new Array(0x100),\n DEF_CHAR = -1;\n\nfor (var i = 0; i < 0x100; i++)\n UNASSIGNED_NODE[i] = UNASSIGNED;\n\n\n// Class DBCSCodec reads and initializes mapping tables.\nfunction DBCSCodec(codecOptions, iconv) {\n this.encodingName = codecOptions.encodingName;\n if (!codecOptions)\n throw new Error(\"DBCS codec is called without the data.\")\n if (!codecOptions.table)\n throw new Error(\"Encoding '\" + this.encodingName + \"' has no data.\");\n\n // Load tables.\n var mappingTable = codecOptions.table();\n\n\n // Decode tables: MBCS -> Unicode.\n\n // decodeTables is a trie, encoded as an array of arrays of integers. Internal arrays are trie nodes and all have len = 256.\n // Trie root is decodeTables[0].\n // Values: >= 0 -> unicode character code. can be > 0xFFFF\n // == UNASSIGNED -> unknown/unassigned sequence.\n // == GB18030_CODE -> this is the end of a GB18030 4-byte sequence.\n // <= NODE_START -> index of the next node in our trie to process next byte.\n // <= SEQ_START -> index of the start of a character code sequence, in decodeTableSeq.\n this.decodeTables = [];\n this.decodeTables[0] = UNASSIGNED_NODE.slice(0); // Create root node.\n\n // Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here. \n this.decodeTableSeq = [];\n\n // Actual mapping tables consist of chunks. Use them to fill up decode tables.\n for (var i = 0; i < mappingTable.length; i++)\n this._addDecodeChunk(mappingTable[i]);\n\n this.defaultCharUnicode = iconv.defaultCharUnicode;\n\n \n // Encode tables: Unicode -> DBCS.\n\n // `encodeTable` is array mapping from unicode char to encoded char. All its values are integers for performance.\n // Because it can be sparse, it is represented as array of buckets by 256 chars each. Bucket can be null.\n // Values: >= 0 -> it is a normal char. Write the value (if <=256 then 1 byte, if <=65536 then 2 bytes, etc.).\n // == UNASSIGNED -> no conversion found. Output a default char.\n // <= SEQ_START -> it's an index in encodeTableSeq, see below. The character starts a sequence.\n this.encodeTable = [];\n \n // `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of\n // objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key\n // means end of sequence (needed when one sequence is a strict subsequence of another).\n // Objects are kept separately from encodeTable to increase performance.\n this.encodeTableSeq = [];\n\n // Some chars can be decoded, but need not be encoded.\n var skipEncodeChars = {};\n if (codecOptions.encodeSkipVals)\n for (var i = 0; i < codecOptions.encodeSkipVals.length; i++) {\n var val = codecOptions.encodeSkipVals[i];\n if (typeof val === 'number')\n skipEncodeChars[val] = true;\n else\n for (var j = val.from; j <= val.to; j++)\n skipEncodeChars[j] = true;\n }\n \n // Use decode trie to recursively fill out encode tables.\n this._fillEncodeTable(0, 0, skipEncodeChars);\n\n // Add more encoding pairs when needed.\n if (codecOptions.encodeAdd) {\n for (var uChar in codecOptions.encodeAdd)\n if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar))\n this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]);\n }\n\n this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)];\n if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0]['?'];\n if (this.defCharSB === UNASSIGNED) this.defCharSB = \"?\".charCodeAt(0);\n\n\n // Load & create GB18030 tables when needed.\n if (typeof codecOptions.gb18030 === 'function') {\n this.gb18030 = codecOptions.gb18030(); // Load GB18030 ranges.\n\n // Add GB18030 decode tables.\n var thirdByteNodeIdx = this.decodeTables.length;\n var thirdByteNode = this.decodeTables[thirdByteNodeIdx] = UNASSIGNED_NODE.slice(0);\n\n var fourthByteNodeIdx = this.decodeTables.length;\n var fourthByteNode = this.decodeTables[fourthByteNodeIdx] = UNASSIGNED_NODE.slice(0);\n\n for (var i = 0x81; i <= 0xFE; i++) {\n var secondByteNodeIdx = NODE_START - this.decodeTables[0][i];\n var secondByteNode = this.decodeTables[secondByteNodeIdx];\n for (var j = 0x30; j <= 0x39; j++)\n secondByteNode[j] = NODE_START - thirdByteNodeIdx;\n }\n for (var i = 0x81; i <= 0xFE; i++)\n thirdByteNode[i] = NODE_START - fourthByteNodeIdx;\n for (var i = 0x30; i <= 0x39; i++)\n fourthByteNode[i] = GB18030_CODE\n } \n}\n\nDBCSCodec.prototype.encoder = DBCSEncoder;\nDBCSCodec.prototype.decoder = DBCSDecoder;\n\n// Decoder helpers\nDBCSCodec.prototype._getDecodeTrieNode = function(addr) {\n var bytes = [];\n for (; addr > 0; addr >>= 8)\n bytes.push(addr & 0xFF);\n if (bytes.length == 0)\n bytes.push(0);\n\n var node = this.decodeTables[0];\n for (var i = bytes.length-1; i > 0; i--) { // Traverse nodes deeper into the trie.\n var val = node[bytes[i]];\n\n if (val == UNASSIGNED) { // Create new node.\n node[bytes[i]] = NODE_START - this.decodeTables.length;\n this.decodeTables.push(node = UNASSIGNED_NODE.slice(0));\n }\n else if (val <= NODE_START) { // Existing node.\n node = this.decodeTables[NODE_START - val];\n }\n else\n throw new Error(\"Overwrite byte in \" + this.encodingName + \", addr: \" + addr.toString(16));\n }\n return node;\n}\n\n\nDBCSCodec.prototype._addDecodeChunk = function(chunk) {\n // First element of chunk is the hex mbcs code where we start.\n var curAddr = parseInt(chunk[0], 16);\n\n // Choose the decoding node where we'll write our chars.\n var writeTable = this._getDecodeTrieNode(curAddr);\n curAddr = curAddr & 0xFF;\n\n // Write all other elements of the chunk to the table.\n for (var k = 1; k < chunk.length; k++) {\n var part = chunk[k];\n if (typeof part === \"string\") { // String, write as-is.\n for (var l = 0; l < part.length;) {\n var code = part.charCodeAt(l++);\n if (0xD800 <= code && code < 0xDC00) { // Decode surrogate\n var codeTrail = part.charCodeAt(l++);\n if (0xDC00 <= codeTrail && codeTrail < 0xE000)\n writeTable[curAddr++] = 0x10000 + (code - 0xD800) * 0x400 + (codeTrail - 0xDC00);\n else\n throw new Error(\"Incorrect surrogate pair in \" + this.encodingName + \" at chunk \" + chunk[0]);\n }\n else if (0x0FF0 < code && code <= 0x0FFF) { // Character sequence (our own encoding used)\n var len = 0xFFF - code + 2;\n var seq = [];\n for (var m = 0; m < len; m++)\n seq.push(part.charCodeAt(l++)); // Simple variation: don't support surrogates or subsequences in seq.\n\n writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;\n this.decodeTableSeq.push(seq);\n }\n else\n writeTable[curAddr++] = code; // Basic char\n }\n } \n else if (typeof part === \"number\") { // Integer, meaning increasing sequence starting with prev character.\n var charCode = writeTable[curAddr - 1] + 1;\n for (var l = 0; l < part; l++)\n writeTable[curAddr++] = charCode++;\n }\n else\n throw new Error(\"Incorrect type '\" + typeof part + \"' given in \" + this.encodingName + \" at chunk \" + chunk[0]);\n }\n if (curAddr > 0xFF)\n throw new Error(\"Incorrect chunk in \" + this.encodingName + \" at addr \" + chunk[0] + \": too long\" + curAddr);\n}\n\n// Encoder helpers\nDBCSCodec.prototype._getEncodeBucket = function(uCode) {\n var high = uCode >> 8; // This could be > 0xFF because of astral characters.\n if (this.encodeTable[high] === undefined)\n this.encodeTable[high] = UNASSIGNED_NODE.slice(0); // Create bucket on demand.\n return this.encodeTable[high];\n}\n\nDBCSCodec.prototype._setEncodeChar = function(uCode, dbcsCode) {\n var bucket = this._getEncodeBucket(uCode);\n var low = uCode & 0xFF;\n if (bucket[low] <= SEQ_START)\n this.encodeTableSeq[SEQ_START-bucket[low]][DEF_CHAR] = dbcsCode; // There's already a sequence, set a single-char subsequence of it.\n else if (bucket[low] == UNASSIGNED)\n bucket[low] = dbcsCode;\n}\n\nDBCSCodec.prototype._setEncodeSequence = function(seq, dbcsCode) {\n \n // Get the root of character tree according to first character of the sequence.\n var uCode = seq[0];\n var bucket = this._getEncodeBucket(uCode);\n var low = uCode & 0xFF;\n\n var node;\n if (bucket[low] <= SEQ_START) {\n // There's already a sequence with - use it.\n node = this.encodeTableSeq[SEQ_START-bucket[low]];\n }\n else {\n // There was no sequence object - allocate a new one.\n node = {};\n if (bucket[low] !== UNASSIGNED) node[DEF_CHAR] = bucket[low]; // If a char was set before - make it a single-char subsequence.\n bucket[low] = SEQ_START - this.encodeTableSeq.length;\n this.encodeTableSeq.push(node);\n }\n\n // Traverse the character tree, allocating new nodes as needed.\n for (var j = 1; j < seq.length-1; j++) {\n var oldVal = node[uCode];\n if (typeof oldVal === 'object')\n node = oldVal;\n else {\n node = node[uCode] = {}\n if (oldVal !== undefined)\n node[DEF_CHAR] = oldVal\n }\n }\n\n // Set the leaf to given dbcsCode.\n uCode = seq[seq.length-1];\n node[uCode] = dbcsCode;\n}\n\nDBCSCodec.prototype._fillEncodeTable = function(nodeIdx, prefix, skipEncodeChars) {\n var node = this.decodeTables[nodeIdx];\n for (var i = 0; i < 0x100; i++) {\n var uCode = node[i];\n var mbCode = prefix + i;\n if (skipEncodeChars[mbCode])\n continue;\n\n if (uCode >= 0)\n this._setEncodeChar(uCode, mbCode);\n else if (uCode <= NODE_START)\n this._fillEncodeTable(NODE_START - uCode, mbCode << 8, skipEncodeChars);\n else if (uCode <= SEQ_START)\n this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode);\n }\n}\n\n\n\n// == Encoder ==================================================================\n\nfunction DBCSEncoder(options, codec) {\n // Encoder state\n this.leadSurrogate = -1;\n this.seqObj = undefined;\n \n // Static data\n this.encodeTable = codec.encodeTable;\n this.encodeTableSeq = codec.encodeTableSeq;\n this.defaultCharSingleByte = codec.defCharSB;\n this.gb18030 = codec.gb18030;\n}\n\nDBCSEncoder.prototype.write = function(str) {\n var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3)),\n leadSurrogate = this.leadSurrogate,\n seqObj = this.seqObj, nextChar = -1,\n i = 0, j = 0;\n\n while (true) {\n // 0. Get next character.\n if (nextChar === -1) {\n if (i == str.length) break;\n var uCode = str.charCodeAt(i++);\n }\n else {\n var uCode = nextChar;\n nextChar = -1; \n }\n\n // 1. Handle surrogates.\n if (0xD800 <= uCode && uCode < 0xE000) { // Char is one of surrogates.\n if (uCode < 0xDC00) { // We've got lead surrogate.\n if (leadSurrogate === -1) {\n leadSurrogate = uCode;\n continue;\n } else {\n leadSurrogate = uCode;\n // Double lead surrogate found.\n uCode = UNASSIGNED;\n }\n } else { // We've got trail surrogate.\n if (leadSurrogate !== -1) {\n uCode = 0x10000 + (leadSurrogate - 0xD800) * 0x400 + (uCode - 0xDC00);\n leadSurrogate = -1;\n } else {\n // Incomplete surrogate pair - only trail surrogate found.\n uCode = UNASSIGNED;\n }\n \n }\n }\n else if (leadSurrogate !== -1) {\n // Incomplete surrogate pair - only lead surrogate found.\n nextChar = uCode; uCode = UNASSIGNED; // Write an error, then current char.\n leadSurrogate = -1;\n }\n\n // 2. Convert uCode character.\n var dbcsCode = UNASSIGNED;\n if (seqObj !== undefined && uCode != UNASSIGNED) { // We are in the middle of the sequence\n var resCode = seqObj[uCode];\n if (typeof resCode === 'object') { // Sequence continues.\n seqObj = resCode;\n continue;\n\n } else if (typeof resCode == 'number') { // Sequence finished. Write it.\n dbcsCode = resCode;\n\n } else if (resCode == undefined) { // Current character is not part of the sequence.\n\n // Try default character for this sequence\n resCode = seqObj[DEF_CHAR];\n if (resCode !== undefined) {\n dbcsCode = resCode; // Found. Write it.\n nextChar = uCode; // Current character will be written too in the next iteration.\n\n } else {\n // TODO: What if we have no default? (resCode == undefined)\n // Then, we should write first char of the sequence as-is and try the rest recursively.\n // Didn't do it for now because no encoding has this situation yet.\n // Currently, just skip the sequence and write current char.\n }\n }\n seqObj = undefined;\n }\n else if (uCode >= 0) { // Regular character\n var subtable = this.encodeTable[uCode >> 8];\n if (subtable !== undefined)\n dbcsCode = subtable[uCode & 0xFF];\n \n if (dbcsCode <= SEQ_START) { // Sequence start\n seqObj = this.encodeTableSeq[SEQ_START-dbcsCode];\n continue;\n }\n\n if (dbcsCode == UNASSIGNED && this.gb18030) {\n // Use GB18030 algorithm to find character(s) to write.\n var idx = findIdx(this.gb18030.uChars, uCode);\n if (idx != -1) {\n var dbcsCode = this.gb18030.gbChars[idx] + (uCode - this.gb18030.uChars[idx]);\n newBuf[j++] = 0x81 + Math.floor(dbcsCode / 12600); dbcsCode = dbcsCode % 12600;\n newBuf[j++] = 0x30 + Math.floor(dbcsCode / 1260); dbcsCode = dbcsCode % 1260;\n newBuf[j++] = 0x81 + Math.floor(dbcsCode / 10); dbcsCode = dbcsCode % 10;\n newBuf[j++] = 0x30 + dbcsCode;\n continue;\n }\n }\n }\n\n // 3. Write dbcsCode character.\n if (dbcsCode === UNASSIGNED)\n dbcsCode = this.defaultCharSingleByte;\n \n if (dbcsCode < 0x100) {\n newBuf[j++] = dbcsCode;\n }\n else if (dbcsCode < 0x10000) {\n newBuf[j++] = dbcsCode >> 8; // high byte\n newBuf[j++] = dbcsCode & 0xFF; // low byte\n }\n else {\n newBuf[j++] = dbcsCode >> 16;\n newBuf[j++] = (dbcsCode >> 8) & 0xFF;\n newBuf[j++] = dbcsCode & 0xFF;\n }\n }\n\n this.seqObj = seqObj;\n this.leadSurrogate = leadSurrogate;\n return newBuf.slice(0, j);\n}\n\nDBCSEncoder.prototype.end = function() {\n if (this.leadSurrogate === -1 && this.seqObj === undefined)\n return; // All clean. Most often case.\n\n var newBuf = Buffer.alloc(10), j = 0;\n\n if (this.seqObj) { // We're in the sequence.\n var dbcsCode = this.seqObj[DEF_CHAR];\n if (dbcsCode !== undefined) { // Write beginning of the sequence.\n if (dbcsCode < 0x100) {\n newBuf[j++] = dbcsCode;\n }\n else {\n newBuf[j++] = dbcsCode >> 8; // high byte\n newBuf[j++] = dbcsCode & 0xFF; // low byte\n }\n } else {\n // See todo above.\n }\n this.seqObj = undefined;\n }\n\n if (this.leadSurrogate !== -1) {\n // Incomplete surrogate pair - only lead surrogate found.\n newBuf[j++] = this.defaultCharSingleByte;\n this.leadSurrogate = -1;\n }\n \n return newBuf.slice(0, j);\n}\n\n// Export for testing\nDBCSEncoder.prototype.findIdx = findIdx;\n\n\n// == Decoder ==================================================================\n\nfunction DBCSDecoder(options, codec) {\n // Decoder state\n this.nodeIdx = 0;\n this.prevBuf = Buffer.alloc(0);\n\n // Static data\n this.decodeTables = codec.decodeTables;\n this.decodeTableSeq = codec.decodeTableSeq;\n this.defaultCharUnicode = codec.defaultCharUnicode;\n this.gb18030 = codec.gb18030;\n}\n\nDBCSDecoder.prototype.write = function(buf) {\n var newBuf = Buffer.alloc(buf.length*2),\n nodeIdx = this.nodeIdx, \n prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length,\n seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence.\n uCode;\n\n if (prevBufOffset > 0) // Make prev buf overlap a little to make it easier to slice later.\n prevBuf = Buffer.concat([prevBuf, buf.slice(0, 10)]);\n \n for (var i = 0, j = 0; i < buf.length; i++) {\n var curByte = (i >= 0) ? buf[i] : prevBuf[i + prevBufOffset];\n\n // Lookup in current trie node.\n var uCode = this.decodeTables[nodeIdx][curByte];\n\n if (uCode >= 0) { \n // Normal character, just use it.\n }\n else if (uCode === UNASSIGNED) { // Unknown char.\n // TODO: Callback with seq.\n //var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);\n i = seqStart; // Try to parse again, after skipping first byte of the sequence ('i' will be incremented by 'for' cycle).\n uCode = this.defaultCharUnicode.charCodeAt(0);\n }\n else if (uCode === GB18030_CODE) {\n var curSeq = (seqStart >= 0) ? buf.slice(seqStart, i+1) : prevBuf.slice(seqStart + prevBufOffset, i+1 + prevBufOffset);\n var ptr = (curSeq[0]-0x81)*12600 + (curSeq[1]-0x30)*1260 + (curSeq[2]-0x81)*10 + (curSeq[3]-0x30);\n var idx = findIdx(this.gb18030.gbChars, ptr);\n uCode = this.gb18030.uChars[idx] + ptr - this.gb18030.gbChars[idx];\n }\n else if (uCode <= NODE_START) { // Go to next trie node.\n nodeIdx = NODE_START - uCode;\n continue;\n }\n else if (uCode <= SEQ_START) { // Output a sequence of chars.\n var seq = this.decodeTableSeq[SEQ_START - uCode];\n for (var k = 0; k < seq.length - 1; k++) {\n uCode = seq[k];\n newBuf[j++] = uCode & 0xFF;\n newBuf[j++] = uCode >> 8;\n }\n uCode = seq[seq.length-1];\n }\n else\n throw new Error(\"iconv-lite internal error: invalid decoding table value \" + uCode + \" at \" + nodeIdx + \"/\" + curByte);\n\n // Write the character to buffer, handling higher planes using surrogate pair.\n if (uCode > 0xFFFF) { \n uCode -= 0x10000;\n var uCodeLead = 0xD800 + Math.floor(uCode / 0x400);\n newBuf[j++] = uCodeLead & 0xFF;\n newBuf[j++] = uCodeLead >> 8;\n\n uCode = 0xDC00 + uCode % 0x400;\n }\n newBuf[j++] = uCode & 0xFF;\n newBuf[j++] = uCode >> 8;\n\n // Reset trie node.\n nodeIdx = 0; seqStart = i+1;\n }\n\n this.nodeIdx = nodeIdx;\n this.prevBuf = (seqStart >= 0) ? buf.slice(seqStart) : prevBuf.slice(seqStart + prevBufOffset);\n return newBuf.slice(0, j).toString('ucs2');\n}\n\nDBCSDecoder.prototype.end = function() {\n var ret = '';\n\n // Try to parse all remaining chars.\n while (this.prevBuf.length > 0) {\n // Skip 1 character in the buffer.\n ret += this.defaultCharUnicode;\n var buf = this.prevBuf.slice(1);\n\n // Parse remaining as usual.\n this.prevBuf = Buffer.alloc(0);\n this.nodeIdx = 0;\n if (buf.length > 0)\n ret += this.write(buf);\n }\n\n this.nodeIdx = 0;\n return ret;\n}\n\n// Binary search for GB18030. Returns largest i such that table[i] <= val.\nfunction findIdx(table, val) {\n if (table[0] > val)\n return -1;\n\n var l = 0, r = table.length;\n while (l < r-1) { // always table[l] <= val < table[r]\n var mid = l + Math.floor((r-l+1)/2);\n if (table[mid] <= val)\n l = mid;\n else\n r = mid;\n }\n return l;\n}\n\n", "\"use strict\";\n\n// Description of supported double byte encodings and aliases.\n// Tables are not require()-d until they are needed to speed up library load.\n// require()-s are direct to support Browserify.\n\nmodule.exports = {\n \n // == Japanese/ShiftJIS ====================================================\n // All japanese encodings are based on JIS X set of standards:\n // JIS X 0201 - Single-byte encoding of ASCII + \u00A5 + Kana chars at 0xA1-0xDF.\n // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. \n // Has several variations in 1978, 1983, 1990 and 1997.\n // JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead.\n // JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233.\n // 2 planes, first is superset of 0208, second - revised 0212.\n // Introduced in 2000, revised 2004. Some characters are in Unicode Plane 2 (0x2xxxx)\n\n // Byte encodings are:\n // * Shift_JIS: Compatible with 0201, uses not defined chars in top half as lead bytes for double-byte\n // encoding of 0208. Lead byte ranges: 0x81-0x9F, 0xE0-0xEF; Trail byte ranges: 0x40-0x7E, 0x80-0x9E, 0x9F-0xFC.\n // Windows CP932 is a superset of Shift_JIS. Some companies added more chars, notably KDDI.\n // * EUC-JP: Up to 3 bytes per character. Used mostly on *nixes.\n // 0x00-0x7F - lower part of 0201\n // 0x8E, 0xA1-0xDF - upper part of 0201\n // (0xA1-0xFE)x2 - 0208 plane (94x94).\n // 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94).\n // * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon.\n // Used as-is in ISO2022 family.\n // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, \n // 0201-1976 Roman, 0208-1978, 0208-1983.\n // * ISO2022-JP-1: Adds esc seq for 0212-1990.\n // * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7.\n // * ISO2022-JP-3: Adds esc seq for 0201-1976 Kana set, 0213-2000 Planes 1, 2.\n // * ISO2022-JP-2004: Adds 0213-2004 Plane 1.\n //\n // After JIS X 0213 appeared, Shift_JIS-2004, EUC-JISX0213 and ISO2022-JP-2004 followed, with just changing the planes.\n //\n // Overall, it seems that it's a mess :( http://www8.plala.or.jp/tkubota1/unicode-symbols-map2.html\n\n 'shiftjis': {\n type: '_dbcs',\n table: function() { return require('./tables/shiftjis.json') },\n encodeAdd: {'\\u00a5': 0x5C, '\\u203E': 0x7E},\n encodeSkipVals: [{from: 0xED40, to: 0xF940}],\n },\n 'csshiftjis': 'shiftjis',\n 'mskanji': 'shiftjis',\n 'sjis': 'shiftjis',\n 'windows31j': 'shiftjis',\n 'ms31j': 'shiftjis',\n 'xsjis': 'shiftjis',\n 'windows932': 'shiftjis',\n 'ms932': 'shiftjis',\n '932': 'shiftjis',\n 'cp932': 'shiftjis',\n\n 'eucjp': {\n type: '_dbcs',\n table: function() { return require('./tables/eucjp.json') },\n encodeAdd: {'\\u00a5': 0x5C, '\\u203E': 0x7E},\n },\n\n // TODO: KDDI extension to Shift_JIS\n // TODO: IBM CCSID 942 = CP932, but F0-F9 custom chars and other char changes.\n // TODO: IBM CCSID 943 = Shift_JIS = CP932 with original Shift_JIS lower 128 chars.\n\n\n // == Chinese/GBK ==========================================================\n // http://en.wikipedia.org/wiki/GBK\n // We mostly implement W3C recommendation: https://www.w3.org/TR/encoding/#gbk-encoder\n\n // Oldest GB2312 (1981, ~7600 chars) is a subset of CP936\n 'gb2312': 'cp936',\n 'gb231280': 'cp936',\n 'gb23121980': 'cp936',\n 'csgb2312': 'cp936',\n 'csiso58gb231280': 'cp936',\n 'euccn': 'cp936',\n\n // Microsoft's CP936 is a subset and approximation of GBK.\n 'windows936': 'cp936',\n 'ms936': 'cp936',\n '936': 'cp936',\n 'cp936': {\n type: '_dbcs',\n table: function() { return require('./tables/cp936.json') },\n },\n\n // GBK (~22000 chars) is an extension of CP936 that added user-mapped chars and some other.\n 'gbk': {\n type: '_dbcs',\n table: function() { return require('./tables/cp936.json').concat(require('./tables/gbk-added.json')) },\n },\n 'xgbk': 'gbk',\n 'isoir58': 'gbk',\n\n // GB18030 is an algorithmic extension of GBK.\n // Main source: https://www.w3.org/TR/encoding/#gbk-encoder\n // http://icu-project.org/docs/papers/gb18030.html\n // http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml\n // http://www.khngai.com/chinese/charmap/tblgbk.php?page=0\n 'gb18030': {\n type: '_dbcs',\n table: function() { return require('./tables/cp936.json').concat(require('./tables/gbk-added.json')) },\n gb18030: function() { return require('./tables/gb18030-ranges.json') },\n encodeSkipVals: [0x80],\n encodeAdd: {'\u20AC': 0xA2E3},\n },\n\n 'chinese': 'gb18030',\n\n\n // == Korean ===============================================================\n // EUC-KR, KS_C_5601 and KS X 1001 are exactly the same.\n 'windows949': 'cp949',\n 'ms949': 'cp949',\n '949': 'cp949',\n 'cp949': {\n type: '_dbcs',\n table: function() { return require('./tables/cp949.json') },\n },\n\n 'cseuckr': 'cp949',\n 'csksc56011987': 'cp949',\n 'euckr': 'cp949',\n 'isoir149': 'cp949',\n 'korean': 'cp949',\n 'ksc56011987': 'cp949',\n 'ksc56011989': 'cp949',\n 'ksc5601': 'cp949',\n\n\n // == Big5/Taiwan/Hong Kong ================================================\n // There are lots of tables for Big5 and cp950. Please see the following links for history:\n // http://moztw.org/docs/big5/ http://www.haible.de/bruno/charsets/conversion-tables/Big5.html\n // Variations, in roughly number of defined chars:\n // * Windows CP 950: Microsoft variant of Big5. Canonical: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT\n // * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/\n // * Big5-2003 (Taiwan standard) almost superset of cp950.\n // * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers.\n // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. \n // many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years.\n // Plus, it has 4 combining sequences.\n // Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299\n // because big5-hkscs is the only encoding to include astral characters in non-algorithmic way.\n // Implementations are not consistent within browsers; sometimes labeled as just big5.\n // MS Internet Explorer switches from big5 to big5-hkscs when a patch applied.\n // Great discussion & recap of what's going on https://bugzilla.mozilla.org/show_bug.cgi?id=912470#c31\n // In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s.\n // Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt\n // http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt\n // \n // Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder\n // Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong.\n\n 'windows950': 'cp950',\n 'ms950': 'cp950',\n '950': 'cp950',\n 'cp950': {\n type: '_dbcs',\n table: function() { return require('./tables/cp950.json') },\n },\n\n // Big5 has many variations and is an extension of cp950. We use Encoding Standard's as a consensus.\n 'big5': 'big5hkscs',\n 'big5hkscs': {\n type: '_dbcs',\n table: function() { return require('./tables/cp950.json').concat(require('./tables/big5-added.json')) },\n encodeSkipVals: [0xa2cc],\n },\n\n 'cnbig5': 'big5hkscs',\n 'csbig5': 'big5hkscs',\n 'xxbig5': 'big5hkscs',\n};\n", "\"use strict\";\n\n// Update this array if you add/rename/remove files in this directory.\n// We support Browserify by skipping automatic module discovery and requiring modules directly.\nvar modules = [\n require(\"./internal\"),\n require(\"./utf16\"),\n require(\"./utf7\"),\n require(\"./sbcs-codec\"),\n require(\"./sbcs-data\"),\n require(\"./sbcs-data-generated\"),\n require(\"./dbcs-codec\"),\n require(\"./dbcs-data\"),\n];\n\n// Put all encoding/alias/codec definitions to single object and export it. \nfor (var i = 0; i < modules.length; i++) {\n var module = modules[i];\n for (var enc in module)\n if (Object.prototype.hasOwnProperty.call(module, enc))\n exports[enc] = module[enc];\n}\n", "\"use strict\";\n\nvar Buffer = require(\"buffer\").Buffer,\n Transform = require(\"stream\").Transform;\n\n\n// == Exports ==================================================================\nmodule.exports = function(iconv) {\n \n // Additional Public API.\n iconv.encodeStream = function encodeStream(encoding, options) {\n return new IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options);\n }\n\n iconv.decodeStream = function decodeStream(encoding, options) {\n return new IconvLiteDecoderStream(iconv.getDecoder(encoding, options), options);\n }\n\n iconv.supportsStreams = true;\n\n\n // Not published yet.\n iconv.IconvLiteEncoderStream = IconvLiteEncoderStream;\n iconv.IconvLiteDecoderStream = IconvLiteDecoderStream;\n iconv._collect = IconvLiteDecoderStream.prototype.collect;\n};\n\n\n// == Encoder stream =======================================================\nfunction IconvLiteEncoderStream(conv, options) {\n this.conv = conv;\n options = options || {};\n options.decodeStrings = false; // We accept only strings, so we don't need to decode them.\n Transform.call(this, options);\n}\n\nIconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {\n constructor: { value: IconvLiteEncoderStream }\n});\n\nIconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {\n if (typeof chunk != 'string')\n return done(new Error(\"Iconv encoding stream needs strings as its input.\"));\n try {\n var res = this.conv.write(chunk);\n if (res && res.length) this.push(res);\n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteEncoderStream.prototype._flush = function(done) {\n try {\n var res = this.conv.end();\n if (res && res.length) this.push(res);\n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteEncoderStream.prototype.collect = function(cb) {\n var chunks = [];\n this.on('error', cb);\n this.on('data', function(chunk) { chunks.push(chunk); });\n this.on('end', function() {\n cb(null, Buffer.concat(chunks));\n });\n return this;\n}\n\n\n// == Decoder stream =======================================================\nfunction IconvLiteDecoderStream(conv, options) {\n this.conv = conv;\n options = options || {};\n options.encoding = this.encoding = 'utf8'; // We output strings.\n Transform.call(this, options);\n}\n\nIconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {\n constructor: { value: IconvLiteDecoderStream }\n});\n\nIconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {\n if (!Buffer.isBuffer(chunk))\n return done(new Error(\"Iconv decoding stream needs buffers as its input.\"));\n try {\n var res = this.conv.write(chunk);\n if (res && res.length) this.push(res, this.encoding);\n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteDecoderStream.prototype._flush = function(done) {\n try {\n var res = this.conv.end();\n if (res && res.length) this.push(res, this.encoding); \n done();\n }\n catch (e) {\n done(e);\n }\n}\n\nIconvLiteDecoderStream.prototype.collect = function(cb) {\n var res = '';\n this.on('error', cb);\n this.on('data', function(chunk) { res += chunk; });\n this.on('end', function() {\n cb(null, res);\n });\n return this;\n}\n\n", "\"use strict\";\nvar Buffer = require(\"buffer\").Buffer;\n// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer\n\n// == Extend Node primitives to use iconv-lite =================================\n\nmodule.exports = function (iconv) {\n var original = undefined; // Place to keep original methods.\n\n // Node authors rewrote Buffer internals to make it compatible with\n // Uint8Array and we cannot patch key functions since then.\n // Note: this does use older Buffer API on a purpose\n iconv.supportsNodeEncodingsExtension = !(Buffer.from || new Buffer(0) instanceof Uint8Array);\n\n iconv.extendNodeEncodings = function extendNodeEncodings() {\n if (original) return;\n original = {};\n\n if (!iconv.supportsNodeEncodingsExtension) {\n console.error(\"ACTION NEEDED: require('iconv-lite').extendNodeEncodings() is not supported in your version of Node\");\n console.error(\"See more info at https://github.com/ashtuchkin/iconv-lite/wiki/Node-v4-compatibility\");\n return;\n }\n\n var nodeNativeEncodings = {\n 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, \n 'base64': true, 'ucs2': true, 'ucs-2': true, 'utf16le': true, 'utf-16le': true,\n };\n\n Buffer.isNativeEncoding = function(enc) {\n return enc && nodeNativeEncodings[enc.toLowerCase()];\n }\n\n // -- SlowBuffer -----------------------------------------------------------\n var SlowBuffer = require('buffer').SlowBuffer;\n\n original.SlowBufferToString = SlowBuffer.prototype.toString;\n SlowBuffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.SlowBufferToString.call(this, encoding, start, end);\n\n // Otherwise, use our decoding method.\n if (typeof start == 'undefined') start = 0;\n if (typeof end == 'undefined') end = this.length;\n return iconv.decode(this.slice(start, end), encoding);\n }\n\n original.SlowBufferWrite = SlowBuffer.prototype.write;\n SlowBuffer.prototype.write = function(string, offset, length, encoding) {\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.SlowBufferWrite.call(this, string, offset, length, encoding);\n\n if (string.length > 0 && (length < 0 || offset < 0))\n throw new RangeError('attempt to write beyond buffer bounds');\n\n // Otherwise, use our encoding method.\n var buf = iconv.encode(string, encoding);\n if (buf.length < length) length = buf.length;\n buf.copy(this, offset, 0, length);\n return length;\n }\n\n // -- Buffer ---------------------------------------------------------------\n\n original.BufferIsEncoding = Buffer.isEncoding;\n Buffer.isEncoding = function(encoding) {\n return Buffer.isNativeEncoding(encoding) || iconv.encodingExists(encoding);\n }\n\n original.BufferByteLength = Buffer.byteLength;\n Buffer.byteLength = SlowBuffer.byteLength = function(str, encoding) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.BufferByteLength.call(this, str, encoding);\n\n // Slow, I know, but we don't have a better way yet.\n return iconv.encode(str, encoding).length;\n }\n\n original.BufferToString = Buffer.prototype.toString;\n Buffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.BufferToString.call(this, encoding, start, end);\n\n // Otherwise, use our decoding method.\n if (typeof start == 'undefined') start = 0;\n if (typeof end == 'undefined') end = this.length;\n return iconv.decode(this.slice(start, end), encoding);\n }\n\n original.BufferWrite = Buffer.prototype.write;\n Buffer.prototype.write = function(string, offset, length, encoding) {\n var _offset = offset, _length = length, _encoding = encoding;\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n encoding = String(encoding || 'utf8').toLowerCase();\n\n // Use native conversion when possible\n if (Buffer.isNativeEncoding(encoding))\n return original.BufferWrite.call(this, string, _offset, _length, _encoding);\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n\n if (string.length > 0 && (length < 0 || offset < 0))\n throw new RangeError('attempt to write beyond buffer bounds');\n\n // Otherwise, use our encoding method.\n var buf = iconv.encode(string, encoding);\n if (buf.length < length) length = buf.length;\n buf.copy(this, offset, 0, length);\n return length;\n\n // TODO: Set _charsWritten.\n }\n\n\n // -- Readable -------------------------------------------------------------\n if (iconv.supportsStreams) {\n var Readable = require('stream').Readable;\n\n original.ReadableSetEncoding = Readable.prototype.setEncoding;\n Readable.prototype.setEncoding = function setEncoding(enc, options) {\n // Use our own decoder, it has the same interface.\n // We cannot use original function as it doesn't handle BOM-s.\n this._readableState.decoder = iconv.getDecoder(enc, options);\n this._readableState.encoding = enc;\n }\n\n Readable.prototype.collect = iconv._collect;\n }\n }\n\n // Remove iconv-lite Node primitive extensions.\n iconv.undoExtendNodeEncodings = function undoExtendNodeEncodings() {\n if (!iconv.supportsNodeEncodingsExtension)\n return;\n if (!original)\n throw new Error(\"require('iconv-lite').undoExtendNodeEncodings(): Nothing to undo; extendNodeEncodings() is not called.\")\n\n delete Buffer.isNativeEncoding;\n\n var SlowBuffer = require('buffer').SlowBuffer;\n\n SlowBuffer.prototype.toString = original.SlowBufferToString;\n SlowBuffer.prototype.write = original.SlowBufferWrite;\n\n Buffer.isEncoding = original.BufferIsEncoding;\n Buffer.byteLength = original.BufferByteLength;\n Buffer.prototype.toString = original.BufferToString;\n Buffer.prototype.write = original.BufferWrite;\n\n if (iconv.supportsStreams) {\n var Readable = require('stream').Readable;\n\n Readable.prototype.setEncoding = original.ReadableSetEncoding;\n delete Readable.prototype.collect;\n }\n\n original = undefined;\n }\n}\n", "\"use strict\";\n\n// Some environments don't have global Buffer (e.g. React Native).\n// Solution would be installing npm modules \"buffer\" and \"stream\" explicitly.\nvar Buffer = require(\"safer-buffer\").Buffer;\n\nvar bomHandling = require(\"./bom-handling\"),\n iconv = module.exports;\n\n// All codecs and aliases are kept here, keyed by encoding name/alias.\n// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`.\niconv.encodings = null;\n\n// Characters emitted in case of error.\niconv.defaultCharUnicode = '\uFFFD';\niconv.defaultCharSingleByte = '?';\n\n// Public API.\niconv.encode = function encode(str, encoding, options) {\n str = \"\" + (str || \"\"); // Ensure string.\n\n var encoder = iconv.getEncoder(encoding, options);\n\n var res = encoder.write(str);\n var trail = encoder.end();\n \n return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res;\n}\n\niconv.decode = function decode(buf, encoding, options) {\n if (typeof buf === 'string') {\n if (!iconv.skipDecodeWarning) {\n console.error('Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding');\n iconv.skipDecodeWarning = true;\n }\n\n buf = Buffer.from(\"\" + (buf || \"\"), \"binary\"); // Ensure buffer.\n }\n\n var decoder = iconv.getDecoder(encoding, options);\n\n var res = decoder.write(buf);\n var trail = decoder.end();\n\n return trail ? (res + trail) : res;\n}\n\niconv.encodingExists = function encodingExists(enc) {\n try {\n iconv.getCodec(enc);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n// Legacy aliases to convert functions\niconv.toEncoding = iconv.encode;\niconv.fromEncoding = iconv.decode;\n\n// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache.\niconv._codecDataCache = {};\niconv.getCodec = function getCodec(encoding) {\n if (!iconv.encodings)\n iconv.encodings = require(\"../encodings\"); // Lazy load all encoding definitions.\n \n // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.\n var enc = iconv._canonicalizeEncoding(encoding);\n\n // Traverse iconv.encodings to find actual codec.\n var codecOptions = {};\n while (true) {\n var codec = iconv._codecDataCache[enc];\n if (codec)\n return codec;\n\n var codecDef = iconv.encodings[enc];\n\n switch (typeof codecDef) {\n case \"string\": // Direct alias to other encoding.\n enc = codecDef;\n break;\n\n case \"object\": // Alias with options. Can be layered.\n for (var key in codecDef)\n codecOptions[key] = codecDef[key];\n\n if (!codecOptions.encodingName)\n codecOptions.encodingName = enc;\n \n enc = codecDef.type;\n break;\n\n case \"function\": // Codec itself.\n if (!codecOptions.encodingName)\n codecOptions.encodingName = enc;\n\n // The codec function must load all tables and return object with .encoder and .decoder methods.\n // It'll be called only once (for each different options object).\n codec = new codecDef(codecOptions, iconv);\n\n iconv._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later.\n return codec;\n\n default:\n throw new Error(\"Encoding not recognized: '\" + encoding + \"' (searched as: '\"+enc+\"')\");\n }\n }\n}\n\niconv._canonicalizeEncoding = function(encoding) {\n // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.\n return (''+encoding).toLowerCase().replace(/:\\d{4}$|[^0-9a-z]/g, \"\");\n}\n\niconv.getEncoder = function getEncoder(encoding, options) {\n var codec = iconv.getCodec(encoding),\n encoder = new codec.encoder(options, codec);\n\n if (codec.bomAware && options && options.addBOM)\n encoder = new bomHandling.PrependBOM(encoder, options);\n\n return encoder;\n}\n\niconv.getDecoder = function getDecoder(encoding, options) {\n var codec = iconv.getCodec(encoding),\n decoder = new codec.decoder(options, codec);\n\n if (codec.bomAware && !(options && options.stripBOM === false))\n decoder = new bomHandling.StripBOM(decoder, options);\n\n return decoder;\n}\n\n\n// Load extensions in Node. All of them are omitted in Browserify build via 'browser' field in package.json.\nvar nodeVer = typeof process !== 'undefined' && process.versions && process.versions.node;\nif (nodeVer) {\n\n // Load streaming support in Node v0.10+\n var nodeVerArr = nodeVer.split(\".\").map(Number);\n if (nodeVerArr[0] > 0 || nodeVerArr[1] >= 10) {\n require(\"./streams\")(iconv);\n }\n\n // Load Node primitive extensions.\n require(\"./extend-node\")(iconv);\n}\n\nif (\"\u0100\" != \"\\u0100\") {\n console.error(\"iconv-lite warning: javascript files use encoding different from utf-8. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info.\");\n}\n", "/*!\n * ee-first\n * Copyright(c) 2014 Jonathan Ong\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = first\n\n/**\n * Get the first event in a set of event emitters and event pairs.\n *\n * @param {array} stuff\n * @param {function} done\n * @public\n */\n\nfunction first(stuff, done) {\n if (!Array.isArray(stuff))\n throw new TypeError('arg must be an array of [ee, events...] arrays')\n\n var cleanups = []\n\n for (var i = 0; i < stuff.length; i++) {\n var arr = stuff[i]\n\n if (!Array.isArray(arr) || arr.length < 2)\n throw new TypeError('each array member must be [ee, events...]')\n\n var ee = arr[0]\n\n for (var j = 1; j < arr.length; j++) {\n var event = arr[j]\n var fn = listener(event, callback)\n\n // listen to the event\n ee.on(event, fn)\n // push this listener to the list of cleanups\n cleanups.push({\n ee: ee,\n event: event,\n fn: fn,\n })\n }\n }\n\n function callback() {\n cleanup()\n done.apply(null, arguments)\n }\n\n function cleanup() {\n var x\n for (var i = 0; i < cleanups.length; i++) {\n x = cleanups[i]\n x.ee.removeListener(x.event, x.fn)\n }\n }\n\n function thunk(fn) {\n done = fn\n }\n\n thunk.cancel = cleanup\n\n return thunk\n}\n\n/**\n * Create the event listener.\n * @private\n */\n\nfunction listener(event, done) {\n return function onevent(arg1) {\n var args = new Array(arguments.length)\n var ee = this\n var err = event === 'error'\n ? arg1\n : null\n\n // copy args to prevent arguments escaping scope\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i]\n }\n\n done(err, ee, event, args)\n }\n}\n", "/*!\n * on-finished\n * Copyright(c) 2013 Jonathan Ong\n * Copyright(c) 2014 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = onFinished\nmodule.exports.isFinished = isFinished\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar asyncHooks = tryRequireAsyncHooks()\nvar first = require('ee-first')\n\n/**\n * Variables.\n * @private\n */\n\n/* istanbul ignore next */\nvar defer = typeof setImmediate === 'function'\n ? setImmediate\n : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) }\n\n/**\n * Invoke callback when the response has finished, useful for\n * cleaning up resources afterwards.\n *\n * @param {object} msg\n * @param {function} listener\n * @return {object}\n * @public\n */\n\nfunction onFinished (msg, listener) {\n if (isFinished(msg) !== false) {\n defer(listener, null, msg)\n return msg\n }\n\n // attach the listener to the message\n attachListener(msg, wrap(listener))\n\n return msg\n}\n\n/**\n * Determine if message is already finished.\n *\n * @param {object} msg\n * @return {boolean}\n * @public\n */\n\nfunction isFinished (msg) {\n var socket = msg.socket\n\n if (typeof msg.finished === 'boolean') {\n // OutgoingMessage\n return Boolean(msg.finished || (socket && !socket.writable))\n }\n\n if (typeof msg.complete === 'boolean') {\n // IncomingMessage\n return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable))\n }\n\n // don't know\n return undefined\n}\n\n/**\n * Attach a finished listener to the message.\n *\n * @param {object} msg\n * @param {function} callback\n * @private\n */\n\nfunction attachFinishedListener (msg, callback) {\n var eeMsg\n var eeSocket\n var finished = false\n\n function onFinish (error) {\n eeMsg.cancel()\n eeSocket.cancel()\n\n finished = true\n callback(error)\n }\n\n // finished on first message event\n eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish)\n\n function onSocket (socket) {\n // remove listener\n msg.removeListener('socket', onSocket)\n\n if (finished) return\n if (eeMsg !== eeSocket) return\n\n // finished on first socket event\n eeSocket = first([[socket, 'error', 'close']], onFinish)\n }\n\n if (msg.socket) {\n // socket already assigned\n onSocket(msg.socket)\n return\n }\n\n // wait for socket to be assigned\n msg.on('socket', onSocket)\n\n if (msg.socket === undefined) {\n // istanbul ignore next: node.js 0.8 patch\n patchAssignSocket(msg, onSocket)\n }\n}\n\n/**\n * Attach the listener to the message.\n *\n * @param {object} msg\n * @return {function}\n * @private\n */\n\nfunction attachListener (msg, listener) {\n var attached = msg.__onFinished\n\n // create a private single listener with queue\n if (!attached || !attached.queue) {\n attached = msg.__onFinished = createListener(msg)\n attachFinishedListener(msg, attached)\n }\n\n attached.queue.push(listener)\n}\n\n/**\n * Create listener on message.\n *\n * @param {object} msg\n * @return {function}\n * @private\n */\n\nfunction createListener (msg) {\n function listener (err) {\n if (msg.__onFinished === listener) msg.__onFinished = null\n if (!listener.queue) return\n\n var queue = listener.queue\n listener.queue = null\n\n for (var i = 0; i < queue.length; i++) {\n queue[i](err, msg)\n }\n }\n\n listener.queue = []\n\n return listener\n}\n\n/**\n * Patch ServerResponse.prototype.assignSocket for node.js 0.8.\n *\n * @param {ServerResponse} res\n * @param {function} callback\n * @private\n */\n\n// istanbul ignore next: node.js 0.8 patch\nfunction patchAssignSocket (res, callback) {\n var assignSocket = res.assignSocket\n\n if (typeof assignSocket !== 'function') return\n\n // res.on('socket', callback) is broken in 0.8\n res.assignSocket = function _assignSocket (socket) {\n assignSocket.call(this, socket)\n callback(socket)\n }\n}\n\n/**\n * Try to require async_hooks\n * @private\n */\n\nfunction tryRequireAsyncHooks () {\n try {\n return require('async_hooks')\n } catch (e) {\n return {}\n }\n}\n\n/**\n * Wrap function with async resource, if possible.\n * AsyncResource.bind static method backported.\n * @private\n */\n\nfunction wrap (fn) {\n var res\n\n // create anonymous resource\n if (asyncHooks.AsyncResource) {\n res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')\n }\n\n // incompatible node.js\n if (!res || !res.runInAsyncScope) {\n return fn\n }\n\n // return bound function\n return res.runInAsyncScope.bind(res, fn, null)\n}\n", "/*!\n * body-parser\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar createError = require('http-errors')\nvar destroy = require('destroy')\nvar getBody = require('raw-body')\nvar iconv = require('iconv-lite')\nvar onFinished = require('on-finished')\nvar unpipe = require('unpipe')\nvar zlib = require('zlib')\n\n/**\n * Module exports.\n */\n\nmodule.exports = read\n\n/**\n * Read a request into a buffer and parse.\n *\n * @param {object} req\n * @param {object} res\n * @param {function} next\n * @param {function} parse\n * @param {function} debug\n * @param {object} options\n * @private\n */\n\nfunction read (req, res, next, parse, debug, options) {\n var length\n var opts = options\n var stream\n\n // flag as parsed\n req._body = true\n\n // read options\n var encoding = opts.encoding !== null\n ? opts.encoding\n : null\n var verify = opts.verify\n\n try {\n // get the content stream\n stream = contentstream(req, debug, opts.inflate)\n length = stream.length\n stream.length = undefined\n } catch (err) {\n return next(err)\n }\n\n // set raw-body options\n opts.length = length\n opts.encoding = verify\n ? null\n : encoding\n\n // assert charset is supported\n if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {\n return next(createError(415, 'unsupported charset \"' + encoding.toUpperCase() + '\"', {\n charset: encoding.toLowerCase(),\n type: 'charset.unsupported'\n }))\n }\n\n // read body\n debug('read body')\n getBody(stream, opts, function (error, body) {\n if (error) {\n var _error\n\n if (error.type === 'encoding.unsupported') {\n // echo back charset\n _error = createError(415, 'unsupported charset \"' + encoding.toUpperCase() + '\"', {\n charset: encoding.toLowerCase(),\n type: 'charset.unsupported'\n })\n } else {\n // set status code on error\n _error = createError(400, error)\n }\n\n // unpipe from stream and destroy\n if (stream !== req) {\n unpipe(req)\n destroy(stream, true)\n }\n\n // read off entire request\n dump(req, function onfinished () {\n next(createError(400, _error))\n })\n return\n }\n\n // verify\n if (verify) {\n try {\n debug('verify body')\n verify(req, res, body, encoding)\n } catch (err) {\n next(createError(403, err, {\n body: body,\n type: err.type || 'entity.verify.failed'\n }))\n return\n }\n }\n\n // parse\n var str = body\n try {\n debug('parse body')\n str = typeof body !== 'string' && encoding !== null\n ? iconv.decode(body, encoding)\n : body\n req.body = parse(str)\n } catch (err) {\n next(createError(400, err, {\n body: str,\n type: err.type || 'entity.parse.failed'\n }))\n return\n }\n\n next()\n })\n}\n\n/**\n * Get the content stream of the request.\n *\n * @param {object} req\n * @param {function} debug\n * @param {boolean} [inflate=true]\n * @return {object}\n * @api private\n */\n\nfunction contentstream (req, debug, inflate) {\n var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()\n var length = req.headers['content-length']\n var stream\n\n debug('content-encoding \"%s\"', encoding)\n\n if (inflate === false && encoding !== 'identity') {\n throw createError(415, 'content encoding unsupported', {\n encoding: encoding,\n type: 'encoding.unsupported'\n })\n }\n\n switch (encoding) {\n case 'deflate':\n stream = zlib.createInflate()\n debug('inflate body')\n req.pipe(stream)\n break\n case 'gzip':\n stream = zlib.createGunzip()\n debug('gunzip body')\n req.pipe(stream)\n break\n case 'identity':\n stream = req\n stream.length = length\n break\n default:\n throw createError(415, 'unsupported content encoding \"' + encoding + '\"', {\n encoding: encoding,\n type: 'encoding.unsupported'\n })\n }\n\n return stream\n}\n\n/**\n * Dump the contents of a request.\n *\n * @param {object} req\n * @param {function} callback\n * @api private\n */\n\nfunction dump (req, callback) {\n if (onFinished.isFinished(req)) {\n callback(null)\n } else {\n onFinished(req, callback)\n req.resume()\n }\n}\n", "/*!\n * media-typer\n * Copyright(c) 2014 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n/**\n * RegExp to match *( \";\" parameter ) in RFC 2616 sec 3.7\n *\n * parameter = token \"=\" ( token | quoted-string )\n * token = 1*\n * separators = \"(\" | \")\" | \"<\" | \">\" | \"@\"\n * | \",\" | \";\" | \":\" | \"\\\" | <\">\n * | \"/\" | \"[\" | \"]\" | \"?\" | \"=\"\n * | \"{\" | \"}\" | SP | HT\n * quoted-string = ( <\"> *(qdtext | quoted-pair ) <\"> )\n * qdtext = >\n * quoted-pair = \"\\\" CHAR\n * CHAR = \n * TEXT = \n * LWS = [CRLF] 1*( SP | HT )\n * CRLF = CR LF\n * CR = \n * LF = \n * SP = \n * SHT = \n * CTL = \n * OCTET = \n */\nvar paramRegExp = /; *([!#$%&'\\*\\+\\-\\.0-9A-Z\\^_`a-z\\|~]+) *= *(\"(?:[ !\\u0023-\\u005b\\u005d-\\u007e\\u0080-\\u00ff]|\\\\[\\u0020-\\u007e])*\"|[!#$%&'\\*\\+\\-\\.0-9A-Z\\^_`a-z\\|~]+) */g;\nvar textRegExp = /^[\\u0020-\\u007e\\u0080-\\u00ff]+$/\nvar tokenRegExp = /^[!#$%&'\\*\\+\\-\\.0-9A-Z\\^_`a-z\\|~]+$/\n\n/**\n * RegExp to match quoted-pair in RFC 2616\n *\n * quoted-pair = \"\\\" CHAR\n * CHAR = \n */\nvar qescRegExp = /\\\\([\\u0000-\\u007f])/g;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 2616\n */\nvar quoteRegExp = /([\\\\\"])/g;\n\n/**\n * RegExp to match type in RFC 6838\n *\n * type-name = restricted-name\n * subtype-name = restricted-name\n * restricted-name = restricted-name-first *126restricted-name-chars\n * restricted-name-first = ALPHA / DIGIT\n * restricted-name-chars = ALPHA / DIGIT / \"!\" / \"#\" /\n * \"$\" / \"&\" / \"-\" / \"^\" / \"_\"\n * restricted-name-chars =/ \".\" ; Characters before first dot always\n * ; specify a facet name\n * restricted-name-chars =/ \"+\" ; Characters after last plus always\n * ; specify a structured syntax suffix\n * ALPHA = %x41-5A / %x61-7A ; A-Z / a-z\n * DIGIT = %x30-39 ; 0-9\n */\nvar subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/\nvar typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/\nvar typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/;\n\n/**\n * Module exports.\n */\n\nexports.format = format\nexports.parse = parse\n\n/**\n * Format object to media type.\n *\n * @param {object} obj\n * @return {string}\n * @api public\n */\n\nfunction format(obj) {\n if (!obj || typeof obj !== 'object') {\n throw new TypeError('argument obj is required')\n }\n\n var parameters = obj.parameters\n var subtype = obj.subtype\n var suffix = obj.suffix\n var type = obj.type\n\n if (!type || !typeNameRegExp.test(type)) {\n throw new TypeError('invalid type')\n }\n\n if (!subtype || !subtypeNameRegExp.test(subtype)) {\n throw new TypeError('invalid subtype')\n }\n\n // format as type/subtype\n var string = type + '/' + subtype\n\n // append +suffix\n if (suffix) {\n if (!typeNameRegExp.test(suffix)) {\n throw new TypeError('invalid suffix')\n }\n\n string += '+' + suffix\n }\n\n // append parameters\n if (parameters && typeof parameters === 'object') {\n var param\n var params = Object.keys(parameters).sort()\n\n for (var i = 0; i < params.length; i++) {\n param = params[i]\n\n if (!tokenRegExp.test(param)) {\n throw new TypeError('invalid parameter name')\n }\n\n string += '; ' + param + '=' + qstring(parameters[param])\n }\n }\n\n return string\n}\n\n/**\n * Parse media type to object.\n *\n * @param {string|object} string\n * @return {Object}\n * @api public\n */\n\nfunction parse(string) {\n if (!string) {\n throw new TypeError('argument string is required')\n }\n\n // support req/res-like objects as argument\n if (typeof string === 'object') {\n string = getcontenttype(string)\n }\n\n if (typeof string !== 'string') {\n throw new TypeError('argument string is required to be a string')\n }\n\n var index = string.indexOf(';')\n var type = index !== -1\n ? string.substr(0, index)\n : string\n\n var key\n var match\n var obj = splitType(type)\n var params = {}\n var value\n\n paramRegExp.lastIndex = index\n\n while (match = paramRegExp.exec(string)) {\n if (match.index !== index) {\n throw new TypeError('invalid parameter format')\n }\n\n index += match[0].length\n key = match[1].toLowerCase()\n value = match[2]\n\n if (value[0] === '\"') {\n // remove quotes and escapes\n value = value\n .substr(1, value.length - 2)\n .replace(qescRegExp, '$1')\n }\n\n params[key] = value\n }\n\n if (index !== -1 && index !== string.length) {\n throw new TypeError('invalid parameter format')\n }\n\n obj.parameters = params\n\n return obj\n}\n\n/**\n * Get content-type from req/res objects.\n *\n * @param {object}\n * @return {Object}\n * @api private\n */\n\nfunction getcontenttype(obj) {\n if (typeof obj.getHeader === 'function') {\n // res-like\n return obj.getHeader('content-type')\n }\n\n if (typeof obj.headers === 'object') {\n // req-like\n return obj.headers && obj.headers['content-type']\n }\n}\n\n/**\n * Quote a string if necessary.\n *\n * @param {string} val\n * @return {string}\n * @api private\n */\n\nfunction qstring(val) {\n var str = String(val)\n\n // no need to quote tokens\n if (tokenRegExp.test(str)) {\n return str\n }\n\n if (str.length > 0 && !textRegExp.test(str)) {\n throw new TypeError('invalid parameter value')\n }\n\n return '\"' + str.replace(quoteRegExp, '\\\\$1') + '\"'\n}\n\n/**\n * Simply \"type/subtype+siffx\" into parts.\n *\n * @param {string} string\n * @return {Object}\n * @api private\n */\n\nfunction splitType(string) {\n var match = typeRegExp.exec(string.toLowerCase())\n\n if (!match) {\n throw new TypeError('invalid media type')\n }\n\n var type = match[1]\n var subtype = match[2]\n var suffix\n\n // suffix after last +\n var index = subtype.lastIndexOf('+')\n if (index !== -1) {\n suffix = subtype.substr(index + 1)\n subtype = subtype.substr(0, index)\n }\n\n var obj = {\n type: type,\n subtype: subtype,\n suffix: suffix\n }\n\n return obj\n}\n", "/*!\n * mime-db\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2015-2022 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n/**\n * Module exports.\n */\n\nmodule.exports = require('./db.json')\n", "/*!\n * mime-types\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar db = require('mime-db')\nvar extname = require('path').extname\n\n/**\n * Module variables.\n * @private\n */\n\nvar EXTRACT_TYPE_REGEXP = /^\\s*([^;\\s]*)(?:;|\\s|$)/\nvar TEXT_TYPE_REGEXP = /^text\\//i\n\n/**\n * Module exports.\n * @public\n */\n\nexports.charset = charset\nexports.charsets = { lookup: charset }\nexports.contentType = contentType\nexports.extension = extension\nexports.extensions = Object.create(null)\nexports.lookup = lookup\nexports.types = Object.create(null)\n\n// Populate the extensions/types maps\npopulateMaps(exports.extensions, exports.types)\n\n/**\n * Get the default charset for a MIME type.\n *\n * @param {string} type\n * @return {boolean|string}\n */\n\nfunction charset (type) {\n if (!type || typeof type !== 'string') {\n return false\n }\n\n // TODO: use media-typer\n var match = EXTRACT_TYPE_REGEXP.exec(type)\n var mime = match && db[match[1].toLowerCase()]\n\n if (mime && mime.charset) {\n return mime.charset\n }\n\n // default text/* to utf-8\n if (match && TEXT_TYPE_REGEXP.test(match[1])) {\n return 'UTF-8'\n }\n\n return false\n}\n\n/**\n * Create a full Content-Type header given a MIME type or extension.\n *\n * @param {string} str\n * @return {boolean|string}\n */\n\nfunction contentType (str) {\n // TODO: should this even be in this module?\n if (!str || typeof str !== 'string') {\n return false\n }\n\n var mime = str.indexOf('/') === -1\n ? exports.lookup(str)\n : str\n\n if (!mime) {\n return false\n }\n\n // TODO: use content-type or other module\n if (mime.indexOf('charset') === -1) {\n var charset = exports.charset(mime)\n if (charset) mime += '; charset=' + charset.toLowerCase()\n }\n\n return mime\n}\n\n/**\n * Get the default extension for a MIME type.\n *\n * @param {string} type\n * @return {boolean|string}\n */\n\nfunction extension (type) {\n if (!type || typeof type !== 'string') {\n return false\n }\n\n // TODO: use media-typer\n var match = EXTRACT_TYPE_REGEXP.exec(type)\n\n // get extensions\n var exts = match && exports.extensions[match[1].toLowerCase()]\n\n if (!exts || !exts.length) {\n return false\n }\n\n return exts[0]\n}\n\n/**\n * Lookup the MIME type for a file path/extension.\n *\n * @param {string} path\n * @return {boolean|string}\n */\n\nfunction lookup (path) {\n if (!path || typeof path !== 'string') {\n return false\n }\n\n // get the extension (\"ext\" or \".ext\" or full path)\n var extension = extname('x.' + path)\n .toLowerCase()\n .substr(1)\n\n if (!extension) {\n return false\n }\n\n return exports.types[extension] || false\n}\n\n/**\n * Populate the extensions and types maps.\n * @private\n */\n\nfunction populateMaps (extensions, types) {\n // source preference (least -> most)\n var preference = ['nginx', 'apache', undefined, 'iana']\n\n Object.keys(db).forEach(function forEachMimeType (type) {\n var mime = db[type]\n var exts = mime.extensions\n\n if (!exts || !exts.length) {\n return\n }\n\n // mime -> extensions\n extensions[type] = exts\n\n // extension -> mime\n for (var i = 0; i < exts.length; i++) {\n var extension = exts[i]\n\n if (types[extension]) {\n var from = preference.indexOf(db[types[extension]].source)\n var to = preference.indexOf(mime.source)\n\n if (types[extension] !== 'application/octet-stream' &&\n (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {\n // skip the remapping\n continue\n }\n }\n\n // set the extension -> mime\n types[extension] = type\n }\n })\n}\n", "/*!\n * type-is\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar typer = require('media-typer')\nvar mime = require('mime-types')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = typeofrequest\nmodule.exports.is = typeis\nmodule.exports.hasBody = hasbody\nmodule.exports.normalize = normalize\nmodule.exports.match = mimeMatch\n\n/**\n * Compare a `value` content-type with `types`.\n * Each `type` can be an extension like `html`,\n * a special shortcut like `multipart` or `urlencoded`,\n * or a mime type.\n *\n * If no types match, `false` is returned.\n * Otherwise, the first `type` that matches is returned.\n *\n * @param {String} value\n * @param {Array} types\n * @public\n */\n\nfunction typeis (value, types_) {\n var i\n var types = types_\n\n // remove parameters and normalize\n var val = tryNormalizeType(value)\n\n // no type or invalid\n if (!val) {\n return false\n }\n\n // support flattened arguments\n if (types && !Array.isArray(types)) {\n types = new Array(arguments.length - 1)\n for (i = 0; i < types.length; i++) {\n types[i] = arguments[i + 1]\n }\n }\n\n // no types, return the content type\n if (!types || !types.length) {\n return val\n }\n\n var type\n for (i = 0; i < types.length; i++) {\n if (mimeMatch(normalize(type = types[i]), val)) {\n return type[0] === '+' || type.indexOf('*') !== -1\n ? val\n : type\n }\n }\n\n // no matches\n return false\n}\n\n/**\n * Check if a request has a request body.\n * A request with a body __must__ either have `transfer-encoding`\n * or `content-length` headers set.\n * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3\n *\n * @param {Object} request\n * @return {Boolean}\n * @public\n */\n\nfunction hasbody (req) {\n return req.headers['transfer-encoding'] !== undefined ||\n !isNaN(req.headers['content-length'])\n}\n\n/**\n * Check if the incoming request contains the \"Content-Type\"\n * header field, and it contains any of the give mime `type`s.\n * If there is no request body, `null` is returned.\n * If there is no content type, `false` is returned.\n * Otherwise, it returns the first `type` that matches.\n *\n * Examples:\n *\n * // With Content-Type: text/html; charset=utf-8\n * this.is('html'); // => 'html'\n * this.is('text/html'); // => 'text/html'\n * this.is('text/*', 'application/json'); // => 'text/html'\n *\n * // When Content-Type is application/json\n * this.is('json', 'urlencoded'); // => 'json'\n * this.is('application/json'); // => 'application/json'\n * this.is('html', 'application/*'); // => 'application/json'\n *\n * this.is('html'); // => false\n *\n * @param {String|Array} types...\n * @return {String|false|null}\n * @public\n */\n\nfunction typeofrequest (req, types_) {\n var types = types_\n\n // no body\n if (!hasbody(req)) {\n return null\n }\n\n // support flattened arguments\n if (arguments.length > 2) {\n types = new Array(arguments.length - 1)\n for (var i = 0; i < types.length; i++) {\n types[i] = arguments[i + 1]\n }\n }\n\n // request content type\n var value = req.headers['content-type']\n\n return typeis(value, types)\n}\n\n/**\n * Normalize a mime type.\n * If it's a shorthand, expand it to a valid mime type.\n *\n * In general, you probably want:\n *\n * var type = is(req, ['urlencoded', 'json', 'multipart']);\n *\n * Then use the appropriate body parsers.\n * These three are the most common request body types\n * and are thus ensured to work.\n *\n * @param {String} type\n * @private\n */\n\nfunction normalize (type) {\n if (typeof type !== 'string') {\n // invalid type\n return false\n }\n\n switch (type) {\n case 'urlencoded':\n return 'application/x-www-form-urlencoded'\n case 'multipart':\n return 'multipart/*'\n }\n\n if (type[0] === '+') {\n // \"+json\" -> \"*/*+json\" expando\n return '*/*' + type\n }\n\n return type.indexOf('/') === -1\n ? mime.lookup(type)\n : type\n}\n\n/**\n * Check if `expected` mime type\n * matches `actual` mime type with\n * wildcard and +suffix support.\n *\n * @param {String} expected\n * @param {String} actual\n * @return {Boolean}\n * @private\n */\n\nfunction mimeMatch (expected, actual) {\n // invalid type\n if (expected === false) {\n return false\n }\n\n // split types\n var actualParts = actual.split('/')\n var expectedParts = expected.split('/')\n\n // invalid format\n if (actualParts.length !== 2 || expectedParts.length !== 2) {\n return false\n }\n\n // validate type\n if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {\n return false\n }\n\n // validate suffix wildcard\n if (expectedParts[1].substr(0, 2) === '*+') {\n return expectedParts[1].length <= actualParts[1].length + 1 &&\n expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)\n }\n\n // validate subtype\n if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {\n return false\n }\n\n return true\n}\n\n/**\n * Normalize a type and remove parameters.\n *\n * @param {string} value\n * @return {string}\n * @private\n */\n\nfunction normalizeType (value) {\n // parse the type\n var type = typer.parse(value)\n\n // remove the parameters\n type.parameters = undefined\n\n // reformat it\n return typer.format(type)\n}\n\n/**\n * Try to normalize a type and remove parameters.\n *\n * @param {string} value\n * @return {string}\n * @private\n */\n\nfunction tryNormalizeType (value) {\n if (!value) {\n return null\n }\n\n try {\n return normalizeType(value)\n } catch (err) {\n return null\n }\n}\n", "/*!\n * body-parser\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar bytes = require('bytes')\nvar contentType = require('content-type')\nvar createError = require('http-errors')\nvar debug = require('debug')('body-parser:json')\nvar read = require('../read')\nvar typeis = require('type-is')\n\n/**\n * Module exports.\n */\n\nmodule.exports = json\n\n/**\n * RegExp to match the first non-space in a string.\n *\n * Allowed whitespace is defined in RFC 7159:\n *\n * ws = *(\n * %x20 / ; Space\n * %x09 / ; Horizontal tab\n * %x0A / ; Line feed or New line\n * %x0D ) ; Carriage return\n */\n\nvar FIRST_CHAR_REGEXP = /^[\\x20\\x09\\x0a\\x0d]*([^\\x20\\x09\\x0a\\x0d])/ // eslint-disable-line no-control-regex\n\n/**\n * Create a middleware to parse JSON bodies.\n *\n * @param {object} [options]\n * @return {function}\n * @public\n */\n\nfunction json (options) {\n var opts = options || {}\n\n var limit = typeof opts.limit !== 'number'\n ? bytes.parse(opts.limit || '100kb')\n : opts.limit\n var inflate = opts.inflate !== false\n var reviver = opts.reviver\n var strict = opts.strict !== false\n var type = opts.type || 'application/json'\n var verify = opts.verify || false\n\n if (verify !== false && typeof verify !== 'function') {\n throw new TypeError('option verify must be function')\n }\n\n // create the appropriate type checking function\n var shouldParse = typeof type !== 'function'\n ? typeChecker(type)\n : type\n\n function parse (body) {\n if (body.length === 0) {\n // special-case empty json body, as it's a common client-side mistake\n // TODO: maybe make this configurable or part of \"strict\" option\n return {}\n }\n\n if (strict) {\n var first = firstchar(body)\n\n if (first !== '{' && first !== '[') {\n debug('strict violation')\n throw createStrictSyntaxError(body, first)\n }\n }\n\n try {\n debug('parse json')\n return JSON.parse(body, reviver)\n } catch (e) {\n throw normalizeJsonSyntaxError(e, {\n message: e.message,\n stack: e.stack\n })\n }\n }\n\n return function jsonParser (req, res, next) {\n if (req._body) {\n debug('body already parsed')\n next()\n return\n }\n\n req.body = req.body || {}\n\n // skip requests without bodies\n if (!typeis.hasBody(req)) {\n debug('skip empty body')\n next()\n return\n }\n\n debug('content-type %j', req.headers['content-type'])\n\n // determine if request should be parsed\n if (!shouldParse(req)) {\n debug('skip parsing')\n next()\n return\n }\n\n // assert charset per RFC 7159 sec 8.1\n var charset = getCharset(req) || 'utf-8'\n if (charset.slice(0, 4) !== 'utf-') {\n debug('invalid charset')\n next(createError(415, 'unsupported charset \"' + charset.toUpperCase() + '\"', {\n charset: charset,\n type: 'charset.unsupported'\n }))\n return\n }\n\n // read\n read(req, res, next, parse, debug, {\n encoding: charset,\n inflate: inflate,\n limit: limit,\n verify: verify\n })\n }\n}\n\n/**\n * Create strict violation syntax error matching native error.\n *\n * @param {string} str\n * @param {string} char\n * @return {Error}\n * @private\n */\n\nfunction createStrictSyntaxError (str, char) {\n var index = str.indexOf(char)\n var partial = index !== -1\n ? str.substring(0, index) + '#'\n : ''\n\n try {\n JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')\n } catch (e) {\n return normalizeJsonSyntaxError(e, {\n message: e.message.replace('#', char),\n stack: e.stack\n })\n }\n}\n\n/**\n * Get the first non-whitespace character in a string.\n *\n * @param {string} str\n * @return {function}\n * @private\n */\n\nfunction firstchar (str) {\n var match = FIRST_CHAR_REGEXP.exec(str)\n\n return match\n ? match[1]\n : undefined\n}\n\n/**\n * Get the charset of a request.\n *\n * @param {object} req\n * @api private\n */\n\nfunction getCharset (req) {\n try {\n return (contentType.parse(req).parameters.charset || '').toLowerCase()\n } catch (e) {\n return undefined\n }\n}\n\n/**\n * Normalize a SyntaxError for JSON.parse.\n *\n * @param {SyntaxError} error\n * @param {object} obj\n * @return {SyntaxError}\n */\n\nfunction normalizeJsonSyntaxError (error, obj) {\n var keys = Object.getOwnPropertyNames(error)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i]\n if (key !== 'stack' && key !== 'message') {\n delete error[key]\n }\n }\n\n // replace stack before message for Node.js 0.10 and below\n error.stack = obj.stack.replace(error.message, obj.message)\n error.message = obj.message\n\n return error\n}\n\n/**\n * Get the simple type checker.\n *\n * @param {string} type\n * @return {function}\n */\n\nfunction typeChecker (type) {\n return function checkType (req) {\n return Boolean(typeis(req, type))\n }\n}\n", "/*!\n * body-parser\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n */\n\nvar bytes = require('bytes')\nvar debug = require('debug')('body-parser:raw')\nvar read = require('../read')\nvar typeis = require('type-is')\n\n/**\n * Module exports.\n */\n\nmodule.exports = raw\n\n/**\n * Create a middleware to parse raw bodies.\n *\n * @param {object} [options]\n * @return {function}\n * @api public\n */\n\nfunction raw (options) {\n var opts = options || {}\n\n var inflate = opts.inflate !== false\n var limit = typeof opts.limit !== 'number'\n ? bytes.parse(opts.limit || '100kb')\n : opts.limit\n var type = opts.type || 'application/octet-stream'\n var verify = opts.verify || false\n\n if (verify !== false && typeof verify !== 'function') {\n throw new TypeError('option verify must be function')\n }\n\n // create the appropriate type checking function\n var shouldParse = typeof type !== 'function'\n ? typeChecker(type)\n : type\n\n function parse (buf) {\n return buf\n }\n\n return function rawParser (req, res, next) {\n if (req._body) {\n debug('body already parsed')\n next()\n return\n }\n\n req.body = req.body || {}\n\n // skip requests without bodies\n if (!typeis.hasBody(req)) {\n debug('skip empty body')\n next()\n return\n }\n\n debug('content-type %j', req.headers['content-type'])\n\n // determine if request should be parsed\n if (!shouldParse(req)) {\n debug('skip parsing')\n next()\n return\n }\n\n // read\n read(req, res, next, parse, debug, {\n encoding: null,\n inflate: inflate,\n limit: limit,\n verify: verify\n })\n }\n}\n\n/**\n * Get the simple type checker.\n *\n * @param {string} type\n * @return {function}\n */\n\nfunction typeChecker (type) {\n return function checkType (req) {\n return Boolean(typeis(req, type))\n }\n}\n", "/*!\n * body-parser\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n */\n\nvar bytes = require('bytes')\nvar contentType = require('content-type')\nvar debug = require('debug')('body-parser:text')\nvar read = require('../read')\nvar typeis = require('type-is')\n\n/**\n * Module exports.\n */\n\nmodule.exports = text\n\n/**\n * Create a middleware to parse text bodies.\n *\n * @param {object} [options]\n * @return {function}\n * @api public\n */\n\nfunction text (options) {\n var opts = options || {}\n\n var defaultCharset = opts.defaultCharset || 'utf-8'\n var inflate = opts.inflate !== false\n var limit = typeof opts.limit !== 'number'\n ? bytes.parse(opts.limit || '100kb')\n : opts.limit\n var type = opts.type || 'text/plain'\n var verify = opts.verify || false\n\n if (verify !== false && typeof verify !== 'function') {\n throw new TypeError('option verify must be function')\n }\n\n // create the appropriate type checking function\n var shouldParse = typeof type !== 'function'\n ? typeChecker(type)\n : type\n\n function parse (buf) {\n return buf\n }\n\n return function textParser (req, res, next) {\n if (req._body) {\n debug('body already parsed')\n next()\n return\n }\n\n req.body = req.body || {}\n\n // skip requests without bodies\n if (!typeis.hasBody(req)) {\n debug('skip empty body')\n next()\n return\n }\n\n debug('content-type %j', req.headers['content-type'])\n\n // determine if request should be parsed\n if (!shouldParse(req)) {\n debug('skip parsing')\n next()\n return\n }\n\n // get charset\n var charset = getCharset(req) || defaultCharset\n\n // read\n read(req, res, next, parse, debug, {\n encoding: charset,\n inflate: inflate,\n limit: limit,\n verify: verify\n })\n }\n}\n\n/**\n * Get the charset of a request.\n *\n * @param {object} req\n * @api private\n */\n\nfunction getCharset (req) {\n try {\n return (contentType.parse(req).parameters.charset || '').toLowerCase()\n } catch (e) {\n return undefined\n }\n}\n\n/**\n * Get the simple type checker.\n *\n * @param {string} type\n * @return {function}\n */\n\nfunction typeChecker (type) {\n return function checkType (req) {\n return Boolean(typeis(req, type))\n }\n}\n", "'use strict';\n\n/* eslint complexity: [2, 18], max-statements: [2, 33] */\nmodule.exports = function hasSymbols() {\n\tif (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }\n\tif (typeof Symbol.iterator === 'symbol') { return true; }\n\n\tvar obj = {};\n\tvar sym = Symbol('test');\n\tvar symObj = Object(sym);\n\tif (typeof sym === 'string') { return false; }\n\n\tif (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }\n\tif (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }\n\n\t// temp disabled per https://github.com/ljharb/object.assign/issues/17\n\t// if (sym instanceof Symbol) { return false; }\n\t// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4\n\t// if (!(symObj instanceof Symbol)) { return false; }\n\n\t// if (typeof Symbol.prototype.toString !== 'function') { return false; }\n\t// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }\n\n\tvar symVal = 42;\n\tobj[sym] = symVal;\n\tfor (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop\n\tif (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }\n\n\tif (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }\n\n\tvar syms = Object.getOwnPropertySymbols(obj);\n\tif (syms.length !== 1 || syms[0] !== sym) { return false; }\n\n\tif (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }\n\n\tif (typeof Object.getOwnPropertyDescriptor === 'function') {\n\t\tvar descriptor = Object.getOwnPropertyDescriptor(obj, sym);\n\t\tif (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }\n\t}\n\n\treturn true;\n};\n", "'use strict';\n\nvar origSymbol = typeof Symbol !== 'undefined' && Symbol;\nvar hasSymbolSham = require('./shams');\n\nmodule.exports = function hasNativeSymbols() {\n\tif (typeof origSymbol !== 'function') { return false; }\n\tif (typeof Symbol !== 'function') { return false; }\n\tif (typeof origSymbol('foo') !== 'symbol') { return false; }\n\tif (typeof Symbol('bar') !== 'symbol') { return false; }\n\n\treturn hasSymbolSham();\n};\n", "'use strict';\n\nvar test = {\n\tfoo: {}\n};\n\nvar $Object = Object;\n\nmodule.exports = function hasProto() {\n\treturn { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);\n};\n", "'use strict';\n\n/* eslint no-invalid-this: 1 */\n\nvar ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';\nvar toStr = Object.prototype.toString;\nvar max = Math.max;\nvar funcType = '[object Function]';\n\nvar concatty = function concatty(a, b) {\n var arr = [];\n\n for (var i = 0; i < a.length; i += 1) {\n arr[i] = a[i];\n }\n for (var j = 0; j < b.length; j += 1) {\n arr[j + a.length] = b[j];\n }\n\n return arr;\n};\n\nvar slicy = function slicy(arrLike, offset) {\n var arr = [];\n for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {\n arr[j] = arrLike[i];\n }\n return arr;\n};\n\nvar joiny = function (arr, joiner) {\n var str = '';\n for (var i = 0; i < arr.length; i += 1) {\n str += arr[i];\n if (i + 1 < arr.length) {\n str += joiner;\n }\n }\n return str;\n};\n\nmodule.exports = function bind(that) {\n var target = this;\n if (typeof target !== 'function' || toStr.apply(target) !== funcType) {\n throw new TypeError(ERROR_MESSAGE + target);\n }\n var args = slicy(arguments, 1);\n\n var bound;\n var binder = function () {\n if (this instanceof bound) {\n var result = target.apply(\n this,\n concatty(args, arguments)\n );\n if (Object(result) === result) {\n return result;\n }\n return this;\n }\n return target.apply(\n that,\n concatty(args, arguments)\n );\n\n };\n\n var boundLength = max(0, target.length - args.length);\n var boundArgs = [];\n for (var i = 0; i < boundLength; i++) {\n boundArgs[i] = '$' + i;\n }\n\n bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);\n\n if (target.prototype) {\n var Empty = function Empty() {};\n Empty.prototype = target.prototype;\n bound.prototype = new Empty();\n Empty.prototype = null;\n }\n\n return bound;\n};\n", "'use strict';\n\nvar implementation = require('./implementation');\n\nmodule.exports = Function.prototype.bind || implementation;\n", "'use strict';\n\nvar call = Function.prototype.call;\nvar $hasOwn = Object.prototype.hasOwnProperty;\nvar bind = require('function-bind');\n\n/** @type {(o: {}, p: PropertyKey) => p is keyof o} */\nmodule.exports = bind.call(call, $hasOwn);\n", "'use strict';\n\nvar undefined;\n\nvar $SyntaxError = SyntaxError;\nvar $Function = Function;\nvar $TypeError = TypeError;\n\n// eslint-disable-next-line consistent-return\nvar getEvalledConstructor = function (expressionSyntax) {\n\ttry {\n\t\treturn $Function('\"use strict\"; return (' + expressionSyntax + ').constructor;')();\n\t} catch (e) {}\n};\n\nvar $gOPD = Object.getOwnPropertyDescriptor;\nif ($gOPD) {\n\ttry {\n\t\t$gOPD({}, '');\n\t} catch (e) {\n\t\t$gOPD = null; // this is IE 8, which has a broken gOPD\n\t}\n}\n\nvar throwTypeError = function () {\n\tthrow new $TypeError();\n};\nvar ThrowTypeError = $gOPD\n\t? (function () {\n\t\ttry {\n\t\t\t// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties\n\t\t\targuments.callee; // IE 8 does not throw here\n\t\t\treturn throwTypeError;\n\t\t} catch (calleeThrows) {\n\t\t\ttry {\n\t\t\t\t// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')\n\t\t\t\treturn $gOPD(arguments, 'callee').get;\n\t\t\t} catch (gOPDthrows) {\n\t\t\t\treturn throwTypeError;\n\t\t\t}\n\t\t}\n\t}())\n\t: throwTypeError;\n\nvar hasSymbols = require('has-symbols')();\nvar hasProto = require('has-proto')();\n\nvar getProto = Object.getPrototypeOf || (\n\thasProto\n\t\t? function (x) { return x.__proto__; } // eslint-disable-line no-proto\n\t\t: null\n);\n\nvar needsEval = {};\n\nvar TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined : getProto(Uint8Array);\n\nvar INTRINSICS = {\n\t'%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,\n\t'%Array%': Array,\n\t'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,\n\t'%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined,\n\t'%AsyncFromSyncIteratorPrototype%': undefined,\n\t'%AsyncFunction%': needsEval,\n\t'%AsyncGenerator%': needsEval,\n\t'%AsyncGeneratorFunction%': needsEval,\n\t'%AsyncIteratorPrototype%': needsEval,\n\t'%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,\n\t'%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,\n\t'%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined : BigInt64Array,\n\t'%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined : BigUint64Array,\n\t'%Boolean%': Boolean,\n\t'%DataView%': typeof DataView === 'undefined' ? undefined : DataView,\n\t'%Date%': Date,\n\t'%decodeURI%': decodeURI,\n\t'%decodeURIComponent%': decodeURIComponent,\n\t'%encodeURI%': encodeURI,\n\t'%encodeURIComponent%': encodeURIComponent,\n\t'%Error%': Error,\n\t'%eval%': eval, // eslint-disable-line no-eval\n\t'%EvalError%': EvalError,\n\t'%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,\n\t'%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,\n\t'%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,\n\t'%Function%': $Function,\n\t'%GeneratorFunction%': needsEval,\n\t'%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,\n\t'%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,\n\t'%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,\n\t'%isFinite%': isFinite,\n\t'%isNaN%': isNaN,\n\t'%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined,\n\t'%JSON%': typeof JSON === 'object' ? JSON : undefined,\n\t'%Map%': typeof Map === 'undefined' ? undefined : Map,\n\t'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()),\n\t'%Math%': Math,\n\t'%Number%': Number,\n\t'%Object%': Object,\n\t'%parseFloat%': parseFloat,\n\t'%parseInt%': parseInt,\n\t'%Promise%': typeof Promise === 'undefined' ? undefined : Promise,\n\t'%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,\n\t'%RangeError%': RangeError,\n\t'%ReferenceError%': ReferenceError,\n\t'%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,\n\t'%RegExp%': RegExp,\n\t'%Set%': typeof Set === 'undefined' ? undefined : Set,\n\t'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Set()[Symbol.iterator]()),\n\t'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,\n\t'%String%': String,\n\t'%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined,\n\t'%Symbol%': hasSymbols ? Symbol : undefined,\n\t'%SyntaxError%': $SyntaxError,\n\t'%ThrowTypeError%': ThrowTypeError,\n\t'%TypedArray%': TypedArray,\n\t'%TypeError%': $TypeError,\n\t'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,\n\t'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,\n\t'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,\n\t'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,\n\t'%URIError%': URIError,\n\t'%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,\n\t'%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,\n\t'%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet\n};\n\nif (getProto) {\n\ttry {\n\t\tnull.error; // eslint-disable-line no-unused-expressions\n\t} catch (e) {\n\t\t// https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229\n\t\tvar errorProto = getProto(getProto(e));\n\t\tINTRINSICS['%Error.prototype%'] = errorProto;\n\t}\n}\n\nvar doEval = function doEval(name) {\n\tvar value;\n\tif (name === '%AsyncFunction%') {\n\t\tvalue = getEvalledConstructor('async function () {}');\n\t} else if (name === '%GeneratorFunction%') {\n\t\tvalue = getEvalledConstructor('function* () {}');\n\t} else if (name === '%AsyncGeneratorFunction%') {\n\t\tvalue = getEvalledConstructor('async function* () {}');\n\t} else if (name === '%AsyncGenerator%') {\n\t\tvar fn = doEval('%AsyncGeneratorFunction%');\n\t\tif (fn) {\n\t\t\tvalue = fn.prototype;\n\t\t}\n\t} else if (name === '%AsyncIteratorPrototype%') {\n\t\tvar gen = doEval('%AsyncGenerator%');\n\t\tif (gen && getProto) {\n\t\t\tvalue = getProto(gen.prototype);\n\t\t}\n\t}\n\n\tINTRINSICS[name] = value;\n\n\treturn value;\n};\n\nvar LEGACY_ALIASES = {\n\t'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],\n\t'%ArrayPrototype%': ['Array', 'prototype'],\n\t'%ArrayProto_entries%': ['Array', 'prototype', 'entries'],\n\t'%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],\n\t'%ArrayProto_keys%': ['Array', 'prototype', 'keys'],\n\t'%ArrayProto_values%': ['Array', 'prototype', 'values'],\n\t'%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],\n\t'%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],\n\t'%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],\n\t'%BooleanPrototype%': ['Boolean', 'prototype'],\n\t'%DataViewPrototype%': ['DataView', 'prototype'],\n\t'%DatePrototype%': ['Date', 'prototype'],\n\t'%ErrorPrototype%': ['Error', 'prototype'],\n\t'%EvalErrorPrototype%': ['EvalError', 'prototype'],\n\t'%Float32ArrayPrototype%': ['Float32Array', 'prototype'],\n\t'%Float64ArrayPrototype%': ['Float64Array', 'prototype'],\n\t'%FunctionPrototype%': ['Function', 'prototype'],\n\t'%Generator%': ['GeneratorFunction', 'prototype'],\n\t'%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],\n\t'%Int8ArrayPrototype%': ['Int8Array', 'prototype'],\n\t'%Int16ArrayPrototype%': ['Int16Array', 'prototype'],\n\t'%Int32ArrayPrototype%': ['Int32Array', 'prototype'],\n\t'%JSONParse%': ['JSON', 'parse'],\n\t'%JSONStringify%': ['JSON', 'stringify'],\n\t'%MapPrototype%': ['Map', 'prototype'],\n\t'%NumberPrototype%': ['Number', 'prototype'],\n\t'%ObjectPrototype%': ['Object', 'prototype'],\n\t'%ObjProto_toString%': ['Object', 'prototype', 'toString'],\n\t'%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],\n\t'%PromisePrototype%': ['Promise', 'prototype'],\n\t'%PromiseProto_then%': ['Promise', 'prototype', 'then'],\n\t'%Promise_all%': ['Promise', 'all'],\n\t'%Promise_reject%': ['Promise', 'reject'],\n\t'%Promise_resolve%': ['Promise', 'resolve'],\n\t'%RangeErrorPrototype%': ['RangeError', 'prototype'],\n\t'%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],\n\t'%RegExpPrototype%': ['RegExp', 'prototype'],\n\t'%SetPrototype%': ['Set', 'prototype'],\n\t'%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],\n\t'%StringPrototype%': ['String', 'prototype'],\n\t'%SymbolPrototype%': ['Symbol', 'prototype'],\n\t'%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],\n\t'%TypedArrayPrototype%': ['TypedArray', 'prototype'],\n\t'%TypeErrorPrototype%': ['TypeError', 'prototype'],\n\t'%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],\n\t'%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],\n\t'%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],\n\t'%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],\n\t'%URIErrorPrototype%': ['URIError', 'prototype'],\n\t'%WeakMapPrototype%': ['WeakMap', 'prototype'],\n\t'%WeakSetPrototype%': ['WeakSet', 'prototype']\n};\n\nvar bind = require('function-bind');\nvar hasOwn = require('hasown');\nvar $concat = bind.call(Function.call, Array.prototype.concat);\nvar $spliceApply = bind.call(Function.apply, Array.prototype.splice);\nvar $replace = bind.call(Function.call, String.prototype.replace);\nvar $strSlice = bind.call(Function.call, String.prototype.slice);\nvar $exec = bind.call(Function.call, RegExp.prototype.exec);\n\n/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */\nvar rePropName = /[^%.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|%$))/g;\nvar reEscapeChar = /\\\\(\\\\)?/g; /** Used to match backslashes in property paths. */\nvar stringToPath = function stringToPath(string) {\n\tvar first = $strSlice(string, 0, 1);\n\tvar last = $strSlice(string, -1);\n\tif (first === '%' && last !== '%') {\n\t\tthrow new $SyntaxError('invalid intrinsic syntax, expected closing `%`');\n\t} else if (last === '%' && first !== '%') {\n\t\tthrow new $SyntaxError('invalid intrinsic syntax, expected opening `%`');\n\t}\n\tvar result = [];\n\t$replace(string, rePropName, function (match, number, quote, subString) {\n\t\tresult[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;\n\t});\n\treturn result;\n};\n/* end adaptation */\n\nvar getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {\n\tvar intrinsicName = name;\n\tvar alias;\n\tif (hasOwn(LEGACY_ALIASES, intrinsicName)) {\n\t\talias = LEGACY_ALIASES[intrinsicName];\n\t\tintrinsicName = '%' + alias[0] + '%';\n\t}\n\n\tif (hasOwn(INTRINSICS, intrinsicName)) {\n\t\tvar value = INTRINSICS[intrinsicName];\n\t\tif (value === needsEval) {\n\t\t\tvalue = doEval(intrinsicName);\n\t\t}\n\t\tif (typeof value === 'undefined' && !allowMissing) {\n\t\t\tthrow new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');\n\t\t}\n\n\t\treturn {\n\t\t\talias: alias,\n\t\t\tname: intrinsicName,\n\t\t\tvalue: value\n\t\t};\n\t}\n\n\tthrow new $SyntaxError('intrinsic ' + name + ' does not exist!');\n};\n\nmodule.exports = function GetIntrinsic(name, allowMissing) {\n\tif (typeof name !== 'string' || name.length === 0) {\n\t\tthrow new $TypeError('intrinsic name must be a non-empty string');\n\t}\n\tif (arguments.length > 1 && typeof allowMissing !== 'boolean') {\n\t\tthrow new $TypeError('\"allowMissing\" argument must be a boolean');\n\t}\n\n\tif ($exec(/^%?[^%]*%?$/, name) === null) {\n\t\tthrow new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');\n\t}\n\tvar parts = stringToPath(name);\n\tvar intrinsicBaseName = parts.length > 0 ? parts[0] : '';\n\n\tvar intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);\n\tvar intrinsicRealName = intrinsic.name;\n\tvar value = intrinsic.value;\n\tvar skipFurtherCaching = false;\n\n\tvar alias = intrinsic.alias;\n\tif (alias) {\n\t\tintrinsicBaseName = alias[0];\n\t\t$spliceApply(parts, $concat([0, 1], alias));\n\t}\n\n\tfor (var i = 1, isOwn = true; i < parts.length; i += 1) {\n\t\tvar part = parts[i];\n\t\tvar first = $strSlice(part, 0, 1);\n\t\tvar last = $strSlice(part, -1);\n\t\tif (\n\t\t\t(\n\t\t\t\t(first === '\"' || first === \"'\" || first === '`')\n\t\t\t\t|| (last === '\"' || last === \"'\" || last === '`')\n\t\t\t)\n\t\t\t&& first !== last\n\t\t) {\n\t\t\tthrow new $SyntaxError('property names with quotes must have matching quotes');\n\t\t}\n\t\tif (part === 'constructor' || !isOwn) {\n\t\t\tskipFurtherCaching = true;\n\t\t}\n\n\t\tintrinsicBaseName += '.' + part;\n\t\tintrinsicRealName = '%' + intrinsicBaseName + '%';\n\n\t\tif (hasOwn(INTRINSICS, intrinsicRealName)) {\n\t\t\tvalue = INTRINSICS[intrinsicRealName];\n\t\t} else if (value != null) {\n\t\t\tif (!(part in value)) {\n\t\t\t\tif (!allowMissing) {\n\t\t\t\t\tthrow new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');\n\t\t\t\t}\n\t\t\t\treturn void undefined;\n\t\t\t}\n\t\t\tif ($gOPD && (i + 1) >= parts.length) {\n\t\t\t\tvar desc = $gOPD(value, part);\n\t\t\t\tisOwn = !!desc;\n\n\t\t\t\t// By convention, when a data property is converted to an accessor\n\t\t\t\t// property to emulate a data property that does not suffer from\n\t\t\t\t// the override mistake, that accessor's getter is marked with\n\t\t\t\t// an `originalValue` property. Here, when we detect this, we\n\t\t\t\t// uphold the illusion by pretending to see that original data\n\t\t\t\t// property, i.e., returning the value rather than the getter\n\t\t\t\t// itself.\n\t\t\t\tif (isOwn && 'get' in desc && !('originalValue' in desc.get)) {\n\t\t\t\t\tvalue = desc.get;\n\t\t\t\t} else {\n\t\t\t\t\tvalue = value[part];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tisOwn = hasOwn(value, part);\n\t\t\t\tvalue = value[part];\n\t\t\t}\n\n\t\t\tif (isOwn && !skipFurtherCaching) {\n\t\t\t\tINTRINSICS[intrinsicRealName] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn value;\n};\n", "'use strict';\n\nvar GetIntrinsic = require('get-intrinsic');\n\nvar $defineProperty = GetIntrinsic('%Object.defineProperty%', true);\n\nvar hasPropertyDescriptors = function hasPropertyDescriptors() {\n\tif ($defineProperty) {\n\t\ttry {\n\t\t\t$defineProperty({}, 'a', { value: 1 });\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\t// IE 8 has a broken defineProperty\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn false;\n};\n\nhasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {\n\t// node v0.6 has a bug where array lengths can be Set but not Defined\n\tif (!hasPropertyDescriptors()) {\n\t\treturn null;\n\t}\n\ttry {\n\t\treturn $defineProperty([], 'length', { value: 1 }).length !== 1;\n\t} catch (e) {\n\t\t// In Firefox 4-22, defining length on an array throws an exception.\n\t\treturn true;\n\t}\n};\n\nmodule.exports = hasPropertyDescriptors;\n", "'use strict';\n\nvar GetIntrinsic = require('get-intrinsic');\n\nvar $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);\n\nif ($gOPD) {\n\ttry {\n\t\t$gOPD([], 'length');\n\t} catch (e) {\n\t\t// IE 8 has a broken gOPD\n\t\t$gOPD = null;\n\t}\n}\n\nmodule.exports = $gOPD;\n", "'use strict';\n\nvar hasPropertyDescriptors = require('has-property-descriptors')();\n\nvar GetIntrinsic = require('get-intrinsic');\n\nvar $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true);\nif ($defineProperty) {\n\ttry {\n\t\t$defineProperty({}, 'a', { value: 1 });\n\t} catch (e) {\n\t\t// IE 8 has a broken defineProperty\n\t\t$defineProperty = false;\n\t}\n}\n\nvar $SyntaxError = GetIntrinsic('%SyntaxError%');\nvar $TypeError = GetIntrinsic('%TypeError%');\n\nvar gopd = require('gopd');\n\n/** @type {(obj: Record, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */\nmodule.exports = function defineDataProperty(\n\tobj,\n\tproperty,\n\tvalue\n) {\n\tif (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {\n\t\tthrow new $TypeError('`obj` must be an object or a function`');\n\t}\n\tif (typeof property !== 'string' && typeof property !== 'symbol') {\n\t\tthrow new $TypeError('`property` must be a string or a symbol`');\n\t}\n\tif (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) {\n\t\tthrow new $TypeError('`nonEnumerable`, if provided, must be a boolean or null');\n\t}\n\tif (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) {\n\t\tthrow new $TypeError('`nonWritable`, if provided, must be a boolean or null');\n\t}\n\tif (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) {\n\t\tthrow new $TypeError('`nonConfigurable`, if provided, must be a boolean or null');\n\t}\n\tif (arguments.length > 6 && typeof arguments[6] !== 'boolean') {\n\t\tthrow new $TypeError('`loose`, if provided, must be a boolean');\n\t}\n\n\tvar nonEnumerable = arguments.length > 3 ? arguments[3] : null;\n\tvar nonWritable = arguments.length > 4 ? arguments[4] : null;\n\tvar nonConfigurable = arguments.length > 5 ? arguments[5] : null;\n\tvar loose = arguments.length > 6 ? arguments[6] : false;\n\n\t/* @type {false | TypedPropertyDescriptor} */\n\tvar desc = !!gopd && gopd(obj, property);\n\n\tif ($defineProperty) {\n\t\t$defineProperty(obj, property, {\n\t\t\tconfigurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable,\n\t\t\tenumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable,\n\t\t\tvalue: value,\n\t\t\twritable: nonWritable === null && desc ? desc.writable : !nonWritable\n\t\t});\n\t} else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) {\n\t\t// must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable\n\t\tobj[property] = value; // eslint-disable-line no-param-reassign\n\t} else {\n\t\tthrow new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.');\n\t}\n};\n", "'use strict';\n\nvar GetIntrinsic = require('get-intrinsic');\nvar define = require('define-data-property');\nvar hasDescriptors = require('has-property-descriptors')();\nvar gOPD = require('gopd');\n\nvar $TypeError = GetIntrinsic('%TypeError%');\nvar $floor = GetIntrinsic('%Math.floor%');\n\nmodule.exports = function setFunctionLength(fn, length) {\n\tif (typeof fn !== 'function') {\n\t\tthrow new $TypeError('`fn` is not a function');\n\t}\n\tif (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) {\n\t\tthrow new $TypeError('`length` must be a positive 32-bit integer');\n\t}\n\n\tvar loose = arguments.length > 2 && !!arguments[2];\n\n\tvar functionLengthIsConfigurable = true;\n\tvar functionLengthIsWritable = true;\n\tif ('length' in fn && gOPD) {\n\t\tvar desc = gOPD(fn, 'length');\n\t\tif (desc && !desc.configurable) {\n\t\t\tfunctionLengthIsConfigurable = false;\n\t\t}\n\t\tif (desc && !desc.writable) {\n\t\t\tfunctionLengthIsWritable = false;\n\t\t}\n\t}\n\n\tif (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {\n\t\tif (hasDescriptors) {\n\t\t\tdefine(fn, 'length', length, true, true);\n\t\t} else {\n\t\t\tdefine(fn, 'length', length);\n\t\t}\n\t}\n\treturn fn;\n};\n", "'use strict';\n\nvar bind = require('function-bind');\nvar GetIntrinsic = require('get-intrinsic');\nvar setFunctionLength = require('set-function-length');\n\nvar $TypeError = GetIntrinsic('%TypeError%');\nvar $apply = GetIntrinsic('%Function.prototype.apply%');\nvar $call = GetIntrinsic('%Function.prototype.call%');\nvar $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);\n\nvar $defineProperty = GetIntrinsic('%Object.defineProperty%', true);\nvar $max = GetIntrinsic('%Math.max%');\n\nif ($defineProperty) {\n\ttry {\n\t\t$defineProperty({}, 'a', { value: 1 });\n\t} catch (e) {\n\t\t// IE 8 has a broken defineProperty\n\t\t$defineProperty = null;\n\t}\n}\n\nmodule.exports = function callBind(originalFunction) {\n\tif (typeof originalFunction !== 'function') {\n\t\tthrow new $TypeError('a function is required');\n\t}\n\tvar func = $reflectApply(bind, $call, arguments);\n\treturn setFunctionLength(\n\t\tfunc,\n\t\t1 + $max(0, originalFunction.length - (arguments.length - 1)),\n\t\ttrue\n\t);\n};\n\nvar applyBind = function applyBind() {\n\treturn $reflectApply(bind, $apply, arguments);\n};\n\nif ($defineProperty) {\n\t$defineProperty(module.exports, 'apply', { value: applyBind });\n} else {\n\tmodule.exports.apply = applyBind;\n}\n", "'use strict';\n\nvar GetIntrinsic = require('get-intrinsic');\n\nvar callBind = require('./');\n\nvar $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));\n\nmodule.exports = function callBoundIntrinsic(name, allowMissing) {\n\tvar intrinsic = GetIntrinsic(name, !!allowMissing);\n\tif (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {\n\t\treturn callBind(intrinsic);\n\t}\n\treturn intrinsic;\n};\n", "module.exports = require('util').inspect;\n", "var hasMap = typeof Map === 'function' && Map.prototype;\nvar mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;\nvar mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;\nvar mapForEach = hasMap && Map.prototype.forEach;\nvar hasSet = typeof Set === 'function' && Set.prototype;\nvar setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;\nvar setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;\nvar setForEach = hasSet && Set.prototype.forEach;\nvar hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;\nvar weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;\nvar hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;\nvar weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;\nvar hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;\nvar weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;\nvar booleanValueOf = Boolean.prototype.valueOf;\nvar objectToString = Object.prototype.toString;\nvar functionToString = Function.prototype.toString;\nvar $match = String.prototype.match;\nvar $slice = String.prototype.slice;\nvar $replace = String.prototype.replace;\nvar $toUpperCase = String.prototype.toUpperCase;\nvar $toLowerCase = String.prototype.toLowerCase;\nvar $test = RegExp.prototype.test;\nvar $concat = Array.prototype.concat;\nvar $join = Array.prototype.join;\nvar $arrSlice = Array.prototype.slice;\nvar $floor = Math.floor;\nvar bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;\nvar gOPS = Object.getOwnPropertySymbols;\nvar symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;\nvar hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';\n// ie, `has-tostringtag/shams\nvar toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')\n ? Symbol.toStringTag\n : null;\nvar isEnumerable = Object.prototype.propertyIsEnumerable;\n\nvar gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (\n [].__proto__ === Array.prototype // eslint-disable-line no-proto\n ? function (O) {\n return O.__proto__; // eslint-disable-line no-proto\n }\n : null\n);\n\nfunction addNumericSeparator(num, str) {\n if (\n num === Infinity\n || num === -Infinity\n || num !== num\n || (num && num > -1000 && num < 1000)\n || $test.call(/e/, str)\n ) {\n return str;\n }\n var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;\n if (typeof num === 'number') {\n var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)\n if (int !== num) {\n var intStr = String(int);\n var dec = $slice.call(str, intStr.length + 1);\n return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');\n }\n }\n return $replace.call(str, sepRegex, '$&_');\n}\n\nvar utilInspect = require('./util.inspect');\nvar inspectCustom = utilInspect.custom;\nvar inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;\n\nmodule.exports = function inspect_(obj, options, depth, seen) {\n var opts = options || {};\n\n if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {\n throw new TypeError('option \"quoteStyle\" must be \"single\" or \"double\"');\n }\n if (\n has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'\n ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity\n : opts.maxStringLength !== null\n )\n ) {\n throw new TypeError('option \"maxStringLength\", if provided, must be a positive integer, Infinity, or `null`');\n }\n var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;\n if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {\n throw new TypeError('option \"customInspect\", if provided, must be `true`, `false`, or `\\'symbol\\'`');\n }\n\n if (\n has(opts, 'indent')\n && opts.indent !== null\n && opts.indent !== '\\t'\n && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)\n ) {\n throw new TypeError('option \"indent\" must be \"\\\\t\", an integer > 0, or `null`');\n }\n if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {\n throw new TypeError('option \"numericSeparator\", if provided, must be `true` or `false`');\n }\n var numericSeparator = opts.numericSeparator;\n\n if (typeof obj === 'undefined') {\n return 'undefined';\n }\n if (obj === null) {\n return 'null';\n }\n if (typeof obj === 'boolean') {\n return obj ? 'true' : 'false';\n }\n\n if (typeof obj === 'string') {\n return inspectString(obj, opts);\n }\n if (typeof obj === 'number') {\n if (obj === 0) {\n return Infinity / obj > 0 ? '0' : '-0';\n }\n var str = String(obj);\n return numericSeparator ? addNumericSeparator(obj, str) : str;\n }\n if (typeof obj === 'bigint') {\n var bigIntStr = String(obj) + 'n';\n return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;\n }\n\n var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;\n if (typeof depth === 'undefined') { depth = 0; }\n if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {\n return isArray(obj) ? '[Array]' : '[Object]';\n }\n\n var indent = getIndent(opts, depth);\n\n if (typeof seen === 'undefined') {\n seen = [];\n } else if (indexOf(seen, obj) >= 0) {\n return '[Circular]';\n }\n\n function inspect(value, from, noIndent) {\n if (from) {\n seen = $arrSlice.call(seen);\n seen.push(from);\n }\n if (noIndent) {\n var newOpts = {\n depth: opts.depth\n };\n if (has(opts, 'quoteStyle')) {\n newOpts.quoteStyle = opts.quoteStyle;\n }\n return inspect_(value, newOpts, depth + 1, seen);\n }\n return inspect_(value, opts, depth + 1, seen);\n }\n\n if (typeof obj === 'function' && !isRegExp(obj)) { // in older engines, regexes are callable\n var name = nameOf(obj);\n var keys = arrObjKeys(obj, inspect);\n return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');\n }\n if (isSymbol(obj)) {\n var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\\(.*\\))_[^)]*$/, '$1') : symToString.call(obj);\n return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;\n }\n if (isElement(obj)) {\n var s = '<' + $toLowerCase.call(String(obj.nodeName));\n var attrs = obj.attributes || [];\n for (var i = 0; i < attrs.length; i++) {\n s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);\n }\n s += '>';\n if (obj.childNodes && obj.childNodes.length) { s += '...'; }\n s += '';\n return s;\n }\n if (isArray(obj)) {\n if (obj.length === 0) { return '[]'; }\n var xs = arrObjKeys(obj, inspect);\n if (indent && !singleLineValues(xs)) {\n return '[' + indentedJoin(xs, indent) + ']';\n }\n return '[ ' + $join.call(xs, ', ') + ' ]';\n }\n if (isError(obj)) {\n var parts = arrObjKeys(obj, inspect);\n if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {\n return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';\n }\n if (parts.length === 0) { return '[' + String(obj) + ']'; }\n return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';\n }\n if (typeof obj === 'object' && customInspect) {\n if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {\n return utilInspect(obj, { depth: maxDepth - depth });\n } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {\n return obj.inspect();\n }\n }\n if (isMap(obj)) {\n var mapParts = [];\n if (mapForEach) {\n mapForEach.call(obj, function (value, key) {\n mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));\n });\n }\n return collectionOf('Map', mapSize.call(obj), mapParts, indent);\n }\n if (isSet(obj)) {\n var setParts = [];\n if (setForEach) {\n setForEach.call(obj, function (value) {\n setParts.push(inspect(value, obj));\n });\n }\n return collectionOf('Set', setSize.call(obj), setParts, indent);\n }\n if (isWeakMap(obj)) {\n return weakCollectionOf('WeakMap');\n }\n if (isWeakSet(obj)) {\n return weakCollectionOf('WeakSet');\n }\n if (isWeakRef(obj)) {\n return weakCollectionOf('WeakRef');\n }\n if (isNumber(obj)) {\n return markBoxed(inspect(Number(obj)));\n }\n if (isBigInt(obj)) {\n return markBoxed(inspect(bigIntValueOf.call(obj)));\n }\n if (isBoolean(obj)) {\n return markBoxed(booleanValueOf.call(obj));\n }\n if (isString(obj)) {\n return markBoxed(inspect(String(obj)));\n }\n if (!isDate(obj) && !isRegExp(obj)) {\n var ys = arrObjKeys(obj, inspect);\n var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;\n var protoTag = obj instanceof Object ? '' : 'null prototype';\n var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';\n var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';\n var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');\n if (ys.length === 0) { return tag + '{}'; }\n if (indent) {\n return tag + '{' + indentedJoin(ys, indent) + '}';\n }\n return tag + '{ ' + $join.call(ys, ', ') + ' }';\n }\n return String(obj);\n};\n\nfunction wrapQuotes(s, defaultStyle, opts) {\n var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '\"' : \"'\";\n return quoteChar + s + quoteChar;\n}\n\nfunction quote(s) {\n return $replace.call(String(s), /\"/g, '"');\n}\n\nfunction isArray(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\nfunction isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\nfunction isRegExp(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\nfunction isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\nfunction isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\nfunction isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\nfunction isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }\n\n// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives\nfunction isSymbol(obj) {\n if (hasShammedSymbols) {\n return obj && typeof obj === 'object' && obj instanceof Symbol;\n }\n if (typeof obj === 'symbol') {\n return true;\n }\n if (!obj || typeof obj !== 'object' || !symToString) {\n return false;\n }\n try {\n symToString.call(obj);\n return true;\n } catch (e) {}\n return false;\n}\n\nfunction isBigInt(obj) {\n if (!obj || typeof obj !== 'object' || !bigIntValueOf) {\n return false;\n }\n try {\n bigIntValueOf.call(obj);\n return true;\n } catch (e) {}\n return false;\n}\n\nvar hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };\nfunction has(obj, key) {\n return hasOwn.call(obj, key);\n}\n\nfunction toStr(obj) {\n return objectToString.call(obj);\n}\n\nfunction nameOf(f) {\n if (f.name) { return f.name; }\n var m = $match.call(functionToString.call(f), /^function\\s*([\\w$]+)/);\n if (m) { return m[1]; }\n return null;\n}\n\nfunction indexOf(xs, x) {\n if (xs.indexOf) { return xs.indexOf(x); }\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) { return i; }\n }\n return -1;\n}\n\nfunction isMap(x) {\n if (!mapSize || !x || typeof x !== 'object') {\n return false;\n }\n try {\n mapSize.call(x);\n try {\n setSize.call(x);\n } catch (s) {\n return true;\n }\n return x instanceof Map; // core-js workaround, pre-v2.5.0\n } catch (e) {}\n return false;\n}\n\nfunction isWeakMap(x) {\n if (!weakMapHas || !x || typeof x !== 'object') {\n return false;\n }\n try {\n weakMapHas.call(x, weakMapHas);\n try {\n weakSetHas.call(x, weakSetHas);\n } catch (s) {\n return true;\n }\n return x instanceof WeakMap; // core-js workaround, pre-v2.5.0\n } catch (e) {}\n return false;\n}\n\nfunction isWeakRef(x) {\n if (!weakRefDeref || !x || typeof x !== 'object') {\n return false;\n }\n try {\n weakRefDeref.call(x);\n return true;\n } catch (e) {}\n return false;\n}\n\nfunction isSet(x) {\n if (!setSize || !x || typeof x !== 'object') {\n return false;\n }\n try {\n setSize.call(x);\n try {\n mapSize.call(x);\n } catch (m) {\n return true;\n }\n return x instanceof Set; // core-js workaround, pre-v2.5.0\n } catch (e) {}\n return false;\n}\n\nfunction isWeakSet(x) {\n if (!weakSetHas || !x || typeof x !== 'object') {\n return false;\n }\n try {\n weakSetHas.call(x, weakSetHas);\n try {\n weakMapHas.call(x, weakMapHas);\n } catch (s) {\n return true;\n }\n return x instanceof WeakSet; // core-js workaround, pre-v2.5.0\n } catch (e) {}\n return false;\n}\n\nfunction isElement(x) {\n if (!x || typeof x !== 'object') { return false; }\n if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {\n return true;\n }\n return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';\n}\n\nfunction inspectString(str, opts) {\n if (str.length > opts.maxStringLength) {\n var remaining = str.length - opts.maxStringLength;\n var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');\n return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;\n }\n // eslint-disable-next-line no-control-regex\n var s = $replace.call($replace.call(str, /(['\\\\])/g, '\\\\$1'), /[\\x00-\\x1f]/g, lowbyte);\n return wrapQuotes(s, 'single', opts);\n}\n\nfunction lowbyte(c) {\n var n = c.charCodeAt(0);\n var x = {\n 8: 'b',\n 9: 't',\n 10: 'n',\n 12: 'f',\n 13: 'r'\n }[n];\n if (x) { return '\\\\' + x; }\n return '\\\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));\n}\n\nfunction markBoxed(str) {\n return 'Object(' + str + ')';\n}\n\nfunction weakCollectionOf(type) {\n return type + ' { ? }';\n}\n\nfunction collectionOf(type, size, entries, indent) {\n var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');\n return type + ' (' + size + ') {' + joinedEntries + '}';\n}\n\nfunction singleLineValues(xs) {\n for (var i = 0; i < xs.length; i++) {\n if (indexOf(xs[i], '\\n') >= 0) {\n return false;\n }\n }\n return true;\n}\n\nfunction getIndent(opts, depth) {\n var baseIndent;\n if (opts.indent === '\\t') {\n baseIndent = '\\t';\n } else if (typeof opts.indent === 'number' && opts.indent > 0) {\n baseIndent = $join.call(Array(opts.indent + 1), ' ');\n } else {\n return null;\n }\n return {\n base: baseIndent,\n prev: $join.call(Array(depth + 1), baseIndent)\n };\n}\n\nfunction indentedJoin(xs, indent) {\n if (xs.length === 0) { return ''; }\n var lineJoiner = '\\n' + indent.prev + indent.base;\n return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\\n' + indent.prev;\n}\n\nfunction arrObjKeys(obj, inspect) {\n var isArr = isArray(obj);\n var xs = [];\n if (isArr) {\n xs.length = obj.length;\n for (var i = 0; i < obj.length; i++) {\n xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';\n }\n }\n var syms = typeof gOPS === 'function' ? gOPS(obj) : [];\n var symMap;\n if (hasShammedSymbols) {\n symMap = {};\n for (var k = 0; k < syms.length; k++) {\n symMap['$' + syms[k]] = syms[k];\n }\n }\n\n for (var key in obj) { // eslint-disable-line no-restricted-syntax\n if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue\n if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue\n if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {\n // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section\n continue; // eslint-disable-line no-restricted-syntax, no-continue\n } else if ($test.call(/[^\\w$]/, key)) {\n xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));\n } else {\n xs.push(key + ': ' + inspect(obj[key], obj));\n }\n }\n if (typeof gOPS === 'function') {\n for (var j = 0; j < syms.length; j++) {\n if (isEnumerable.call(obj, syms[j])) {\n xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));\n }\n }\n }\n return xs;\n}\n", "'use strict';\n\nvar GetIntrinsic = require('get-intrinsic');\nvar callBound = require('call-bind/callBound');\nvar inspect = require('object-inspect');\n\nvar $TypeError = GetIntrinsic('%TypeError%');\nvar $WeakMap = GetIntrinsic('%WeakMap%', true);\nvar $Map = GetIntrinsic('%Map%', true);\n\nvar $weakMapGet = callBound('WeakMap.prototype.get', true);\nvar $weakMapSet = callBound('WeakMap.prototype.set', true);\nvar $weakMapHas = callBound('WeakMap.prototype.has', true);\nvar $mapGet = callBound('Map.prototype.get', true);\nvar $mapSet = callBound('Map.prototype.set', true);\nvar $mapHas = callBound('Map.prototype.has', true);\n\n/*\n * This function traverses the list returning the node corresponding to the\n * given key.\n *\n * That node is also moved to the head of the list, so that if it's accessed\n * again we don't need to traverse the whole list. By doing so, all the recently\n * used nodes can be accessed relatively quickly.\n */\nvar listGetNode = function (list, key) { // eslint-disable-line consistent-return\n\tfor (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {\n\t\tif (curr.key === key) {\n\t\t\tprev.next = curr.next;\n\t\t\tcurr.next = list.next;\n\t\t\tlist.next = curr; // eslint-disable-line no-param-reassign\n\t\t\treturn curr;\n\t\t}\n\t}\n};\n\nvar listGet = function (objects, key) {\n\tvar node = listGetNode(objects, key);\n\treturn node && node.value;\n};\nvar listSet = function (objects, key, value) {\n\tvar node = listGetNode(objects, key);\n\tif (node) {\n\t\tnode.value = value;\n\t} else {\n\t\t// Prepend the new node to the beginning of the list\n\t\tobjects.next = { // eslint-disable-line no-param-reassign\n\t\t\tkey: key,\n\t\t\tnext: objects.next,\n\t\t\tvalue: value\n\t\t};\n\t}\n};\nvar listHas = function (objects, key) {\n\treturn !!listGetNode(objects, key);\n};\n\nmodule.exports = function getSideChannel() {\n\tvar $wm;\n\tvar $m;\n\tvar $o;\n\tvar channel = {\n\t\tassert: function (key) {\n\t\t\tif (!channel.has(key)) {\n\t\t\t\tthrow new $TypeError('Side channel does not contain ' + inspect(key));\n\t\t\t}\n\t\t},\n\t\tget: function (key) { // eslint-disable-line consistent-return\n\t\t\tif ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {\n\t\t\t\tif ($wm) {\n\t\t\t\t\treturn $weakMapGet($wm, key);\n\t\t\t\t}\n\t\t\t} else if ($Map) {\n\t\t\t\tif ($m) {\n\t\t\t\t\treturn $mapGet($m, key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ($o) { // eslint-disable-line no-lonely-if\n\t\t\t\t\treturn listGet($o, key);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\thas: function (key) {\n\t\t\tif ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {\n\t\t\t\tif ($wm) {\n\t\t\t\t\treturn $weakMapHas($wm, key);\n\t\t\t\t}\n\t\t\t} else if ($Map) {\n\t\t\t\tif ($m) {\n\t\t\t\t\treturn $mapHas($m, key);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ($o) { // eslint-disable-line no-lonely-if\n\t\t\t\t\treturn listHas($o, key);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\tset: function (key, value) {\n\t\t\tif ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {\n\t\t\t\tif (!$wm) {\n\t\t\t\t\t$wm = new $WeakMap();\n\t\t\t\t}\n\t\t\t\t$weakMapSet($wm, key, value);\n\t\t\t} else if ($Map) {\n\t\t\t\tif (!$m) {\n\t\t\t\t\t$m = new $Map();\n\t\t\t\t}\n\t\t\t\t$mapSet($m, key, value);\n\t\t\t} else {\n\t\t\t\tif (!$o) {\n\t\t\t\t\t/*\n\t\t\t\t\t * Initialize the linked list as an empty node, so that we don't have\n\t\t\t\t\t * to special-case handling of the first node: we can always refer to\n\t\t\t\t\t * it as (previous node).next, instead of something like (list).head\n\t\t\t\t\t */\n\t\t\t\t\t$o = { key: {}, next: null };\n\t\t\t\t}\n\t\t\t\tlistSet($o, key, value);\n\t\t\t}\n\t\t}\n\t};\n\treturn channel;\n};\n", "'use strict';\n\nvar replace = String.prototype.replace;\nvar percentTwenties = /%20/g;\n\nvar Format = {\n RFC1738: 'RFC1738',\n RFC3986: 'RFC3986'\n};\n\nmodule.exports = {\n 'default': Format.RFC3986,\n formatters: {\n RFC1738: function (value) {\n return replace.call(value, percentTwenties, '+');\n },\n RFC3986: function (value) {\n return String(value);\n }\n },\n RFC1738: Format.RFC1738,\n RFC3986: Format.RFC3986\n};\n", "'use strict';\n\nvar formats = require('./formats');\n\nvar has = Object.prototype.hasOwnProperty;\nvar isArray = Array.isArray;\n\nvar hexTable = (function () {\n var array = [];\n for (var i = 0; i < 256; ++i) {\n array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());\n }\n\n return array;\n}());\n\nvar compactQueue = function compactQueue(queue) {\n while (queue.length > 1) {\n var item = queue.pop();\n var obj = item.obj[item.prop];\n\n if (isArray(obj)) {\n var compacted = [];\n\n for (var j = 0; j < obj.length; ++j) {\n if (typeof obj[j] !== 'undefined') {\n compacted.push(obj[j]);\n }\n }\n\n item.obj[item.prop] = compacted;\n }\n }\n};\n\nvar arrayToObject = function arrayToObject(source, options) {\n var obj = options && options.plainObjects ? Object.create(null) : {};\n for (var i = 0; i < source.length; ++i) {\n if (typeof source[i] !== 'undefined') {\n obj[i] = source[i];\n }\n }\n\n return obj;\n};\n\nvar merge = function merge(target, source, options) {\n /* eslint no-param-reassign: 0 */\n if (!source) {\n return target;\n }\n\n if (typeof source !== 'object') {\n if (isArray(target)) {\n target.push(source);\n } else if (target && typeof target === 'object') {\n if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {\n target[source] = true;\n }\n } else {\n return [target, source];\n }\n\n return target;\n }\n\n if (!target || typeof target !== 'object') {\n return [target].concat(source);\n }\n\n var mergeTarget = target;\n if (isArray(target) && !isArray(source)) {\n mergeTarget = arrayToObject(target, options);\n }\n\n if (isArray(target) && isArray(source)) {\n source.forEach(function (item, i) {\n if (has.call(target, i)) {\n var targetItem = target[i];\n if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {\n target[i] = merge(targetItem, item, options);\n } else {\n target.push(item);\n }\n } else {\n target[i] = item;\n }\n });\n return target;\n }\n\n return Object.keys(source).reduce(function (acc, key) {\n var value = source[key];\n\n if (has.call(acc, key)) {\n acc[key] = merge(acc[key], value, options);\n } else {\n acc[key] = value;\n }\n return acc;\n }, mergeTarget);\n};\n\nvar assign = function assignSingleSource(target, source) {\n return Object.keys(source).reduce(function (acc, key) {\n acc[key] = source[key];\n return acc;\n }, target);\n};\n\nvar decode = function (str, decoder, charset) {\n var strWithoutPlus = str.replace(/\\+/g, ' ');\n if (charset === 'iso-8859-1') {\n // unescape never throws, no try...catch needed:\n return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);\n }\n // utf-8\n try {\n return decodeURIComponent(strWithoutPlus);\n } catch (e) {\n return strWithoutPlus;\n }\n};\n\nvar encode = function encode(str, defaultEncoder, charset, kind, format) {\n // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n // It has been adapted here for stricter adherence to RFC 3986\n if (str.length === 0) {\n return str;\n }\n\n var string = str;\n if (typeof str === 'symbol') {\n string = Symbol.prototype.toString.call(str);\n } else if (typeof str !== 'string') {\n string = String(str);\n }\n\n if (charset === 'iso-8859-1') {\n return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {\n return '%26%23' + parseInt($0.slice(2), 16) + '%3B';\n });\n }\n\n var out = '';\n for (var i = 0; i < string.length; ++i) {\n var c = string.charCodeAt(i);\n\n if (\n c === 0x2D // -\n || c === 0x2E // .\n || c === 0x5F // _\n || c === 0x7E // ~\n || (c >= 0x30 && c <= 0x39) // 0-9\n || (c >= 0x41 && c <= 0x5A) // a-z\n || (c >= 0x61 && c <= 0x7A) // A-Z\n || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )\n ) {\n out += string.charAt(i);\n continue;\n }\n\n if (c < 0x80) {\n out = out + hexTable[c];\n continue;\n }\n\n if (c < 0x800) {\n out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);\n continue;\n }\n\n if (c < 0xD800 || c >= 0xE000) {\n out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);\n continue;\n }\n\n i += 1;\n c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));\n /* eslint operator-linebreak: [2, \"before\"] */\n out += hexTable[0xF0 | (c >> 18)]\n + hexTable[0x80 | ((c >> 12) & 0x3F)]\n + hexTable[0x80 | ((c >> 6) & 0x3F)]\n + hexTable[0x80 | (c & 0x3F)];\n }\n\n return out;\n};\n\nvar compact = function compact(value) {\n var queue = [{ obj: { o: value }, prop: 'o' }];\n var refs = [];\n\n for (var i = 0; i < queue.length; ++i) {\n var item = queue[i];\n var obj = item.obj[item.prop];\n\n var keys = Object.keys(obj);\n for (var j = 0; j < keys.length; ++j) {\n var key = keys[j];\n var val = obj[key];\n if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {\n queue.push({ obj: obj, prop: key });\n refs.push(val);\n }\n }\n }\n\n compactQueue(queue);\n\n return value;\n};\n\nvar isRegExp = function isRegExp(obj) {\n return Object.prototype.toString.call(obj) === '[object RegExp]';\n};\n\nvar isBuffer = function isBuffer(obj) {\n if (!obj || typeof obj !== 'object') {\n return false;\n }\n\n return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));\n};\n\nvar combine = function combine(a, b) {\n return [].concat(a, b);\n};\n\nvar maybeMap = function maybeMap(val, fn) {\n if (isArray(val)) {\n var mapped = [];\n for (var i = 0; i < val.length; i += 1) {\n mapped.push(fn(val[i]));\n }\n return mapped;\n }\n return fn(val);\n};\n\nmodule.exports = {\n arrayToObject: arrayToObject,\n assign: assign,\n combine: combine,\n compact: compact,\n decode: decode,\n encode: encode,\n isBuffer: isBuffer,\n isRegExp: isRegExp,\n maybeMap: maybeMap,\n merge: merge\n};\n", "'use strict';\n\nvar getSideChannel = require('side-channel');\nvar utils = require('./utils');\nvar formats = require('./formats');\nvar has = Object.prototype.hasOwnProperty;\n\nvar arrayPrefixGenerators = {\n brackets: function brackets(prefix) {\n return prefix + '[]';\n },\n comma: 'comma',\n indices: function indices(prefix, key) {\n return prefix + '[' + key + ']';\n },\n repeat: function repeat(prefix) {\n return prefix;\n }\n};\n\nvar isArray = Array.isArray;\nvar split = String.prototype.split;\nvar push = Array.prototype.push;\nvar pushToArray = function (arr, valueOrArray) {\n push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);\n};\n\nvar toISO = Date.prototype.toISOString;\n\nvar defaultFormat = formats['default'];\nvar defaults = {\n addQueryPrefix: false,\n allowDots: false,\n charset: 'utf-8',\n charsetSentinel: false,\n delimiter: '&',\n encode: true,\n encoder: utils.encode,\n encodeValuesOnly: false,\n format: defaultFormat,\n formatter: formats.formatters[defaultFormat],\n // deprecated\n indices: false,\n serializeDate: function serializeDate(date) {\n return toISO.call(date);\n },\n skipNulls: false,\n strictNullHandling: false\n};\n\nvar isNonNullishPrimitive = function isNonNullishPrimitive(v) {\n return typeof v === 'string'\n || typeof v === 'number'\n || typeof v === 'boolean'\n || typeof v === 'symbol'\n || typeof v === 'bigint';\n};\n\nvar sentinel = {};\n\nvar stringify = function stringify(\n object,\n prefix,\n generateArrayPrefix,\n commaRoundTrip,\n strictNullHandling,\n skipNulls,\n encoder,\n filter,\n sort,\n allowDots,\n serializeDate,\n format,\n formatter,\n encodeValuesOnly,\n charset,\n sideChannel\n) {\n var obj = object;\n\n var tmpSc = sideChannel;\n var step = 0;\n var findFlag = false;\n while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {\n // Where object last appeared in the ref tree\n var pos = tmpSc.get(object);\n step += 1;\n if (typeof pos !== 'undefined') {\n if (pos === step) {\n throw new RangeError('Cyclic object value');\n } else {\n findFlag = true; // Break while\n }\n }\n if (typeof tmpSc.get(sentinel) === 'undefined') {\n step = 0;\n }\n }\n\n if (typeof filter === 'function') {\n obj = filter(prefix, obj);\n } else if (obj instanceof Date) {\n obj = serializeDate(obj);\n } else if (generateArrayPrefix === 'comma' && isArray(obj)) {\n obj = utils.maybeMap(obj, function (value) {\n if (value instanceof Date) {\n return serializeDate(value);\n }\n return value;\n });\n }\n\n if (obj === null) {\n if (strictNullHandling) {\n return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;\n }\n\n obj = '';\n }\n\n if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {\n if (encoder) {\n var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);\n if (generateArrayPrefix === 'comma' && encodeValuesOnly) {\n var valuesArray = split.call(String(obj), ',');\n var valuesJoined = '';\n for (var i = 0; i < valuesArray.length; ++i) {\n valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));\n }\n return [formatter(keyValue) + (commaRoundTrip && isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];\n }\n return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];\n }\n return [formatter(prefix) + '=' + formatter(String(obj))];\n }\n\n var values = [];\n\n if (typeof obj === 'undefined') {\n return values;\n }\n\n var objKeys;\n if (generateArrayPrefix === 'comma' && isArray(obj)) {\n // we need to join elements in\n objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];\n } else if (isArray(filter)) {\n objKeys = filter;\n } else {\n var keys = Object.keys(obj);\n objKeys = sort ? keys.sort(sort) : keys;\n }\n\n var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;\n\n for (var j = 0; j < objKeys.length; ++j) {\n var key = objKeys[j];\n var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];\n\n if (skipNulls && value === null) {\n continue;\n }\n\n var keyPrefix = isArray(obj)\n ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix\n : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');\n\n sideChannel.set(object, step);\n var valueSideChannel = getSideChannel();\n valueSideChannel.set(sentinel, sideChannel);\n pushToArray(values, stringify(\n value,\n keyPrefix,\n generateArrayPrefix,\n commaRoundTrip,\n strictNullHandling,\n skipNulls,\n encoder,\n filter,\n sort,\n allowDots,\n serializeDate,\n format,\n formatter,\n encodeValuesOnly,\n charset,\n valueSideChannel\n ));\n }\n\n return values;\n};\n\nvar normalizeStringifyOptions = function normalizeStringifyOptions(opts) {\n if (!opts) {\n return defaults;\n }\n\n if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {\n throw new TypeError('Encoder has to be a function.');\n }\n\n var charset = opts.charset || defaults.charset;\n if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {\n throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');\n }\n\n var format = formats['default'];\n if (typeof opts.format !== 'undefined') {\n if (!has.call(formats.formatters, opts.format)) {\n throw new TypeError('Unknown format option provided.');\n }\n format = opts.format;\n }\n var formatter = formats.formatters[format];\n\n var filter = defaults.filter;\n if (typeof opts.filter === 'function' || isArray(opts.filter)) {\n filter = opts.filter;\n }\n\n return {\n addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,\n allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,\n charset: charset,\n charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,\n delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,\n encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,\n encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,\n encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,\n filter: filter,\n format: format,\n formatter: formatter,\n serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,\n skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,\n sort: typeof opts.sort === 'function' ? opts.sort : null,\n strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling\n };\n};\n\nmodule.exports = function (object, opts) {\n var obj = object;\n var options = normalizeStringifyOptions(opts);\n\n var objKeys;\n var filter;\n\n if (typeof options.filter === 'function') {\n filter = options.filter;\n obj = filter('', obj);\n } else if (isArray(options.filter)) {\n filter = options.filter;\n objKeys = filter;\n }\n\n var keys = [];\n\n if (typeof obj !== 'object' || obj === null) {\n return '';\n }\n\n var arrayFormat;\n if (opts && opts.arrayFormat in arrayPrefixGenerators) {\n arrayFormat = opts.arrayFormat;\n } else if (opts && 'indices' in opts) {\n arrayFormat = opts.indices ? 'indices' : 'repeat';\n } else {\n arrayFormat = 'indices';\n }\n\n var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];\n if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {\n throw new TypeError('`commaRoundTrip` must be a boolean, or absent');\n }\n var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;\n\n if (!objKeys) {\n objKeys = Object.keys(obj);\n }\n\n if (options.sort) {\n objKeys.sort(options.sort);\n }\n\n var sideChannel = getSideChannel();\n for (var i = 0; i < objKeys.length; ++i) {\n var key = objKeys[i];\n\n if (options.skipNulls && obj[key] === null) {\n continue;\n }\n pushToArray(keys, stringify(\n obj[key],\n key,\n generateArrayPrefix,\n commaRoundTrip,\n options.strictNullHandling,\n options.skipNulls,\n options.encode ? options.encoder : null,\n options.filter,\n options.sort,\n options.allowDots,\n options.serializeDate,\n options.format,\n options.formatter,\n options.encodeValuesOnly,\n options.charset,\n sideChannel\n ));\n }\n\n var joined = keys.join(options.delimiter);\n var prefix = options.addQueryPrefix === true ? '?' : '';\n\n if (options.charsetSentinel) {\n if (options.charset === 'iso-8859-1') {\n // encodeURIComponent('✓'), the \"numeric entity\" representation of a checkmark\n prefix += 'utf8=%26%2310003%3B&';\n } else {\n // encodeURIComponent('\u2713')\n prefix += 'utf8=%E2%9C%93&';\n }\n }\n\n return joined.length > 0 ? prefix + joined : '';\n};\n", "'use strict';\n\nvar utils = require('./utils');\n\nvar has = Object.prototype.hasOwnProperty;\nvar isArray = Array.isArray;\n\nvar defaults = {\n allowDots: false,\n allowPrototypes: false,\n allowSparse: false,\n arrayLimit: 20,\n charset: 'utf-8',\n charsetSentinel: false,\n comma: false,\n decoder: utils.decode,\n delimiter: '&',\n depth: 5,\n ignoreQueryPrefix: false,\n interpretNumericEntities: false,\n parameterLimit: 1000,\n parseArrays: true,\n plainObjects: false,\n strictNullHandling: false\n};\n\nvar interpretNumericEntities = function (str) {\n return str.replace(/&#(\\d+);/g, function ($0, numberStr) {\n return String.fromCharCode(parseInt(numberStr, 10));\n });\n};\n\nvar parseArrayValue = function (val, options) {\n if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {\n return val.split(',');\n }\n\n return val;\n};\n\n// This is what browsers will submit when the \u2713 character occurs in an\n// application/x-www-form-urlencoded body and the encoding of the page containing\n// the form is iso-8859-1, or when the submitted form has an accept-charset\n// attribute of iso-8859-1. Presumably also with other charsets that do not contain\n// the \u2713 character, such as us-ascii.\nvar isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')\n\n// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.\nvar charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('\u2713')\n\nvar parseValues = function parseQueryStringValues(str, options) {\n var obj = {};\n var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\\?/, '') : str;\n var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;\n var parts = cleanStr.split(options.delimiter, limit);\n var skipIndex = -1; // Keep track of where the utf8 sentinel was found\n var i;\n\n var charset = options.charset;\n if (options.charsetSentinel) {\n for (i = 0; i < parts.length; ++i) {\n if (parts[i].indexOf('utf8=') === 0) {\n if (parts[i] === charsetSentinel) {\n charset = 'utf-8';\n } else if (parts[i] === isoSentinel) {\n charset = 'iso-8859-1';\n }\n skipIndex = i;\n i = parts.length; // The eslint settings do not allow break;\n }\n }\n }\n\n for (i = 0; i < parts.length; ++i) {\n if (i === skipIndex) {\n continue;\n }\n var part = parts[i];\n\n var bracketEqualsPos = part.indexOf(']=');\n var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;\n\n var key, val;\n if (pos === -1) {\n key = options.decoder(part, defaults.decoder, charset, 'key');\n val = options.strictNullHandling ? null : '';\n } else {\n key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');\n val = utils.maybeMap(\n parseArrayValue(part.slice(pos + 1), options),\n function (encodedVal) {\n return options.decoder(encodedVal, defaults.decoder, charset, 'value');\n }\n );\n }\n\n if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {\n val = interpretNumericEntities(val);\n }\n\n if (part.indexOf('[]=') > -1) {\n val = isArray(val) ? [val] : val;\n }\n\n if (has.call(obj, key)) {\n obj[key] = utils.combine(obj[key], val);\n } else {\n obj[key] = val;\n }\n }\n\n return obj;\n};\n\nvar parseObject = function (chain, val, options, valuesParsed) {\n var leaf = valuesParsed ? val : parseArrayValue(val, options);\n\n for (var i = chain.length - 1; i >= 0; --i) {\n var obj;\n var root = chain[i];\n\n if (root === '[]' && options.parseArrays) {\n obj = [].concat(leaf);\n } else {\n obj = options.plainObjects ? Object.create(null) : {};\n var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;\n var index = parseInt(cleanRoot, 10);\n if (!options.parseArrays && cleanRoot === '') {\n obj = { 0: leaf };\n } else if (\n !isNaN(index)\n && root !== cleanRoot\n && String(index) === cleanRoot\n && index >= 0\n && (options.parseArrays && index <= options.arrayLimit)\n ) {\n obj = [];\n obj[index] = leaf;\n } else if (cleanRoot !== '__proto__') {\n obj[cleanRoot] = leaf;\n }\n }\n\n leaf = obj;\n }\n\n return leaf;\n};\n\nvar parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {\n if (!givenKey) {\n return;\n }\n\n // Transform dot notation to bracket notation\n var key = options.allowDots ? givenKey.replace(/\\.([^.[]+)/g, '[$1]') : givenKey;\n\n // The regex chunks\n\n var brackets = /(\\[[^[\\]]*])/;\n var child = /(\\[[^[\\]]*])/g;\n\n // Get the parent\n\n var segment = options.depth > 0 && brackets.exec(key);\n var parent = segment ? key.slice(0, segment.index) : key;\n\n // Stash the parent if it exists\n\n var keys = [];\n if (parent) {\n // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties\n if (!options.plainObjects && has.call(Object.prototype, parent)) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(parent);\n }\n\n // Loop through children appending to the array until we hit depth\n\n var i = 0;\n while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {\n i += 1;\n if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n keys.push(segment[1]);\n }\n\n // If there's a remainder, just add whatever is left\n\n if (segment) {\n keys.push('[' + key.slice(segment.index) + ']');\n }\n\n return parseObject(keys, val, options, valuesParsed);\n};\n\nvar normalizeParseOptions = function normalizeParseOptions(opts) {\n if (!opts) {\n return defaults;\n }\n\n if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {\n throw new TypeError('Decoder has to be a function.');\n }\n\n if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {\n throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');\n }\n var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;\n\n return {\n allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,\n allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,\n allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,\n arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,\n charset: charset,\n charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,\n comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,\n decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,\n delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,\n // eslint-disable-next-line no-implicit-coercion, no-extra-parens\n depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,\n ignoreQueryPrefix: opts.ignoreQueryPrefix === true,\n interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,\n parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,\n parseArrays: opts.parseArrays !== false,\n plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,\n strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling\n };\n};\n\nmodule.exports = function (str, opts) {\n var options = normalizeParseOptions(opts);\n\n if (str === '' || str === null || typeof str === 'undefined') {\n return options.plainObjects ? Object.create(null) : {};\n }\n\n var tempObj = typeof str === 'string' ? parseValues(str, options) : str;\n var obj = options.plainObjects ? Object.create(null) : {};\n\n // Iterate over the keys and setup the new object\n\n var keys = Object.keys(tempObj);\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');\n obj = utils.merge(obj, newObj, options);\n }\n\n if (options.allowSparse === true) {\n return obj;\n }\n\n return utils.compact(obj);\n};\n", "'use strict';\n\nvar stringify = require('./stringify');\nvar parse = require('./parse');\nvar formats = require('./formats');\n\nmodule.exports = {\n formats: formats,\n parse: parse,\n stringify: stringify\n};\n", "/*!\n * body-parser\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar bytes = require('bytes')\nvar contentType = require('content-type')\nvar createError = require('http-errors')\nvar debug = require('debug')('body-parser:urlencoded')\nvar deprecate = require('depd')('body-parser')\nvar read = require('../read')\nvar typeis = require('type-is')\n\n/**\n * Module exports.\n */\n\nmodule.exports = urlencoded\n\n/**\n * Cache of parser modules.\n */\n\nvar parsers = Object.create(null)\n\n/**\n * Create a middleware to parse urlencoded bodies.\n *\n * @param {object} [options]\n * @return {function}\n * @public\n */\n\nfunction urlencoded (options) {\n var opts = options || {}\n\n // notice because option default will flip in next major\n if (opts.extended === undefined) {\n deprecate('undefined extended: provide extended option')\n }\n\n var extended = opts.extended !== false\n var inflate = opts.inflate !== false\n var limit = typeof opts.limit !== 'number'\n ? bytes.parse(opts.limit || '100kb')\n : opts.limit\n var type = opts.type || 'application/x-www-form-urlencoded'\n var verify = opts.verify || false\n\n if (verify !== false && typeof verify !== 'function') {\n throw new TypeError('option verify must be function')\n }\n\n // create the appropriate query parser\n var queryparse = extended\n ? extendedparser(opts)\n : simpleparser(opts)\n\n // create the appropriate type checking function\n var shouldParse = typeof type !== 'function'\n ? typeChecker(type)\n : type\n\n function parse (body) {\n return body.length\n ? queryparse(body)\n : {}\n }\n\n return function urlencodedParser (req, res, next) {\n if (req._body) {\n debug('body already parsed')\n next()\n return\n }\n\n req.body = req.body || {}\n\n // skip requests without bodies\n if (!typeis.hasBody(req)) {\n debug('skip empty body')\n next()\n return\n }\n\n debug('content-type %j', req.headers['content-type'])\n\n // determine if request should be parsed\n if (!shouldParse(req)) {\n debug('skip parsing')\n next()\n return\n }\n\n // assert charset\n var charset = getCharset(req) || 'utf-8'\n if (charset !== 'utf-8') {\n debug('invalid charset')\n next(createError(415, 'unsupported charset \"' + charset.toUpperCase() + '\"', {\n charset: charset,\n type: 'charset.unsupported'\n }))\n return\n }\n\n // read\n read(req, res, next, parse, debug, {\n debug: debug,\n encoding: charset,\n inflate: inflate,\n limit: limit,\n verify: verify\n })\n }\n}\n\n/**\n * Get the extended query parser.\n *\n * @param {object} options\n */\n\nfunction extendedparser (options) {\n var parameterLimit = options.parameterLimit !== undefined\n ? options.parameterLimit\n : 1000\n var parse = parser('qs')\n\n if (isNaN(parameterLimit) || parameterLimit < 1) {\n throw new TypeError('option parameterLimit must be a positive number')\n }\n\n if (isFinite(parameterLimit)) {\n parameterLimit = parameterLimit | 0\n }\n\n return function queryparse (body) {\n var paramCount = parameterCount(body, parameterLimit)\n\n if (paramCount === undefined) {\n debug('too many parameters')\n throw createError(413, 'too many parameters', {\n type: 'parameters.too.many'\n })\n }\n\n var arrayLimit = Math.max(100, paramCount)\n\n debug('parse extended urlencoding')\n return parse(body, {\n allowPrototypes: true,\n arrayLimit: arrayLimit,\n depth: Infinity,\n parameterLimit: parameterLimit\n })\n }\n}\n\n/**\n * Get the charset of a request.\n *\n * @param {object} req\n * @api private\n */\n\nfunction getCharset (req) {\n try {\n return (contentType.parse(req).parameters.charset || '').toLowerCase()\n } catch (e) {\n return undefined\n }\n}\n\n/**\n * Count the number of parameters, stopping once limit reached\n *\n * @param {string} body\n * @param {number} limit\n * @api private\n */\n\nfunction parameterCount (body, limit) {\n var count = 0\n var index = 0\n\n while ((index = body.indexOf('&', index)) !== -1) {\n count++\n index++\n\n if (count === limit) {\n return undefined\n }\n }\n\n return count\n}\n\n/**\n * Get parser for module name dynamically.\n *\n * @param {string} name\n * @return {function}\n * @api private\n */\n\nfunction parser (name) {\n var mod = parsers[name]\n\n if (mod !== undefined) {\n return mod.parse\n }\n\n // this uses a switch for static require analysis\n switch (name) {\n case 'qs':\n mod = require('qs')\n break\n case 'querystring':\n mod = require('querystring')\n break\n }\n\n // store to prevent invoking require()\n parsers[name] = mod\n\n return mod.parse\n}\n\n/**\n * Get the simple query parser.\n *\n * @param {object} options\n */\n\nfunction simpleparser (options) {\n var parameterLimit = options.parameterLimit !== undefined\n ? options.parameterLimit\n : 1000\n var parse = parser('querystring')\n\n if (isNaN(parameterLimit) || parameterLimit < 1) {\n throw new TypeError('option parameterLimit must be a positive number')\n }\n\n if (isFinite(parameterLimit)) {\n parameterLimit = parameterLimit | 0\n }\n\n return function queryparse (body) {\n var paramCount = parameterCount(body, parameterLimit)\n\n if (paramCount === undefined) {\n debug('too many parameters')\n throw createError(413, 'too many parameters', {\n type: 'parameters.too.many'\n })\n }\n\n debug('parse urlencoding')\n return parse(body, undefined, undefined, { maxKeys: parameterLimit })\n }\n}\n\n/**\n * Get the simple type checker.\n *\n * @param {string} type\n * @return {function}\n */\n\nfunction typeChecker (type) {\n return function checkType (req) {\n return Boolean(typeis(req, type))\n }\n}\n", "/*!\n * body-parser\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar deprecate = require('depd')('body-parser')\n\n/**\n * Cache of loaded parsers.\n * @private\n */\n\nvar parsers = Object.create(null)\n\n/**\n * @typedef Parsers\n * @type {function}\n * @property {function} json\n * @property {function} raw\n * @property {function} text\n * @property {function} urlencoded\n */\n\n/**\n * Module exports.\n * @type {Parsers}\n */\n\nexports = module.exports = deprecate.function(bodyParser,\n 'bodyParser: use individual json/urlencoded middlewares')\n\n/**\n * JSON parser.\n * @public\n */\n\nObject.defineProperty(exports, 'json', {\n configurable: true,\n enumerable: true,\n get: createParserGetter('json')\n})\n\n/**\n * Raw parser.\n * @public\n */\n\nObject.defineProperty(exports, 'raw', {\n configurable: true,\n enumerable: true,\n get: createParserGetter('raw')\n})\n\n/**\n * Text parser.\n * @public\n */\n\nObject.defineProperty(exports, 'text', {\n configurable: true,\n enumerable: true,\n get: createParserGetter('text')\n})\n\n/**\n * URL-encoded parser.\n * @public\n */\n\nObject.defineProperty(exports, 'urlencoded', {\n configurable: true,\n enumerable: true,\n get: createParserGetter('urlencoded')\n})\n\n/**\n * Create a middleware to parse json and urlencoded bodies.\n *\n * @param {object} [options]\n * @return {function}\n * @deprecated\n * @public\n */\n\nfunction bodyParser (options) {\n // use default type for parsers\n var opts = Object.create(options || null, {\n type: {\n configurable: true,\n enumerable: true,\n value: undefined,\n writable: true\n }\n })\n\n var _urlencoded = exports.urlencoded(opts)\n var _json = exports.json(opts)\n\n return function bodyParser (req, res, next) {\n _json(req, res, function (err) {\n if (err) return next(err)\n _urlencoded(req, res, next)\n })\n }\n}\n\n/**\n * Create a getter for loading a parser.\n * @private\n */\n\nfunction createParserGetter (name) {\n return function get () {\n return loadParser(name)\n }\n}\n\n/**\n * Load a parser module.\n * @private\n */\n\nfunction loadParser (parserName) {\n var parser = parsers[parserName]\n\n if (parser !== undefined) {\n return parser\n }\n\n // this uses a switch for static require analysis\n switch (parserName) {\n case 'json':\n parser = require('./lib/types/json')\n break\n case 'raw':\n parser = require('./lib/types/raw')\n break\n case 'text':\n parser = require('./lib/types/text')\n break\n case 'urlencoded':\n parser = require('./lib/types/urlencoded')\n break\n }\n\n // store to prevent invoking require()\n return (parsers[parserName] = parser)\n}\n", "/*!\n * merge-descriptors\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = merge\n\n/**\n * Module variables.\n * @private\n */\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n\n/**\n * Merge the property descriptors of `src` into `dest`\n *\n * @param {object} dest Object to add descriptors to\n * @param {object} src Object to clone descriptors from\n * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties\n * @returns {object} Reference to dest\n * @public\n */\n\nfunction merge(dest, src, redefine) {\n if (!dest) {\n throw new TypeError('argument dest is required')\n }\n\n if (!src) {\n throw new TypeError('argument src is required')\n }\n\n if (redefine === undefined) {\n // Default to true\n redefine = true\n }\n\n Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {\n if (!redefine && hasOwnProperty.call(dest, name)) {\n // Skip desriptor\n return\n }\n\n // Copy descriptor\n var descriptor = Object.getOwnPropertyDescriptor(src, name)\n Object.defineProperty(dest, name, descriptor)\n })\n\n return dest\n}\n", "/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isNaN(val) === false) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n if (ms >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (ms >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (ms >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (ms >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n return plural(ms, d, 'day') ||\n plural(ms, h, 'hour') ||\n plural(ms, m, 'minute') ||\n plural(ms, s, 'second') ||\n ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) {\n return;\n }\n if (ms < n * 1.5) {\n return Math.floor(ms / n) + ' ' + name;\n }\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n", "\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = createDebug.debug = createDebug['default'] = createDebug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n */\n\nexports.formatters = {};\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n * @param {String} namespace\n * @return {Number}\n * @api private\n */\n\nfunction selectColor(namespace) {\n var hash = 0, i;\n\n for (i in namespace) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n hash |= 0; // Convert to 32bit integer\n }\n\n return exports.colors[Math.abs(hash) % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction createDebug(namespace) {\n\n function debug() {\n // disabled?\n if (!debug.enabled) return;\n\n var self = debug;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // turn the `arguments` into a proper Array\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %O\n args.unshift('%O');\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n // apply env-specific formatting (colors, etc.)\n exports.formatArgs.call(self, args);\n\n var logFn = debug.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n\n debug.namespace = namespace;\n debug.enabled = exports.enabled(namespace);\n debug.useColors = exports.useColors();\n debug.color = selectColor(namespace);\n\n // env-specific initialization logic for debug instances\n if ('function' === typeof exports.init) {\n exports.init(debug);\n }\n\n return debug;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n exports.names = [];\n exports.skips = [];\n\n var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n", "/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n && 'undefined' != typeof chrome.storage\n ? chrome.storage.local\n : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // NB: In an Electron preload script, document will be defined but not fully\n // initialized. Since we know we're in Chrome, we'll just detect this case\n // explicitly\n if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {\n return true;\n }\n\n // is webkit? http://stackoverflow.com/a/16459606/376773\n // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n // double check webkit in userAgent just in case we are in a worker\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n try {\n return JSON.stringify(v);\n } catch (err) {\n return '[UnexpectedJSONParseError]: ' + err.message;\n }\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return;\n\n var c = 'color: ' + this.color;\n args.splice(1, 0, c, 'color: inherit')\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-zA-Z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n exports.storage.removeItem('debug');\n } else {\n exports.storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = exports.storage.debug;\n } catch(e) {}\n\n // If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n if (!r && typeof process !== 'undefined' && 'env' in process) {\n r = process.env.DEBUG;\n }\n\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n try {\n return window.localStorage;\n } catch (e) {}\n}\n", "/**\n * Module dependencies.\n */\n\nvar tty = require('tty');\nvar util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(function (key) {\n return /^debug_/i.test(key);\n}).reduce(function (obj, key) {\n // camel-case\n var prop = key\n .substring(6)\n .toLowerCase()\n .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });\n\n // coerce string value into JS value\n var val = process.env[key];\n if (/^(yes|on|true|enabled)$/i.test(val)) val = true;\n else if (/^(no|off|false|disabled)$/i.test(val)) val = false;\n else if (val === 'null') val = null;\n else val = Number(val);\n\n obj[prop] = val;\n return obj;\n}, {});\n\n/**\n * The file descriptor to write the `debug()` calls to.\n * Set the `DEBUG_FD` env variable to override with another value. i.e.:\n *\n * $ DEBUG_FD=3 node script.js 3>debug.log\n */\n\nvar fd = parseInt(process.env.DEBUG_FD, 10) || 2;\n\nif (1 !== fd && 2 !== fd) {\n util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')()\n}\n\nvar stream = 1 === fd ? process.stdout :\n 2 === fd ? process.stderr :\n createWritableStdioStream(fd);\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n return 'colors' in exports.inspectOpts\n ? Boolean(exports.inspectOpts.colors)\n : tty.isatty(fd);\n}\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nexports.formatters.o = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts)\n .split('\\n').map(function(str) {\n return str.trim()\n }).join(' ');\n};\n\n/**\n * Map %o to `util.inspect()`, allowing multiple lines if needed.\n */\n\nexports.formatters.O = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts);\n};\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var name = this.namespace;\n var useColors = this.useColors;\n\n if (useColors) {\n var c = this.color;\n var prefix = ' \\u001b[3' + c + ';1m' + name + ' ' + '\\u001b[0m';\n\n args[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n args.push('\\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\\u001b[0m');\n } else {\n args[0] = new Date().toUTCString()\n + ' ' + name + ' ' + args[0];\n }\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to `stream`.\n */\n\nfunction log() {\n return stream.write(util.format.apply(util, arguments) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n if (null == namespaces) {\n // If you set a process.env field to null or undefined, it gets cast to the\n // string 'null' or 'undefined'. Just delete instead.\n delete process.env.DEBUG;\n } else {\n process.env.DEBUG = namespaces;\n }\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n return process.env.DEBUG;\n}\n\n/**\n * Copied from `node/src/node.js`.\n *\n * XXX: It's lame that node doesn't expose this API out-of-the-box. It also\n * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.\n */\n\nfunction createWritableStdioStream (fd) {\n var stream;\n var tty_wrap = process.binding('tty_wrap');\n\n // Note stream._type is used for test-module-load-list.js\n\n switch (tty_wrap.guessHandleType(fd)) {\n case 'TTY':\n stream = new tty.WriteStream(fd);\n stream._type = 'tty';\n\n // Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n case 'FILE':\n var fs = require('fs');\n stream = new fs.SyncWriteStream(fd, { autoClose: false });\n stream._type = 'fs';\n break;\n\n case 'PIPE':\n case 'TCP':\n var net = require('net');\n stream = new net.Socket({\n fd: fd,\n readable: false,\n writable: true\n });\n\n // FIXME Should probably have an option in net.Socket to create a\n // stream from an existing fd which is writable only. But for now\n // we'll just add this hack and set the `readable` member to false.\n // Test: ./node test/fixtures/echo.js < /etc/passwd\n stream.readable = false;\n stream.read = null;\n stream._type = 'pipe';\n\n // FIXME Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n default:\n // Probably an error on in uv_guess_handle()\n throw new Error('Implement me. Unknown stream file type!');\n }\n\n // For supporting legacy API we put the FD here.\n stream.fd = fd;\n\n stream._isStdio = true;\n\n return stream;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init (debug) {\n debug.inspectOpts = {};\n\n var keys = Object.keys(exports.inspectOpts);\n for (var i = 0; i < keys.length; i++) {\n debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n }\n}\n\n/**\n * Enable namespaces listed in `process.env.DEBUG` initially.\n */\n\nexports.enable(load());\n", "/**\n * Detect Electron renderer process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process !== 'undefined' && process.type === 'renderer') {\n module.exports = require('./browser.js');\n} else {\n module.exports = require('./node.js');\n}\n", "/*!\n * encodeurl\n * Copyright(c) 2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = encodeUrl\n\n/**\n * RegExp to match non-URL code points, *after* encoding (i.e. not including \"%\")\n * and including invalid escape sequences.\n * @private\n */\n\nvar ENCODE_CHARS_REGEXP = /(?:[^\\x21\\x25\\x26-\\x3B\\x3D\\x3F-\\x5B\\x5D\\x5F\\x61-\\x7A\\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g\n\n/**\n * RegExp to match unmatched surrogate pair.\n * @private\n */\n\nvar UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF]([^\\uDC00-\\uDFFF]|$)/g\n\n/**\n * String to replace unmatched surrogate pair with.\n * @private\n */\n\nvar UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\\uFFFD$2'\n\n/**\n * Encode a URL to a percent-encoded form, excluding already-encoded sequences.\n *\n * This function will take an already-encoded URL and encode all the non-URL\n * code points. This function will not encode the \"%\" character unless it is\n * not part of a valid sequence (`%20` will be left as-is, but `%foo` will\n * be encoded as `%25foo`).\n *\n * This encode is meant to be \"safe\" and does not throw errors. It will try as\n * hard as it can to properly encode the given URL, including replacing any raw,\n * unpaired surrogate pairs with the Unicode replacement character prior to\n * encoding.\n *\n * @param {string} url\n * @return {string}\n * @public\n */\n\nfunction encodeUrl (url) {\n return String(url)\n .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)\n .replace(ENCODE_CHARS_REGEXP, encodeURI)\n}\n", "/*!\n * escape-html\n * Copyright(c) 2012-2013 TJ Holowaychuk\n * Copyright(c) 2015 Andreas Lubbe\n * Copyright(c) 2015 Tiancheng \"Timothy\" Gu\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module variables.\n * @private\n */\n\nvar matchHtmlRegExp = /[\"'&<>]/;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = escapeHtml;\n\n/**\n * Escape special characters in the given string of html.\n *\n * @param {string} string The string to escape for inserting into HTML\n * @return {string}\n * @public\n */\n\nfunction escapeHtml(string) {\n var str = '' + string;\n var match = matchHtmlRegExp.exec(str);\n\n if (!match) {\n return str;\n }\n\n var escape;\n var html = '';\n var index = 0;\n var lastIndex = 0;\n\n for (index = match.index; index < str.length; index++) {\n switch (str.charCodeAt(index)) {\n case 34: // \"\n escape = '"';\n break;\n case 38: // &\n escape = '&';\n break;\n case 39: // '\n escape = ''';\n break;\n case 60: // <\n escape = '<';\n break;\n case 62: // >\n escape = '>';\n break;\n default:\n continue;\n }\n\n if (lastIndex !== index) {\n html += str.substring(lastIndex, index);\n }\n\n lastIndex = index + 1;\n html += escape;\n }\n\n return lastIndex !== index\n ? html + str.substring(lastIndex, index)\n : html;\n}\n", "/*!\n * parseurl\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2014-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar url = require('url')\nvar parse = url.parse\nvar Url = url.Url\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = parseurl\nmodule.exports.original = originalurl\n\n/**\n * Parse the `req` url with memoization.\n *\n * @param {ServerRequest} req\n * @return {Object}\n * @public\n */\n\nfunction parseurl (req) {\n var url = req.url\n\n if (url === undefined) {\n // URL is undefined\n return undefined\n }\n\n var parsed = req._parsedUrl\n\n if (fresh(url, parsed)) {\n // Return cached URL parse\n return parsed\n }\n\n // Parse the URL\n parsed = fastparse(url)\n parsed._raw = url\n\n return (req._parsedUrl = parsed)\n};\n\n/**\n * Parse the `req` original url with fallback and memoization.\n *\n * @param {ServerRequest} req\n * @return {Object}\n * @public\n */\n\nfunction originalurl (req) {\n var url = req.originalUrl\n\n if (typeof url !== 'string') {\n // Fallback\n return parseurl(req)\n }\n\n var parsed = req._parsedOriginalUrl\n\n if (fresh(url, parsed)) {\n // Return cached URL parse\n return parsed\n }\n\n // Parse the URL\n parsed = fastparse(url)\n parsed._raw = url\n\n return (req._parsedOriginalUrl = parsed)\n};\n\n/**\n * Parse the `str` url with fast-path short-cut.\n *\n * @param {string} str\n * @return {Object}\n * @private\n */\n\nfunction fastparse (str) {\n if (typeof str !== 'string' || str.charCodeAt(0) !== 0x2f /* / */) {\n return parse(str)\n }\n\n var pathname = str\n var query = null\n var search = null\n\n // This takes the regexp from https://github.com/joyent/node/pull/7878\n // Which is /^(\\/[^?#\\s]*)(\\?[^#\\s]*)?$/\n // And unrolls it into a for loop\n for (var i = 1; i < str.length; i++) {\n switch (str.charCodeAt(i)) {\n case 0x3f: /* ? */\n if (search === null) {\n pathname = str.substring(0, i)\n query = str.substring(i + 1)\n search = str.substring(i)\n }\n break\n case 0x09: /* \\t */\n case 0x0a: /* \\n */\n case 0x0c: /* \\f */\n case 0x0d: /* \\r */\n case 0x20: /* */\n case 0x23: /* # */\n case 0xa0:\n case 0xfeff:\n return parse(str)\n }\n }\n\n var url = Url !== undefined\n ? new Url()\n : {}\n\n url.path = str\n url.href = str\n url.pathname = pathname\n\n if (search !== null) {\n url.query = query\n url.search = search\n }\n\n return url\n}\n\n/**\n * Determine if parsed is still fresh for url.\n *\n * @param {string} url\n * @param {object} parsedUrl\n * @return {boolean}\n * @private\n */\n\nfunction fresh (url, parsedUrl) {\n return typeof parsedUrl === 'object' &&\n parsedUrl !== null &&\n (Url === undefined || parsedUrl instanceof Url) &&\n parsedUrl._raw === url\n}\n", "/*!\n * finalhandler\n * Copyright(c) 2014-2022 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar debug = require('debug')('finalhandler')\nvar encodeUrl = require('encodeurl')\nvar escapeHtml = require('escape-html')\nvar onFinished = require('on-finished')\nvar parseUrl = require('parseurl')\nvar statuses = require('statuses')\nvar unpipe = require('unpipe')\n\n/**\n * Module variables.\n * @private\n */\n\nvar DOUBLE_SPACE_REGEXP = /\\x20{2}/g\nvar NEWLINE_REGEXP = /\\n/g\n\n/* istanbul ignore next */\nvar defer = typeof setImmediate === 'function'\n ? setImmediate\n : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) }\nvar isFinished = onFinished.isFinished\n\n/**\n * Create a minimal HTML document.\n *\n * @param {string} message\n * @private\n */\n\nfunction createHtmlDocument (message) {\n var body = escapeHtml(message)\n .replace(NEWLINE_REGEXP, '
')\n .replace(DOUBLE_SPACE_REGEXP, '  ')\n\n return '\\n' +\n '\\n' +\n '\\n' +\n '\\n' +\n 'Error\\n' +\n '\\n' +\n '\\n' +\n '
' + body + '
\\n' +\n '\\n' +\n '\\n'\n}\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = finalhandler\n\n/**\n * Create a function to handle the final response.\n *\n * @param {Request} req\n * @param {Response} res\n * @param {Object} [options]\n * @return {Function}\n * @public\n */\n\nfunction finalhandler (req, res, options) {\n var opts = options || {}\n\n // get environment\n var env = opts.env || process.env.NODE_ENV || 'development'\n\n // get error callback\n var onerror = opts.onerror\n\n return function (err) {\n var headers\n var msg\n var status\n\n // ignore 404 on in-flight response\n if (!err && headersSent(res)) {\n debug('cannot 404 after headers sent')\n return\n }\n\n // unhandled error\n if (err) {\n // respect status code from error\n status = getErrorStatusCode(err)\n\n if (status === undefined) {\n // fallback to status code on response\n status = getResponseStatusCode(res)\n } else {\n // respect headers from error\n headers = getErrorHeaders(err)\n }\n\n // get error message\n msg = getErrorMessage(err, status, env)\n } else {\n // not found\n status = 404\n msg = 'Cannot ' + req.method + ' ' + encodeUrl(getResourceName(req))\n }\n\n debug('default %s', status)\n\n // schedule onerror callback\n if (err && onerror) {\n defer(onerror, err, req, res)\n }\n\n // cannot actually respond\n if (headersSent(res)) {\n debug('cannot %d after headers sent', status)\n req.socket.destroy()\n return\n }\n\n // send response\n send(req, res, status, headers, msg)\n }\n}\n\n/**\n * Get headers from Error object.\n *\n * @param {Error} err\n * @return {object}\n * @private\n */\n\nfunction getErrorHeaders (err) {\n if (!err.headers || typeof err.headers !== 'object') {\n return undefined\n }\n\n var headers = Object.create(null)\n var keys = Object.keys(err.headers)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i]\n headers[key] = err.headers[key]\n }\n\n return headers\n}\n\n/**\n * Get message from Error object, fallback to status message.\n *\n * @param {Error} err\n * @param {number} status\n * @param {string} env\n * @return {string}\n * @private\n */\n\nfunction getErrorMessage (err, status, env) {\n var msg\n\n if (env !== 'production') {\n // use err.stack, which typically includes err.message\n msg = err.stack\n\n // fallback to err.toString() when possible\n if (!msg && typeof err.toString === 'function') {\n msg = err.toString()\n }\n }\n\n return msg || statuses.message[status]\n}\n\n/**\n * Get status code from Error object.\n *\n * @param {Error} err\n * @return {number}\n * @private\n */\n\nfunction getErrorStatusCode (err) {\n // check err.status\n if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) {\n return err.status\n }\n\n // check err.statusCode\n if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) {\n return err.statusCode\n }\n\n return undefined\n}\n\n/**\n * Get resource name for the request.\n *\n * This is typically just the original pathname of the request\n * but will fallback to \"resource\" is that cannot be determined.\n *\n * @param {IncomingMessage} req\n * @return {string}\n * @private\n */\n\nfunction getResourceName (req) {\n try {\n return parseUrl.original(req).pathname\n } catch (e) {\n return 'resource'\n }\n}\n\n/**\n * Get status code from response.\n *\n * @param {OutgoingMessage} res\n * @return {number}\n * @private\n */\n\nfunction getResponseStatusCode (res) {\n var status = res.statusCode\n\n // default status code to 500 if outside valid range\n if (typeof status !== 'number' || status < 400 || status > 599) {\n status = 500\n }\n\n return status\n}\n\n/**\n * Determine if the response headers have been sent.\n *\n * @param {object} res\n * @returns {boolean}\n * @private\n */\n\nfunction headersSent (res) {\n return typeof res.headersSent !== 'boolean'\n ? Boolean(res._header)\n : res.headersSent\n}\n\n/**\n * Send response.\n *\n * @param {IncomingMessage} req\n * @param {OutgoingMessage} res\n * @param {number} status\n * @param {object} headers\n * @param {string} message\n * @private\n */\n\nfunction send (req, res, status, headers, message) {\n function write () {\n // response body\n var body = createHtmlDocument(message)\n\n // response status\n res.statusCode = status\n res.statusMessage = statuses.message[status]\n\n // remove any content headers\n res.removeHeader('Content-Encoding')\n res.removeHeader('Content-Language')\n res.removeHeader('Content-Range')\n\n // response headers\n setHeaders(res, headers)\n\n // security headers\n res.setHeader('Content-Security-Policy', \"default-src 'none'\")\n res.setHeader('X-Content-Type-Options', 'nosniff')\n\n // standard headers\n res.setHeader('Content-Type', 'text/html; charset=utf-8')\n res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'))\n\n if (req.method === 'HEAD') {\n res.end()\n return\n }\n\n res.end(body, 'utf8')\n }\n\n if (isFinished(req)) {\n write()\n return\n }\n\n // unpipe everything from the request\n unpipe(req)\n\n // flush the request\n onFinished(req, write)\n req.resume()\n}\n\n/**\n * Set response headers from an object.\n *\n * @param {OutgoingMessage} res\n * @param {object} headers\n * @private\n */\n\nfunction setHeaders (res, headers) {\n if (!headers) {\n return\n }\n\n var keys = Object.keys(headers)\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i]\n res.setHeader(key, headers[key])\n }\n}\n", "/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isNaN(val) === false) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n if (ms >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (ms >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (ms >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (ms >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n return plural(ms, d, 'day') ||\n plural(ms, h, 'hour') ||\n plural(ms, m, 'minute') ||\n plural(ms, s, 'second') ||\n ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) {\n return;\n }\n if (ms < n * 1.5) {\n return Math.floor(ms / n) + ' ' + name;\n }\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n", "\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = createDebug.debug = createDebug['default'] = createDebug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n */\n\nexports.formatters = {};\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n * @param {String} namespace\n * @return {Number}\n * @api private\n */\n\nfunction selectColor(namespace) {\n var hash = 0, i;\n\n for (i in namespace) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n hash |= 0; // Convert to 32bit integer\n }\n\n return exports.colors[Math.abs(hash) % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction createDebug(namespace) {\n\n function debug() {\n // disabled?\n if (!debug.enabled) return;\n\n var self = debug;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // turn the `arguments` into a proper Array\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %O\n args.unshift('%O');\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n // apply env-specific formatting (colors, etc.)\n exports.formatArgs.call(self, args);\n\n var logFn = debug.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n\n debug.namespace = namespace;\n debug.enabled = exports.enabled(namespace);\n debug.useColors = exports.useColors();\n debug.color = selectColor(namespace);\n\n // env-specific initialization logic for debug instances\n if ('function' === typeof exports.init) {\n exports.init(debug);\n }\n\n return debug;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n exports.names = [];\n exports.skips = [];\n\n var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n", "/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n && 'undefined' != typeof chrome.storage\n ? chrome.storage.local\n : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // NB: In an Electron preload script, document will be defined but not fully\n // initialized. Since we know we're in Chrome, we'll just detect this case\n // explicitly\n if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {\n return true;\n }\n\n // is webkit? http://stackoverflow.com/a/16459606/376773\n // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n // double check webkit in userAgent just in case we are in a worker\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n try {\n return JSON.stringify(v);\n } catch (err) {\n return '[UnexpectedJSONParseError]: ' + err.message;\n }\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return;\n\n var c = 'color: ' + this.color;\n args.splice(1, 0, c, 'color: inherit')\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-zA-Z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n exports.storage.removeItem('debug');\n } else {\n exports.storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = exports.storage.debug;\n } catch(e) {}\n\n // If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n if (!r && typeof process !== 'undefined' && 'env' in process) {\n r = process.env.DEBUG;\n }\n\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n try {\n return window.localStorage;\n } catch (e) {}\n}\n", "/**\n * Module dependencies.\n */\n\nvar tty = require('tty');\nvar util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(function (key) {\n return /^debug_/i.test(key);\n}).reduce(function (obj, key) {\n // camel-case\n var prop = key\n .substring(6)\n .toLowerCase()\n .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });\n\n // coerce string value into JS value\n var val = process.env[key];\n if (/^(yes|on|true|enabled)$/i.test(val)) val = true;\n else if (/^(no|off|false|disabled)$/i.test(val)) val = false;\n else if (val === 'null') val = null;\n else val = Number(val);\n\n obj[prop] = val;\n return obj;\n}, {});\n\n/**\n * The file descriptor to write the `debug()` calls to.\n * Set the `DEBUG_FD` env variable to override with another value. i.e.:\n *\n * $ DEBUG_FD=3 node script.js 3>debug.log\n */\n\nvar fd = parseInt(process.env.DEBUG_FD, 10) || 2;\n\nif (1 !== fd && 2 !== fd) {\n util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')()\n}\n\nvar stream = 1 === fd ? process.stdout :\n 2 === fd ? process.stderr :\n createWritableStdioStream(fd);\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n return 'colors' in exports.inspectOpts\n ? Boolean(exports.inspectOpts.colors)\n : tty.isatty(fd);\n}\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nexports.formatters.o = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts)\n .split('\\n').map(function(str) {\n return str.trim()\n }).join(' ');\n};\n\n/**\n * Map %o to `util.inspect()`, allowing multiple lines if needed.\n */\n\nexports.formatters.O = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts);\n};\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var name = this.namespace;\n var useColors = this.useColors;\n\n if (useColors) {\n var c = this.color;\n var prefix = ' \\u001b[3' + c + ';1m' + name + ' ' + '\\u001b[0m';\n\n args[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n args.push('\\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\\u001b[0m');\n } else {\n args[0] = new Date().toUTCString()\n + ' ' + name + ' ' + args[0];\n }\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to `stream`.\n */\n\nfunction log() {\n return stream.write(util.format.apply(util, arguments) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n if (null == namespaces) {\n // If you set a process.env field to null or undefined, it gets cast to the\n // string 'null' or 'undefined'. Just delete instead.\n delete process.env.DEBUG;\n } else {\n process.env.DEBUG = namespaces;\n }\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n return process.env.DEBUG;\n}\n\n/**\n * Copied from `node/src/node.js`.\n *\n * XXX: It's lame that node doesn't expose this API out-of-the-box. It also\n * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.\n */\n\nfunction createWritableStdioStream (fd) {\n var stream;\n var tty_wrap = process.binding('tty_wrap');\n\n // Note stream._type is used for test-module-load-list.js\n\n switch (tty_wrap.guessHandleType(fd)) {\n case 'TTY':\n stream = new tty.WriteStream(fd);\n stream._type = 'tty';\n\n // Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n case 'FILE':\n var fs = require('fs');\n stream = new fs.SyncWriteStream(fd, { autoClose: false });\n stream._type = 'fs';\n break;\n\n case 'PIPE':\n case 'TCP':\n var net = require('net');\n stream = new net.Socket({\n fd: fd,\n readable: false,\n writable: true\n });\n\n // FIXME Should probably have an option in net.Socket to create a\n // stream from an existing fd which is writable only. But for now\n // we'll just add this hack and set the `readable` member to false.\n // Test: ./node test/fixtures/echo.js < /etc/passwd\n stream.readable = false;\n stream.read = null;\n stream._type = 'pipe';\n\n // FIXME Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n default:\n // Probably an error on in uv_guess_handle()\n throw new Error('Implement me. Unknown stream file type!');\n }\n\n // For supporting legacy API we put the FD here.\n stream.fd = fd;\n\n stream._isStdio = true;\n\n return stream;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init (debug) {\n debug.inspectOpts = {};\n\n var keys = Object.keys(exports.inspectOpts);\n for (var i = 0; i < keys.length; i++) {\n debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n }\n}\n\n/**\n * Enable namespaces listed in `process.env.DEBUG` initially.\n */\n\nexports.enable(load());\n", "/**\n * Detect Electron renderer process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process !== 'undefined' && process.type === 'renderer') {\n module.exports = require('./browser.js');\n} else {\n module.exports = require('./node.js');\n}\n", "'use strict'\n\n/**\n * Expose `arrayFlatten`.\n */\nmodule.exports = arrayFlatten\n\n/**\n * Recursive flatten function with depth.\n *\n * @param {Array} array\n * @param {Array} result\n * @param {Number} depth\n * @return {Array}\n */\nfunction flattenWithDepth (array, result, depth) {\n for (var i = 0; i < array.length; i++) {\n var value = array[i]\n\n if (depth > 0 && Array.isArray(value)) {\n flattenWithDepth(value, result, depth - 1)\n } else {\n result.push(value)\n }\n }\n\n return result\n}\n\n/**\n * Recursive flatten function. Omitting depth is slightly faster.\n *\n * @param {Array} array\n * @param {Array} result\n * @return {Array}\n */\nfunction flattenForever (array, result) {\n for (var i = 0; i < array.length; i++) {\n var value = array[i]\n\n if (Array.isArray(value)) {\n flattenForever(value, result)\n } else {\n result.push(value)\n }\n }\n\n return result\n}\n\n/**\n * Flatten an array, with the ability to define a depth.\n *\n * @param {Array} array\n * @param {Number} depth\n * @return {Array}\n */\nfunction arrayFlatten (array, depth) {\n if (depth == null) {\n return flattenForever(array, [])\n }\n\n return flattenWithDepth(array, [], depth)\n}\n", "/**\n * Expose `pathtoRegexp`.\n */\n\nmodule.exports = pathtoRegexp;\n\n/**\n * Match matching groups in a regular expression.\n */\nvar MATCHING_GROUP_REGEXP = /\\((?!\\?)/g;\n\n/**\n * Normalize the given path string,\n * returning a regular expression.\n *\n * An empty array should be passed,\n * which will contain the placeholder\n * key names. For example \"/user/:id\" will\n * then contain [\"id\"].\n *\n * @param {String|RegExp|Array} path\n * @param {Array} keys\n * @param {Object} options\n * @return {RegExp}\n * @api private\n */\n\nfunction pathtoRegexp(path, keys, options) {\n options = options || {};\n keys = keys || [];\n var strict = options.strict;\n var end = options.end !== false;\n var flags = options.sensitive ? '' : 'i';\n var extraOffset = 0;\n var keysOffset = keys.length;\n var i = 0;\n var name = 0;\n var m;\n\n if (path instanceof RegExp) {\n while (m = MATCHING_GROUP_REGEXP.exec(path.source)) {\n keys.push({\n name: name++,\n optional: false,\n offset: m.index\n });\n }\n\n return path;\n }\n\n if (Array.isArray(path)) {\n // Map array parts into regexps and return their source. We also pass\n // the same keys and options instance into every generation to get\n // consistent matching groups before we join the sources together.\n path = path.map(function (value) {\n return pathtoRegexp(value, keys, options).source;\n });\n\n return new RegExp('(?:' + path.join('|') + ')', flags);\n }\n\n path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?'))\n .replace(/\\/\\(/g, '/(?:')\n .replace(/([\\/\\.])/g, '\\\\$1')\n .replace(/(\\\\\\/)?(\\\\\\.)?:(\\w+)(\\(.*?\\))?(\\*)?(\\?)?/g, function (match, slash, format, key, capture, star, optional, offset) {\n slash = slash || '';\n format = format || '';\n capture = capture || '([^\\\\/' + format + ']+?)';\n optional = optional || '';\n\n keys.push({\n name: key,\n optional: !!optional,\n offset: offset + extraOffset\n });\n\n var result = ''\n + (optional ? '' : slash)\n + '(?:'\n + format + (optional ? slash : '') + capture\n + (star ? '((?:[\\\\/' + format + '].+?)?)' : '')\n + ')'\n + optional;\n\n extraOffset += result.length - match.length;\n\n return result;\n })\n .replace(/\\*/g, function (star, index) {\n var len = keys.length\n\n while (len-- > keysOffset && keys[len].offset > index) {\n keys[len].offset += 3; // Replacement length minus asterisk length.\n }\n\n return '(.*)';\n });\n\n // This is a workaround for handling unnamed matching groups.\n while (m = MATCHING_GROUP_REGEXP.exec(path)) {\n var escapeCount = 0;\n var index = m.index;\n\n while (path.charAt(--index) === '\\\\') {\n escapeCount++;\n }\n\n // It's possible to escape the bracket.\n if (escapeCount % 2 === 1) {\n continue;\n }\n\n if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {\n keys.splice(keysOffset + i, 0, {\n name: name++, // Unnamed matching groups must be consistently linear.\n optional: false,\n offset: m.index\n });\n }\n\n i++;\n }\n\n // If the path is non-ending, match until the end or a slash.\n path += (end ? '$' : (path[path.length - 1] === '/' ? '' : '(?=\\\\/|$)'));\n\n return new RegExp(path, flags);\n};\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar pathRegexp = require('path-to-regexp');\nvar debug = require('debug')('express:router:layer');\n\n/**\n * Module variables.\n * @private\n */\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = Layer;\n\nfunction Layer(path, options, fn) {\n if (!(this instanceof Layer)) {\n return new Layer(path, options, fn);\n }\n\n debug('new %o', path)\n var opts = options || {};\n\n this.handle = fn;\n this.name = fn.name || '';\n this.params = undefined;\n this.path = undefined;\n this.regexp = pathRegexp(path, this.keys = [], opts);\n\n // set fast path flags\n this.regexp.fast_star = path === '*'\n this.regexp.fast_slash = path === '/' && opts.end === false\n}\n\n/**\n * Handle the error for the layer.\n *\n * @param {Error} error\n * @param {Request} req\n * @param {Response} res\n * @param {function} next\n * @api private\n */\n\nLayer.prototype.handle_error = function handle_error(error, req, res, next) {\n var fn = this.handle;\n\n if (fn.length !== 4) {\n // not a standard error handler\n return next(error);\n }\n\n try {\n fn(error, req, res, next);\n } catch (err) {\n next(err);\n }\n};\n\n/**\n * Handle the request for the layer.\n *\n * @param {Request} req\n * @param {Response} res\n * @param {function} next\n * @api private\n */\n\nLayer.prototype.handle_request = function handle(req, res, next) {\n var fn = this.handle;\n\n if (fn.length > 3) {\n // not a standard request handler\n return next();\n }\n\n try {\n fn(req, res, next);\n } catch (err) {\n next(err);\n }\n};\n\n/**\n * Check if this route matches `path`, if so\n * populate `.params`.\n *\n * @param {String} path\n * @return {Boolean}\n * @api private\n */\n\nLayer.prototype.match = function match(path) {\n var match\n\n if (path != null) {\n // fast path non-ending match for / (any path matches)\n if (this.regexp.fast_slash) {\n this.params = {}\n this.path = ''\n return true\n }\n\n // fast path for * (everything matched in a param)\n if (this.regexp.fast_star) {\n this.params = {'0': decode_param(path)}\n this.path = path\n return true\n }\n\n // match the path\n match = this.regexp.exec(path)\n }\n\n if (!match) {\n this.params = undefined;\n this.path = undefined;\n return false;\n }\n\n // store values\n this.params = {};\n this.path = match[0]\n\n var keys = this.keys;\n var params = this.params;\n\n for (var i = 1; i < match.length; i++) {\n var key = keys[i - 1];\n var prop = key.name;\n var val = decode_param(match[i])\n\n if (val !== undefined || !(hasOwnProperty.call(params, prop))) {\n params[prop] = val;\n }\n }\n\n return true;\n};\n\n/**\n * Decode param value.\n *\n * @param {string} val\n * @return {string}\n * @private\n */\n\nfunction decode_param(val) {\n if (typeof val !== 'string' || val.length === 0) {\n return val;\n }\n\n try {\n return decodeURIComponent(val);\n } catch (err) {\n if (err instanceof URIError) {\n err.message = 'Failed to decode param \\'' + val + '\\'';\n err.status = err.statusCode = 400;\n }\n\n throw err;\n }\n}\n", "/*!\n * methods\n * Copyright(c) 2013-2014 TJ Holowaychuk\n * Copyright(c) 2015-2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar http = require('http');\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = getCurrentNodeMethods() || getBasicNodeMethods();\n\n/**\n * Get the current Node.js methods.\n * @private\n */\n\nfunction getCurrentNodeMethods() {\n return http.METHODS && http.METHODS.map(function lowerCaseMethod(method) {\n return method.toLowerCase();\n });\n}\n\n/**\n * Get the \"basic\" Node.js methods, a snapshot from Node.js 0.10.\n * @private\n */\n\nfunction getBasicNodeMethods() {\n return [\n 'get',\n 'post',\n 'put',\n 'head',\n 'delete',\n 'options',\n 'trace',\n 'copy',\n 'lock',\n 'mkcol',\n 'move',\n 'purge',\n 'propfind',\n 'proppatch',\n 'unlock',\n 'report',\n 'mkactivity',\n 'checkout',\n 'merge',\n 'm-search',\n 'notify',\n 'subscribe',\n 'unsubscribe',\n 'patch',\n 'search',\n 'connect'\n ];\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar debug = require('debug')('express:router:route');\nvar flatten = require('array-flatten');\nvar Layer = require('./layer');\nvar methods = require('methods');\n\n/**\n * Module variables.\n * @private\n */\n\nvar slice = Array.prototype.slice;\nvar toString = Object.prototype.toString;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = Route;\n\n/**\n * Initialize `Route` with the given `path`,\n *\n * @param {String} path\n * @public\n */\n\nfunction Route(path) {\n this.path = path;\n this.stack = [];\n\n debug('new %o', path)\n\n // route handlers for various http methods\n this.methods = {};\n}\n\n/**\n * Determine if the route handles a given method.\n * @private\n */\n\nRoute.prototype._handles_method = function _handles_method(method) {\n if (this.methods._all) {\n return true;\n }\n\n var name = method.toLowerCase();\n\n if (name === 'head' && !this.methods['head']) {\n name = 'get';\n }\n\n return Boolean(this.methods[name]);\n};\n\n/**\n * @return {Array} supported HTTP methods\n * @private\n */\n\nRoute.prototype._options = function _options() {\n var methods = Object.keys(this.methods);\n\n // append automatic head\n if (this.methods.get && !this.methods.head) {\n methods.push('head');\n }\n\n for (var i = 0; i < methods.length; i++) {\n // make upper case\n methods[i] = methods[i].toUpperCase();\n }\n\n return methods;\n};\n\n/**\n * dispatch req, res into this route\n * @private\n */\n\nRoute.prototype.dispatch = function dispatch(req, res, done) {\n var idx = 0;\n var stack = this.stack;\n var sync = 0\n\n if (stack.length === 0) {\n return done();\n }\n\n var method = req.method.toLowerCase();\n if (method === 'head' && !this.methods['head']) {\n method = 'get';\n }\n\n req.route = this;\n\n next();\n\n function next(err) {\n // signal to exit route\n if (err && err === 'route') {\n return done();\n }\n\n // signal to exit router\n if (err && err === 'router') {\n return done(err)\n }\n\n // max sync stack\n if (++sync > 100) {\n return setImmediate(next, err)\n }\n\n var layer = stack[idx++]\n\n // end of layers\n if (!layer) {\n return done(err)\n }\n\n if (layer.method && layer.method !== method) {\n next(err)\n } else if (err) {\n layer.handle_error(err, req, res, next);\n } else {\n layer.handle_request(req, res, next);\n }\n\n sync = 0\n }\n};\n\n/**\n * Add a handler for all HTTP verbs to this route.\n *\n * Behaves just like middleware and can respond or call `next`\n * to continue processing.\n *\n * You can use multiple `.all` call to add multiple handlers.\n *\n * function check_something(req, res, next){\n * next();\n * };\n *\n * function validate_user(req, res, next){\n * next();\n * };\n *\n * route\n * .all(validate_user)\n * .all(check_something)\n * .get(function(req, res, next){\n * res.send('hello world');\n * });\n *\n * @param {function} handler\n * @return {Route} for chaining\n * @api public\n */\n\nRoute.prototype.all = function all() {\n var handles = flatten(slice.call(arguments));\n\n for (var i = 0; i < handles.length; i++) {\n var handle = handles[i];\n\n if (typeof handle !== 'function') {\n var type = toString.call(handle);\n var msg = 'Route.all() requires a callback function but got a ' + type\n throw new TypeError(msg);\n }\n\n var layer = Layer('/', {}, handle);\n layer.method = undefined;\n\n this.methods._all = true;\n this.stack.push(layer);\n }\n\n return this;\n};\n\nmethods.forEach(function(method){\n Route.prototype[method] = function(){\n var handles = flatten(slice.call(arguments));\n\n for (var i = 0; i < handles.length; i++) {\n var handle = handles[i];\n\n if (typeof handle !== 'function') {\n var type = toString.call(handle);\n var msg = 'Route.' + method + '() requires a callback function but got a ' + type\n throw new Error(msg);\n }\n\n debug('%s %o', method, this.path)\n\n var layer = Layer('/', {}, handle);\n layer.method = method;\n\n this.methods[method] = true;\n this.stack.push(layer);\n }\n\n return this;\n };\n});\n", "/**\n * Merge object b with object a.\n *\n * var a = { foo: 'bar' }\n * , b = { bar: 'baz' };\n *\n * merge(a, b);\n * // => { foo: 'bar', bar: 'baz' }\n *\n * @param {Object} a\n * @param {Object} b\n * @return {Object}\n * @api public\n */\n\nexports = module.exports = function(a, b){\n if (a && b) {\n for (var key in b) {\n a[key] = b[key];\n }\n }\n return a;\n};\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar Route = require('./route');\nvar Layer = require('./layer');\nvar methods = require('methods');\nvar mixin = require('utils-merge');\nvar debug = require('debug')('express:router');\nvar deprecate = require('depd')('express');\nvar flatten = require('array-flatten');\nvar parseUrl = require('parseurl');\nvar setPrototypeOf = require('setprototypeof')\n\n/**\n * Module variables.\n * @private\n */\n\nvar objectRegExp = /^\\[object (\\S+)\\]$/;\nvar slice = Array.prototype.slice;\nvar toString = Object.prototype.toString;\n\n/**\n * Initialize a new `Router` with the given `options`.\n *\n * @param {Object} [options]\n * @return {Router} which is an callable function\n * @public\n */\n\nvar proto = module.exports = function(options) {\n var opts = options || {};\n\n function router(req, res, next) {\n router.handle(req, res, next);\n }\n\n // mixin Router class functions\n setPrototypeOf(router, proto)\n\n router.params = {};\n router._params = [];\n router.caseSensitive = opts.caseSensitive;\n router.mergeParams = opts.mergeParams;\n router.strict = opts.strict;\n router.stack = [];\n\n return router;\n};\n\n/**\n * Map the given param placeholder `name`(s) to the given callback.\n *\n * Parameter mapping is used to provide pre-conditions to routes\n * which use normalized placeholders. For example a _:user_id_ parameter\n * could automatically load a user's information from the database without\n * any additional code,\n *\n * The callback uses the same signature as middleware, the only difference\n * being that the value of the placeholder is passed, in this case the _id_\n * of the user. Once the `next()` function is invoked, just like middleware\n * it will continue on to execute the route, or subsequent parameter functions.\n *\n * Just like in middleware, you must either respond to the request or call next\n * to avoid stalling the request.\n *\n * app.param('user_id', function(req, res, next, id){\n * User.find(id, function(err, user){\n * if (err) {\n * return next(err);\n * } else if (!user) {\n * return next(new Error('failed to load user'));\n * }\n * req.user = user;\n * next();\n * });\n * });\n *\n * @param {String} name\n * @param {Function} fn\n * @return {app} for chaining\n * @public\n */\n\nproto.param = function param(name, fn) {\n // param logic\n if (typeof name === 'function') {\n deprecate('router.param(fn): Refactor to use path params');\n this._params.push(name);\n return;\n }\n\n // apply param functions\n var params = this._params;\n var len = params.length;\n var ret;\n\n if (name[0] === ':') {\n deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.slice(1)) + ', fn) instead')\n name = name.slice(1)\n }\n\n for (var i = 0; i < len; ++i) {\n if (ret = params[i](name, fn)) {\n fn = ret;\n }\n }\n\n // ensure we end up with a\n // middleware function\n if ('function' !== typeof fn) {\n throw new Error('invalid param() call for ' + name + ', got ' + fn);\n }\n\n (this.params[name] = this.params[name] || []).push(fn);\n return this;\n};\n\n/**\n * Dispatch a req, res into the router.\n * @private\n */\n\nproto.handle = function handle(req, res, out) {\n var self = this;\n\n debug('dispatching %s %s', req.method, req.url);\n\n var idx = 0;\n var protohost = getProtohost(req.url) || ''\n var removed = '';\n var slashAdded = false;\n var sync = 0\n var paramcalled = {};\n\n // store options for OPTIONS request\n // only used if OPTIONS request\n var options = [];\n\n // middleware and routes\n var stack = self.stack;\n\n // manage inter-router variables\n var parentParams = req.params;\n var parentUrl = req.baseUrl || '';\n var done = restore(out, req, 'baseUrl', 'next', 'params');\n\n // setup next layer\n req.next = next;\n\n // for options requests, respond with a default if nothing else responds\n if (req.method === 'OPTIONS') {\n done = wrap(done, function(old, err) {\n if (err || options.length === 0) return old(err);\n sendOptionsResponse(res, options, old);\n });\n }\n\n // setup basic req values\n req.baseUrl = parentUrl;\n req.originalUrl = req.originalUrl || req.url;\n\n next();\n\n function next(err) {\n var layerError = err === 'route'\n ? null\n : err;\n\n // remove added slash\n if (slashAdded) {\n req.url = req.url.slice(1)\n slashAdded = false;\n }\n\n // restore altered req.url\n if (removed.length !== 0) {\n req.baseUrl = parentUrl;\n req.url = protohost + removed + req.url.slice(protohost.length)\n removed = '';\n }\n\n // signal to exit router\n if (layerError === 'router') {\n setImmediate(done, null)\n return\n }\n\n // no more matching layers\n if (idx >= stack.length) {\n setImmediate(done, layerError);\n return;\n }\n\n // max sync stack\n if (++sync > 100) {\n return setImmediate(next, err)\n }\n\n // get pathname of request\n var path = getPathname(req);\n\n if (path == null) {\n return done(layerError);\n }\n\n // find next matching layer\n var layer;\n var match;\n var route;\n\n while (match !== true && idx < stack.length) {\n layer = stack[idx++];\n match = matchLayer(layer, path);\n route = layer.route;\n\n if (typeof match !== 'boolean') {\n // hold on to layerError\n layerError = layerError || match;\n }\n\n if (match !== true) {\n continue;\n }\n\n if (!route) {\n // process non-route handlers normally\n continue;\n }\n\n if (layerError) {\n // routes do not match with a pending error\n match = false;\n continue;\n }\n\n var method = req.method;\n var has_method = route._handles_method(method);\n\n // build up automatic options response\n if (!has_method && method === 'OPTIONS') {\n appendMethods(options, route._options());\n }\n\n // don't even bother matching route\n if (!has_method && method !== 'HEAD') {\n match = false;\n }\n }\n\n // no match\n if (match !== true) {\n return done(layerError);\n }\n\n // store route for dispatch on change\n if (route) {\n req.route = route;\n }\n\n // Capture one-time layer values\n req.params = self.mergeParams\n ? mergeParams(layer.params, parentParams)\n : layer.params;\n var layerPath = layer.path;\n\n // this should be done for the layer\n self.process_params(layer, paramcalled, req, res, function (err) {\n if (err) {\n next(layerError || err)\n } else if (route) {\n layer.handle_request(req, res, next)\n } else {\n trim_prefix(layer, layerError, layerPath, path)\n }\n\n sync = 0\n });\n }\n\n function trim_prefix(layer, layerError, layerPath, path) {\n if (layerPath.length !== 0) {\n // Validate path is a prefix match\n if (layerPath !== path.slice(0, layerPath.length)) {\n next(layerError)\n return\n }\n\n // Validate path breaks on a path separator\n var c = path[layerPath.length]\n if (c && c !== '/' && c !== '.') return next(layerError)\n\n // Trim off the part of the url that matches the route\n // middleware (.use stuff) needs to have the path stripped\n debug('trim prefix (%s) from url %s', layerPath, req.url);\n removed = layerPath;\n req.url = protohost + req.url.slice(protohost.length + removed.length)\n\n // Ensure leading slash\n if (!protohost && req.url[0] !== '/') {\n req.url = '/' + req.url;\n slashAdded = true;\n }\n\n // Setup base URL (no trailing slash)\n req.baseUrl = parentUrl + (removed[removed.length - 1] === '/'\n ? removed.substring(0, removed.length - 1)\n : removed);\n }\n\n debug('%s %s : %s', layer.name, layerPath, req.originalUrl);\n\n if (layerError) {\n layer.handle_error(layerError, req, res, next);\n } else {\n layer.handle_request(req, res, next);\n }\n }\n};\n\n/**\n * Process any parameters for the layer.\n * @private\n */\n\nproto.process_params = function process_params(layer, called, req, res, done) {\n var params = this.params;\n\n // captured parameters from the layer, keys and values\n var keys = layer.keys;\n\n // fast track\n if (!keys || keys.length === 0) {\n return done();\n }\n\n var i = 0;\n var name;\n var paramIndex = 0;\n var key;\n var paramVal;\n var paramCallbacks;\n var paramCalled;\n\n // process params in order\n // param callbacks can be async\n function param(err) {\n if (err) {\n return done(err);\n }\n\n if (i >= keys.length ) {\n return done();\n }\n\n paramIndex = 0;\n key = keys[i++];\n name = key.name;\n paramVal = req.params[name];\n paramCallbacks = params[name];\n paramCalled = called[name];\n\n if (paramVal === undefined || !paramCallbacks) {\n return param();\n }\n\n // param previously called with same value or error occurred\n if (paramCalled && (paramCalled.match === paramVal\n || (paramCalled.error && paramCalled.error !== 'route'))) {\n // restore value\n req.params[name] = paramCalled.value;\n\n // next param\n return param(paramCalled.error);\n }\n\n called[name] = paramCalled = {\n error: null,\n match: paramVal,\n value: paramVal\n };\n\n paramCallback();\n }\n\n // single param callbacks\n function paramCallback(err) {\n var fn = paramCallbacks[paramIndex++];\n\n // store updated value\n paramCalled.value = req.params[key.name];\n\n if (err) {\n // store error\n paramCalled.error = err;\n param(err);\n return;\n }\n\n if (!fn) return param();\n\n try {\n fn(req, res, paramCallback, paramVal, key.name);\n } catch (e) {\n paramCallback(e);\n }\n }\n\n param();\n};\n\n/**\n * Use the given middleware function, with optional path, defaulting to \"/\".\n *\n * Use (like `.all`) will run for any http METHOD, but it will not add\n * handlers for those methods so OPTIONS requests will not consider `.use`\n * functions even if they could respond.\n *\n * The other difference is that _route_ path is stripped and not visible\n * to the handler function. The main effect of this feature is that mounted\n * handlers can operate without any code changes regardless of the \"prefix\"\n * pathname.\n *\n * @public\n */\n\nproto.use = function use(fn) {\n var offset = 0;\n var path = '/';\n\n // default path to '/'\n // disambiguate router.use([fn])\n if (typeof fn !== 'function') {\n var arg = fn;\n\n while (Array.isArray(arg) && arg.length !== 0) {\n arg = arg[0];\n }\n\n // first arg is the path\n if (typeof arg !== 'function') {\n offset = 1;\n path = fn;\n }\n }\n\n var callbacks = flatten(slice.call(arguments, offset));\n\n if (callbacks.length === 0) {\n throw new TypeError('Router.use() requires a middleware function')\n }\n\n for (var i = 0; i < callbacks.length; i++) {\n var fn = callbacks[i];\n\n if (typeof fn !== 'function') {\n throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))\n }\n\n // add the middleware\n debug('use %o %s', path, fn.name || '')\n\n var layer = new Layer(path, {\n sensitive: this.caseSensitive,\n strict: false,\n end: false\n }, fn);\n\n layer.route = undefined;\n\n this.stack.push(layer);\n }\n\n return this;\n};\n\n/**\n * Create a new Route for the given path.\n *\n * Each route contains a separate middleware stack and VERB handlers.\n *\n * See the Route api documentation for details on adding handlers\n * and middleware to routes.\n *\n * @param {String} path\n * @return {Route}\n * @public\n */\n\nproto.route = function route(path) {\n var route = new Route(path);\n\n var layer = new Layer(path, {\n sensitive: this.caseSensitive,\n strict: this.strict,\n end: true\n }, route.dispatch.bind(route));\n\n layer.route = route;\n\n this.stack.push(layer);\n return route;\n};\n\n// create Router#VERB functions\nmethods.concat('all').forEach(function(method){\n proto[method] = function(path){\n var route = this.route(path)\n route[method].apply(route, slice.call(arguments, 1));\n return this;\n };\n});\n\n// append methods to a list of methods\nfunction appendMethods(list, addition) {\n for (var i = 0; i < addition.length; i++) {\n var method = addition[i];\n if (list.indexOf(method) === -1) {\n list.push(method);\n }\n }\n}\n\n// get pathname of request\nfunction getPathname(req) {\n try {\n return parseUrl(req).pathname;\n } catch (err) {\n return undefined;\n }\n}\n\n// Get get protocol + host for a URL\nfunction getProtohost(url) {\n if (typeof url !== 'string' || url.length === 0 || url[0] === '/') {\n return undefined\n }\n\n var searchIndex = url.indexOf('?')\n var pathLength = searchIndex !== -1\n ? searchIndex\n : url.length\n var fqdnIndex = url.slice(0, pathLength).indexOf('://')\n\n return fqdnIndex !== -1\n ? url.substring(0, url.indexOf('/', 3 + fqdnIndex))\n : undefined\n}\n\n// get type for error message\nfunction gettype(obj) {\n var type = typeof obj;\n\n if (type !== 'object') {\n return type;\n }\n\n // inspect [[Class]] for objects\n return toString.call(obj)\n .replace(objectRegExp, '$1');\n}\n\n/**\n * Match path to a layer.\n *\n * @param {Layer} layer\n * @param {string} path\n * @private\n */\n\nfunction matchLayer(layer, path) {\n try {\n return layer.match(path);\n } catch (err) {\n return err;\n }\n}\n\n// merge params with parent params\nfunction mergeParams(params, parent) {\n if (typeof parent !== 'object' || !parent) {\n return params;\n }\n\n // make copy of parent for base\n var obj = mixin({}, parent);\n\n // simple non-numeric merging\n if (!(0 in params) || !(0 in parent)) {\n return mixin(obj, params);\n }\n\n var i = 0;\n var o = 0;\n\n // determine numeric gaps\n while (i in params) {\n i++;\n }\n\n while (o in parent) {\n o++;\n }\n\n // offset numeric indices in params before merge\n for (i--; i >= 0; i--) {\n params[i + o] = params[i];\n\n // create holes for the merge when necessary\n if (i < o) {\n delete params[i];\n }\n }\n\n return mixin(obj, params);\n}\n\n// restore obj props after function\nfunction restore(fn, obj) {\n var props = new Array(arguments.length - 2);\n var vals = new Array(arguments.length - 2);\n\n for (var i = 0; i < props.length; i++) {\n props[i] = arguments[i + 2];\n vals[i] = obj[props[i]];\n }\n\n return function () {\n // restore vals\n for (var i = 0; i < props.length; i++) {\n obj[props[i]] = vals[i];\n }\n\n return fn.apply(this, arguments);\n };\n}\n\n// send an OPTIONS response\nfunction sendOptionsResponse(res, options, next) {\n try {\n var body = options.join(',');\n res.set('Allow', body);\n res.send(body);\n } catch (err) {\n next(err);\n }\n}\n\n// wrap a function\nfunction wrap(old, fn) {\n return function proxy() {\n var args = new Array(arguments.length + 1);\n\n args[0] = old;\n for (var i = 0, len = arguments.length; i < len; i++) {\n args[i + 1] = arguments[i];\n }\n\n fn.apply(this, args);\n };\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar setPrototypeOf = require('setprototypeof')\n\n/**\n * Initialization middleware, exposing the\n * request and response to each other, as well\n * as defaulting the X-Powered-By header field.\n *\n * @param {Function} app\n * @return {Function}\n * @api private\n */\n\nexports.init = function(app){\n return function expressInit(req, res, next){\n if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');\n req.res = res;\n res.req = req;\n req.next = next;\n\n setPrototypeOf(req, app.request)\n setPrototypeOf(res, app.response)\n\n res.locals = res.locals || Object.create(null);\n\n next();\n };\n};\n\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n */\n\nvar merge = require('utils-merge')\nvar parseUrl = require('parseurl');\nvar qs = require('qs');\n\n/**\n * @param {Object} options\n * @return {Function}\n * @api public\n */\n\nmodule.exports = function query(options) {\n var opts = merge({}, options)\n var queryparse = qs.parse;\n\n if (typeof options === 'function') {\n queryparse = options;\n opts = undefined;\n }\n\n if (opts !== undefined && opts.allowPrototypes === undefined) {\n // back-compat for qs module\n opts.allowPrototypes = true;\n }\n\n return function query(req, res, next){\n if (!req.query) {\n var val = parseUrl(req).query;\n req.query = queryparse(val, opts);\n }\n\n next();\n };\n};\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar debug = require('debug')('express:view');\nvar path = require('path');\nvar fs = require('fs');\n\n/**\n * Module variables.\n * @private\n */\n\nvar dirname = path.dirname;\nvar basename = path.basename;\nvar extname = path.extname;\nvar join = path.join;\nvar resolve = path.resolve;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = View;\n\n/**\n * Initialize a new `View` with the given `name`.\n *\n * Options:\n *\n * - `defaultEngine` the default template engine name\n * - `engines` template engine require() cache\n * - `root` root path for view lookup\n *\n * @param {string} name\n * @param {object} options\n * @public\n */\n\nfunction View(name, options) {\n var opts = options || {};\n\n this.defaultEngine = opts.defaultEngine;\n this.ext = extname(name);\n this.name = name;\n this.root = opts.root;\n\n if (!this.ext && !this.defaultEngine) {\n throw new Error('No default engine was specified and no extension was provided.');\n }\n\n var fileName = name;\n\n if (!this.ext) {\n // get extension from default engine name\n this.ext = this.defaultEngine[0] !== '.'\n ? '.' + this.defaultEngine\n : this.defaultEngine;\n\n fileName += this.ext;\n }\n\n if (!opts.engines[this.ext]) {\n // load engine\n var mod = this.ext.slice(1)\n debug('require \"%s\"', mod)\n\n // default engine export\n var fn = require(mod).__express\n\n if (typeof fn !== 'function') {\n throw new Error('Module \"' + mod + '\" does not provide a view engine.')\n }\n\n opts.engines[this.ext] = fn\n }\n\n // store loaded engine\n this.engine = opts.engines[this.ext];\n\n // lookup path\n this.path = this.lookup(fileName);\n}\n\n/**\n * Lookup view by the given `name`\n *\n * @param {string} name\n * @private\n */\n\nView.prototype.lookup = function lookup(name) {\n var path;\n var roots = [].concat(this.root);\n\n debug('lookup \"%s\"', name);\n\n for (var i = 0; i < roots.length && !path; i++) {\n var root = roots[i];\n\n // resolve the path\n var loc = resolve(root, name);\n var dir = dirname(loc);\n var file = basename(loc);\n\n // resolve the file\n path = this.resolve(dir, file);\n }\n\n return path;\n};\n\n/**\n * Render with the given options.\n *\n * @param {object} options\n * @param {function} callback\n * @private\n */\n\nView.prototype.render = function render(options, callback) {\n debug('render \"%s\"', this.path);\n this.engine(this.path, options, callback);\n};\n\n/**\n * Resolve the file within the given directory.\n *\n * @param {string} dir\n * @param {string} file\n * @private\n */\n\nView.prototype.resolve = function resolve(dir, file) {\n var ext = this.ext;\n\n // .\n var path = join(dir, file);\n var stat = tryStat(path);\n\n if (stat && stat.isFile()) {\n return path;\n }\n\n // /index.\n path = join(dir, basename(file, ext), 'index' + ext);\n stat = tryStat(path);\n\n if (stat && stat.isFile()) {\n return path;\n }\n};\n\n/**\n * Return a stat, maybe.\n *\n * @param {string} path\n * @return {fs.Stats}\n * @private\n */\n\nfunction tryStat(path) {\n debug('stat \"%s\"', path);\n\n try {\n return fs.statSync(path);\n } catch (e) {\n return undefined;\n }\n}\n", "/*! safe-buffer. MIT License. Feross Aboukhadijeh */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n", "/*!\n * content-disposition\n * Copyright(c) 2014-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = contentDisposition\nmodule.exports.parse = parse\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar basename = require('path').basename\nvar Buffer = require('safe-buffer').Buffer\n\n/**\n * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including \"%\")\n * @private\n */\n\nvar ENCODE_URL_ATTR_CHAR_REGEXP = /[\\x00-\\x20\"'()*,/:;<=>?@[\\\\\\]{}\\x7f]/g // eslint-disable-line no-control-regex\n\n/**\n * RegExp to match percent encoding escape.\n * @private\n */\n\nvar HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/\nvar HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g\n\n/**\n * RegExp to match non-latin1 characters.\n * @private\n */\n\nvar NON_LATIN1_REGEXP = /[^\\x20-\\x7e\\xa0-\\xff]/g\n\n/**\n * RegExp to match quoted-pair in RFC 2616\n *\n * quoted-pair = \"\\\" CHAR\n * CHAR = \n * @private\n */\n\nvar QESC_REGEXP = /\\\\([\\u0000-\\u007f])/g // eslint-disable-line no-control-regex\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 2616\n * @private\n */\n\nvar QUOTE_REGEXP = /([\\\\\"])/g\n\n/**\n * RegExp for various RFC 2616 grammar\n *\n * parameter = token \"=\" ( token | quoted-string )\n * token = 1*\n * separators = \"(\" | \")\" | \"<\" | \">\" | \"@\"\n * | \",\" | \";\" | \":\" | \"\\\" | <\">\n * | \"/\" | \"[\" | \"]\" | \"?\" | \"=\"\n * | \"{\" | \"}\" | SP | HT\n * quoted-string = ( <\"> *(qdtext | quoted-pair ) <\"> )\n * qdtext = >\n * quoted-pair = \"\\\" CHAR\n * CHAR = \n * TEXT = \n * LWS = [CRLF] 1*( SP | HT )\n * CRLF = CR LF\n * CR = \n * LF = \n * SP = \n * HT = \n * CTL = \n * OCTET = \n * @private\n */\n\nvar PARAM_REGEXP = /;[\\x09\\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\\x09\\x20]*=[\\x09\\x20]*(\"(?:[\\x20!\\x23-\\x5b\\x5d-\\x7e\\x80-\\xff]|\\\\[\\x20-\\x7e])*\"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\\x09\\x20]*/g // eslint-disable-line no-control-regex\nvar TEXT_REGEXP = /^[\\x20-\\x7e\\x80-\\xff]+$/\nvar TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/\n\n/**\n * RegExp for various RFC 5987 grammar\n *\n * ext-value = charset \"'\" [ language ] \"'\" value-chars\n * charset = \"UTF-8\" / \"ISO-8859-1\" / mime-charset\n * mime-charset = 1*mime-charsetc\n * mime-charsetc = ALPHA / DIGIT\n * / \"!\" / \"#\" / \"$\" / \"%\" / \"&\"\n * / \"+\" / \"-\" / \"^\" / \"_\" / \"`\"\n * / \"{\" / \"}\" / \"~\"\n * language = ( 2*3ALPHA [ extlang ] )\n * / 4ALPHA\n * / 5*8ALPHA\n * extlang = *3( \"-\" 3ALPHA )\n * value-chars = *( pct-encoded / attr-char )\n * pct-encoded = \"%\" HEXDIG HEXDIG\n * attr-char = ALPHA / DIGIT\n * / \"!\" / \"#\" / \"$\" / \"&\" / \"+\" / \"-\" / \".\"\n * / \"^\" / \"_\" / \"`\" / \"|\" / \"~\"\n * @private\n */\n\nvar EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/\n\n/**\n * RegExp for various RFC 6266 grammar\n *\n * disposition-type = \"inline\" | \"attachment\" | disp-ext-type\n * disp-ext-type = token\n * disposition-parm = filename-parm | disp-ext-parm\n * filename-parm = \"filename\" \"=\" value\n * | \"filename*\" \"=\" ext-value\n * disp-ext-parm = token \"=\" value\n * | ext-token \"=\" ext-value\n * ext-token = \n * @private\n */\n\nvar DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\\x09\\x20]*(?:$|;)/ // eslint-disable-line no-control-regex\n\n/**\n * Create an attachment Content-Disposition header.\n *\n * @param {string} [filename]\n * @param {object} [options]\n * @param {string} [options.type=attachment]\n * @param {string|boolean} [options.fallback=true]\n * @return {string}\n * @public\n */\n\nfunction contentDisposition (filename, options) {\n var opts = options || {}\n\n // get type\n var type = opts.type || 'attachment'\n\n // get parameters\n var params = createparams(filename, opts.fallback)\n\n // format into string\n return format(new ContentDisposition(type, params))\n}\n\n/**\n * Create parameters object from filename and fallback.\n *\n * @param {string} [filename]\n * @param {string|boolean} [fallback=true]\n * @return {object}\n * @private\n */\n\nfunction createparams (filename, fallback) {\n if (filename === undefined) {\n return\n }\n\n var params = {}\n\n if (typeof filename !== 'string') {\n throw new TypeError('filename must be a string')\n }\n\n // fallback defaults to true\n if (fallback === undefined) {\n fallback = true\n }\n\n if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {\n throw new TypeError('fallback must be a string or boolean')\n }\n\n if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {\n throw new TypeError('fallback must be ISO-8859-1 string')\n }\n\n // restrict to file base name\n var name = basename(filename)\n\n // determine if name is suitable for quoted string\n var isQuotedString = TEXT_REGEXP.test(name)\n\n // generate fallback name\n var fallbackName = typeof fallback !== 'string'\n ? fallback && getlatin1(name)\n : basename(fallback)\n var hasFallback = typeof fallbackName === 'string' && fallbackName !== name\n\n // set extended filename parameter\n if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {\n params['filename*'] = name\n }\n\n // set filename parameter\n if (isQuotedString || hasFallback) {\n params.filename = hasFallback\n ? fallbackName\n : name\n }\n\n return params\n}\n\n/**\n * Format object to Content-Disposition header.\n *\n * @param {object} obj\n * @param {string} obj.type\n * @param {object} [obj.parameters]\n * @return {string}\n * @private\n */\n\nfunction format (obj) {\n var parameters = obj.parameters\n var type = obj.type\n\n if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {\n throw new TypeError('invalid type')\n }\n\n // start with normalized type\n var string = String(type).toLowerCase()\n\n // append parameters\n if (parameters && typeof parameters === 'object') {\n var param\n var params = Object.keys(parameters).sort()\n\n for (var i = 0; i < params.length; i++) {\n param = params[i]\n\n var val = param.substr(-1) === '*'\n ? ustring(parameters[param])\n : qstring(parameters[param])\n\n string += '; ' + param + '=' + val\n }\n }\n\n return string\n}\n\n/**\n * Decode a RFC 5987 field value (gracefully).\n *\n * @param {string} str\n * @return {string}\n * @private\n */\n\nfunction decodefield (str) {\n var match = EXT_VALUE_REGEXP.exec(str)\n\n if (!match) {\n throw new TypeError('invalid extended field value')\n }\n\n var charset = match[1].toLowerCase()\n var encoded = match[2]\n var value\n\n // to binary string\n var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode)\n\n switch (charset) {\n case 'iso-8859-1':\n value = getlatin1(binary)\n break\n case 'utf-8':\n value = Buffer.from(binary, 'binary').toString('utf8')\n break\n default:\n throw new TypeError('unsupported charset in extended field')\n }\n\n return value\n}\n\n/**\n * Get ISO-8859-1 version of string.\n *\n * @param {string} val\n * @return {string}\n * @private\n */\n\nfunction getlatin1 (val) {\n // simple Unicode -> ISO-8859-1 transformation\n return String(val).replace(NON_LATIN1_REGEXP, '?')\n}\n\n/**\n * Parse Content-Disposition header string.\n *\n * @param {string} string\n * @return {object}\n * @public\n */\n\nfunction parse (string) {\n if (!string || typeof string !== 'string') {\n throw new TypeError('argument string is required')\n }\n\n var match = DISPOSITION_TYPE_REGEXP.exec(string)\n\n if (!match) {\n throw new TypeError('invalid type format')\n }\n\n // normalize type\n var index = match[0].length\n var type = match[1].toLowerCase()\n\n var key\n var names = []\n var params = {}\n var value\n\n // calculate index to start at\n index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'\n ? index - 1\n : index\n\n // match parameters\n while ((match = PARAM_REGEXP.exec(string))) {\n if (match.index !== index) {\n throw new TypeError('invalid parameter format')\n }\n\n index += match[0].length\n key = match[1].toLowerCase()\n value = match[2]\n\n if (names.indexOf(key) !== -1) {\n throw new TypeError('invalid duplicate parameter')\n }\n\n names.push(key)\n\n if (key.indexOf('*') + 1 === key.length) {\n // decode extended value\n key = key.slice(0, -1)\n value = decodefield(value)\n\n // overwrite existing value\n params[key] = value\n continue\n }\n\n if (typeof params[key] === 'string') {\n continue\n }\n\n if (value[0] === '\"') {\n // remove quotes and escapes\n value = value\n .substr(1, value.length - 2)\n .replace(QESC_REGEXP, '$1')\n }\n\n params[key] = value\n }\n\n if (index !== -1 && index !== string.length) {\n throw new TypeError('invalid parameter format')\n }\n\n return new ContentDisposition(type, params)\n}\n\n/**\n * Percent decode a single character.\n *\n * @param {string} str\n * @param {string} hex\n * @return {string}\n * @private\n */\n\nfunction pdecode (str, hex) {\n return String.fromCharCode(parseInt(hex, 16))\n}\n\n/**\n * Percent encode a single character.\n *\n * @param {string} char\n * @return {string}\n * @private\n */\n\nfunction pencode (char) {\n return '%' + String(char)\n .charCodeAt(0)\n .toString(16)\n .toUpperCase()\n}\n\n/**\n * Quote a string for HTTP.\n *\n * @param {string} val\n * @return {string}\n * @private\n */\n\nfunction qstring (val) {\n var str = String(val)\n\n return '\"' + str.replace(QUOTE_REGEXP, '\\\\$1') + '\"'\n}\n\n/**\n * Encode a Unicode string for HTTP (RFC 5987).\n *\n * @param {string} val\n * @return {string}\n * @private\n */\n\nfunction ustring (val) {\n var str = String(val)\n\n // percent encode as UTF-8\n var encoded = encodeURIComponent(str)\n .replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode)\n\n return 'UTF-8\\'\\'' + encoded\n}\n\n/**\n * Class for parsed Content-Disposition header for v8 optimization\n *\n * @public\n * @param {string} type\n * @param {object} parameters\n * @constructor\n */\n\nfunction ContentDisposition (type, parameters) {\n this.type = type\n this.parameters = parameters\n}\n", "/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isNaN(val) === false) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^((?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n if (ms >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (ms >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (ms >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (ms >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n return plural(ms, d, 'day') ||\n plural(ms, h, 'hour') ||\n plural(ms, m, 'minute') ||\n plural(ms, s, 'second') ||\n ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, n, name) {\n if (ms < n) {\n return;\n }\n if (ms < n * 1.5) {\n return Math.floor(ms / n) + ' ' + name;\n }\n return Math.ceil(ms / n) + ' ' + name + 's';\n}\n", "\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = createDebug.debug = createDebug['default'] = createDebug;\nexports.coerce = coerce;\nexports.disable = disable;\nexports.enable = enable;\nexports.enabled = enabled;\nexports.humanize = require('ms');\n\n/**\n * The currently active debug mode names, and names to skip.\n */\n\nexports.names = [];\nexports.skips = [];\n\n/**\n * Map of special \"%n\" handling functions, for the debug \"format\" argument.\n *\n * Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n */\n\nexports.formatters = {};\n\n/**\n * Previous log timestamp.\n */\n\nvar prevTime;\n\n/**\n * Select a color.\n * @param {String} namespace\n * @return {Number}\n * @api private\n */\n\nfunction selectColor(namespace) {\n var hash = 0, i;\n\n for (i in namespace) {\n hash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n hash |= 0; // Convert to 32bit integer\n }\n\n return exports.colors[Math.abs(hash) % exports.colors.length];\n}\n\n/**\n * Create a debugger with the given `namespace`.\n *\n * @param {String} namespace\n * @return {Function}\n * @api public\n */\n\nfunction createDebug(namespace) {\n\n function debug() {\n // disabled?\n if (!debug.enabled) return;\n\n var self = debug;\n\n // set `diff` timestamp\n var curr = +new Date();\n var ms = curr - (prevTime || curr);\n self.diff = ms;\n self.prev = prevTime;\n self.curr = curr;\n prevTime = curr;\n\n // turn the `arguments` into a proper Array\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n\n args[0] = exports.coerce(args[0]);\n\n if ('string' !== typeof args[0]) {\n // anything else let's inspect with %O\n args.unshift('%O');\n }\n\n // apply any `formatters` transformations\n var index = 0;\n args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {\n // if we encounter an escaped % then don't increase the array index\n if (match === '%%') return match;\n index++;\n var formatter = exports.formatters[format];\n if ('function' === typeof formatter) {\n var val = args[index];\n match = formatter.call(self, val);\n\n // now we need to remove `args[index]` since it's inlined in the `format`\n args.splice(index, 1);\n index--;\n }\n return match;\n });\n\n // apply env-specific formatting (colors, etc.)\n exports.formatArgs.call(self, args);\n\n var logFn = debug.log || exports.log || console.log.bind(console);\n logFn.apply(self, args);\n }\n\n debug.namespace = namespace;\n debug.enabled = exports.enabled(namespace);\n debug.useColors = exports.useColors();\n debug.color = selectColor(namespace);\n\n // env-specific initialization logic for debug instances\n if ('function' === typeof exports.init) {\n exports.init(debug);\n }\n\n return debug;\n}\n\n/**\n * Enables a debug mode by namespaces. This can include modes\n * separated by a colon and wildcards.\n *\n * @param {String} namespaces\n * @api public\n */\n\nfunction enable(namespaces) {\n exports.save(namespaces);\n\n exports.names = [];\n exports.skips = [];\n\n var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n var len = split.length;\n\n for (var i = 0; i < len; i++) {\n if (!split[i]) continue; // ignore empty strings\n namespaces = split[i].replace(/\\*/g, '.*?');\n if (namespaces[0] === '-') {\n exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));\n } else {\n exports.names.push(new RegExp('^' + namespaces + '$'));\n }\n }\n}\n\n/**\n * Disable debug output.\n *\n * @api public\n */\n\nfunction disable() {\n exports.enable('');\n}\n\n/**\n * Returns true if the given mode name is enabled, false otherwise.\n *\n * @param {String} name\n * @return {Boolean}\n * @api public\n */\n\nfunction enabled(name) {\n var i, len;\n for (i = 0, len = exports.skips.length; i < len; i++) {\n if (exports.skips[i].test(name)) {\n return false;\n }\n }\n for (i = 0, len = exports.names.length; i < len; i++) {\n if (exports.names[i].test(name)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Coerce `val`.\n *\n * @param {Mixed} val\n * @return {Mixed}\n * @api private\n */\n\nfunction coerce(val) {\n if (val instanceof Error) return val.stack || val.message;\n return val;\n}\n", "/**\n * This is the web browser implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = 'undefined' != typeof chrome\n && 'undefined' != typeof chrome.storage\n ? chrome.storage.local\n : localstorage();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n 'lightseagreen',\n 'forestgreen',\n 'goldenrod',\n 'dodgerblue',\n 'darkorchid',\n 'crimson'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\nfunction useColors() {\n // NB: In an Electron preload script, document will be defined but not fully\n // initialized. Since we know we're in Chrome, we'll just detect this case\n // explicitly\n if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {\n return true;\n }\n\n // is webkit? http://stackoverflow.com/a/16459606/376773\n // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n // is firebug? http://stackoverflow.com/a/398120/376773\n (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n // is firefox >= v31?\n // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n // double check webkit in userAgent just in case we are in a worker\n (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nexports.formatters.j = function(v) {\n try {\n return JSON.stringify(v);\n } catch (err) {\n return '[UnexpectedJSONParseError]: ' + err.message;\n }\n};\n\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var useColors = this.useColors;\n\n args[0] = (useColors ? '%c' : '')\n + this.namespace\n + (useColors ? ' %c' : ' ')\n + args[0]\n + (useColors ? '%c ' : ' ')\n + '+' + exports.humanize(this.diff);\n\n if (!useColors) return;\n\n var c = 'color: ' + this.color;\n args.splice(1, 0, c, 'color: inherit')\n\n // the final \"%c\" is somewhat tricky, because there could be other\n // arguments passed either before or after the %c, so we need to\n // figure out the correct index to insert the CSS into\n var index = 0;\n var lastC = 0;\n args[0].replace(/%[a-zA-Z%]/g, function(match) {\n if ('%%' === match) return;\n index++;\n if ('%c' === match) {\n // we only are interested in the *last* %c\n // (the user may have provided their own)\n lastC = index;\n }\n });\n\n args.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.log()` when available.\n * No-op when `console.log` is not a \"function\".\n *\n * @api public\n */\n\nfunction log() {\n // this hackery is required for IE8/9, where\n // the `console.log` function doesn't have 'apply'\n return 'object' === typeof console\n && console.log\n && Function.prototype.apply.call(console.log, console, arguments);\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n try {\n if (null == namespaces) {\n exports.storage.removeItem('debug');\n } else {\n exports.storage.debug = namespaces;\n }\n } catch(e) {}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n var r;\n try {\n r = exports.storage.debug;\n } catch(e) {}\n\n // If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n if (!r && typeof process !== 'undefined' && 'env' in process) {\n r = process.env.DEBUG;\n }\n\n return r;\n}\n\n/**\n * Enable namespaces listed in `localStorage.debug` initially.\n */\n\nexports.enable(load());\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n try {\n return window.localStorage;\n } catch (e) {}\n}\n", "/**\n * Module dependencies.\n */\n\nvar tty = require('tty');\nvar util = require('util');\n\n/**\n * This is the Node.js implementation of `debug()`.\n *\n * Expose `debug()` as the module.\n */\n\nexports = module.exports = require('./debug');\nexports.init = init;\nexports.log = log;\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\n\n/**\n * Colors.\n */\n\nexports.colors = [6, 2, 3, 4, 5, 1];\n\n/**\n * Build up the default `inspectOpts` object from the environment variables.\n *\n * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js\n */\n\nexports.inspectOpts = Object.keys(process.env).filter(function (key) {\n return /^debug_/i.test(key);\n}).reduce(function (obj, key) {\n // camel-case\n var prop = key\n .substring(6)\n .toLowerCase()\n .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });\n\n // coerce string value into JS value\n var val = process.env[key];\n if (/^(yes|on|true|enabled)$/i.test(val)) val = true;\n else if (/^(no|off|false|disabled)$/i.test(val)) val = false;\n else if (val === 'null') val = null;\n else val = Number(val);\n\n obj[prop] = val;\n return obj;\n}, {});\n\n/**\n * The file descriptor to write the `debug()` calls to.\n * Set the `DEBUG_FD` env variable to override with another value. i.e.:\n *\n * $ DEBUG_FD=3 node script.js 3>debug.log\n */\n\nvar fd = parseInt(process.env.DEBUG_FD, 10) || 2;\n\nif (1 !== fd && 2 !== fd) {\n util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')()\n}\n\nvar stream = 1 === fd ? process.stdout :\n 2 === fd ? process.stderr :\n createWritableStdioStream(fd);\n\n/**\n * Is stdout a TTY? Colored output is enabled when `true`.\n */\n\nfunction useColors() {\n return 'colors' in exports.inspectOpts\n ? Boolean(exports.inspectOpts.colors)\n : tty.isatty(fd);\n}\n\n/**\n * Map %o to `util.inspect()`, all on a single line.\n */\n\nexports.formatters.o = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts)\n .split('\\n').map(function(str) {\n return str.trim()\n }).join(' ');\n};\n\n/**\n * Map %o to `util.inspect()`, allowing multiple lines if needed.\n */\n\nexports.formatters.O = function(v) {\n this.inspectOpts.colors = this.useColors;\n return util.inspect(v, this.inspectOpts);\n};\n\n/**\n * Adds ANSI color escape codes if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n var name = this.namespace;\n var useColors = this.useColors;\n\n if (useColors) {\n var c = this.color;\n var prefix = ' \\u001b[3' + c + ';1m' + name + ' ' + '\\u001b[0m';\n\n args[0] = prefix + args[0].split('\\n').join('\\n' + prefix);\n args.push('\\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\\u001b[0m');\n } else {\n args[0] = new Date().toUTCString()\n + ' ' + name + ' ' + args[0];\n }\n}\n\n/**\n * Invokes `util.format()` with the specified arguments and writes to `stream`.\n */\n\nfunction log() {\n return stream.write(util.format.apply(util, arguments) + '\\n');\n}\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\n\nfunction save(namespaces) {\n if (null == namespaces) {\n // If you set a process.env field to null or undefined, it gets cast to the\n // string 'null' or 'undefined'. Just delete instead.\n delete process.env.DEBUG;\n } else {\n process.env.DEBUG = namespaces;\n }\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\n\nfunction load() {\n return process.env.DEBUG;\n}\n\n/**\n * Copied from `node/src/node.js`.\n *\n * XXX: It's lame that node doesn't expose this API out-of-the-box. It also\n * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.\n */\n\nfunction createWritableStdioStream (fd) {\n var stream;\n var tty_wrap = process.binding('tty_wrap');\n\n // Note stream._type is used for test-module-load-list.js\n\n switch (tty_wrap.guessHandleType(fd)) {\n case 'TTY':\n stream = new tty.WriteStream(fd);\n stream._type = 'tty';\n\n // Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n case 'FILE':\n var fs = require('fs');\n stream = new fs.SyncWriteStream(fd, { autoClose: false });\n stream._type = 'fs';\n break;\n\n case 'PIPE':\n case 'TCP':\n var net = require('net');\n stream = new net.Socket({\n fd: fd,\n readable: false,\n writable: true\n });\n\n // FIXME Should probably have an option in net.Socket to create a\n // stream from an existing fd which is writable only. But for now\n // we'll just add this hack and set the `readable` member to false.\n // Test: ./node test/fixtures/echo.js < /etc/passwd\n stream.readable = false;\n stream.read = null;\n stream._type = 'pipe';\n\n // FIXME Hack to have stream not keep the event loop alive.\n // See https://github.com/joyent/node/issues/1726\n if (stream._handle && stream._handle.unref) {\n stream._handle.unref();\n }\n break;\n\n default:\n // Probably an error on in uv_guess_handle()\n throw new Error('Implement me. Unknown stream file type!');\n }\n\n // For supporting legacy API we put the FD here.\n stream.fd = fd;\n\n stream._isStdio = true;\n\n return stream;\n}\n\n/**\n * Init logic for `debug` instances.\n *\n * Create a new `inspectOpts` object in case `useColors` is set\n * differently for a particular `debug` instance.\n */\n\nfunction init (debug) {\n debug.inspectOpts = {};\n\n var keys = Object.keys(exports.inspectOpts);\n for (var i = 0; i < keys.length; i++) {\n debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];\n }\n}\n\n/**\n * Enable namespaces listed in `process.env.DEBUG` initially.\n */\n\nexports.enable(load());\n", "/**\n * Detect Electron renderer process, which is node, but we should\n * treat as a browser.\n */\n\nif (typeof process !== 'undefined' && process.type === 'renderer') {\n module.exports = require('./browser.js');\n} else {\n module.exports = require('./node.js');\n}\n", "/*!\n * etag\n * Copyright(c) 2014-2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = etag\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar crypto = require('crypto')\nvar Stats = require('fs').Stats\n\n/**\n * Module variables.\n * @private\n */\n\nvar toString = Object.prototype.toString\n\n/**\n * Generate an entity tag.\n *\n * @param {Buffer|string} entity\n * @return {string}\n * @private\n */\n\nfunction entitytag (entity) {\n if (entity.length === 0) {\n // fast-path empty\n return '\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"'\n }\n\n // compute hash of entity\n var hash = crypto\n .createHash('sha1')\n .update(entity, 'utf8')\n .digest('base64')\n .substring(0, 27)\n\n // compute length of entity\n var len = typeof entity === 'string'\n ? Buffer.byteLength(entity, 'utf8')\n : entity.length\n\n return '\"' + len.toString(16) + '-' + hash + '\"'\n}\n\n/**\n * Create a simple ETag.\n *\n * @param {string|Buffer|Stats} entity\n * @param {object} [options]\n * @param {boolean} [options.weak]\n * @return {String}\n * @public\n */\n\nfunction etag (entity, options) {\n if (entity == null) {\n throw new TypeError('argument entity is required')\n }\n\n // support fs.Stats object\n var isStats = isstats(entity)\n var weak = options && typeof options.weak === 'boolean'\n ? options.weak\n : isStats\n\n // validate argument\n if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {\n throw new TypeError('argument entity must be string, Buffer, or fs.Stats')\n }\n\n // generate entity tag\n var tag = isStats\n ? stattag(entity)\n : entitytag(entity)\n\n return weak\n ? 'W/' + tag\n : tag\n}\n\n/**\n * Determine if object is a Stats object.\n *\n * @param {object} obj\n * @return {boolean}\n * @api private\n */\n\nfunction isstats (obj) {\n // genuine fs.Stats\n if (typeof Stats === 'function' && obj instanceof Stats) {\n return true\n }\n\n // quack quack\n return obj && typeof obj === 'object' &&\n 'ctime' in obj && toString.call(obj.ctime) === '[object Date]' &&\n 'mtime' in obj && toString.call(obj.mtime) === '[object Date]' &&\n 'ino' in obj && typeof obj.ino === 'number' &&\n 'size' in obj && typeof obj.size === 'number'\n}\n\n/**\n * Generate a tag for a stat.\n *\n * @param {object} stat\n * @return {string}\n * @private\n */\n\nfunction stattag (stat) {\n var mtime = stat.mtime.getTime().toString(16)\n var size = stat.size.toString(16)\n\n return '\"' + size + '-' + mtime + '\"'\n}\n", "/*!\n * fresh\n * Copyright(c) 2012 TJ Holowaychuk\n * Copyright(c) 2016-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * RegExp to check for no-cache token in Cache-Control.\n * @private\n */\n\nvar CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\\s*?no-cache\\s*?(?:,|$)/\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = fresh\n\n/**\n * Check freshness of the response using request and response headers.\n *\n * @param {Object} reqHeaders\n * @param {Object} resHeaders\n * @return {Boolean}\n * @public\n */\n\nfunction fresh (reqHeaders, resHeaders) {\n // fields\n var modifiedSince = reqHeaders['if-modified-since']\n var noneMatch = reqHeaders['if-none-match']\n\n // unconditional request\n if (!modifiedSince && !noneMatch) {\n return false\n }\n\n // Always return stale when Cache-Control: no-cache\n // to support end-to-end reload requests\n // https://tools.ietf.org/html/rfc2616#section-14.9.4\n var cacheControl = reqHeaders['cache-control']\n if (cacheControl && CACHE_CONTROL_NO_CACHE_REGEXP.test(cacheControl)) {\n return false\n }\n\n // if-none-match\n if (noneMatch && noneMatch !== '*') {\n var etag = resHeaders['etag']\n\n if (!etag) {\n return false\n }\n\n var etagStale = true\n var matches = parseTokenList(noneMatch)\n for (var i = 0; i < matches.length; i++) {\n var match = matches[i]\n if (match === etag || match === 'W/' + etag || 'W/' + match === etag) {\n etagStale = false\n break\n }\n }\n\n if (etagStale) {\n return false\n }\n }\n\n // if-modified-since\n if (modifiedSince) {\n var lastModified = resHeaders['last-modified']\n var modifiedStale = !lastModified || !(parseHttpDate(lastModified) <= parseHttpDate(modifiedSince))\n\n if (modifiedStale) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Parse an HTTP Date into a number.\n *\n * @param {string} date\n * @private\n */\n\nfunction parseHttpDate (date) {\n var timestamp = date && Date.parse(date)\n\n // istanbul ignore next: guard against date.js Date.parse patching\n return typeof timestamp === 'number'\n ? timestamp\n : NaN\n}\n\n/**\n * Parse a HTTP token list.\n *\n * @param {string} str\n * @private\n */\n\nfunction parseTokenList (str) {\n var end = 0\n var list = []\n var start = 0\n\n // gather tokens\n for (var i = 0, len = str.length; i < len; i++) {\n switch (str.charCodeAt(i)) {\n case 0x20: /* */\n if (start === end) {\n start = end = i + 1\n }\n break\n case 0x2c: /* , */\n list.push(str.substring(start, end))\n start = end = i + 1\n break\n default:\n end = i + 1\n break\n }\n }\n\n // final token\n list.push(str.substring(start, end))\n\n return list\n}\n", "var path = require('path');\nvar fs = require('fs');\n\nfunction Mime() {\n // Map of extension -> mime type\n this.types = Object.create(null);\n\n // Map of mime type -> extension\n this.extensions = Object.create(null);\n}\n\n/**\n * Define mimetype -> extension mappings. Each key is a mime-type that maps\n * to an array of extensions associated with the type. The first extension is\n * used as the default extension for the type.\n *\n * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});\n *\n * @param map (Object) type definitions\n */\nMime.prototype.define = function (map) {\n for (var type in map) {\n var exts = map[type];\n for (var i = 0; i < exts.length; i++) {\n if (process.env.DEBUG_MIME && this.types[exts[i]]) {\n console.warn((this._loading || \"define()\").replace(/.*\\//, ''), 'changes \"' + exts[i] + '\" extension type from ' +\n this.types[exts[i]] + ' to ' + type);\n }\n\n this.types[exts[i]] = type;\n }\n\n // Default extension is the first one we encounter\n if (!this.extensions[type]) {\n this.extensions[type] = exts[0];\n }\n }\n};\n\n/**\n * Load an Apache2-style \".types\" file\n *\n * This may be called multiple times (it's expected). Where files declare\n * overlapping types/extensions, the last file wins.\n *\n * @param file (String) path of file to load.\n */\nMime.prototype.load = function(file) {\n this._loading = file;\n // Read file and split into lines\n var map = {},\n content = fs.readFileSync(file, 'ascii'),\n lines = content.split(/[\\r\\n]+/);\n\n lines.forEach(function(line) {\n // Clean up whitespace/comments, and split into fields\n var fields = line.replace(/\\s*#.*|^\\s*|\\s*$/g, '').split(/\\s+/);\n map[fields.shift()] = fields;\n });\n\n this.define(map);\n\n this._loading = null;\n};\n\n/**\n * Lookup a mime type based on extension\n */\nMime.prototype.lookup = function(path, fallback) {\n var ext = path.replace(/^.*[\\.\\/\\\\]/, '').toLowerCase();\n\n return this.types[ext] || fallback || this.default_type;\n};\n\n/**\n * Return file extension associated with a mime type\n */\nMime.prototype.extension = function(mimeType) {\n var type = mimeType.match(/^\\s*([^;\\s]*)(?:;|\\s|$)/)[1].toLowerCase();\n return this.extensions[type];\n};\n\n// Default instance\nvar mime = new Mime();\n\n// Define built-in types\nmime.define(require('./types.json'));\n\n// Default type\nmime.default_type = mime.lookup('bin');\n\n//\n// Additional API specific to the default instance\n//\n\nmime.Mime = Mime;\n\n/**\n * Lookup a charset based on mime type.\n */\nmime.charsets = {\n lookup: function(mimeType, fallback) {\n // Assume text types are utf8\n return (/^text\\/|^application\\/(javascript|json)/).test(mimeType) ? 'UTF-8' : fallback;\n }\n};\n\nmodule.exports = mime;\n", "/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n", "/*!\n * range-parser\n * Copyright(c) 2012-2014 TJ Holowaychuk\n * Copyright(c) 2015-2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = rangeParser\n\n/**\n * Parse \"Range\" header `str` relative to the given file `size`.\n *\n * @param {Number} size\n * @param {String} str\n * @param {Object} [options]\n * @return {Array}\n * @public\n */\n\nfunction rangeParser (size, str, options) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string')\n }\n\n var index = str.indexOf('=')\n\n if (index === -1) {\n return -2\n }\n\n // split the range string\n var arr = str.slice(index + 1).split(',')\n var ranges = []\n\n // add ranges type\n ranges.type = str.slice(0, index)\n\n // parse all ranges\n for (var i = 0; i < arr.length; i++) {\n var range = arr[i].split('-')\n var start = parseInt(range[0], 10)\n var end = parseInt(range[1], 10)\n\n // -nnn\n if (isNaN(start)) {\n start = size - end\n end = size - 1\n // nnn-\n } else if (isNaN(end)) {\n end = size - 1\n }\n\n // limit last-byte-pos to current length\n if (end > size - 1) {\n end = size - 1\n }\n\n // invalid or unsatisifiable\n if (isNaN(start) || isNaN(end) || start > end || start < 0) {\n continue\n }\n\n // add range\n ranges.push({\n start: start,\n end: end\n })\n }\n\n if (ranges.length < 1) {\n // unsatisifiable\n return -1\n }\n\n return options && options.combine\n ? combineRanges(ranges)\n : ranges\n}\n\n/**\n * Combine overlapping & adjacent ranges.\n * @private\n */\n\nfunction combineRanges (ranges) {\n var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart)\n\n for (var j = 0, i = 1; i < ordered.length; i++) {\n var range = ordered[i]\n var current = ordered[j]\n\n if (range.start > current.end + 1) {\n // next range\n ordered[++j] = range\n } else if (range.end > current.end) {\n // extend range\n current.end = range.end\n current.index = Math.min(current.index, range.index)\n }\n }\n\n // trim ordered array\n ordered.length = j + 1\n\n // generate combined range\n var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex)\n\n // copy ranges type\n combined.type = ranges.type\n\n return combined\n}\n\n/**\n * Map function to add index value to ranges.\n * @private\n */\n\nfunction mapWithIndex (range, index) {\n return {\n start: range.start,\n end: range.end,\n index: index\n }\n}\n\n/**\n * Map function to remove index value from ranges.\n * @private\n */\n\nfunction mapWithoutIndex (range) {\n return {\n start: range.start,\n end: range.end\n }\n}\n\n/**\n * Sort function to sort ranges by index.\n * @private\n */\n\nfunction sortByRangeIndex (a, b) {\n return a.index - b.index\n}\n\n/**\n * Sort function to sort ranges by start position.\n * @private\n */\n\nfunction sortByRangeStart (a, b) {\n return a.start - b.start\n}\n", "/*!\n * send\n * Copyright(c) 2012 TJ Holowaychuk\n * Copyright(c) 2014-2022 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar createError = require('http-errors')\nvar debug = require('debug')('send')\nvar deprecate = require('depd')('send')\nvar destroy = require('destroy')\nvar encodeUrl = require('encodeurl')\nvar escapeHtml = require('escape-html')\nvar etag = require('etag')\nvar fresh = require('fresh')\nvar fs = require('fs')\nvar mime = require('mime')\nvar ms = require('ms')\nvar onFinished = require('on-finished')\nvar parseRange = require('range-parser')\nvar path = require('path')\nvar statuses = require('statuses')\nvar Stream = require('stream')\nvar util = require('util')\n\n/**\n * Path function references.\n * @private\n */\n\nvar extname = path.extname\nvar join = path.join\nvar normalize = path.normalize\nvar resolve = path.resolve\nvar sep = path.sep\n\n/**\n * Regular expression for identifying a bytes Range header.\n * @private\n */\n\nvar BYTES_RANGE_REGEXP = /^ *bytes=/\n\n/**\n * Maximum value allowed for the max age.\n * @private\n */\n\nvar MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000 // 1 year\n\n/**\n * Regular expression to match a path with a directory up component.\n * @private\n */\n\nvar UP_PATH_REGEXP = /(?:^|[\\\\/])\\.\\.(?:[\\\\/]|$)/\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = send\nmodule.exports.mime = mime\n\n/**\n * Return a `SendStream` for `req` and `path`.\n *\n * @param {object} req\n * @param {string} path\n * @param {object} [options]\n * @return {SendStream}\n * @public\n */\n\nfunction send (req, path, options) {\n return new SendStream(req, path, options)\n}\n\n/**\n * Initialize a `SendStream` with the given `path`.\n *\n * @param {Request} req\n * @param {String} path\n * @param {object} [options]\n * @private\n */\n\nfunction SendStream (req, path, options) {\n Stream.call(this)\n\n var opts = options || {}\n\n this.options = opts\n this.path = path\n this.req = req\n\n this._acceptRanges = opts.acceptRanges !== undefined\n ? Boolean(opts.acceptRanges)\n : true\n\n this._cacheControl = opts.cacheControl !== undefined\n ? Boolean(opts.cacheControl)\n : true\n\n this._etag = opts.etag !== undefined\n ? Boolean(opts.etag)\n : true\n\n this._dotfiles = opts.dotfiles !== undefined\n ? opts.dotfiles\n : 'ignore'\n\n if (this._dotfiles !== 'ignore' && this._dotfiles !== 'allow' && this._dotfiles !== 'deny') {\n throw new TypeError('dotfiles option must be \"allow\", \"deny\", or \"ignore\"')\n }\n\n this._hidden = Boolean(opts.hidden)\n\n if (opts.hidden !== undefined) {\n deprecate('hidden: use dotfiles: \\'' + (this._hidden ? 'allow' : 'ignore') + '\\' instead')\n }\n\n // legacy support\n if (opts.dotfiles === undefined) {\n this._dotfiles = undefined\n }\n\n this._extensions = opts.extensions !== undefined\n ? normalizeList(opts.extensions, 'extensions option')\n : []\n\n this._immutable = opts.immutable !== undefined\n ? Boolean(opts.immutable)\n : false\n\n this._index = opts.index !== undefined\n ? normalizeList(opts.index, 'index option')\n : ['index.html']\n\n this._lastModified = opts.lastModified !== undefined\n ? Boolean(opts.lastModified)\n : true\n\n this._maxage = opts.maxAge || opts.maxage\n this._maxage = typeof this._maxage === 'string'\n ? ms(this._maxage)\n : Number(this._maxage)\n this._maxage = !isNaN(this._maxage)\n ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE)\n : 0\n\n this._root = opts.root\n ? resolve(opts.root)\n : null\n\n if (!this._root && opts.from) {\n this.from(opts.from)\n }\n}\n\n/**\n * Inherits from `Stream`.\n */\n\nutil.inherits(SendStream, Stream)\n\n/**\n * Enable or disable etag generation.\n *\n * @param {Boolean} val\n * @return {SendStream}\n * @api public\n */\n\nSendStream.prototype.etag = deprecate.function(function etag (val) {\n this._etag = Boolean(val)\n debug('etag %s', this._etag)\n return this\n}, 'send.etag: pass etag as option')\n\n/**\n * Enable or disable \"hidden\" (dot) files.\n *\n * @param {Boolean} path\n * @return {SendStream}\n * @api public\n */\n\nSendStream.prototype.hidden = deprecate.function(function hidden (val) {\n this._hidden = Boolean(val)\n this._dotfiles = undefined\n debug('hidden %s', this._hidden)\n return this\n}, 'send.hidden: use dotfiles option')\n\n/**\n * Set index `paths`, set to a falsy\n * value to disable index support.\n *\n * @param {String|Boolean|Array} paths\n * @return {SendStream}\n * @api public\n */\n\nSendStream.prototype.index = deprecate.function(function index (paths) {\n var index = !paths ? [] : normalizeList(paths, 'paths argument')\n debug('index %o', paths)\n this._index = index\n return this\n}, 'send.index: pass index as option')\n\n/**\n * Set root `path`.\n *\n * @param {String} path\n * @return {SendStream}\n * @api public\n */\n\nSendStream.prototype.root = function root (path) {\n this._root = resolve(String(path))\n debug('root %s', this._root)\n return this\n}\n\nSendStream.prototype.from = deprecate.function(SendStream.prototype.root,\n 'send.from: pass root as option')\n\nSendStream.prototype.root = deprecate.function(SendStream.prototype.root,\n 'send.root: pass root as option')\n\n/**\n * Set max-age to `maxAge`.\n *\n * @param {Number} maxAge\n * @return {SendStream}\n * @api public\n */\n\nSendStream.prototype.maxage = deprecate.function(function maxage (maxAge) {\n this._maxage = typeof maxAge === 'string'\n ? ms(maxAge)\n : Number(maxAge)\n this._maxage = !isNaN(this._maxage)\n ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE)\n : 0\n debug('max-age %d', this._maxage)\n return this\n}, 'send.maxage: pass maxAge as option')\n\n/**\n * Emit error with `status`.\n *\n * @param {number} status\n * @param {Error} [err]\n * @private\n */\n\nSendStream.prototype.error = function error (status, err) {\n // emit if listeners instead of responding\n if (hasListeners(this, 'error')) {\n return this.emit('error', createHttpError(status, err))\n }\n\n var res = this.res\n var msg = statuses.message[status] || String(status)\n var doc = createHtmlDocument('Error', escapeHtml(msg))\n\n // clear existing headers\n clearHeaders(res)\n\n // add error headers\n if (err && err.headers) {\n setHeaders(res, err.headers)\n }\n\n // send basic response\n res.statusCode = status\n res.setHeader('Content-Type', 'text/html; charset=UTF-8')\n res.setHeader('Content-Length', Buffer.byteLength(doc))\n res.setHeader('Content-Security-Policy', \"default-src 'none'\")\n res.setHeader('X-Content-Type-Options', 'nosniff')\n res.end(doc)\n}\n\n/**\n * Check if the pathname ends with \"/\".\n *\n * @return {boolean}\n * @private\n */\n\nSendStream.prototype.hasTrailingSlash = function hasTrailingSlash () {\n return this.path[this.path.length - 1] === '/'\n}\n\n/**\n * Check if this is a conditional GET request.\n *\n * @return {Boolean}\n * @api private\n */\n\nSendStream.prototype.isConditionalGET = function isConditionalGET () {\n return this.req.headers['if-match'] ||\n this.req.headers['if-unmodified-since'] ||\n this.req.headers['if-none-match'] ||\n this.req.headers['if-modified-since']\n}\n\n/**\n * Check if the request preconditions failed.\n *\n * @return {boolean}\n * @private\n */\n\nSendStream.prototype.isPreconditionFailure = function isPreconditionFailure () {\n var req = this.req\n var res = this.res\n\n // if-match\n var match = req.headers['if-match']\n if (match) {\n var etag = res.getHeader('ETag')\n return !etag || (match !== '*' && parseTokenList(match).every(function (match) {\n return match !== etag && match !== 'W/' + etag && 'W/' + match !== etag\n }))\n }\n\n // if-unmodified-since\n var unmodifiedSince = parseHttpDate(req.headers['if-unmodified-since'])\n if (!isNaN(unmodifiedSince)) {\n var lastModified = parseHttpDate(res.getHeader('Last-Modified'))\n return isNaN(lastModified) || lastModified > unmodifiedSince\n }\n\n return false\n}\n\n/**\n * Strip various content header fields for a change in entity.\n *\n * @private\n */\n\nSendStream.prototype.removeContentHeaderFields = function removeContentHeaderFields () {\n var res = this.res\n\n res.removeHeader('Content-Encoding')\n res.removeHeader('Content-Language')\n res.removeHeader('Content-Length')\n res.removeHeader('Content-Range')\n res.removeHeader('Content-Type')\n}\n\n/**\n * Respond with 304 not modified.\n *\n * @api private\n */\n\nSendStream.prototype.notModified = function notModified () {\n var res = this.res\n debug('not modified')\n this.removeContentHeaderFields()\n res.statusCode = 304\n res.end()\n}\n\n/**\n * Raise error that headers already sent.\n *\n * @api private\n */\n\nSendStream.prototype.headersAlreadySent = function headersAlreadySent () {\n var err = new Error('Can\\'t set headers after they are sent.')\n debug('headers already sent')\n this.error(500, err)\n}\n\n/**\n * Check if the request is cacheable, aka\n * responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}).\n *\n * @return {Boolean}\n * @api private\n */\n\nSendStream.prototype.isCachable = function isCachable () {\n var statusCode = this.res.statusCode\n return (statusCode >= 200 && statusCode < 300) ||\n statusCode === 304\n}\n\n/**\n * Handle stat() error.\n *\n * @param {Error} error\n * @private\n */\n\nSendStream.prototype.onStatError = function onStatError (error) {\n switch (error.code) {\n case 'ENAMETOOLONG':\n case 'ENOENT':\n case 'ENOTDIR':\n this.error(404, error)\n break\n default:\n this.error(500, error)\n break\n }\n}\n\n/**\n * Check if the cache is fresh.\n *\n * @return {Boolean}\n * @api private\n */\n\nSendStream.prototype.isFresh = function isFresh () {\n return fresh(this.req.headers, {\n etag: this.res.getHeader('ETag'),\n 'last-modified': this.res.getHeader('Last-Modified')\n })\n}\n\n/**\n * Check if the range is fresh.\n *\n * @return {Boolean}\n * @api private\n */\n\nSendStream.prototype.isRangeFresh = function isRangeFresh () {\n var ifRange = this.req.headers['if-range']\n\n if (!ifRange) {\n return true\n }\n\n // if-range as etag\n if (ifRange.indexOf('\"') !== -1) {\n var etag = this.res.getHeader('ETag')\n return Boolean(etag && ifRange.indexOf(etag) !== -1)\n }\n\n // if-range as modified date\n var lastModified = this.res.getHeader('Last-Modified')\n return parseHttpDate(lastModified) <= parseHttpDate(ifRange)\n}\n\n/**\n * Redirect to path.\n *\n * @param {string} path\n * @private\n */\n\nSendStream.prototype.redirect = function redirect (path) {\n var res = this.res\n\n if (hasListeners(this, 'directory')) {\n this.emit('directory', res, path)\n return\n }\n\n if (this.hasTrailingSlash()) {\n this.error(403)\n return\n }\n\n var loc = encodeUrl(collapseLeadingSlashes(this.path + '/'))\n var doc = createHtmlDocument('Redirecting', 'Redirecting to ' +\n escapeHtml(loc) + '')\n\n // redirect\n res.statusCode = 301\n res.setHeader('Content-Type', 'text/html; charset=UTF-8')\n res.setHeader('Content-Length', Buffer.byteLength(doc))\n res.setHeader('Content-Security-Policy', \"default-src 'none'\")\n res.setHeader('X-Content-Type-Options', 'nosniff')\n res.setHeader('Location', loc)\n res.end(doc)\n}\n\n/**\n * Pipe to `res.\n *\n * @param {Stream} res\n * @return {Stream} res\n * @api public\n */\n\nSendStream.prototype.pipe = function pipe (res) {\n // root path\n var root = this._root\n\n // references\n this.res = res\n\n // decode the path\n var path = decode(this.path)\n if (path === -1) {\n this.error(400)\n return res\n }\n\n // null byte(s)\n if (~path.indexOf('\\0')) {\n this.error(400)\n return res\n }\n\n var parts\n if (root !== null) {\n // normalize\n if (path) {\n path = normalize('.' + sep + path)\n }\n\n // malicious path\n if (UP_PATH_REGEXP.test(path)) {\n debug('malicious path \"%s\"', path)\n this.error(403)\n return res\n }\n\n // explode path parts\n parts = path.split(sep)\n\n // join / normalize from optional root dir\n path = normalize(join(root, path))\n } else {\n // \"..\" is malicious without \"root\"\n if (UP_PATH_REGEXP.test(path)) {\n debug('malicious path \"%s\"', path)\n this.error(403)\n return res\n }\n\n // explode path parts\n parts = normalize(path).split(sep)\n\n // resolve the path\n path = resolve(path)\n }\n\n // dotfile handling\n if (containsDotFile(parts)) {\n var access = this._dotfiles\n\n // legacy support\n if (access === undefined) {\n access = parts[parts.length - 1][0] === '.'\n ? (this._hidden ? 'allow' : 'ignore')\n : 'allow'\n }\n\n debug('%s dotfile \"%s\"', access, path)\n switch (access) {\n case 'allow':\n break\n case 'deny':\n this.error(403)\n return res\n case 'ignore':\n default:\n this.error(404)\n return res\n }\n }\n\n // index file support\n if (this._index.length && this.hasTrailingSlash()) {\n this.sendIndex(path)\n return res\n }\n\n this.sendFile(path)\n return res\n}\n\n/**\n * Transfer `path`.\n *\n * @param {String} path\n * @api public\n */\n\nSendStream.prototype.send = function send (path, stat) {\n var len = stat.size\n var options = this.options\n var opts = {}\n var res = this.res\n var req = this.req\n var ranges = req.headers.range\n var offset = options.start || 0\n\n if (headersSent(res)) {\n // impossible to send now\n this.headersAlreadySent()\n return\n }\n\n debug('pipe \"%s\"', path)\n\n // set header fields\n this.setHeader(path, stat)\n\n // set content-type\n this.type(path)\n\n // conditional GET support\n if (this.isConditionalGET()) {\n if (this.isPreconditionFailure()) {\n this.error(412)\n return\n }\n\n if (this.isCachable() && this.isFresh()) {\n this.notModified()\n return\n }\n }\n\n // adjust len to start/end options\n len = Math.max(0, len - offset)\n if (options.end !== undefined) {\n var bytes = options.end - offset + 1\n if (len > bytes) len = bytes\n }\n\n // Range support\n if (this._acceptRanges && BYTES_RANGE_REGEXP.test(ranges)) {\n // parse\n ranges = parseRange(len, ranges, {\n combine: true\n })\n\n // If-Range support\n if (!this.isRangeFresh()) {\n debug('range stale')\n ranges = -2\n }\n\n // unsatisfiable\n if (ranges === -1) {\n debug('range unsatisfiable')\n\n // Content-Range\n res.setHeader('Content-Range', contentRange('bytes', len))\n\n // 416 Requested Range Not Satisfiable\n return this.error(416, {\n headers: { 'Content-Range': res.getHeader('Content-Range') }\n })\n }\n\n // valid (syntactically invalid/multiple ranges are treated as a regular response)\n if (ranges !== -2 && ranges.length === 1) {\n debug('range %j', ranges)\n\n // Content-Range\n res.statusCode = 206\n res.setHeader('Content-Range', contentRange('bytes', len, ranges[0]))\n\n // adjust for requested range\n offset += ranges[0].start\n len = ranges[0].end - ranges[0].start + 1\n }\n }\n\n // clone options\n for (var prop in options) {\n opts[prop] = options[prop]\n }\n\n // set read options\n opts.start = offset\n opts.end = Math.max(offset, offset + len - 1)\n\n // content-length\n res.setHeader('Content-Length', len)\n\n // HEAD support\n if (req.method === 'HEAD') {\n res.end()\n return\n }\n\n this.stream(path, opts)\n}\n\n/**\n * Transfer file for `path`.\n *\n * @param {String} path\n * @api private\n */\nSendStream.prototype.sendFile = function sendFile (path) {\n var i = 0\n var self = this\n\n debug('stat \"%s\"', path)\n fs.stat(path, function onstat (err, stat) {\n if (err && err.code === 'ENOENT' && !extname(path) && path[path.length - 1] !== sep) {\n // not found, check extensions\n return next(err)\n }\n if (err) return self.onStatError(err)\n if (stat.isDirectory()) return self.redirect(path)\n self.emit('file', path, stat)\n self.send(path, stat)\n })\n\n function next (err) {\n if (self._extensions.length <= i) {\n return err\n ? self.onStatError(err)\n : self.error(404)\n }\n\n var p = path + '.' + self._extensions[i++]\n\n debug('stat \"%s\"', p)\n fs.stat(p, function (err, stat) {\n if (err) return next(err)\n if (stat.isDirectory()) return next()\n self.emit('file', p, stat)\n self.send(p, stat)\n })\n }\n}\n\n/**\n * Transfer index for `path`.\n *\n * @param {String} path\n * @api private\n */\nSendStream.prototype.sendIndex = function sendIndex (path) {\n var i = -1\n var self = this\n\n function next (err) {\n if (++i >= self._index.length) {\n if (err) return self.onStatError(err)\n return self.error(404)\n }\n\n var p = join(path, self._index[i])\n\n debug('stat \"%s\"', p)\n fs.stat(p, function (err, stat) {\n if (err) return next(err)\n if (stat.isDirectory()) return next()\n self.emit('file', p, stat)\n self.send(p, stat)\n })\n }\n\n next()\n}\n\n/**\n * Stream `path` to the response.\n *\n * @param {String} path\n * @param {Object} options\n * @api private\n */\n\nSendStream.prototype.stream = function stream (path, options) {\n var self = this\n var res = this.res\n\n // pipe\n var stream = fs.createReadStream(path, options)\n this.emit('stream', stream)\n stream.pipe(res)\n\n // cleanup\n function cleanup () {\n destroy(stream, true)\n }\n\n // response finished, cleanup\n onFinished(res, cleanup)\n\n // error handling\n stream.on('error', function onerror (err) {\n // clean up stream early\n cleanup()\n\n // error\n self.onStatError(err)\n })\n\n // end\n stream.on('end', function onend () {\n self.emit('end')\n })\n}\n\n/**\n * Set content-type based on `path`\n * if it hasn't been explicitly set.\n *\n * @param {String} path\n * @api private\n */\n\nSendStream.prototype.type = function type (path) {\n var res = this.res\n\n if (res.getHeader('Content-Type')) return\n\n var type = mime.lookup(path)\n\n if (!type) {\n debug('no content-type')\n return\n }\n\n var charset = mime.charsets.lookup(type)\n\n debug('content-type %s', type)\n res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : ''))\n}\n\n/**\n * Set response header fields, most\n * fields may be pre-defined.\n *\n * @param {String} path\n * @param {Object} stat\n * @api private\n */\n\nSendStream.prototype.setHeader = function setHeader (path, stat) {\n var res = this.res\n\n this.emit('headers', res, path, stat)\n\n if (this._acceptRanges && !res.getHeader('Accept-Ranges')) {\n debug('accept ranges')\n res.setHeader('Accept-Ranges', 'bytes')\n }\n\n if (this._cacheControl && !res.getHeader('Cache-Control')) {\n var cacheControl = 'public, max-age=' + Math.floor(this._maxage / 1000)\n\n if (this._immutable) {\n cacheControl += ', immutable'\n }\n\n debug('cache-control %s', cacheControl)\n res.setHeader('Cache-Control', cacheControl)\n }\n\n if (this._lastModified && !res.getHeader('Last-Modified')) {\n var modified = stat.mtime.toUTCString()\n debug('modified %s', modified)\n res.setHeader('Last-Modified', modified)\n }\n\n if (this._etag && !res.getHeader('ETag')) {\n var val = etag(stat)\n debug('etag %s', val)\n res.setHeader('ETag', val)\n }\n}\n\n/**\n * Clear all headers from a response.\n *\n * @param {object} res\n * @private\n */\n\nfunction clearHeaders (res) {\n var headers = getHeaderNames(res)\n\n for (var i = 0; i < headers.length; i++) {\n res.removeHeader(headers[i])\n }\n}\n\n/**\n * Collapse all leading slashes into a single slash\n *\n * @param {string} str\n * @private\n */\nfunction collapseLeadingSlashes (str) {\n for (var i = 0; i < str.length; i++) {\n if (str[i] !== '/') {\n break\n }\n }\n\n return i > 1\n ? '/' + str.substr(i)\n : str\n}\n\n/**\n * Determine if path parts contain a dotfile.\n *\n * @api private\n */\n\nfunction containsDotFile (parts) {\n for (var i = 0; i < parts.length; i++) {\n var part = parts[i]\n if (part.length > 1 && part[0] === '.') {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Create a Content-Range header.\n *\n * @param {string} type\n * @param {number} size\n * @param {array} [range]\n */\n\nfunction contentRange (type, size, range) {\n return type + ' ' + (range ? range.start + '-' + range.end : '*') + '/' + size\n}\n\n/**\n * Create a minimal HTML document.\n *\n * @param {string} title\n * @param {string} body\n * @private\n */\n\nfunction createHtmlDocument (title, body) {\n return '\\n' +\n '\\n' +\n '\\n' +\n '\\n' +\n '' + title + '\\n' +\n '\\n' +\n '\\n' +\n '
' + body + '
\\n' +\n '\\n' +\n '\\n'\n}\n\n/**\n * Create a HttpError object from simple arguments.\n *\n * @param {number} status\n * @param {Error|object} err\n * @private\n */\n\nfunction createHttpError (status, err) {\n if (!err) {\n return createError(status)\n }\n\n return err instanceof Error\n ? createError(status, err, { expose: false })\n : createError(status, err)\n}\n\n/**\n * decodeURIComponent.\n *\n * Allows V8 to only deoptimize this fn instead of all\n * of send().\n *\n * @param {String} path\n * @api private\n */\n\nfunction decode (path) {\n try {\n return decodeURIComponent(path)\n } catch (err) {\n return -1\n }\n}\n\n/**\n * Get the header names on a respnse.\n *\n * @param {object} res\n * @returns {array[string]}\n * @private\n */\n\nfunction getHeaderNames (res) {\n return typeof res.getHeaderNames !== 'function'\n ? Object.keys(res._headers || {})\n : res.getHeaderNames()\n}\n\n/**\n * Determine if emitter has listeners of a given type.\n *\n * The way to do this check is done three different ways in Node.js >= 0.8\n * so this consolidates them into a minimal set using instance methods.\n *\n * @param {EventEmitter} emitter\n * @param {string} type\n * @returns {boolean}\n * @private\n */\n\nfunction hasListeners (emitter, type) {\n var count = typeof emitter.listenerCount !== 'function'\n ? emitter.listeners(type).length\n : emitter.listenerCount(type)\n\n return count > 0\n}\n\n/**\n * Determine if the response headers have been sent.\n *\n * @param {object} res\n * @returns {boolean}\n * @private\n */\n\nfunction headersSent (res) {\n return typeof res.headersSent !== 'boolean'\n ? Boolean(res._header)\n : res.headersSent\n}\n\n/**\n * Normalize the index option into an array.\n *\n * @param {boolean|string|array} val\n * @param {string} name\n * @private\n */\n\nfunction normalizeList (val, name) {\n var list = [].concat(val || [])\n\n for (var i = 0; i < list.length; i++) {\n if (typeof list[i] !== 'string') {\n throw new TypeError(name + ' must be array of strings or false')\n }\n }\n\n return list\n}\n\n/**\n * Parse an HTTP Date into a number.\n *\n * @param {string} date\n * @private\n */\n\nfunction parseHttpDate (date) {\n var timestamp = date && Date.parse(date)\n\n return typeof timestamp === 'number'\n ? timestamp\n : NaN\n}\n\n/**\n * Parse a HTTP token list.\n *\n * @param {string} str\n * @private\n */\n\nfunction parseTokenList (str) {\n var end = 0\n var list = []\n var start = 0\n\n // gather tokens\n for (var i = 0, len = str.length; i < len; i++) {\n switch (str.charCodeAt(i)) {\n case 0x20: /* */\n if (start === end) {\n start = end = i + 1\n }\n break\n case 0x2c: /* , */\n if (start !== end) {\n list.push(str.substring(start, end))\n }\n start = end = i + 1\n break\n default:\n end = i + 1\n break\n }\n }\n\n // final token\n if (start !== end) {\n list.push(str.substring(start, end))\n }\n\n return list\n}\n\n/**\n * Set an object of headers on a response.\n *\n * @param {object} res\n * @param {object} headers\n * @private\n */\n\nfunction setHeaders (res, headers) {\n var keys = Object.keys(headers)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i]\n res.setHeader(key, headers[key])\n }\n}\n", "/*!\n * forwarded\n * Copyright(c) 2014-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = forwarded\n\n/**\n * Get all addresses in the request, using the `X-Forwarded-For` header.\n *\n * @param {object} req\n * @return {array}\n * @public\n */\n\nfunction forwarded (req) {\n if (!req) {\n throw new TypeError('argument req is required')\n }\n\n // simple header parsing\n var proxyAddrs = parse(req.headers['x-forwarded-for'] || '')\n var socketAddr = getSocketAddr(req)\n var addrs = [socketAddr].concat(proxyAddrs)\n\n // return all addresses\n return addrs\n}\n\n/**\n * Get the socket address for a request.\n *\n * @param {object} req\n * @return {string}\n * @private\n */\n\nfunction getSocketAddr (req) {\n return req.socket\n ? req.socket.remoteAddress\n : req.connection.remoteAddress\n}\n\n/**\n * Parse the X-Forwarded-For header.\n *\n * @param {string} header\n * @private\n */\n\nfunction parse (header) {\n var end = header.length\n var list = []\n var start = header.length\n\n // gather addresses, backwards\n for (var i = header.length - 1; i >= 0; i--) {\n switch (header.charCodeAt(i)) {\n case 0x20: /* */\n if (start === end) {\n start = end = i\n }\n break\n case 0x2c: /* , */\n if (start !== end) {\n list.push(header.substring(start, end))\n }\n start = end = i\n break\n default:\n start = i\n break\n }\n }\n\n // final address\n if (start !== end) {\n list.push(header.substring(start, end))\n }\n\n return list\n}\n", "(function() {\n var expandIPv6, ipaddr, ipv4Part, ipv4Regexes, ipv6Part, ipv6Regexes, matchCIDR, root, zoneIndex;\n\n ipaddr = {};\n\n root = this;\n\n if ((typeof module !== \"undefined\" && module !== null) && module.exports) {\n module.exports = ipaddr;\n } else {\n root['ipaddr'] = ipaddr;\n }\n\n matchCIDR = function(first, second, partSize, cidrBits) {\n var part, shift;\n if (first.length !== second.length) {\n throw new Error(\"ipaddr: cannot match CIDR for objects with different lengths\");\n }\n part = 0;\n while (cidrBits > 0) {\n shift = partSize - cidrBits;\n if (shift < 0) {\n shift = 0;\n }\n if (first[part] >> shift !== second[part] >> shift) {\n return false;\n }\n cidrBits -= partSize;\n part += 1;\n }\n return true;\n };\n\n ipaddr.subnetMatch = function(address, rangeList, defaultName) {\n var k, len, rangeName, rangeSubnets, subnet;\n if (defaultName == null) {\n defaultName = 'unicast';\n }\n for (rangeName in rangeList) {\n rangeSubnets = rangeList[rangeName];\n if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) {\n rangeSubnets = [rangeSubnets];\n }\n for (k = 0, len = rangeSubnets.length; k < len; k++) {\n subnet = rangeSubnets[k];\n if (address.kind() === subnet[0].kind()) {\n if (address.match.apply(address, subnet)) {\n return rangeName;\n }\n }\n }\n }\n return defaultName;\n };\n\n ipaddr.IPv4 = (function() {\n function IPv4(octets) {\n var k, len, octet;\n if (octets.length !== 4) {\n throw new Error(\"ipaddr: ipv4 octet count should be 4\");\n }\n for (k = 0, len = octets.length; k < len; k++) {\n octet = octets[k];\n if (!((0 <= octet && octet <= 255))) {\n throw new Error(\"ipaddr: ipv4 octet should fit in 8 bits\");\n }\n }\n this.octets = octets;\n }\n\n IPv4.prototype.kind = function() {\n return 'ipv4';\n };\n\n IPv4.prototype.toString = function() {\n return this.octets.join(\".\");\n };\n\n IPv4.prototype.toNormalizedString = function() {\n return this.toString();\n };\n\n IPv4.prototype.toByteArray = function() {\n return this.octets.slice(0);\n };\n\n IPv4.prototype.match = function(other, cidrRange) {\n var ref;\n if (cidrRange === void 0) {\n ref = other, other = ref[0], cidrRange = ref[1];\n }\n if (other.kind() !== 'ipv4') {\n throw new Error(\"ipaddr: cannot match ipv4 address with non-ipv4 one\");\n }\n return matchCIDR(this.octets, other.octets, 8, cidrRange);\n };\n\n IPv4.prototype.SpecialRanges = {\n unspecified: [[new IPv4([0, 0, 0, 0]), 8]],\n broadcast: [[new IPv4([255, 255, 255, 255]), 32]],\n multicast: [[new IPv4([224, 0, 0, 0]), 4]],\n linkLocal: [[new IPv4([169, 254, 0, 0]), 16]],\n loopback: [[new IPv4([127, 0, 0, 0]), 8]],\n carrierGradeNat: [[new IPv4([100, 64, 0, 0]), 10]],\n \"private\": [[new IPv4([10, 0, 0, 0]), 8], [new IPv4([172, 16, 0, 0]), 12], [new IPv4([192, 168, 0, 0]), 16]],\n reserved: [[new IPv4([192, 0, 0, 0]), 24], [new IPv4([192, 0, 2, 0]), 24], [new IPv4([192, 88, 99, 0]), 24], [new IPv4([198, 51, 100, 0]), 24], [new IPv4([203, 0, 113, 0]), 24], [new IPv4([240, 0, 0, 0]), 4]]\n };\n\n IPv4.prototype.range = function() {\n return ipaddr.subnetMatch(this, this.SpecialRanges);\n };\n\n IPv4.prototype.toIPv4MappedAddress = function() {\n return ipaddr.IPv6.parse(\"::ffff:\" + (this.toString()));\n };\n\n IPv4.prototype.prefixLengthFromSubnetMask = function() {\n var cidr, i, k, octet, stop, zeros, zerotable;\n zerotable = {\n 0: 8,\n 128: 7,\n 192: 6,\n 224: 5,\n 240: 4,\n 248: 3,\n 252: 2,\n 254: 1,\n 255: 0\n };\n cidr = 0;\n stop = false;\n for (i = k = 3; k >= 0; i = k += -1) {\n octet = this.octets[i];\n if (octet in zerotable) {\n zeros = zerotable[octet];\n if (stop && zeros !== 0) {\n return null;\n }\n if (zeros !== 8) {\n stop = true;\n }\n cidr += zeros;\n } else {\n return null;\n }\n }\n return 32 - cidr;\n };\n\n return IPv4;\n\n })();\n\n ipv4Part = \"(0?\\\\d+|0x[a-f0-9]+)\";\n\n ipv4Regexes = {\n fourOctet: new RegExp(\"^\" + ipv4Part + \"\\\\.\" + ipv4Part + \"\\\\.\" + ipv4Part + \"\\\\.\" + ipv4Part + \"$\", 'i'),\n longValue: new RegExp(\"^\" + ipv4Part + \"$\", 'i')\n };\n\n ipaddr.IPv4.parser = function(string) {\n var match, parseIntAuto, part, shift, value;\n parseIntAuto = function(string) {\n if (string[0] === \"0\" && string[1] !== \"x\") {\n return parseInt(string, 8);\n } else {\n return parseInt(string);\n }\n };\n if (match = string.match(ipv4Regexes.fourOctet)) {\n return (function() {\n var k, len, ref, results;\n ref = match.slice(1, 6);\n results = [];\n for (k = 0, len = ref.length; k < len; k++) {\n part = ref[k];\n results.push(parseIntAuto(part));\n }\n return results;\n })();\n } else if (match = string.match(ipv4Regexes.longValue)) {\n value = parseIntAuto(match[1]);\n if (value > 0xffffffff || value < 0) {\n throw new Error(\"ipaddr: address outside defined range\");\n }\n return ((function() {\n var k, results;\n results = [];\n for (shift = k = 0; k <= 24; shift = k += 8) {\n results.push((value >> shift) & 0xff);\n }\n return results;\n })()).reverse();\n } else {\n return null;\n }\n };\n\n ipaddr.IPv6 = (function() {\n function IPv6(parts, zoneId) {\n var i, k, l, len, part, ref;\n if (parts.length === 16) {\n this.parts = [];\n for (i = k = 0; k <= 14; i = k += 2) {\n this.parts.push((parts[i] << 8) | parts[i + 1]);\n }\n } else if (parts.length === 8) {\n this.parts = parts;\n } else {\n throw new Error(\"ipaddr: ipv6 part count should be 8 or 16\");\n }\n ref = this.parts;\n for (l = 0, len = ref.length; l < len; l++) {\n part = ref[l];\n if (!((0 <= part && part <= 0xffff))) {\n throw new Error(\"ipaddr: ipv6 part should fit in 16 bits\");\n }\n }\n if (zoneId) {\n this.zoneId = zoneId;\n }\n }\n\n IPv6.prototype.kind = function() {\n return 'ipv6';\n };\n\n IPv6.prototype.toString = function() {\n return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/, '::');\n };\n\n IPv6.prototype.toRFC5952String = function() {\n var bestMatchIndex, bestMatchLength, match, regex, string;\n regex = /((^|:)(0(:|$)){2,})/g;\n string = this.toNormalizedString();\n bestMatchIndex = 0;\n bestMatchLength = -1;\n while ((match = regex.exec(string))) {\n if (match[0].length > bestMatchLength) {\n bestMatchIndex = match.index;\n bestMatchLength = match[0].length;\n }\n }\n if (bestMatchLength < 0) {\n return string;\n }\n return string.substring(0, bestMatchIndex) + '::' + string.substring(bestMatchIndex + bestMatchLength);\n };\n\n IPv6.prototype.toByteArray = function() {\n var bytes, k, len, part, ref;\n bytes = [];\n ref = this.parts;\n for (k = 0, len = ref.length; k < len; k++) {\n part = ref[k];\n bytes.push(part >> 8);\n bytes.push(part & 0xff);\n }\n return bytes;\n };\n\n IPv6.prototype.toNormalizedString = function() {\n var addr, part, suffix;\n addr = ((function() {\n var k, len, ref, results;\n ref = this.parts;\n results = [];\n for (k = 0, len = ref.length; k < len; k++) {\n part = ref[k];\n results.push(part.toString(16));\n }\n return results;\n }).call(this)).join(\":\");\n suffix = '';\n if (this.zoneId) {\n suffix = '%' + this.zoneId;\n }\n return addr + suffix;\n };\n\n IPv6.prototype.toFixedLengthString = function() {\n var addr, part, suffix;\n addr = ((function() {\n var k, len, ref, results;\n ref = this.parts;\n results = [];\n for (k = 0, len = ref.length; k < len; k++) {\n part = ref[k];\n results.push(part.toString(16).padStart(4, '0'));\n }\n return results;\n }).call(this)).join(\":\");\n suffix = '';\n if (this.zoneId) {\n suffix = '%' + this.zoneId;\n }\n return addr + suffix;\n };\n\n IPv6.prototype.match = function(other, cidrRange) {\n var ref;\n if (cidrRange === void 0) {\n ref = other, other = ref[0], cidrRange = ref[1];\n }\n if (other.kind() !== 'ipv6') {\n throw new Error(\"ipaddr: cannot match ipv6 address with non-ipv6 one\");\n }\n return matchCIDR(this.parts, other.parts, 16, cidrRange);\n };\n\n IPv6.prototype.SpecialRanges = {\n unspecified: [new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128],\n linkLocal: [new IPv6([0xfe80, 0, 0, 0, 0, 0, 0, 0]), 10],\n multicast: [new IPv6([0xff00, 0, 0, 0, 0, 0, 0, 0]), 8],\n loopback: [new IPv6([0, 0, 0, 0, 0, 0, 0, 1]), 128],\n uniqueLocal: [new IPv6([0xfc00, 0, 0, 0, 0, 0, 0, 0]), 7],\n ipv4Mapped: [new IPv6([0, 0, 0, 0, 0, 0xffff, 0, 0]), 96],\n rfc6145: [new IPv6([0, 0, 0, 0, 0xffff, 0, 0, 0]), 96],\n rfc6052: [new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96],\n '6to4': [new IPv6([0x2002, 0, 0, 0, 0, 0, 0, 0]), 16],\n teredo: [new IPv6([0x2001, 0, 0, 0, 0, 0, 0, 0]), 32],\n reserved: [[new IPv6([0x2001, 0xdb8, 0, 0, 0, 0, 0, 0]), 32]]\n };\n\n IPv6.prototype.range = function() {\n return ipaddr.subnetMatch(this, this.SpecialRanges);\n };\n\n IPv6.prototype.isIPv4MappedAddress = function() {\n return this.range() === 'ipv4Mapped';\n };\n\n IPv6.prototype.toIPv4Address = function() {\n var high, low, ref;\n if (!this.isIPv4MappedAddress()) {\n throw new Error(\"ipaddr: trying to convert a generic ipv6 address to ipv4\");\n }\n ref = this.parts.slice(-2), high = ref[0], low = ref[1];\n return new ipaddr.IPv4([high >> 8, high & 0xff, low >> 8, low & 0xff]);\n };\n\n IPv6.prototype.prefixLengthFromSubnetMask = function() {\n var cidr, i, k, part, stop, zeros, zerotable;\n zerotable = {\n 0: 16,\n 32768: 15,\n 49152: 14,\n 57344: 13,\n 61440: 12,\n 63488: 11,\n 64512: 10,\n 65024: 9,\n 65280: 8,\n 65408: 7,\n 65472: 6,\n 65504: 5,\n 65520: 4,\n 65528: 3,\n 65532: 2,\n 65534: 1,\n 65535: 0\n };\n cidr = 0;\n stop = false;\n for (i = k = 7; k >= 0; i = k += -1) {\n part = this.parts[i];\n if (part in zerotable) {\n zeros = zerotable[part];\n if (stop && zeros !== 0) {\n return null;\n }\n if (zeros !== 16) {\n stop = true;\n }\n cidr += zeros;\n } else {\n return null;\n }\n }\n return 128 - cidr;\n };\n\n return IPv6;\n\n })();\n\n ipv6Part = \"(?:[0-9a-f]+::?)+\";\n\n zoneIndex = \"%[0-9a-z]{1,}\";\n\n ipv6Regexes = {\n zoneIndex: new RegExp(zoneIndex, 'i'),\n \"native\": new RegExp(\"^(::)?(\" + ipv6Part + \")?([0-9a-f]+)?(::)?(\" + zoneIndex + \")?$\", 'i'),\n transitional: new RegExp((\"^((?:\" + ipv6Part + \")|(?:::)(?:\" + ipv6Part + \")?)\") + (ipv4Part + \"\\\\.\" + ipv4Part + \"\\\\.\" + ipv4Part + \"\\\\.\" + ipv4Part) + (\"(\" + zoneIndex + \")?$\"), 'i')\n };\n\n expandIPv6 = function(string, parts) {\n var colonCount, lastColon, part, replacement, replacementCount, zoneId;\n if (string.indexOf('::') !== string.lastIndexOf('::')) {\n return null;\n }\n zoneId = (string.match(ipv6Regexes['zoneIndex']) || [])[0];\n if (zoneId) {\n zoneId = zoneId.substring(1);\n string = string.replace(/%.+$/, '');\n }\n colonCount = 0;\n lastColon = -1;\n while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) {\n colonCount++;\n }\n if (string.substr(0, 2) === '::') {\n colonCount--;\n }\n if (string.substr(-2, 2) === '::') {\n colonCount--;\n }\n if (colonCount > parts) {\n return null;\n }\n replacementCount = parts - colonCount;\n replacement = ':';\n while (replacementCount--) {\n replacement += '0:';\n }\n string = string.replace('::', replacement);\n if (string[0] === ':') {\n string = string.slice(1);\n }\n if (string[string.length - 1] === ':') {\n string = string.slice(0, -1);\n }\n parts = (function() {\n var k, len, ref, results;\n ref = string.split(\":\");\n results = [];\n for (k = 0, len = ref.length; k < len; k++) {\n part = ref[k];\n results.push(parseInt(part, 16));\n }\n return results;\n })();\n return {\n parts: parts,\n zoneId: zoneId\n };\n };\n\n ipaddr.IPv6.parser = function(string) {\n var addr, k, len, match, octet, octets, zoneId;\n if (ipv6Regexes['native'].test(string)) {\n return expandIPv6(string, 8);\n } else if (match = string.match(ipv6Regexes['transitional'])) {\n zoneId = match[6] || '';\n addr = expandIPv6(match[1].slice(0, -1) + zoneId, 6);\n if (addr.parts) {\n octets = [parseInt(match[2]), parseInt(match[3]), parseInt(match[4]), parseInt(match[5])];\n for (k = 0, len = octets.length; k < len; k++) {\n octet = octets[k];\n if (!((0 <= octet && octet <= 255))) {\n return null;\n }\n }\n addr.parts.push(octets[0] << 8 | octets[1]);\n addr.parts.push(octets[2] << 8 | octets[3]);\n return {\n parts: addr.parts,\n zoneId: addr.zoneId\n };\n }\n }\n return null;\n };\n\n ipaddr.IPv4.isIPv4 = ipaddr.IPv6.isIPv6 = function(string) {\n return this.parser(string) !== null;\n };\n\n ipaddr.IPv4.isValid = function(string) {\n var e;\n try {\n new this(this.parser(string));\n return true;\n } catch (error1) {\n e = error1;\n return false;\n }\n };\n\n ipaddr.IPv4.isValidFourPartDecimal = function(string) {\n if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\\d*)(\\.(0|[1-9]\\d*)){3}$/)) {\n return true;\n } else {\n return false;\n }\n };\n\n ipaddr.IPv6.isValid = function(string) {\n var addr, e;\n if (typeof string === \"string\" && string.indexOf(\":\") === -1) {\n return false;\n }\n try {\n addr = this.parser(string);\n new this(addr.parts, addr.zoneId);\n return true;\n } catch (error1) {\n e = error1;\n return false;\n }\n };\n\n ipaddr.IPv4.parse = function(string) {\n var parts;\n parts = this.parser(string);\n if (parts === null) {\n throw new Error(\"ipaddr: string is not formatted like ip address\");\n }\n return new this(parts);\n };\n\n ipaddr.IPv6.parse = function(string) {\n var addr;\n addr = this.parser(string);\n if (addr.parts === null) {\n throw new Error(\"ipaddr: string is not formatted like ip address\");\n }\n return new this(addr.parts, addr.zoneId);\n };\n\n ipaddr.IPv4.parseCIDR = function(string) {\n var maskLength, match, parsed;\n if (match = string.match(/^(.+)\\/(\\d+)$/)) {\n maskLength = parseInt(match[2]);\n if (maskLength >= 0 && maskLength <= 32) {\n parsed = [this.parse(match[1]), maskLength];\n Object.defineProperty(parsed, 'toString', {\n value: function() {\n return this.join('/');\n }\n });\n return parsed;\n }\n }\n throw new Error(\"ipaddr: string is not formatted like an IPv4 CIDR range\");\n };\n\n ipaddr.IPv4.subnetMaskFromPrefixLength = function(prefix) {\n var filledOctetCount, j, octets;\n prefix = parseInt(prefix);\n if (prefix < 0 || prefix > 32) {\n throw new Error('ipaddr: invalid IPv4 prefix length');\n }\n octets = [0, 0, 0, 0];\n j = 0;\n filledOctetCount = Math.floor(prefix / 8);\n while (j < filledOctetCount) {\n octets[j] = 255;\n j++;\n }\n if (filledOctetCount < 4) {\n octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - (prefix % 8);\n }\n return new this(octets);\n };\n\n ipaddr.IPv4.broadcastAddressFromCIDR = function(string) {\n var cidr, error, i, ipInterfaceOctets, octets, subnetMaskOctets;\n try {\n cidr = this.parseCIDR(string);\n ipInterfaceOctets = cidr[0].toByteArray();\n subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();\n octets = [];\n i = 0;\n while (i < 4) {\n octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);\n i++;\n }\n return new this(octets);\n } catch (error1) {\n error = error1;\n throw new Error('ipaddr: the address does not have IPv4 CIDR format');\n }\n };\n\n ipaddr.IPv4.networkAddressFromCIDR = function(string) {\n var cidr, error, i, ipInterfaceOctets, octets, subnetMaskOctets;\n try {\n cidr = this.parseCIDR(string);\n ipInterfaceOctets = cidr[0].toByteArray();\n subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();\n octets = [];\n i = 0;\n while (i < 4) {\n octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));\n i++;\n }\n return new this(octets);\n } catch (error1) {\n error = error1;\n throw new Error('ipaddr: the address does not have IPv4 CIDR format');\n }\n };\n\n ipaddr.IPv6.parseCIDR = function(string) {\n var maskLength, match, parsed;\n if (match = string.match(/^(.+)\\/(\\d+)$/)) {\n maskLength = parseInt(match[2]);\n if (maskLength >= 0 && maskLength <= 128) {\n parsed = [this.parse(match[1]), maskLength];\n Object.defineProperty(parsed, 'toString', {\n value: function() {\n return this.join('/');\n }\n });\n return parsed;\n }\n }\n throw new Error(\"ipaddr: string is not formatted like an IPv6 CIDR range\");\n };\n\n ipaddr.isValid = function(string) {\n return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string);\n };\n\n ipaddr.parse = function(string) {\n if (ipaddr.IPv6.isValid(string)) {\n return ipaddr.IPv6.parse(string);\n } else if (ipaddr.IPv4.isValid(string)) {\n return ipaddr.IPv4.parse(string);\n } else {\n throw new Error(\"ipaddr: the address has neither IPv6 nor IPv4 format\");\n }\n };\n\n ipaddr.parseCIDR = function(string) {\n var e;\n try {\n return ipaddr.IPv6.parseCIDR(string);\n } catch (error1) {\n e = error1;\n try {\n return ipaddr.IPv4.parseCIDR(string);\n } catch (error1) {\n e = error1;\n throw new Error(\"ipaddr: the address has neither IPv6 nor IPv4 CIDR format\");\n }\n }\n };\n\n ipaddr.fromByteArray = function(bytes) {\n var length;\n length = bytes.length;\n if (length === 4) {\n return new ipaddr.IPv4(bytes);\n } else if (length === 16) {\n return new ipaddr.IPv6(bytes);\n } else {\n throw new Error(\"ipaddr: the binary input is neither an IPv6 nor IPv4 address\");\n }\n };\n\n ipaddr.process = function(string) {\n var addr;\n addr = this.parse(string);\n if (addr.kind() === 'ipv6' && addr.isIPv4MappedAddress()) {\n return addr.toIPv4Address();\n } else {\n return addr;\n }\n };\n\n}).call(this);\n", "/*!\n * proxy-addr\n * Copyright(c) 2014-2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = proxyaddr\nmodule.exports.all = alladdrs\nmodule.exports.compile = compile\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar forwarded = require('forwarded')\nvar ipaddr = require('ipaddr.js')\n\n/**\n * Variables.\n * @private\n */\n\nvar DIGIT_REGEXP = /^[0-9]+$/\nvar isip = ipaddr.isValid\nvar parseip = ipaddr.parse\n\n/**\n * Pre-defined IP ranges.\n * @private\n */\n\nvar IP_RANGES = {\n linklocal: ['169.254.0.0/16', 'fe80::/10'],\n loopback: ['127.0.0.1/8', '::1/128'],\n uniquelocal: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7']\n}\n\n/**\n * Get all addresses in the request, optionally stopping\n * at the first untrusted.\n *\n * @param {Object} request\n * @param {Function|Array|String} [trust]\n * @public\n */\n\nfunction alladdrs (req, trust) {\n // get addresses\n var addrs = forwarded(req)\n\n if (!trust) {\n // Return all addresses\n return addrs\n }\n\n if (typeof trust !== 'function') {\n trust = compile(trust)\n }\n\n for (var i = 0; i < addrs.length - 1; i++) {\n if (trust(addrs[i], i)) continue\n\n addrs.length = i + 1\n }\n\n return addrs\n}\n\n/**\n * Compile argument into trust function.\n *\n * @param {Array|String} val\n * @private\n */\n\nfunction compile (val) {\n if (!val) {\n throw new TypeError('argument is required')\n }\n\n var trust\n\n if (typeof val === 'string') {\n trust = [val]\n } else if (Array.isArray(val)) {\n trust = val.slice()\n } else {\n throw new TypeError('unsupported trust argument')\n }\n\n for (var i = 0; i < trust.length; i++) {\n val = trust[i]\n\n if (!Object.prototype.hasOwnProperty.call(IP_RANGES, val)) {\n continue\n }\n\n // Splice in pre-defined range\n val = IP_RANGES[val]\n trust.splice.apply(trust, [i, 1].concat(val))\n i += val.length - 1\n }\n\n return compileTrust(compileRangeSubnets(trust))\n}\n\n/**\n * Compile `arr` elements into range subnets.\n *\n * @param {Array} arr\n * @private\n */\n\nfunction compileRangeSubnets (arr) {\n var rangeSubnets = new Array(arr.length)\n\n for (var i = 0; i < arr.length; i++) {\n rangeSubnets[i] = parseipNotation(arr[i])\n }\n\n return rangeSubnets\n}\n\n/**\n * Compile range subnet array into trust function.\n *\n * @param {Array} rangeSubnets\n * @private\n */\n\nfunction compileTrust (rangeSubnets) {\n // Return optimized function based on length\n var len = rangeSubnets.length\n return len === 0\n ? trustNone\n : len === 1\n ? trustSingle(rangeSubnets[0])\n : trustMulti(rangeSubnets)\n}\n\n/**\n * Parse IP notation string into range subnet.\n *\n * @param {String} note\n * @private\n */\n\nfunction parseipNotation (note) {\n var pos = note.lastIndexOf('/')\n var str = pos !== -1\n ? note.substring(0, pos)\n : note\n\n if (!isip(str)) {\n throw new TypeError('invalid IP address: ' + str)\n }\n\n var ip = parseip(str)\n\n if (pos === -1 && ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) {\n // Store as IPv4\n ip = ip.toIPv4Address()\n }\n\n var max = ip.kind() === 'ipv6'\n ? 128\n : 32\n\n var range = pos !== -1\n ? note.substring(pos + 1, note.length)\n : null\n\n if (range === null) {\n range = max\n } else if (DIGIT_REGEXP.test(range)) {\n range = parseInt(range, 10)\n } else if (ip.kind() === 'ipv4' && isip(range)) {\n range = parseNetmask(range)\n } else {\n range = null\n }\n\n if (range <= 0 || range > max) {\n throw new TypeError('invalid range on address: ' + note)\n }\n\n return [ip, range]\n}\n\n/**\n * Parse netmask string into CIDR range.\n *\n * @param {String} netmask\n * @private\n */\n\nfunction parseNetmask (netmask) {\n var ip = parseip(netmask)\n var kind = ip.kind()\n\n return kind === 'ipv4'\n ? ip.prefixLengthFromSubnetMask()\n : null\n}\n\n/**\n * Determine address of proxied request.\n *\n * @param {Object} request\n * @param {Function|Array|String} trust\n * @public\n */\n\nfunction proxyaddr (req, trust) {\n if (!req) {\n throw new TypeError('req argument is required')\n }\n\n if (!trust) {\n throw new TypeError('trust argument is required')\n }\n\n var addrs = alladdrs(req, trust)\n var addr = addrs[addrs.length - 1]\n\n return addr\n}\n\n/**\n * Static trust function to trust nothing.\n *\n * @private\n */\n\nfunction trustNone () {\n return false\n}\n\n/**\n * Compile trust function for multiple subnets.\n *\n * @param {Array} subnets\n * @private\n */\n\nfunction trustMulti (subnets) {\n return function trust (addr) {\n if (!isip(addr)) return false\n\n var ip = parseip(addr)\n var ipconv\n var kind = ip.kind()\n\n for (var i = 0; i < subnets.length; i++) {\n var subnet = subnets[i]\n var subnetip = subnet[0]\n var subnetkind = subnetip.kind()\n var subnetrange = subnet[1]\n var trusted = ip\n\n if (kind !== subnetkind) {\n if (subnetkind === 'ipv4' && !ip.isIPv4MappedAddress()) {\n // Incompatible IP addresses\n continue\n }\n\n if (!ipconv) {\n // Convert IP to match subnet IP kind\n ipconv = subnetkind === 'ipv4'\n ? ip.toIPv4Address()\n : ip.toIPv4MappedAddress()\n }\n\n trusted = ipconv\n }\n\n if (trusted.match(subnetip, subnetrange)) {\n return true\n }\n }\n\n return false\n }\n}\n\n/**\n * Compile trust function for single subnet.\n *\n * @param {Object} subnet\n * @private\n */\n\nfunction trustSingle (subnet) {\n var subnetip = subnet[0]\n var subnetkind = subnetip.kind()\n var subnetisipv4 = subnetkind === 'ipv4'\n var subnetrange = subnet[1]\n\n return function trust (addr) {\n if (!isip(addr)) return false\n\n var ip = parseip(addr)\n var kind = ip.kind()\n\n if (kind !== subnetkind) {\n if (subnetisipv4 && !ip.isIPv4MappedAddress()) {\n // Incompatible IP addresses\n return false\n }\n\n // Convert IP to match subnet IP kind\n ip = subnetisipv4\n ? ip.toIPv4Address()\n : ip.toIPv4MappedAddress()\n }\n\n return ip.match(subnetip, subnetrange)\n }\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @api private\n */\n\nvar Buffer = require('safe-buffer').Buffer\nvar contentDisposition = require('content-disposition');\nvar contentType = require('content-type');\nvar deprecate = require('depd')('express');\nvar flatten = require('array-flatten');\nvar mime = require('send').mime;\nvar etag = require('etag');\nvar proxyaddr = require('proxy-addr');\nvar qs = require('qs');\nvar querystring = require('querystring');\n\n/**\n * Return strong ETag for `body`.\n *\n * @param {String|Buffer} body\n * @param {String} [encoding]\n * @return {String}\n * @api private\n */\n\nexports.etag = createETagGenerator({ weak: false })\n\n/**\n * Return weak ETag for `body`.\n *\n * @param {String|Buffer} body\n * @param {String} [encoding]\n * @return {String}\n * @api private\n */\n\nexports.wetag = createETagGenerator({ weak: true })\n\n/**\n * Check if `path` looks absolute.\n *\n * @param {String} path\n * @return {Boolean}\n * @api private\n */\n\nexports.isAbsolute = function(path){\n if ('/' === path[0]) return true;\n if (':' === path[1] && ('\\\\' === path[2] || '/' === path[2])) return true; // Windows device path\n if ('\\\\\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path\n};\n\n/**\n * Flatten the given `arr`.\n *\n * @param {Array} arr\n * @return {Array}\n * @api private\n */\n\nexports.flatten = deprecate.function(flatten,\n 'utils.flatten: use array-flatten npm module instead');\n\n/**\n * Normalize the given `type`, for example \"html\" becomes \"text/html\".\n *\n * @param {String} type\n * @return {Object}\n * @api private\n */\n\nexports.normalizeType = function(type){\n return ~type.indexOf('/')\n ? acceptParams(type)\n : { value: mime.lookup(type), params: {} };\n};\n\n/**\n * Normalize `types`, for example \"html\" becomes \"text/html\".\n *\n * @param {Array} types\n * @return {Array}\n * @api private\n */\n\nexports.normalizeTypes = function(types){\n var ret = [];\n\n for (var i = 0; i < types.length; ++i) {\n ret.push(exports.normalizeType(types[i]));\n }\n\n return ret;\n};\n\n/**\n * Generate Content-Disposition header appropriate for the filename.\n * non-ascii filenames are urlencoded and a filename* parameter is added\n *\n * @param {String} filename\n * @return {String}\n * @api private\n */\n\nexports.contentDisposition = deprecate.function(contentDisposition,\n 'utils.contentDisposition: use content-disposition npm module instead');\n\n/**\n * Parse accept params `str` returning an\n * object with `.value`, `.quality` and `.params`.\n * also includes `.originalIndex` for stable sorting\n *\n * @param {String} str\n * @param {Number} index\n * @return {Object}\n * @api private\n */\n\nfunction acceptParams(str, index) {\n var parts = str.split(/ *; */);\n var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index };\n\n for (var i = 1; i < parts.length; ++i) {\n var pms = parts[i].split(/ *= */);\n if ('q' === pms[0]) {\n ret.quality = parseFloat(pms[1]);\n } else {\n ret.params[pms[0]] = pms[1];\n }\n }\n\n return ret;\n}\n\n/**\n * Compile \"etag\" value to function.\n *\n * @param {Boolean|String|Function} val\n * @return {Function}\n * @api private\n */\n\nexports.compileETag = function(val) {\n var fn;\n\n if (typeof val === 'function') {\n return val;\n }\n\n switch (val) {\n case true:\n case 'weak':\n fn = exports.wetag;\n break;\n case false:\n break;\n case 'strong':\n fn = exports.etag;\n break;\n default:\n throw new TypeError('unknown value for etag function: ' + val);\n }\n\n return fn;\n}\n\n/**\n * Compile \"query parser\" value to function.\n *\n * @param {String|Function} val\n * @return {Function}\n * @api private\n */\n\nexports.compileQueryParser = function compileQueryParser(val) {\n var fn;\n\n if (typeof val === 'function') {\n return val;\n }\n\n switch (val) {\n case true:\n case 'simple':\n fn = querystring.parse;\n break;\n case false:\n fn = newObject;\n break;\n case 'extended':\n fn = parseExtendedQueryString;\n break;\n default:\n throw new TypeError('unknown value for query parser function: ' + val);\n }\n\n return fn;\n}\n\n/**\n * Compile \"proxy trust\" value to function.\n *\n * @param {Boolean|String|Number|Array|Function} val\n * @return {Function}\n * @api private\n */\n\nexports.compileTrust = function(val) {\n if (typeof val === 'function') return val;\n\n if (val === true) {\n // Support plain true/false\n return function(){ return true };\n }\n\n if (typeof val === 'number') {\n // Support trusting hop count\n return function(a, i){ return i < val };\n }\n\n if (typeof val === 'string') {\n // Support comma-separated values\n val = val.split(',')\n .map(function (v) { return v.trim() })\n }\n\n return proxyaddr.compile(val || []);\n}\n\n/**\n * Set the charset in a given Content-Type string.\n *\n * @param {String} type\n * @param {String} charset\n * @return {String}\n * @api private\n */\n\nexports.setCharset = function setCharset(type, charset) {\n if (!type || !charset) {\n return type;\n }\n\n // parse type\n var parsed = contentType.parse(type);\n\n // set charset\n parsed.parameters.charset = charset;\n\n // format type\n return contentType.format(parsed);\n};\n\n/**\n * Create an ETag generator function, generating ETags with\n * the given options.\n *\n * @param {object} options\n * @return {function}\n * @private\n */\n\nfunction createETagGenerator (options) {\n return function generateETag (body, encoding) {\n var buf = !Buffer.isBuffer(body)\n ? Buffer.from(body, encoding)\n : body\n\n return etag(buf, options)\n }\n}\n\n/**\n * Parse an extended query string with qs.\n *\n * @return {Object}\n * @private\n */\n\nfunction parseExtendedQueryString(str) {\n return qs.parse(str, {\n allowPrototypes: true\n });\n}\n\n/**\n * Return new empty object.\n *\n * @return {Object}\n * @api private\n */\n\nfunction newObject() {\n return {};\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar finalhandler = require('finalhandler');\nvar Router = require('./router');\nvar methods = require('methods');\nvar middleware = require('./middleware/init');\nvar query = require('./middleware/query');\nvar debug = require('debug')('express:application');\nvar View = require('./view');\nvar http = require('http');\nvar compileETag = require('./utils').compileETag;\nvar compileQueryParser = require('./utils').compileQueryParser;\nvar compileTrust = require('./utils').compileTrust;\nvar deprecate = require('depd')('express');\nvar flatten = require('array-flatten');\nvar merge = require('utils-merge');\nvar resolve = require('path').resolve;\nvar setPrototypeOf = require('setprototypeof')\n\n/**\n * Module variables.\n * @private\n */\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty\nvar slice = Array.prototype.slice;\n\n/**\n * Application prototype.\n */\n\nvar app = exports = module.exports = {};\n\n/**\n * Variable for trust proxy inheritance back-compat\n * @private\n */\n\nvar trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';\n\n/**\n * Initialize the server.\n *\n * - setup default configuration\n * - setup default middleware\n * - setup route reflection methods\n *\n * @private\n */\n\napp.init = function init() {\n this.cache = {};\n this.engines = {};\n this.settings = {};\n\n this.defaultConfiguration();\n};\n\n/**\n * Initialize application configuration.\n * @private\n */\n\napp.defaultConfiguration = function defaultConfiguration() {\n var env = process.env.NODE_ENV || 'development';\n\n // default settings\n this.enable('x-powered-by');\n this.set('etag', 'weak');\n this.set('env', env);\n this.set('query parser', 'extended');\n this.set('subdomain offset', 2);\n this.set('trust proxy', false);\n\n // trust proxy inherit back-compat\n Object.defineProperty(this.settings, trustProxyDefaultSymbol, {\n configurable: true,\n value: true\n });\n\n debug('booting in %s mode', env);\n\n this.on('mount', function onmount(parent) {\n // inherit trust proxy\n if (this.settings[trustProxyDefaultSymbol] === true\n && typeof parent.settings['trust proxy fn'] === 'function') {\n delete this.settings['trust proxy'];\n delete this.settings['trust proxy fn'];\n }\n\n // inherit protos\n setPrototypeOf(this.request, parent.request)\n setPrototypeOf(this.response, parent.response)\n setPrototypeOf(this.engines, parent.engines)\n setPrototypeOf(this.settings, parent.settings)\n });\n\n // setup locals\n this.locals = Object.create(null);\n\n // top-most app is mounted at /\n this.mountpath = '/';\n\n // default locals\n this.locals.settings = this.settings;\n\n // default configuration\n this.set('view', View);\n this.set('views', resolve('views'));\n this.set('jsonp callback name', 'callback');\n\n if (env === 'production') {\n this.enable('view cache');\n }\n\n Object.defineProperty(this, 'router', {\n get: function() {\n throw new Error('\\'app.router\\' is deprecated!\\nPlease see the 3.x to 4.x migration guide for details on how to update your app.');\n }\n });\n};\n\n/**\n * lazily adds the base router if it has not yet been added.\n *\n * We cannot add the base router in the defaultConfiguration because\n * it reads app settings which might be set after that has run.\n *\n * @private\n */\napp.lazyrouter = function lazyrouter() {\n if (!this._router) {\n this._router = new Router({\n caseSensitive: this.enabled('case sensitive routing'),\n strict: this.enabled('strict routing')\n });\n\n this._router.use(query(this.get('query parser fn')));\n this._router.use(middleware.init(this));\n }\n};\n\n/**\n * Dispatch a req, res pair into the application. Starts pipeline processing.\n *\n * If no callback is provided, then default error handlers will respond\n * in the event of an error bubbling through the stack.\n *\n * @private\n */\n\napp.handle = function handle(req, res, callback) {\n var router = this._router;\n\n // final handler\n var done = callback || finalhandler(req, res, {\n env: this.get('env'),\n onerror: logerror.bind(this)\n });\n\n // no routes\n if (!router) {\n debug('no routes defined on app');\n done();\n return;\n }\n\n router.handle(req, res, done);\n};\n\n/**\n * Proxy `Router#use()` to add middleware to the app router.\n * See Router#use() documentation for details.\n *\n * If the _fn_ parameter is an express app, then it will be\n * mounted at the _route_ specified.\n *\n * @public\n */\n\napp.use = function use(fn) {\n var offset = 0;\n var path = '/';\n\n // default path to '/'\n // disambiguate app.use([fn])\n if (typeof fn !== 'function') {\n var arg = fn;\n\n while (Array.isArray(arg) && arg.length !== 0) {\n arg = arg[0];\n }\n\n // first arg is the path\n if (typeof arg !== 'function') {\n offset = 1;\n path = fn;\n }\n }\n\n var fns = flatten(slice.call(arguments, offset));\n\n if (fns.length === 0) {\n throw new TypeError('app.use() requires a middleware function')\n }\n\n // setup router\n this.lazyrouter();\n var router = this._router;\n\n fns.forEach(function (fn) {\n // non-express app\n if (!fn || !fn.handle || !fn.set) {\n return router.use(path, fn);\n }\n\n debug('.use app under %s', path);\n fn.mountpath = path;\n fn.parent = this;\n\n // restore .app property on req and res\n router.use(path, function mounted_app(req, res, next) {\n var orig = req.app;\n fn.handle(req, res, function (err) {\n setPrototypeOf(req, orig.request)\n setPrototypeOf(res, orig.response)\n next(err);\n });\n });\n\n // mounted an app\n fn.emit('mount', this);\n }, this);\n\n return this;\n};\n\n/**\n * Proxy to the app `Router#route()`\n * Returns a new `Route` instance for the _path_.\n *\n * Routes are isolated middleware stacks for specific paths.\n * See the Route api docs for details.\n *\n * @public\n */\n\napp.route = function route(path) {\n this.lazyrouter();\n return this._router.route(path);\n};\n\n/**\n * Register the given template engine callback `fn`\n * as `ext`.\n *\n * By default will `require()` the engine based on the\n * file extension. For example if you try to render\n * a \"foo.ejs\" file Express will invoke the following internally:\n *\n * app.engine('ejs', require('ejs').__express);\n *\n * For engines that do not provide `.__express` out of the box,\n * or if you wish to \"map\" a different extension to the template engine\n * you may use this method. For example mapping the EJS template engine to\n * \".html\" files:\n *\n * app.engine('html', require('ejs').renderFile);\n *\n * In this case EJS provides a `.renderFile()` method with\n * the same signature that Express expects: `(path, options, callback)`,\n * though note that it aliases this method as `ejs.__express` internally\n * so if you're using \".ejs\" extensions you don't need to do anything.\n *\n * Some template engines do not follow this convention, the\n * [Consolidate.js](https://github.com/tj/consolidate.js)\n * library was created to map all of node's popular template\n * engines to follow this convention, thus allowing them to\n * work seamlessly within Express.\n *\n * @param {String} ext\n * @param {Function} fn\n * @return {app} for chaining\n * @public\n */\n\napp.engine = function engine(ext, fn) {\n if (typeof fn !== 'function') {\n throw new Error('callback function required');\n }\n\n // get file extension\n var extension = ext[0] !== '.'\n ? '.' + ext\n : ext;\n\n // store engine\n this.engines[extension] = fn;\n\n return this;\n};\n\n/**\n * Proxy to `Router#param()` with one added api feature. The _name_ parameter\n * can be an array of names.\n *\n * See the Router#param() docs for more details.\n *\n * @param {String|Array} name\n * @param {Function} fn\n * @return {app} for chaining\n * @public\n */\n\napp.param = function param(name, fn) {\n this.lazyrouter();\n\n if (Array.isArray(name)) {\n for (var i = 0; i < name.length; i++) {\n this.param(name[i], fn);\n }\n\n return this;\n }\n\n this._router.param(name, fn);\n\n return this;\n};\n\n/**\n * Assign `setting` to `val`, or return `setting`'s value.\n *\n * app.set('foo', 'bar');\n * app.set('foo');\n * // => \"bar\"\n *\n * Mounted servers inherit their parent server's settings.\n *\n * @param {String} setting\n * @param {*} [val]\n * @return {Server} for chaining\n * @public\n */\n\napp.set = function set(setting, val) {\n if (arguments.length === 1) {\n // app.get(setting)\n var settings = this.settings\n\n while (settings && settings !== Object.prototype) {\n if (hasOwnProperty.call(settings, setting)) {\n return settings[setting]\n }\n\n settings = Object.getPrototypeOf(settings)\n }\n\n return undefined\n }\n\n debug('set \"%s\" to %o', setting, val);\n\n // set value\n this.settings[setting] = val;\n\n // trigger matched settings\n switch (setting) {\n case 'etag':\n this.set('etag fn', compileETag(val));\n break;\n case 'query parser':\n this.set('query parser fn', compileQueryParser(val));\n break;\n case 'trust proxy':\n this.set('trust proxy fn', compileTrust(val));\n\n // trust proxy inherit back-compat\n Object.defineProperty(this.settings, trustProxyDefaultSymbol, {\n configurable: true,\n value: false\n });\n\n break;\n }\n\n return this;\n};\n\n/**\n * Return the app's absolute pathname\n * based on the parent(s) that have\n * mounted it.\n *\n * For example if the application was\n * mounted as \"/admin\", which itself\n * was mounted as \"/blog\" then the\n * return value would be \"/blog/admin\".\n *\n * @return {String}\n * @private\n */\n\napp.path = function path() {\n return this.parent\n ? this.parent.path() + this.mountpath\n : '';\n};\n\n/**\n * Check if `setting` is enabled (truthy).\n *\n * app.enabled('foo')\n * // => false\n *\n * app.enable('foo')\n * app.enabled('foo')\n * // => true\n *\n * @param {String} setting\n * @return {Boolean}\n * @public\n */\n\napp.enabled = function enabled(setting) {\n return Boolean(this.set(setting));\n};\n\n/**\n * Check if `setting` is disabled.\n *\n * app.disabled('foo')\n * // => true\n *\n * app.enable('foo')\n * app.disabled('foo')\n * // => false\n *\n * @param {String} setting\n * @return {Boolean}\n * @public\n */\n\napp.disabled = function disabled(setting) {\n return !this.set(setting);\n};\n\n/**\n * Enable `setting`.\n *\n * @param {String} setting\n * @return {app} for chaining\n * @public\n */\n\napp.enable = function enable(setting) {\n return this.set(setting, true);\n};\n\n/**\n * Disable `setting`.\n *\n * @param {String} setting\n * @return {app} for chaining\n * @public\n */\n\napp.disable = function disable(setting) {\n return this.set(setting, false);\n};\n\n/**\n * Delegate `.VERB(...)` calls to `router.VERB(...)`.\n */\n\nmethods.forEach(function(method){\n app[method] = function(path){\n if (method === 'get' && arguments.length === 1) {\n // app.get(setting)\n return this.set(path);\n }\n\n this.lazyrouter();\n\n var route = this._router.route(path);\n route[method].apply(route, slice.call(arguments, 1));\n return this;\n };\n});\n\n/**\n * Special-cased \"all\" method, applying the given route `path`,\n * middleware, and callback to _every_ HTTP method.\n *\n * @param {String} path\n * @param {Function} ...\n * @return {app} for chaining\n * @public\n */\n\napp.all = function all(path) {\n this.lazyrouter();\n\n var route = this._router.route(path);\n var args = slice.call(arguments, 1);\n\n for (var i = 0; i < methods.length; i++) {\n route[methods[i]].apply(route, args);\n }\n\n return this;\n};\n\n// del -> delete alias\n\napp.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');\n\n/**\n * Render the given view `name` name with `options`\n * and a callback accepting an error and the\n * rendered template string.\n *\n * Example:\n *\n * app.render('email', { name: 'Tobi' }, function(err, html){\n * // ...\n * })\n *\n * @param {String} name\n * @param {Object|Function} options or fn\n * @param {Function} callback\n * @public\n */\n\napp.render = function render(name, options, callback) {\n var cache = this.cache;\n var done = callback;\n var engines = this.engines;\n var opts = options;\n var renderOptions = {};\n var view;\n\n // support callback function as second arg\n if (typeof options === 'function') {\n done = options;\n opts = {};\n }\n\n // merge app.locals\n merge(renderOptions, this.locals);\n\n // merge options._locals\n if (opts._locals) {\n merge(renderOptions, opts._locals);\n }\n\n // merge options\n merge(renderOptions, opts);\n\n // set .cache unless explicitly provided\n if (renderOptions.cache == null) {\n renderOptions.cache = this.enabled('view cache');\n }\n\n // primed cache\n if (renderOptions.cache) {\n view = cache[name];\n }\n\n // view\n if (!view) {\n var View = this.get('view');\n\n view = new View(name, {\n defaultEngine: this.get('view engine'),\n root: this.get('views'),\n engines: engines\n });\n\n if (!view.path) {\n var dirs = Array.isArray(view.root) && view.root.length > 1\n ? 'directories \"' + view.root.slice(0, -1).join('\", \"') + '\" or \"' + view.root[view.root.length - 1] + '\"'\n : 'directory \"' + view.root + '\"'\n var err = new Error('Failed to lookup view \"' + name + '\" in views ' + dirs);\n err.view = view;\n return done(err);\n }\n\n // prime the cache\n if (renderOptions.cache) {\n cache[name] = view;\n }\n }\n\n // render\n tryRender(view, renderOptions, done);\n};\n\n/**\n * Listen for connections.\n *\n * A node `http.Server` is returned, with this\n * application (which is a `Function`) as its\n * callback. If you wish to create both an HTTP\n * and HTTPS server you may do so with the \"http\"\n * and \"https\" modules as shown here:\n *\n * var http = require('http')\n * , https = require('https')\n * , express = require('express')\n * , app = express();\n *\n * http.createServer(app).listen(80);\n * https.createServer({ ... }, app).listen(443);\n *\n * @return {http.Server}\n * @public\n */\n\napp.listen = function listen() {\n var server = http.createServer(this);\n return server.listen.apply(server, arguments);\n};\n\n/**\n * Log error using console.error.\n *\n * @param {Error} err\n * @private\n */\n\nfunction logerror(err) {\n /* istanbul ignore next */\n if (this.get('env') !== 'test') console.error(err.stack || err.toString());\n}\n\n/**\n * Try rendering a view.\n * @private\n */\n\nfunction tryRender(view, options, callback) {\n try {\n view.render(options, callback);\n } catch (err) {\n callback(err);\n }\n}\n", "/**\n * negotiator\n * Copyright(c) 2012 Isaac Z. Schlueter\n * Copyright(c) 2014 Federico Romero\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = preferredCharsets;\nmodule.exports.preferredCharsets = preferredCharsets;\n\n/**\n * Module variables.\n * @private\n */\n\nvar simpleCharsetRegExp = /^\\s*([^\\s;]+)\\s*(?:;(.*))?$/;\n\n/**\n * Parse the Accept-Charset header.\n * @private\n */\n\nfunction parseAcceptCharset(accept) {\n var accepts = accept.split(',');\n\n for (var i = 0, j = 0; i < accepts.length; i++) {\n var charset = parseCharset(accepts[i].trim(), i);\n\n if (charset) {\n accepts[j++] = charset;\n }\n }\n\n // trim accepts\n accepts.length = j;\n\n return accepts;\n}\n\n/**\n * Parse a charset from the Accept-Charset header.\n * @private\n */\n\nfunction parseCharset(str, i) {\n var match = simpleCharsetRegExp.exec(str);\n if (!match) return null;\n\n var charset = match[1];\n var q = 1;\n if (match[2]) {\n var params = match[2].split(';')\n for (var j = 0; j < params.length; j++) {\n var p = params[j].trim().split('=');\n if (p[0] === 'q') {\n q = parseFloat(p[1]);\n break;\n }\n }\n }\n\n return {\n charset: charset,\n q: q,\n i: i\n };\n}\n\n/**\n * Get the priority of a charset.\n * @private\n */\n\nfunction getCharsetPriority(charset, accepted, index) {\n var priority = {o: -1, q: 0, s: 0};\n\n for (var i = 0; i < accepted.length; i++) {\n var spec = specify(charset, accepted[i], index);\n\n if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {\n priority = spec;\n }\n }\n\n return priority;\n}\n\n/**\n * Get the specificity of the charset.\n * @private\n */\n\nfunction specify(charset, spec, index) {\n var s = 0;\n if(spec.charset.toLowerCase() === charset.toLowerCase()){\n s |= 1;\n } else if (spec.charset !== '*' ) {\n return null\n }\n\n return {\n i: index,\n o: spec.i,\n q: spec.q,\n s: s\n }\n}\n\n/**\n * Get the preferred charsets from an Accept-Charset header.\n * @public\n */\n\nfunction preferredCharsets(accept, provided) {\n // RFC 2616 sec 14.2: no header = *\n var accepts = parseAcceptCharset(accept === undefined ? '*' : accept || '');\n\n if (!provided) {\n // sorted list of all charsets\n return accepts\n .filter(isQuality)\n .sort(compareSpecs)\n .map(getFullCharset);\n }\n\n var priorities = provided.map(function getPriority(type, index) {\n return getCharsetPriority(type, accepts, index);\n });\n\n // sorted list of accepted charsets\n return priorities.filter(isQuality).sort(compareSpecs).map(function getCharset(priority) {\n return provided[priorities.indexOf(priority)];\n });\n}\n\n/**\n * Compare two specs.\n * @private\n */\n\nfunction compareSpecs(a, b) {\n return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;\n}\n\n/**\n * Get full charset string.\n * @private\n */\n\nfunction getFullCharset(spec) {\n return spec.charset;\n}\n\n/**\n * Check if a spec has any quality.\n * @private\n */\n\nfunction isQuality(spec) {\n return spec.q > 0;\n}\n", "/**\n * negotiator\n * Copyright(c) 2012 Isaac Z. Schlueter\n * Copyright(c) 2014 Federico Romero\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = preferredEncodings;\nmodule.exports.preferredEncodings = preferredEncodings;\n\n/**\n * Module variables.\n * @private\n */\n\nvar simpleEncodingRegExp = /^\\s*([^\\s;]+)\\s*(?:;(.*))?$/;\n\n/**\n * Parse the Accept-Encoding header.\n * @private\n */\n\nfunction parseAcceptEncoding(accept) {\n var accepts = accept.split(',');\n var hasIdentity = false;\n var minQuality = 1;\n\n for (var i = 0, j = 0; i < accepts.length; i++) {\n var encoding = parseEncoding(accepts[i].trim(), i);\n\n if (encoding) {\n accepts[j++] = encoding;\n hasIdentity = hasIdentity || specify('identity', encoding);\n minQuality = Math.min(minQuality, encoding.q || 1);\n }\n }\n\n if (!hasIdentity) {\n /*\n * If identity doesn't explicitly appear in the accept-encoding header,\n * it's added to the list of acceptable encoding with the lowest q\n */\n accepts[j++] = {\n encoding: 'identity',\n q: minQuality,\n i: i\n };\n }\n\n // trim accepts\n accepts.length = j;\n\n return accepts;\n}\n\n/**\n * Parse an encoding from the Accept-Encoding header.\n * @private\n */\n\nfunction parseEncoding(str, i) {\n var match = simpleEncodingRegExp.exec(str);\n if (!match) return null;\n\n var encoding = match[1];\n var q = 1;\n if (match[2]) {\n var params = match[2].split(';');\n for (var j = 0; j < params.length; j++) {\n var p = params[j].trim().split('=');\n if (p[0] === 'q') {\n q = parseFloat(p[1]);\n break;\n }\n }\n }\n\n return {\n encoding: encoding,\n q: q,\n i: i\n };\n}\n\n/**\n * Get the priority of an encoding.\n * @private\n */\n\nfunction getEncodingPriority(encoding, accepted, index) {\n var priority = {o: -1, q: 0, s: 0};\n\n for (var i = 0; i < accepted.length; i++) {\n var spec = specify(encoding, accepted[i], index);\n\n if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {\n priority = spec;\n }\n }\n\n return priority;\n}\n\n/**\n * Get the specificity of the encoding.\n * @private\n */\n\nfunction specify(encoding, spec, index) {\n var s = 0;\n if(spec.encoding.toLowerCase() === encoding.toLowerCase()){\n s |= 1;\n } else if (spec.encoding !== '*' ) {\n return null\n }\n\n return {\n i: index,\n o: spec.i,\n q: spec.q,\n s: s\n }\n};\n\n/**\n * Get the preferred encodings from an Accept-Encoding header.\n * @public\n */\n\nfunction preferredEncodings(accept, provided) {\n var accepts = parseAcceptEncoding(accept || '');\n\n if (!provided) {\n // sorted list of all encodings\n return accepts\n .filter(isQuality)\n .sort(compareSpecs)\n .map(getFullEncoding);\n }\n\n var priorities = provided.map(function getPriority(type, index) {\n return getEncodingPriority(type, accepts, index);\n });\n\n // sorted list of accepted encodings\n return priorities.filter(isQuality).sort(compareSpecs).map(function getEncoding(priority) {\n return provided[priorities.indexOf(priority)];\n });\n}\n\n/**\n * Compare two specs.\n * @private\n */\n\nfunction compareSpecs(a, b) {\n return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;\n}\n\n/**\n * Get full encoding string.\n * @private\n */\n\nfunction getFullEncoding(spec) {\n return spec.encoding;\n}\n\n/**\n * Check if a spec has any quality.\n * @private\n */\n\nfunction isQuality(spec) {\n return spec.q > 0;\n}\n", "/**\n * negotiator\n * Copyright(c) 2012 Isaac Z. Schlueter\n * Copyright(c) 2014 Federico Romero\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = preferredLanguages;\nmodule.exports.preferredLanguages = preferredLanguages;\n\n/**\n * Module variables.\n * @private\n */\n\nvar simpleLanguageRegExp = /^\\s*([^\\s\\-;]+)(?:-([^\\s;]+))?\\s*(?:;(.*))?$/;\n\n/**\n * Parse the Accept-Language header.\n * @private\n */\n\nfunction parseAcceptLanguage(accept) {\n var accepts = accept.split(',');\n\n for (var i = 0, j = 0; i < accepts.length; i++) {\n var language = parseLanguage(accepts[i].trim(), i);\n\n if (language) {\n accepts[j++] = language;\n }\n }\n\n // trim accepts\n accepts.length = j;\n\n return accepts;\n}\n\n/**\n * Parse a language from the Accept-Language header.\n * @private\n */\n\nfunction parseLanguage(str, i) {\n var match = simpleLanguageRegExp.exec(str);\n if (!match) return null;\n\n var prefix = match[1]\n var suffix = match[2]\n var full = prefix\n\n if (suffix) full += \"-\" + suffix;\n\n var q = 1;\n if (match[3]) {\n var params = match[3].split(';')\n for (var j = 0; j < params.length; j++) {\n var p = params[j].split('=');\n if (p[0] === 'q') q = parseFloat(p[1]);\n }\n }\n\n return {\n prefix: prefix,\n suffix: suffix,\n q: q,\n i: i,\n full: full\n };\n}\n\n/**\n * Get the priority of a language.\n * @private\n */\n\nfunction getLanguagePriority(language, accepted, index) {\n var priority = {o: -1, q: 0, s: 0};\n\n for (var i = 0; i < accepted.length; i++) {\n var spec = specify(language, accepted[i], index);\n\n if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {\n priority = spec;\n }\n }\n\n return priority;\n}\n\n/**\n * Get the specificity of the language.\n * @private\n */\n\nfunction specify(language, spec, index) {\n var p = parseLanguage(language)\n if (!p) return null;\n var s = 0;\n if(spec.full.toLowerCase() === p.full.toLowerCase()){\n s |= 4;\n } else if (spec.prefix.toLowerCase() === p.full.toLowerCase()) {\n s |= 2;\n } else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) {\n s |= 1;\n } else if (spec.full !== '*' ) {\n return null\n }\n\n return {\n i: index,\n o: spec.i,\n q: spec.q,\n s: s\n }\n};\n\n/**\n * Get the preferred languages from an Accept-Language header.\n * @public\n */\n\nfunction preferredLanguages(accept, provided) {\n // RFC 2616 sec 14.4: no header = *\n var accepts = parseAcceptLanguage(accept === undefined ? '*' : accept || '');\n\n if (!provided) {\n // sorted list of all languages\n return accepts\n .filter(isQuality)\n .sort(compareSpecs)\n .map(getFullLanguage);\n }\n\n var priorities = provided.map(function getPriority(type, index) {\n return getLanguagePriority(type, accepts, index);\n });\n\n // sorted list of accepted languages\n return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) {\n return provided[priorities.indexOf(priority)];\n });\n}\n\n/**\n * Compare two specs.\n * @private\n */\n\nfunction compareSpecs(a, b) {\n return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;\n}\n\n/**\n * Get full language string.\n * @private\n */\n\nfunction getFullLanguage(spec) {\n return spec.full;\n}\n\n/**\n * Check if a spec has any quality.\n * @private\n */\n\nfunction isQuality(spec) {\n return spec.q > 0;\n}\n", "/**\n * negotiator\n * Copyright(c) 2012 Isaac Z. Schlueter\n * Copyright(c) 2014 Federico Romero\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = preferredMediaTypes;\nmodule.exports.preferredMediaTypes = preferredMediaTypes;\n\n/**\n * Module variables.\n * @private\n */\n\nvar simpleMediaTypeRegExp = /^\\s*([^\\s\\/;]+)\\/([^;\\s]+)\\s*(?:;(.*))?$/;\n\n/**\n * Parse the Accept header.\n * @private\n */\n\nfunction parseAccept(accept) {\n var accepts = splitMediaTypes(accept);\n\n for (var i = 0, j = 0; i < accepts.length; i++) {\n var mediaType = parseMediaType(accepts[i].trim(), i);\n\n if (mediaType) {\n accepts[j++] = mediaType;\n }\n }\n\n // trim accepts\n accepts.length = j;\n\n return accepts;\n}\n\n/**\n * Parse a media type from the Accept header.\n * @private\n */\n\nfunction parseMediaType(str, i) {\n var match = simpleMediaTypeRegExp.exec(str);\n if (!match) return null;\n\n var params = Object.create(null);\n var q = 1;\n var subtype = match[2];\n var type = match[1];\n\n if (match[3]) {\n var kvps = splitParameters(match[3]).map(splitKeyValuePair);\n\n for (var j = 0; j < kvps.length; j++) {\n var pair = kvps[j];\n var key = pair[0].toLowerCase();\n var val = pair[1];\n\n // get the value, unwrapping quotes\n var value = val && val[0] === '\"' && val[val.length - 1] === '\"'\n ? val.substr(1, val.length - 2)\n : val;\n\n if (key === 'q') {\n q = parseFloat(value);\n break;\n }\n\n // store parameter\n params[key] = value;\n }\n }\n\n return {\n type: type,\n subtype: subtype,\n params: params,\n q: q,\n i: i\n };\n}\n\n/**\n * Get the priority of a media type.\n * @private\n */\n\nfunction getMediaTypePriority(type, accepted, index) {\n var priority = {o: -1, q: 0, s: 0};\n\n for (var i = 0; i < accepted.length; i++) {\n var spec = specify(type, accepted[i], index);\n\n if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) {\n priority = spec;\n }\n }\n\n return priority;\n}\n\n/**\n * Get the specificity of the media type.\n * @private\n */\n\nfunction specify(type, spec, index) {\n var p = parseMediaType(type);\n var s = 0;\n\n if (!p) {\n return null;\n }\n\n if(spec.type.toLowerCase() == p.type.toLowerCase()) {\n s |= 4\n } else if(spec.type != '*') {\n return null;\n }\n\n if(spec.subtype.toLowerCase() == p.subtype.toLowerCase()) {\n s |= 2\n } else if(spec.subtype != '*') {\n return null;\n }\n\n var keys = Object.keys(spec.params);\n if (keys.length > 0) {\n if (keys.every(function (k) {\n return spec.params[k] == '*' || (spec.params[k] || '').toLowerCase() == (p.params[k] || '').toLowerCase();\n })) {\n s |= 1\n } else {\n return null\n }\n }\n\n return {\n i: index,\n o: spec.i,\n q: spec.q,\n s: s,\n }\n}\n\n/**\n * Get the preferred media types from an Accept header.\n * @public\n */\n\nfunction preferredMediaTypes(accept, provided) {\n // RFC 2616 sec 14.2: no header = */*\n var accepts = parseAccept(accept === undefined ? '*/*' : accept || '');\n\n if (!provided) {\n // sorted list of all types\n return accepts\n .filter(isQuality)\n .sort(compareSpecs)\n .map(getFullType);\n }\n\n var priorities = provided.map(function getPriority(type, index) {\n return getMediaTypePriority(type, accepts, index);\n });\n\n // sorted list of accepted types\n return priorities.filter(isQuality).sort(compareSpecs).map(function getType(priority) {\n return provided[priorities.indexOf(priority)];\n });\n}\n\n/**\n * Compare two specs.\n * @private\n */\n\nfunction compareSpecs(a, b) {\n return (b.q - a.q) || (b.s - a.s) || (a.o - b.o) || (a.i - b.i) || 0;\n}\n\n/**\n * Get full type string.\n * @private\n */\n\nfunction getFullType(spec) {\n return spec.type + '/' + spec.subtype;\n}\n\n/**\n * Check if a spec has any quality.\n * @private\n */\n\nfunction isQuality(spec) {\n return spec.q > 0;\n}\n\n/**\n * Count the number of quotes in a string.\n * @private\n */\n\nfunction quoteCount(string) {\n var count = 0;\n var index = 0;\n\n while ((index = string.indexOf('\"', index)) !== -1) {\n count++;\n index++;\n }\n\n return count;\n}\n\n/**\n * Split a key value pair.\n * @private\n */\n\nfunction splitKeyValuePair(str) {\n var index = str.indexOf('=');\n var key;\n var val;\n\n if (index === -1) {\n key = str;\n } else {\n key = str.substr(0, index);\n val = str.substr(index + 1);\n }\n\n return [key, val];\n}\n\n/**\n * Split an Accept header into media types.\n * @private\n */\n\nfunction splitMediaTypes(accept) {\n var accepts = accept.split(',');\n\n for (var i = 1, j = 0; i < accepts.length; i++) {\n if (quoteCount(accepts[j]) % 2 == 0) {\n accepts[++j] = accepts[i];\n } else {\n accepts[j] += ',' + accepts[i];\n }\n }\n\n // trim accepts\n accepts.length = j + 1;\n\n return accepts;\n}\n\n/**\n * Split a string of parameters.\n * @private\n */\n\nfunction splitParameters(str) {\n var parameters = str.split(';');\n\n for (var i = 1, j = 0; i < parameters.length; i++) {\n if (quoteCount(parameters[j]) % 2 == 0) {\n parameters[++j] = parameters[i];\n } else {\n parameters[j] += ';' + parameters[i];\n }\n }\n\n // trim parameters\n parameters.length = j + 1;\n\n for (var i = 0; i < parameters.length; i++) {\n parameters[i] = parameters[i].trim();\n }\n\n return parameters;\n}\n", "/*!\n * negotiator\n * Copyright(c) 2012 Federico Romero\n * Copyright(c) 2012-2014 Isaac Z. Schlueter\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\nvar preferredCharsets = require('./lib/charset')\nvar preferredEncodings = require('./lib/encoding')\nvar preferredLanguages = require('./lib/language')\nvar preferredMediaTypes = require('./lib/mediaType')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = Negotiator;\nmodule.exports.Negotiator = Negotiator;\n\n/**\n * Create a Negotiator instance from a request.\n * @param {object} request\n * @public\n */\n\nfunction Negotiator(request) {\n if (!(this instanceof Negotiator)) {\n return new Negotiator(request);\n }\n\n this.request = request;\n}\n\nNegotiator.prototype.charset = function charset(available) {\n var set = this.charsets(available);\n return set && set[0];\n};\n\nNegotiator.prototype.charsets = function charsets(available) {\n return preferredCharsets(this.request.headers['accept-charset'], available);\n};\n\nNegotiator.prototype.encoding = function encoding(available) {\n var set = this.encodings(available);\n return set && set[0];\n};\n\nNegotiator.prototype.encodings = function encodings(available) {\n return preferredEncodings(this.request.headers['accept-encoding'], available);\n};\n\nNegotiator.prototype.language = function language(available) {\n var set = this.languages(available);\n return set && set[0];\n};\n\nNegotiator.prototype.languages = function languages(available) {\n return preferredLanguages(this.request.headers['accept-language'], available);\n};\n\nNegotiator.prototype.mediaType = function mediaType(available) {\n var set = this.mediaTypes(available);\n return set && set[0];\n};\n\nNegotiator.prototype.mediaTypes = function mediaTypes(available) {\n return preferredMediaTypes(this.request.headers.accept, available);\n};\n\n// Backwards compatibility\nNegotiator.prototype.preferredCharset = Negotiator.prototype.charset;\nNegotiator.prototype.preferredCharsets = Negotiator.prototype.charsets;\nNegotiator.prototype.preferredEncoding = Negotiator.prototype.encoding;\nNegotiator.prototype.preferredEncodings = Negotiator.prototype.encodings;\nNegotiator.prototype.preferredLanguage = Negotiator.prototype.language;\nNegotiator.prototype.preferredLanguages = Negotiator.prototype.languages;\nNegotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType;\nNegotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes;\n", "/*!\n * accepts\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar Negotiator = require('negotiator')\nvar mime = require('mime-types')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = Accepts\n\n/**\n * Create a new Accepts object for the given req.\n *\n * @param {object} req\n * @public\n */\n\nfunction Accepts (req) {\n if (!(this instanceof Accepts)) {\n return new Accepts(req)\n }\n\n this.headers = req.headers\n this.negotiator = new Negotiator(req)\n}\n\n/**\n * Check if the given `type(s)` is acceptable, returning\n * the best match when true, otherwise `undefined`, in which\n * case you should respond with 406 \"Not Acceptable\".\n *\n * The `type` value may be a single mime type string\n * such as \"application/json\", the extension name\n * such as \"json\" or an array `[\"json\", \"html\", \"text/plain\"]`. When a list\n * or array is given the _best_ match, if any is returned.\n *\n * Examples:\n *\n * // Accept: text/html\n * this.types('html');\n * // => \"html\"\n *\n * // Accept: text/*, application/json\n * this.types('html');\n * // => \"html\"\n * this.types('text/html');\n * // => \"text/html\"\n * this.types('json', 'text');\n * // => \"json\"\n * this.types('application/json');\n * // => \"application/json\"\n *\n * // Accept: text/*, application/json\n * this.types('image/png');\n * this.types('png');\n * // => undefined\n *\n * // Accept: text/*;q=.5, application/json\n * this.types(['html', 'json']);\n * this.types('html', 'json');\n * // => \"json\"\n *\n * @param {String|Array} types...\n * @return {String|Array|Boolean}\n * @public\n */\n\nAccepts.prototype.type =\nAccepts.prototype.types = function (types_) {\n var types = types_\n\n // support flattened arguments\n if (types && !Array.isArray(types)) {\n types = new Array(arguments.length)\n for (var i = 0; i < types.length; i++) {\n types[i] = arguments[i]\n }\n }\n\n // no types, return all requested types\n if (!types || types.length === 0) {\n return this.negotiator.mediaTypes()\n }\n\n // no accept header, return first given type\n if (!this.headers.accept) {\n return types[0]\n }\n\n var mimes = types.map(extToMime)\n var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))\n var first = accepts[0]\n\n return first\n ? types[mimes.indexOf(first)]\n : false\n}\n\n/**\n * Return accepted encodings or best fit based on `encodings`.\n *\n * Given `Accept-Encoding: gzip, deflate`\n * an array sorted by quality is returned:\n *\n * ['gzip', 'deflate']\n *\n * @param {String|Array} encodings...\n * @return {String|Array}\n * @public\n */\n\nAccepts.prototype.encoding =\nAccepts.prototype.encodings = function (encodings_) {\n var encodings = encodings_\n\n // support flattened arguments\n if (encodings && !Array.isArray(encodings)) {\n encodings = new Array(arguments.length)\n for (var i = 0; i < encodings.length; i++) {\n encodings[i] = arguments[i]\n }\n }\n\n // no encodings, return all requested encodings\n if (!encodings || encodings.length === 0) {\n return this.negotiator.encodings()\n }\n\n return this.negotiator.encodings(encodings)[0] || false\n}\n\n/**\n * Return accepted charsets or best fit based on `charsets`.\n *\n * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`\n * an array sorted by quality is returned:\n *\n * ['utf-8', 'utf-7', 'iso-8859-1']\n *\n * @param {String|Array} charsets...\n * @return {String|Array}\n * @public\n */\n\nAccepts.prototype.charset =\nAccepts.prototype.charsets = function (charsets_) {\n var charsets = charsets_\n\n // support flattened arguments\n if (charsets && !Array.isArray(charsets)) {\n charsets = new Array(arguments.length)\n for (var i = 0; i < charsets.length; i++) {\n charsets[i] = arguments[i]\n }\n }\n\n // no charsets, return all requested charsets\n if (!charsets || charsets.length === 0) {\n return this.negotiator.charsets()\n }\n\n return this.negotiator.charsets(charsets)[0] || false\n}\n\n/**\n * Return accepted languages or best fit based on `langs`.\n *\n * Given `Accept-Language: en;q=0.8, es, pt`\n * an array sorted by quality is returned:\n *\n * ['es', 'pt', 'en']\n *\n * @param {String|Array} langs...\n * @return {Array|String}\n * @public\n */\n\nAccepts.prototype.lang =\nAccepts.prototype.langs =\nAccepts.prototype.language =\nAccepts.prototype.languages = function (languages_) {\n var languages = languages_\n\n // support flattened arguments\n if (languages && !Array.isArray(languages)) {\n languages = new Array(arguments.length)\n for (var i = 0; i < languages.length; i++) {\n languages[i] = arguments[i]\n }\n }\n\n // no languages, return all requested languages\n if (!languages || languages.length === 0) {\n return this.negotiator.languages()\n }\n\n return this.negotiator.languages(languages)[0] || false\n}\n\n/**\n * Convert extnames to mime.\n *\n * @param {String} type\n * @return {String}\n * @private\n */\n\nfunction extToMime (type) {\n return type.indexOf('/') === -1\n ? mime.lookup(type)\n : type\n}\n\n/**\n * Check if mime is valid.\n *\n * @param {String} type\n * @return {String}\n * @private\n */\n\nfunction validMime (type) {\n return typeof type === 'string'\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar accepts = require('accepts');\nvar deprecate = require('depd')('express');\nvar isIP = require('net').isIP;\nvar typeis = require('type-is');\nvar http = require('http');\nvar fresh = require('fresh');\nvar parseRange = require('range-parser');\nvar parse = require('parseurl');\nvar proxyaddr = require('proxy-addr');\n\n/**\n * Request prototype.\n * @public\n */\n\nvar req = Object.create(http.IncomingMessage.prototype)\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = req\n\n/**\n * Return request header.\n *\n * The `Referrer` header field is special-cased,\n * both `Referrer` and `Referer` are interchangeable.\n *\n * Examples:\n *\n * req.get('Content-Type');\n * // => \"text/plain\"\n *\n * req.get('content-type');\n * // => \"text/plain\"\n *\n * req.get('Something');\n * // => undefined\n *\n * Aliased as `req.header()`.\n *\n * @param {String} name\n * @return {String}\n * @public\n */\n\nreq.get =\nreq.header = function header(name) {\n if (!name) {\n throw new TypeError('name argument is required to req.get');\n }\n\n if (typeof name !== 'string') {\n throw new TypeError('name must be a string to req.get');\n }\n\n var lc = name.toLowerCase();\n\n switch (lc) {\n case 'referer':\n case 'referrer':\n return this.headers.referrer\n || this.headers.referer;\n default:\n return this.headers[lc];\n }\n};\n\n/**\n * To do: update docs.\n *\n * Check if the given `type(s)` is acceptable, returning\n * the best match when true, otherwise `undefined`, in which\n * case you should respond with 406 \"Not Acceptable\".\n *\n * The `type` value may be a single MIME type string\n * such as \"application/json\", an extension name\n * such as \"json\", a comma-delimited list such as \"json, html, text/plain\",\n * an argument list such as `\"json\", \"html\", \"text/plain\"`,\n * or an array `[\"json\", \"html\", \"text/plain\"]`. When a list\n * or array is given, the _best_ match, if any is returned.\n *\n * Examples:\n *\n * // Accept: text/html\n * req.accepts('html');\n * // => \"html\"\n *\n * // Accept: text/*, application/json\n * req.accepts('html');\n * // => \"html\"\n * req.accepts('text/html');\n * // => \"text/html\"\n * req.accepts('json, text');\n * // => \"json\"\n * req.accepts('application/json');\n * // => \"application/json\"\n *\n * // Accept: text/*, application/json\n * req.accepts('image/png');\n * req.accepts('png');\n * // => undefined\n *\n * // Accept: text/*;q=.5, application/json\n * req.accepts(['html', 'json']);\n * req.accepts('html', 'json');\n * req.accepts('html, json');\n * // => \"json\"\n *\n * @param {String|Array} type(s)\n * @return {String|Array|Boolean}\n * @public\n */\n\nreq.accepts = function(){\n var accept = accepts(this);\n return accept.types.apply(accept, arguments);\n};\n\n/**\n * Check if the given `encoding`s are accepted.\n *\n * @param {String} ...encoding\n * @return {String|Array}\n * @public\n */\n\nreq.acceptsEncodings = function(){\n var accept = accepts(this);\n return accept.encodings.apply(accept, arguments);\n};\n\nreq.acceptsEncoding = deprecate.function(req.acceptsEncodings,\n 'req.acceptsEncoding: Use acceptsEncodings instead');\n\n/**\n * Check if the given `charset`s are acceptable,\n * otherwise you should respond with 406 \"Not Acceptable\".\n *\n * @param {String} ...charset\n * @return {String|Array}\n * @public\n */\n\nreq.acceptsCharsets = function(){\n var accept = accepts(this);\n return accept.charsets.apply(accept, arguments);\n};\n\nreq.acceptsCharset = deprecate.function(req.acceptsCharsets,\n 'req.acceptsCharset: Use acceptsCharsets instead');\n\n/**\n * Check if the given `lang`s are acceptable,\n * otherwise you should respond with 406 \"Not Acceptable\".\n *\n * @param {String} ...lang\n * @return {String|Array}\n * @public\n */\n\nreq.acceptsLanguages = function(){\n var accept = accepts(this);\n return accept.languages.apply(accept, arguments);\n};\n\nreq.acceptsLanguage = deprecate.function(req.acceptsLanguages,\n 'req.acceptsLanguage: Use acceptsLanguages instead');\n\n/**\n * Parse Range header field, capping to the given `size`.\n *\n * Unspecified ranges such as \"0-\" require knowledge of your resource length. In\n * the case of a byte range this is of course the total number of bytes. If the\n * Range header field is not given `undefined` is returned, `-1` when unsatisfiable,\n * and `-2` when syntactically invalid.\n *\n * When ranges are returned, the array has a \"type\" property which is the type of\n * range that is required (most commonly, \"bytes\"). Each array element is an object\n * with a \"start\" and \"end\" property for the portion of the range.\n *\n * The \"combine\" option can be set to `true` and overlapping & adjacent ranges\n * will be combined into a single range.\n *\n * NOTE: remember that ranges are inclusive, so for example \"Range: users=0-3\"\n * should respond with 4 users when available, not 3.\n *\n * @param {number} size\n * @param {object} [options]\n * @param {boolean} [options.combine=false]\n * @return {number|array}\n * @public\n */\n\nreq.range = function range(size, options) {\n var range = this.get('Range');\n if (!range) return;\n return parseRange(size, range, options);\n};\n\n/**\n * Return the value of param `name` when present or `defaultValue`.\n *\n * - Checks route placeholders, ex: _/user/:id_\n * - Checks body params, ex: id=12, {\"id\":12}\n * - Checks query string params, ex: ?id=12\n *\n * To utilize request bodies, `req.body`\n * should be an object. This can be done by using\n * the `bodyParser()` middleware.\n *\n * @param {String} name\n * @param {Mixed} [defaultValue]\n * @return {String}\n * @public\n */\n\nreq.param = function param(name, defaultValue) {\n var params = this.params || {};\n var body = this.body || {};\n var query = this.query || {};\n\n var args = arguments.length === 1\n ? 'name'\n : 'name, default';\n deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead');\n\n if (null != params[name] && params.hasOwnProperty(name)) return params[name];\n if (null != body[name]) return body[name];\n if (null != query[name]) return query[name];\n\n return defaultValue;\n};\n\n/**\n * Check if the incoming request contains the \"Content-Type\"\n * header field, and it contains the given mime `type`.\n *\n * Examples:\n *\n * // With Content-Type: text/html; charset=utf-8\n * req.is('html');\n * req.is('text/html');\n * req.is('text/*');\n * // => true\n *\n * // When Content-Type is application/json\n * req.is('json');\n * req.is('application/json');\n * req.is('application/*');\n * // => true\n *\n * req.is('html');\n * // => false\n *\n * @param {String|Array} types...\n * @return {String|false|null}\n * @public\n */\n\nreq.is = function is(types) {\n var arr = types;\n\n // support flattened arguments\n if (!Array.isArray(types)) {\n arr = new Array(arguments.length);\n for (var i = 0; i < arr.length; i++) {\n arr[i] = arguments[i];\n }\n }\n\n return typeis(this, arr);\n};\n\n/**\n * Return the protocol string \"http\" or \"https\"\n * when requested with TLS. When the \"trust proxy\"\n * setting trusts the socket address, the\n * \"X-Forwarded-Proto\" header field will be trusted\n * and used if present.\n *\n * If you're running behind a reverse proxy that\n * supplies https for you this may be enabled.\n *\n * @return {String}\n * @public\n */\n\ndefineGetter(req, 'protocol', function protocol(){\n var proto = this.connection.encrypted\n ? 'https'\n : 'http';\n var trust = this.app.get('trust proxy fn');\n\n if (!trust(this.connection.remoteAddress, 0)) {\n return proto;\n }\n\n // Note: X-Forwarded-Proto is normally only ever a\n // single value, but this is to be safe.\n var header = this.get('X-Forwarded-Proto') || proto\n var index = header.indexOf(',')\n\n return index !== -1\n ? header.substring(0, index).trim()\n : header.trim()\n});\n\n/**\n * Short-hand for:\n *\n * req.protocol === 'https'\n *\n * @return {Boolean}\n * @public\n */\n\ndefineGetter(req, 'secure', function secure(){\n return this.protocol === 'https';\n});\n\n/**\n * Return the remote address from the trusted proxy.\n *\n * The is the remote address on the socket unless\n * \"trust proxy\" is set.\n *\n * @return {String}\n * @public\n */\n\ndefineGetter(req, 'ip', function ip(){\n var trust = this.app.get('trust proxy fn');\n return proxyaddr(this, trust);\n});\n\n/**\n * When \"trust proxy\" is set, trusted proxy addresses + client.\n *\n * For example if the value were \"client, proxy1, proxy2\"\n * you would receive the array `[\"client\", \"proxy1\", \"proxy2\"]`\n * where \"proxy2\" is the furthest down-stream and \"proxy1\" and\n * \"proxy2\" were trusted.\n *\n * @return {Array}\n * @public\n */\n\ndefineGetter(req, 'ips', function ips() {\n var trust = this.app.get('trust proxy fn');\n var addrs = proxyaddr.all(this, trust);\n\n // reverse the order (to farthest -> closest)\n // and remove socket address\n addrs.reverse().pop()\n\n return addrs\n});\n\n/**\n * Return subdomains as an array.\n *\n * Subdomains are the dot-separated parts of the host before the main domain of\n * the app. By default, the domain of the app is assumed to be the last two\n * parts of the host. This can be changed by setting \"subdomain offset\".\n *\n * For example, if the domain is \"tobi.ferrets.example.com\":\n * If \"subdomain offset\" is not set, req.subdomains is `[\"ferrets\", \"tobi\"]`.\n * If \"subdomain offset\" is 3, req.subdomains is `[\"tobi\"]`.\n *\n * @return {Array}\n * @public\n */\n\ndefineGetter(req, 'subdomains', function subdomains() {\n var hostname = this.hostname;\n\n if (!hostname) return [];\n\n var offset = this.app.get('subdomain offset');\n var subdomains = !isIP(hostname)\n ? hostname.split('.').reverse()\n : [hostname];\n\n return subdomains.slice(offset);\n});\n\n/**\n * Short-hand for `url.parse(req.url).pathname`.\n *\n * @return {String}\n * @public\n */\n\ndefineGetter(req, 'path', function path() {\n return parse(this).pathname;\n});\n\n/**\n * Parse the \"Host\" header field to a hostname.\n *\n * When the \"trust proxy\" setting trusts the socket\n * address, the \"X-Forwarded-Host\" header field will\n * be trusted.\n *\n * @return {String}\n * @public\n */\n\ndefineGetter(req, 'hostname', function hostname(){\n var trust = this.app.get('trust proxy fn');\n var host = this.get('X-Forwarded-Host');\n\n if (!host || !trust(this.connection.remoteAddress, 0)) {\n host = this.get('Host');\n } else if (host.indexOf(',') !== -1) {\n // Note: X-Forwarded-Host is normally only ever a\n // single value, but this is to be safe.\n host = host.substring(0, host.indexOf(',')).trimRight()\n }\n\n if (!host) return;\n\n // IPv6 literal support\n var offset = host[0] === '['\n ? host.indexOf(']') + 1\n : 0;\n var index = host.indexOf(':', offset);\n\n return index !== -1\n ? host.substring(0, index)\n : host;\n});\n\n// TODO: change req.host to return host in next major\n\ndefineGetter(req, 'host', deprecate.function(function host(){\n return this.hostname;\n}, 'req.host: Use req.hostname instead'));\n\n/**\n * Check if the request is fresh, aka\n * Last-Modified and/or the ETag\n * still match.\n *\n * @return {Boolean}\n * @public\n */\n\ndefineGetter(req, 'fresh', function(){\n var method = this.method;\n var res = this.res\n var status = res.statusCode\n\n // GET or HEAD for weak freshness validation only\n if ('GET' !== method && 'HEAD' !== method) return false;\n\n // 2xx or 304 as per rfc2616 14.26\n if ((status >= 200 && status < 300) || 304 === status) {\n return fresh(this.headers, {\n 'etag': res.get('ETag'),\n 'last-modified': res.get('Last-Modified')\n })\n }\n\n return false;\n});\n\n/**\n * Check if the request is stale, aka\n * \"Last-Modified\" and / or the \"ETag\" for the\n * resource has changed.\n *\n * @return {Boolean}\n * @public\n */\n\ndefineGetter(req, 'stale', function stale(){\n return !this.fresh;\n});\n\n/**\n * Check if the request was an _XMLHttpRequest_.\n *\n * @return {Boolean}\n * @public\n */\n\ndefineGetter(req, 'xhr', function xhr(){\n var val = this.get('X-Requested-With') || '';\n return val.toLowerCase() === 'xmlhttprequest';\n});\n\n/**\n * Helper function for creating a getter on an object.\n *\n * @param {Object} obj\n * @param {String} name\n * @param {Function} getter\n * @private\n */\nfunction defineGetter(obj, name, getter) {\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: true,\n get: getter\n });\n}\n", "/**\n * Module dependencies.\n */\n\nvar crypto = require('crypto');\n\n/**\n * Sign the given `val` with `secret`.\n *\n * @param {String} val\n * @param {String} secret\n * @return {String}\n * @api private\n */\n\nexports.sign = function(val, secret){\n if ('string' != typeof val) throw new TypeError(\"Cookie value must be provided as a string.\");\n if ('string' != typeof secret) throw new TypeError(\"Secret string must be provided.\");\n return val + '.' + crypto\n .createHmac('sha256', secret)\n .update(val)\n .digest('base64')\n .replace(/\\=+$/, '');\n};\n\n/**\n * Unsign and decode the given `val` with `secret`,\n * returning `false` if the signature is invalid.\n *\n * @param {String} val\n * @param {String} secret\n * @return {String|Boolean}\n * @api private\n */\n\nexports.unsign = function(val, secret){\n if ('string' != typeof val) throw new TypeError(\"Signed cookie string must be provided.\");\n if ('string' != typeof secret) throw new TypeError(\"Secret string must be provided.\");\n var str = val.slice(0, val.lastIndexOf('.'))\n , mac = exports.sign(str, secret);\n \n return sha1(mac) == sha1(val) ? str : false;\n};\n\n/**\n * Private\n */\n\nfunction sha1(str){\n return crypto.createHash('sha1').update(str).digest('hex');\n}\n", "/*!\n * cookie\n * Copyright(c) 2012-2014 Roman Shtylman\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module exports.\n * @public\n */\n\nexports.parse = parse;\nexports.serialize = serialize;\n\n/**\n * Module variables.\n * @private\n */\n\nvar __toString = Object.prototype.toString\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\n\nvar fieldContentRegExp = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+$/;\n\n/**\n * Parse a cookie header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n *\n * @param {string} str\n * @param {object} [options]\n * @return {object}\n * @public\n */\n\nfunction parse(str, options) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {}\n var opt = options || {};\n var dec = opt.decode || decode;\n\n var index = 0\n while (index < str.length) {\n var eqIdx = str.indexOf('=', index)\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break\n }\n\n var endIdx = str.indexOf(';', index)\n\n if (endIdx === -1) {\n endIdx = str.length\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(';', eqIdx - 1) + 1\n continue\n }\n\n var key = str.slice(index, eqIdx).trim()\n\n // only assign once\n if (undefined === obj[key]) {\n var val = str.slice(eqIdx + 1, endIdx).trim()\n\n // quoted values\n if (val.charCodeAt(0) === 0x22) {\n val = val.slice(1, -1)\n }\n\n obj[key] = tryDecode(val, dec);\n }\n\n index = endIdx + 1\n }\n\n return obj;\n}\n\n/**\n * Serialize data into a cookie header.\n *\n * Serialize the a name value pair into a cookie string suitable for\n * http headers. An optional options object specified cookie parameters.\n *\n * serialize('foo', 'bar', { httpOnly: true })\n * => \"foo=bar; httpOnly\"\n *\n * @param {string} name\n * @param {string} val\n * @param {object} [options]\n * @return {string}\n * @public\n */\n\nfunction serialize(name, val, options) {\n var opt = options || {};\n var enc = opt.encode || encode;\n\n if (typeof enc !== 'function') {\n throw new TypeError('option encode is invalid');\n }\n\n if (!fieldContentRegExp.test(name)) {\n throw new TypeError('argument name is invalid');\n }\n\n var value = enc(val);\n\n if (value && !fieldContentRegExp.test(value)) {\n throw new TypeError('argument val is invalid');\n }\n\n var str = name + '=' + value;\n\n if (null != opt.maxAge) {\n var maxAge = opt.maxAge - 0;\n\n if (isNaN(maxAge) || !isFinite(maxAge)) {\n throw new TypeError('option maxAge is invalid')\n }\n\n str += '; Max-Age=' + Math.floor(maxAge);\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new TypeError('option domain is invalid');\n }\n\n str += '; Domain=' + opt.domain;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new TypeError('option path is invalid');\n }\n\n str += '; Path=' + opt.path;\n }\n\n if (opt.expires) {\n var expires = opt.expires\n\n if (!isDate(expires) || isNaN(expires.valueOf())) {\n throw new TypeError('option expires is invalid');\n }\n\n str += '; Expires=' + expires.toUTCString()\n }\n\n if (opt.httpOnly) {\n str += '; HttpOnly';\n }\n\n if (opt.secure) {\n str += '; Secure';\n }\n\n if (opt.priority) {\n var priority = typeof opt.priority === 'string'\n ? opt.priority.toLowerCase()\n : opt.priority\n\n switch (priority) {\n case 'low':\n str += '; Priority=Low'\n break\n case 'medium':\n str += '; Priority=Medium'\n break\n case 'high':\n str += '; Priority=High'\n break\n default:\n throw new TypeError('option priority is invalid')\n }\n }\n\n if (opt.sameSite) {\n var sameSite = typeof opt.sameSite === 'string'\n ? opt.sameSite.toLowerCase() : opt.sameSite;\n\n switch (sameSite) {\n case true:\n str += '; SameSite=Strict';\n break;\n case 'lax':\n str += '; SameSite=Lax';\n break;\n case 'strict':\n str += '; SameSite=Strict';\n break;\n case 'none':\n str += '; SameSite=None';\n break;\n default:\n throw new TypeError('option sameSite is invalid');\n }\n }\n\n return str;\n}\n\n/**\n * URL-decode string value. Optimized to skip native call when no %.\n *\n * @param {string} str\n * @returns {string}\n */\n\nfunction decode (str) {\n return str.indexOf('%') !== -1\n ? decodeURIComponent(str)\n : str\n}\n\n/**\n * URL-encode value.\n *\n * @param {string} str\n * @returns {string}\n */\n\nfunction encode (val) {\n return encodeURIComponent(val)\n}\n\n/**\n * Determine if value is a Date.\n *\n * @param {*} val\n * @private\n */\n\nfunction isDate (val) {\n return __toString.call(val) === '[object Date]' ||\n val instanceof Date\n}\n\n/**\n * Try decoding a string using a decoding function.\n *\n * @param {string} str\n * @param {function} decode\n * @private\n */\n\nfunction tryDecode(str, decode) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n", "/*!\n * vary\n * Copyright(c) 2014-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n */\n\nmodule.exports = vary\nmodule.exports.append = append\n\n/**\n * RegExp to match field-name in RFC 7230 sec 3.2\n *\n * field-name = token\n * token = 1*tchar\n * tchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\"\n * / \"+\" / \"-\" / \".\" / \"^\" / \"_\" / \"`\" / \"|\" / \"~\"\n * / DIGIT / ALPHA\n * ; any VCHAR, except delimiters\n */\n\nvar FIELD_NAME_REGEXP = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/\n\n/**\n * Append a field to a vary header.\n *\n * @param {String} header\n * @param {String|Array} field\n * @return {String}\n * @public\n */\n\nfunction append (header, field) {\n if (typeof header !== 'string') {\n throw new TypeError('header argument is required')\n }\n\n if (!field) {\n throw new TypeError('field argument is required')\n }\n\n // get fields array\n var fields = !Array.isArray(field)\n ? parse(String(field))\n : field\n\n // assert on invalid field names\n for (var j = 0; j < fields.length; j++) {\n if (!FIELD_NAME_REGEXP.test(fields[j])) {\n throw new TypeError('field argument contains an invalid header name')\n }\n }\n\n // existing, unspecified vary\n if (header === '*') {\n return header\n }\n\n // enumerate current values\n var val = header\n var vals = parse(header.toLowerCase())\n\n // unspecified vary\n if (fields.indexOf('*') !== -1 || vals.indexOf('*') !== -1) {\n return '*'\n }\n\n for (var i = 0; i < fields.length; i++) {\n var fld = fields[i].toLowerCase()\n\n // append value (case-preserving)\n if (vals.indexOf(fld) === -1) {\n vals.push(fld)\n val = val\n ? val + ', ' + fields[i]\n : fields[i]\n }\n }\n\n return val\n}\n\n/**\n * Parse a vary header into an array.\n *\n * @param {String} header\n * @return {Array}\n * @private\n */\n\nfunction parse (header) {\n var end = 0\n var list = []\n var start = 0\n\n // gather tokens\n for (var i = 0, len = header.length; i < len; i++) {\n switch (header.charCodeAt(i)) {\n case 0x20: /* */\n if (start === end) {\n start = end = i + 1\n }\n break\n case 0x2c: /* , */\n list.push(header.substring(start, end))\n start = end = i + 1\n break\n default:\n end = i + 1\n break\n }\n }\n\n // final token\n list.push(header.substring(start, end))\n\n return list\n}\n\n/**\n * Mark that a request is varied on a header field.\n *\n * @param {Object} res\n * @param {String|Array} field\n * @public\n */\n\nfunction vary (res, field) {\n if (!res || !res.getHeader || !res.setHeader) {\n // quack quack\n throw new TypeError('res argument is required')\n }\n\n // get existing header\n var val = res.getHeader('Vary') || ''\n var header = Array.isArray(val)\n ? val.join(', ')\n : String(val)\n\n // set new header\n if ((val = append(header, field))) {\n res.setHeader('Vary', val)\n }\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar Buffer = require('safe-buffer').Buffer\nvar contentDisposition = require('content-disposition');\nvar createError = require('http-errors')\nvar deprecate = require('depd')('express');\nvar encodeUrl = require('encodeurl');\nvar escapeHtml = require('escape-html');\nvar http = require('http');\nvar isAbsolute = require('./utils').isAbsolute;\nvar onFinished = require('on-finished');\nvar path = require('path');\nvar statuses = require('statuses')\nvar merge = require('utils-merge');\nvar sign = require('cookie-signature').sign;\nvar normalizeType = require('./utils').normalizeType;\nvar normalizeTypes = require('./utils').normalizeTypes;\nvar setCharset = require('./utils').setCharset;\nvar cookie = require('cookie');\nvar send = require('send');\nvar extname = path.extname;\nvar mime = send.mime;\nvar resolve = path.resolve;\nvar vary = require('vary');\n\n/**\n * Response prototype.\n * @public\n */\n\nvar res = Object.create(http.ServerResponse.prototype)\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = res\n\n/**\n * Module variables.\n * @private\n */\n\nvar charsetRegExp = /;\\s*charset\\s*=/;\n\n/**\n * Set status `code`.\n *\n * @param {Number} code\n * @return {ServerResponse}\n * @public\n */\n\nres.status = function status(code) {\n if ((typeof code === 'string' || Math.floor(code) !== code) && code > 99 && code < 1000) {\n deprecate('res.status(' + JSON.stringify(code) + '): use res.status(' + Math.floor(code) + ') instead')\n }\n this.statusCode = code;\n return this;\n};\n\n/**\n * Set Link header field with the given `links`.\n *\n * Examples:\n *\n * res.links({\n * next: 'http://api.example.com/users?page=2',\n * last: 'http://api.example.com/users?page=5'\n * });\n *\n * @param {Object} links\n * @return {ServerResponse}\n * @public\n */\n\nres.links = function(links){\n var link = this.get('Link') || '';\n if (link) link += ', ';\n return this.set('Link', link + Object.keys(links).map(function(rel){\n return '<' + links[rel] + '>; rel=\"' + rel + '\"';\n }).join(', '));\n};\n\n/**\n * Send a response.\n *\n * Examples:\n *\n * res.send(Buffer.from('wahoo'));\n * res.send({ some: 'json' });\n * res.send('

some html

');\n *\n * @param {string|number|boolean|object|Buffer} body\n * @public\n */\n\nres.send = function send(body) {\n var chunk = body;\n var encoding;\n var req = this.req;\n var type;\n\n // settings\n var app = this.app;\n\n // allow status / body\n if (arguments.length === 2) {\n // res.send(body, status) backwards compat\n if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') {\n deprecate('res.send(body, status): Use res.status(status).send(body) instead');\n this.statusCode = arguments[1];\n } else {\n deprecate('res.send(status, body): Use res.status(status).send(body) instead');\n this.statusCode = arguments[0];\n chunk = arguments[1];\n }\n }\n\n // disambiguate res.send(status) and res.send(status, num)\n if (typeof chunk === 'number' && arguments.length === 1) {\n // res.send(status) will set status message as text string\n if (!this.get('Content-Type')) {\n this.type('txt');\n }\n\n deprecate('res.send(status): Use res.sendStatus(status) instead');\n this.statusCode = chunk;\n chunk = statuses.message[chunk]\n }\n\n switch (typeof chunk) {\n // string defaulting to html\n case 'string':\n if (!this.get('Content-Type')) {\n this.type('html');\n }\n break;\n case 'boolean':\n case 'number':\n case 'object':\n if (chunk === null) {\n chunk = '';\n } else if (Buffer.isBuffer(chunk)) {\n if (!this.get('Content-Type')) {\n this.type('bin');\n }\n } else {\n return this.json(chunk);\n }\n break;\n }\n\n // write strings in utf-8\n if (typeof chunk === 'string') {\n encoding = 'utf8';\n type = this.get('Content-Type');\n\n // reflect this in content-type\n if (typeof type === 'string') {\n this.set('Content-Type', setCharset(type, 'utf-8'));\n }\n }\n\n // determine if ETag should be generated\n var etagFn = app.get('etag fn')\n var generateETag = !this.get('ETag') && typeof etagFn === 'function'\n\n // populate Content-Length\n var len\n if (chunk !== undefined) {\n if (Buffer.isBuffer(chunk)) {\n // get length of Buffer\n len = chunk.length\n } else if (!generateETag && chunk.length < 1000) {\n // just calculate length when no ETag + small chunk\n len = Buffer.byteLength(chunk, encoding)\n } else {\n // convert chunk to Buffer and calculate\n chunk = Buffer.from(chunk, encoding)\n encoding = undefined;\n len = chunk.length\n }\n\n this.set('Content-Length', len);\n }\n\n // populate ETag\n var etag;\n if (generateETag && len !== undefined) {\n if ((etag = etagFn(chunk, encoding))) {\n this.set('ETag', etag);\n }\n }\n\n // freshness\n if (req.fresh) this.statusCode = 304;\n\n // strip irrelevant headers\n if (204 === this.statusCode || 304 === this.statusCode) {\n this.removeHeader('Content-Type');\n this.removeHeader('Content-Length');\n this.removeHeader('Transfer-Encoding');\n chunk = '';\n }\n\n // alter headers for 205\n if (this.statusCode === 205) {\n this.set('Content-Length', '0')\n this.removeHeader('Transfer-Encoding')\n chunk = ''\n }\n\n if (req.method === 'HEAD') {\n // skip body for HEAD\n this.end();\n } else {\n // respond\n this.end(chunk, encoding);\n }\n\n return this;\n};\n\n/**\n * Send JSON response.\n *\n * Examples:\n *\n * res.json(null);\n * res.json({ user: 'tj' });\n *\n * @param {string|number|boolean|object} obj\n * @public\n */\n\nres.json = function json(obj) {\n var val = obj;\n\n // allow status / body\n if (arguments.length === 2) {\n // res.json(body, status) backwards compat\n if (typeof arguments[1] === 'number') {\n deprecate('res.json(obj, status): Use res.status(status).json(obj) instead');\n this.statusCode = arguments[1];\n } else {\n deprecate('res.json(status, obj): Use res.status(status).json(obj) instead');\n this.statusCode = arguments[0];\n val = arguments[1];\n }\n }\n\n // settings\n var app = this.app;\n var escape = app.get('json escape')\n var replacer = app.get('json replacer');\n var spaces = app.get('json spaces');\n var body = stringify(val, replacer, spaces, escape)\n\n // content-type\n if (!this.get('Content-Type')) {\n this.set('Content-Type', 'application/json');\n }\n\n return this.send(body);\n};\n\n/**\n * Send JSON response with JSONP callback support.\n *\n * Examples:\n *\n * res.jsonp(null);\n * res.jsonp({ user: 'tj' });\n *\n * @param {string|number|boolean|object} obj\n * @public\n */\n\nres.jsonp = function jsonp(obj) {\n var val = obj;\n\n // allow status / body\n if (arguments.length === 2) {\n // res.jsonp(body, status) backwards compat\n if (typeof arguments[1] === 'number') {\n deprecate('res.jsonp(obj, status): Use res.status(status).jsonp(obj) instead');\n this.statusCode = arguments[1];\n } else {\n deprecate('res.jsonp(status, obj): Use res.status(status).jsonp(obj) instead');\n this.statusCode = arguments[0];\n val = arguments[1];\n }\n }\n\n // settings\n var app = this.app;\n var escape = app.get('json escape')\n var replacer = app.get('json replacer');\n var spaces = app.get('json spaces');\n var body = stringify(val, replacer, spaces, escape)\n var callback = this.req.query[app.get('jsonp callback name')];\n\n // content-type\n if (!this.get('Content-Type')) {\n this.set('X-Content-Type-Options', 'nosniff');\n this.set('Content-Type', 'application/json');\n }\n\n // fixup callback\n if (Array.isArray(callback)) {\n callback = callback[0];\n }\n\n // jsonp\n if (typeof callback === 'string' && callback.length !== 0) {\n this.set('X-Content-Type-Options', 'nosniff');\n this.set('Content-Type', 'text/javascript');\n\n // restrict callback charset\n callback = callback.replace(/[^\\[\\]\\w$.]/g, '');\n\n if (body === undefined) {\n // empty argument\n body = ''\n } else if (typeof body === 'string') {\n // replace chars not allowed in JavaScript that are in JSON\n body = body\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029')\n }\n\n // the /**/ is a specific security mitigation for \"Rosetta Flash JSONP abuse\"\n // the typeof check is just to reduce client error noise\n body = '/**/ typeof ' + callback + ' === \\'function\\' && ' + callback + '(' + body + ');';\n }\n\n return this.send(body);\n};\n\n/**\n * Send given HTTP status code.\n *\n * Sets the response status to `statusCode` and the body of the\n * response to the standard description from node's http.STATUS_CODES\n * or the statusCode number if no description.\n *\n * Examples:\n *\n * res.sendStatus(200);\n *\n * @param {number} statusCode\n * @public\n */\n\nres.sendStatus = function sendStatus(statusCode) {\n var body = statuses.message[statusCode] || String(statusCode)\n\n this.statusCode = statusCode;\n this.type('txt');\n\n return this.send(body);\n};\n\n/**\n * Transfer the file at the given `path`.\n *\n * Automatically sets the _Content-Type_ response header field.\n * The callback `callback(err)` is invoked when the transfer is complete\n * or when an error occurs. Be sure to check `res.headersSent`\n * if you wish to attempt responding, as the header and some data\n * may have already been transferred.\n *\n * Options:\n *\n * - `maxAge` defaulting to 0 (can be string converted by `ms`)\n * - `root` root directory for relative filenames\n * - `headers` object of headers to serve with file\n * - `dotfiles` serve dotfiles, defaulting to false; can be `\"allow\"` to send them\n *\n * Other options are passed along to `send`.\n *\n * Examples:\n *\n * The following example illustrates how `res.sendFile()` may\n * be used as an alternative for the `static()` middleware for\n * dynamic situations. The code backing `res.sendFile()` is actually\n * the same code, so HTTP cache support etc is identical.\n *\n * app.get('/user/:uid/photos/:file', function(req, res){\n * var uid = req.params.uid\n * , file = req.params.file;\n *\n * req.user.mayViewFilesFrom(uid, function(yes){\n * if (yes) {\n * res.sendFile('/uploads/' + uid + '/' + file);\n * } else {\n * res.send(403, 'Sorry! you cant see that.');\n * }\n * });\n * });\n *\n * @public\n */\n\nres.sendFile = function sendFile(path, options, callback) {\n var done = callback;\n var req = this.req;\n var res = this;\n var next = req.next;\n var opts = options || {};\n\n if (!path) {\n throw new TypeError('path argument is required to res.sendFile');\n }\n\n if (typeof path !== 'string') {\n throw new TypeError('path must be a string to res.sendFile')\n }\n\n // support function as second arg\n if (typeof options === 'function') {\n done = options;\n opts = {};\n }\n\n if (!opts.root && !isAbsolute(path)) {\n throw new TypeError('path must be absolute or specify root to res.sendFile');\n }\n\n // create file stream\n var pathname = encodeURI(path);\n var file = send(req, pathname, opts);\n\n // transfer\n sendfile(res, file, opts, function (err) {\n if (done) return done(err);\n if (err && err.code === 'EISDIR') return next();\n\n // next() all but write errors\n if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {\n next(err);\n }\n });\n};\n\n/**\n * Transfer the file at the given `path`.\n *\n * Automatically sets the _Content-Type_ response header field.\n * The callback `callback(err)` is invoked when the transfer is complete\n * or when an error occurs. Be sure to check `res.headersSent`\n * if you wish to attempt responding, as the header and some data\n * may have already been transferred.\n *\n * Options:\n *\n * - `maxAge` defaulting to 0 (can be string converted by `ms`)\n * - `root` root directory for relative filenames\n * - `headers` object of headers to serve with file\n * - `dotfiles` serve dotfiles, defaulting to false; can be `\"allow\"` to send them\n *\n * Other options are passed along to `send`.\n *\n * Examples:\n *\n * The following example illustrates how `res.sendfile()` may\n * be used as an alternative for the `static()` middleware for\n * dynamic situations. The code backing `res.sendfile()` is actually\n * the same code, so HTTP cache support etc is identical.\n *\n * app.get('/user/:uid/photos/:file', function(req, res){\n * var uid = req.params.uid\n * , file = req.params.file;\n *\n * req.user.mayViewFilesFrom(uid, function(yes){\n * if (yes) {\n * res.sendfile('/uploads/' + uid + '/' + file);\n * } else {\n * res.send(403, 'Sorry! you cant see that.');\n * }\n * });\n * });\n *\n * @public\n */\n\nres.sendfile = function (path, options, callback) {\n var done = callback;\n var req = this.req;\n var res = this;\n var next = req.next;\n var opts = options || {};\n\n // support function as second arg\n if (typeof options === 'function') {\n done = options;\n opts = {};\n }\n\n // create file stream\n var file = send(req, path, opts);\n\n // transfer\n sendfile(res, file, opts, function (err) {\n if (done) return done(err);\n if (err && err.code === 'EISDIR') return next();\n\n // next() all but write errors\n if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {\n next(err);\n }\n });\n};\n\nres.sendfile = deprecate.function(res.sendfile,\n 'res.sendfile: Use res.sendFile instead');\n\n/**\n * Transfer the file at the given `path` as an attachment.\n *\n * Optionally providing an alternate attachment `filename`,\n * and optional callback `callback(err)`. The callback is invoked\n * when the data transfer is complete, or when an error has\n * occurred. Be sure to check `res.headersSent` if you plan to respond.\n *\n * Optionally providing an `options` object to use with `res.sendFile()`.\n * This function will set the `Content-Disposition` header, overriding\n * any `Content-Disposition` header passed as header options in order\n * to set the attachment and filename.\n *\n * This method uses `res.sendFile()`.\n *\n * @public\n */\n\nres.download = function download (path, filename, options, callback) {\n var done = callback;\n var name = filename;\n var opts = options || null\n\n // support function as second or third arg\n if (typeof filename === 'function') {\n done = filename;\n name = null;\n opts = null\n } else if (typeof options === 'function') {\n done = options\n opts = null\n }\n\n // support optional filename, where options may be in it's place\n if (typeof filename === 'object' &&\n (typeof options === 'function' || options === undefined)) {\n name = null\n opts = filename\n }\n\n // set Content-Disposition when file is sent\n var headers = {\n 'Content-Disposition': contentDisposition(name || path)\n };\n\n // merge user-provided headers\n if (opts && opts.headers) {\n var keys = Object.keys(opts.headers)\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i]\n if (key.toLowerCase() !== 'content-disposition') {\n headers[key] = opts.headers[key]\n }\n }\n }\n\n // merge user-provided options\n opts = Object.create(opts)\n opts.headers = headers\n\n // Resolve the full path for sendFile\n var fullPath = !opts.root\n ? resolve(path)\n : path\n\n // send file\n return this.sendFile(fullPath, opts, done)\n};\n\n/**\n * Set _Content-Type_ response header with `type` through `mime.lookup()`\n * when it does not contain \"/\", or set the Content-Type to `type` otherwise.\n *\n * Examples:\n *\n * res.type('.html');\n * res.type('html');\n * res.type('json');\n * res.type('application/json');\n * res.type('png');\n *\n * @param {String} type\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.contentType =\nres.type = function contentType(type) {\n var ct = type.indexOf('/') === -1\n ? mime.lookup(type)\n : type;\n\n return this.set('Content-Type', ct);\n};\n\n/**\n * Respond to the Acceptable formats using an `obj`\n * of mime-type callbacks.\n *\n * This method uses `req.accepted`, an array of\n * acceptable types ordered by their quality values.\n * When \"Accept\" is not present the _first_ callback\n * is invoked, otherwise the first match is used. When\n * no match is performed the server responds with\n * 406 \"Not Acceptable\".\n *\n * Content-Type is set for you, however if you choose\n * you may alter this within the callback using `res.type()`\n * or `res.set('Content-Type', ...)`.\n *\n * res.format({\n * 'text/plain': function(){\n * res.send('hey');\n * },\n *\n * 'text/html': function(){\n * res.send('

hey

');\n * },\n *\n * 'application/json': function () {\n * res.send({ message: 'hey' });\n * }\n * });\n *\n * In addition to canonicalized MIME types you may\n * also use extnames mapped to these types:\n *\n * res.format({\n * text: function(){\n * res.send('hey');\n * },\n *\n * html: function(){\n * res.send('

hey

');\n * },\n *\n * json: function(){\n * res.send({ message: 'hey' });\n * }\n * });\n *\n * By default Express passes an `Error`\n * with a `.status` of 406 to `next(err)`\n * if a match is not made. If you provide\n * a `.default` callback it will be invoked\n * instead.\n *\n * @param {Object} obj\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.format = function(obj){\n var req = this.req;\n var next = req.next;\n\n var keys = Object.keys(obj)\n .filter(function (v) { return v !== 'default' })\n\n var key = keys.length > 0\n ? req.accepts(keys)\n : false;\n\n this.vary(\"Accept\");\n\n if (key) {\n this.set('Content-Type', normalizeType(key).value);\n obj[key](req, this, next);\n } else if (obj.default) {\n obj.default(req, this, next)\n } else {\n next(createError(406, {\n types: normalizeTypes(keys).map(function (o) { return o.value })\n }))\n }\n\n return this;\n};\n\n/**\n * Set _Content-Disposition_ header to _attachment_ with optional `filename`.\n *\n * @param {String} filename\n * @return {ServerResponse}\n * @public\n */\n\nres.attachment = function attachment(filename) {\n if (filename) {\n this.type(extname(filename));\n }\n\n this.set('Content-Disposition', contentDisposition(filename));\n\n return this;\n};\n\n/**\n * Append additional header `field` with value `val`.\n *\n * Example:\n *\n * res.append('Link', ['', '']);\n * res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');\n * res.append('Warning', '199 Miscellaneous warning');\n *\n * @param {String} field\n * @param {String|Array} val\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.append = function append(field, val) {\n var prev = this.get(field);\n var value = val;\n\n if (prev) {\n // concat the new and prev vals\n value = Array.isArray(prev) ? prev.concat(val)\n : Array.isArray(val) ? [prev].concat(val)\n : [prev, val]\n }\n\n return this.set(field, value);\n};\n\n/**\n * Set header `field` to `val`, or pass\n * an object of header fields.\n *\n * Examples:\n *\n * res.set('Foo', ['bar', 'baz']);\n * res.set('Accept', 'application/json');\n * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });\n *\n * Aliased as `res.header()`.\n *\n * @param {String|Object} field\n * @param {String|Array} val\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.set =\nres.header = function header(field, val) {\n if (arguments.length === 2) {\n var value = Array.isArray(val)\n ? val.map(String)\n : String(val);\n\n // add charset to content-type\n if (field.toLowerCase() === 'content-type') {\n if (Array.isArray(value)) {\n throw new TypeError('Content-Type cannot be set to an Array');\n }\n if (!charsetRegExp.test(value)) {\n var charset = mime.charsets.lookup(value.split(';')[0]);\n if (charset) value += '; charset=' + charset.toLowerCase();\n }\n }\n\n this.setHeader(field, value);\n } else {\n for (var key in field) {\n this.set(key, field[key]);\n }\n }\n return this;\n};\n\n/**\n * Get value for header `field`.\n *\n * @param {String} field\n * @return {String}\n * @public\n */\n\nres.get = function(field){\n return this.getHeader(field);\n};\n\n/**\n * Clear cookie `name`.\n *\n * @param {String} name\n * @param {Object} [options]\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.clearCookie = function clearCookie(name, options) {\n var opts = merge({ expires: new Date(1), path: '/' }, options);\n\n return this.cookie(name, '', opts);\n};\n\n/**\n * Set cookie `name` to `value`, with the given `options`.\n *\n * Options:\n *\n * - `maxAge` max-age in milliseconds, converted to `expires`\n * - `signed` sign the cookie\n * - `path` defaults to \"/\"\n *\n * Examples:\n *\n * // \"Remember Me\" for 15 minutes\n * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });\n *\n * // same as above\n * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })\n *\n * @param {String} name\n * @param {String|Object} value\n * @param {Object} [options]\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.cookie = function (name, value, options) {\n var opts = merge({}, options);\n var secret = this.req.secret;\n var signed = opts.signed;\n\n if (signed && !secret) {\n throw new Error('cookieParser(\"secret\") required for signed cookies');\n }\n\n var val = typeof value === 'object'\n ? 'j:' + JSON.stringify(value)\n : String(value);\n\n if (signed) {\n val = 's:' + sign(val, secret);\n }\n\n if (opts.maxAge != null) {\n var maxAge = opts.maxAge - 0\n\n if (!isNaN(maxAge)) {\n opts.expires = new Date(Date.now() + maxAge)\n opts.maxAge = Math.floor(maxAge / 1000)\n }\n }\n\n if (opts.path == null) {\n opts.path = '/';\n }\n\n this.append('Set-Cookie', cookie.serialize(name, String(val), opts));\n\n return this;\n};\n\n/**\n * Set the location header to `url`.\n *\n * The given `url` can also be \"back\", which redirects\n * to the _Referrer_ or _Referer_ headers or \"/\".\n *\n * Examples:\n *\n * res.location('/foo/bar').;\n * res.location('http://example.com');\n * res.location('../login');\n *\n * @param {String} url\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.location = function location(url) {\n var loc = url;\n\n // \"back\" is an alias for the referrer\n if (url === 'back') {\n loc = this.req.get('Referrer') || '/';\n }\n\n // set location\n return this.set('Location', encodeUrl(loc));\n};\n\n/**\n * Redirect to the given `url` with optional response `status`\n * defaulting to 302.\n *\n * The resulting `url` is determined by `res.location()`, so\n * it will play nicely with mounted apps, relative paths,\n * `\"back\"` etc.\n *\n * Examples:\n *\n * res.redirect('/foo/bar');\n * res.redirect('http://example.com');\n * res.redirect(301, 'http://example.com');\n * res.redirect('../login'); // /blog/post/1 -> /blog/login\n *\n * @public\n */\n\nres.redirect = function redirect(url) {\n var address = url;\n var body;\n var status = 302;\n\n // allow status / url\n if (arguments.length === 2) {\n if (typeof arguments[0] === 'number') {\n status = arguments[0];\n address = arguments[1];\n } else {\n deprecate('res.redirect(url, status): Use res.redirect(status, url) instead');\n status = arguments[1];\n }\n }\n\n // Set location header\n address = this.location(address).get('Location');\n\n // Support text/{plain,html} by default\n this.format({\n text: function(){\n body = statuses.message[status] + '. Redirecting to ' + address\n },\n\n html: function(){\n var u = escapeHtml(address);\n body = '

' + statuses.message[status] + '. Redirecting to ' + u + '

'\n },\n\n default: function(){\n body = '';\n }\n });\n\n // Respond\n this.statusCode = status;\n this.set('Content-Length', Buffer.byteLength(body));\n\n if (this.req.method === 'HEAD') {\n this.end();\n } else {\n this.end(body);\n }\n};\n\n/**\n * Add `field` to Vary. If already present in the Vary set, then\n * this call is simply ignored.\n *\n * @param {Array|String} field\n * @return {ServerResponse} for chaining\n * @public\n */\n\nres.vary = function(field){\n // checks for back-compat\n if (!field || (Array.isArray(field) && !field.length)) {\n deprecate('res.vary(): Provide a field name');\n return this;\n }\n\n vary(this, field);\n\n return this;\n};\n\n/**\n * Render `view` with the given `options` and optional callback `fn`.\n * When a callback function is given a response will _not_ be made\n * automatically, otherwise a response of _200_ and _text/html_ is given.\n *\n * Options:\n *\n * - `cache` boolean hinting to the engine it should cache\n * - `filename` filename of the view being rendered\n *\n * @public\n */\n\nres.render = function render(view, options, callback) {\n var app = this.req.app;\n var done = callback;\n var opts = options || {};\n var req = this.req;\n var self = this;\n\n // support callback function as second arg\n if (typeof options === 'function') {\n done = options;\n opts = {};\n }\n\n // merge res.locals\n opts._locals = self.locals;\n\n // default callback to respond\n done = done || function (err, str) {\n if (err) return req.next(err);\n self.send(str);\n };\n\n // render\n app.render(view, opts, done);\n};\n\n// pipe the send file stream\nfunction sendfile(res, file, options, callback) {\n var done = false;\n var streaming;\n\n // request aborted\n function onaborted() {\n if (done) return;\n done = true;\n\n var err = new Error('Request aborted');\n err.code = 'ECONNABORTED';\n callback(err);\n }\n\n // directory\n function ondirectory() {\n if (done) return;\n done = true;\n\n var err = new Error('EISDIR, read');\n err.code = 'EISDIR';\n callback(err);\n }\n\n // errors\n function onerror(err) {\n if (done) return;\n done = true;\n callback(err);\n }\n\n // ended\n function onend() {\n if (done) return;\n done = true;\n callback();\n }\n\n // file\n function onfile() {\n streaming = false;\n }\n\n // finished\n function onfinish(err) {\n if (err && err.code === 'ECONNRESET') return onaborted();\n if (err) return onerror(err);\n if (done) return;\n\n setImmediate(function () {\n if (streaming !== false && !done) {\n onaborted();\n return;\n }\n\n if (done) return;\n done = true;\n callback();\n });\n }\n\n // streaming\n function onstream() {\n streaming = true;\n }\n\n file.on('directory', ondirectory);\n file.on('end', onend);\n file.on('error', onerror);\n file.on('file', onfile);\n file.on('stream', onstream);\n onFinished(res, onfinish);\n\n if (options.headers) {\n // set headers on successful transfer\n file.on('headers', function headers(res) {\n var obj = options.headers;\n var keys = Object.keys(obj);\n\n for (var i = 0; i < keys.length; i++) {\n var k = keys[i];\n res.setHeader(k, obj[k]);\n }\n });\n }\n\n // pipe\n file.pipe(res);\n}\n\n/**\n * Stringify JSON, like JSON.stringify, but v8 optimized, with the\n * ability to escape characters that can trigger HTML sniffing.\n *\n * @param {*} value\n * @param {function} replacer\n * @param {number} spaces\n * @param {boolean} escape\n * @returns {string}\n * @private\n */\n\nfunction stringify (value, replacer, spaces, escape) {\n // v8 checks arguments.length for optimizing simple call\n // https://bugs.chromium.org/p/v8/issues/detail?id=4730\n var json = replacer || spaces\n ? JSON.stringify(value, replacer, spaces)\n : JSON.stringify(value);\n\n if (escape && typeof json === 'string') {\n json = json.replace(/[<>&]/g, function (c) {\n switch (c.charCodeAt(0)) {\n case 0x3c:\n return '\\\\u003c'\n case 0x3e:\n return '\\\\u003e'\n case 0x26:\n return '\\\\u0026'\n /* istanbul ignore next: unreachable default */\n default:\n return c\n }\n })\n }\n\n return json\n}\n", "/*!\n * serve-static\n * Copyright(c) 2010 Sencha Inc.\n * Copyright(c) 2011 TJ Holowaychuk\n * Copyright(c) 2014-2016 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar encodeUrl = require('encodeurl')\nvar escapeHtml = require('escape-html')\nvar parseUrl = require('parseurl')\nvar resolve = require('path').resolve\nvar send = require('send')\nvar url = require('url')\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = serveStatic\nmodule.exports.mime = send.mime\n\n/**\n * @param {string} root\n * @param {object} [options]\n * @return {function}\n * @public\n */\n\nfunction serveStatic (root, options) {\n if (!root) {\n throw new TypeError('root path required')\n }\n\n if (typeof root !== 'string') {\n throw new TypeError('root path must be a string')\n }\n\n // copy options object\n var opts = Object.create(options || null)\n\n // fall-though\n var fallthrough = opts.fallthrough !== false\n\n // default redirect\n var redirect = opts.redirect !== false\n\n // headers listener\n var setHeaders = opts.setHeaders\n\n if (setHeaders && typeof setHeaders !== 'function') {\n throw new TypeError('option setHeaders must be function')\n }\n\n // setup options for send\n opts.maxage = opts.maxage || opts.maxAge || 0\n opts.root = resolve(root)\n\n // construct directory listener\n var onDirectory = redirect\n ? createRedirectDirectoryListener()\n : createNotFoundDirectoryListener()\n\n return function serveStatic (req, res, next) {\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n if (fallthrough) {\n return next()\n }\n\n // method not allowed\n res.statusCode = 405\n res.setHeader('Allow', 'GET, HEAD')\n res.setHeader('Content-Length', '0')\n res.end()\n return\n }\n\n var forwardError = !fallthrough\n var originalUrl = parseUrl.original(req)\n var path = parseUrl(req).pathname\n\n // make sure redirect occurs at mount\n if (path === '/' && originalUrl.pathname.substr(-1) !== '/') {\n path = ''\n }\n\n // create send stream\n var stream = send(req, path, opts)\n\n // add directory handler\n stream.on('directory', onDirectory)\n\n // add headers listener\n if (setHeaders) {\n stream.on('headers', setHeaders)\n }\n\n // add file listener for fallthrough\n if (fallthrough) {\n stream.on('file', function onFile () {\n // once file is determined, always forward error\n forwardError = true\n })\n }\n\n // forward errors\n stream.on('error', function error (err) {\n if (forwardError || !(err.statusCode < 500)) {\n next(err)\n return\n }\n\n next()\n })\n\n // pipe\n stream.pipe(res)\n }\n}\n\n/**\n * Collapse all leading slashes into a single slash\n * @private\n */\nfunction collapseLeadingSlashes (str) {\n for (var i = 0; i < str.length; i++) {\n if (str.charCodeAt(i) !== 0x2f /* / */) {\n break\n }\n }\n\n return i > 1\n ? '/' + str.substr(i)\n : str\n}\n\n/**\n * Create a minimal HTML document.\n *\n * @param {string} title\n * @param {string} body\n * @private\n */\n\nfunction createHtmlDocument (title, body) {\n return '\\n' +\n '\\n' +\n '\\n' +\n '\\n' +\n '' + title + '\\n' +\n '\\n' +\n '\\n' +\n '
' + body + '
\\n' +\n '\\n' +\n '\\n'\n}\n\n/**\n * Create a directory listener that just 404s.\n * @private\n */\n\nfunction createNotFoundDirectoryListener () {\n return function notFound () {\n this.error(404)\n }\n}\n\n/**\n * Create a directory listener that performs a redirect.\n * @private\n */\n\nfunction createRedirectDirectoryListener () {\n return function redirect (res) {\n if (this.hasTrailingSlash()) {\n this.error(404)\n return\n }\n\n // get original URL\n var originalUrl = parseUrl.original(this.req)\n\n // append trailing slash\n originalUrl.path = null\n originalUrl.pathname = collapseLeadingSlashes(originalUrl.pathname + '/')\n\n // reformat the URL\n var loc = encodeUrl(url.format(originalUrl))\n var doc = createHtmlDocument('Redirecting', 'Redirecting to ' +\n escapeHtml(loc) + '')\n\n // send redirect response\n res.statusCode = 301\n res.setHeader('Content-Type', 'text/html; charset=UTF-8')\n res.setHeader('Content-Length', Buffer.byteLength(doc))\n res.setHeader('Content-Security-Policy', \"default-src 'none'\")\n res.setHeader('X-Content-Type-Options', 'nosniff')\n res.setHeader('Location', loc)\n res.end(doc)\n }\n}\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n */\n\nvar bodyParser = require('body-parser')\nvar EventEmitter = require('events').EventEmitter;\nvar mixin = require('merge-descriptors');\nvar proto = require('./application');\nvar Route = require('./router/route');\nvar Router = require('./router');\nvar req = require('./request');\nvar res = require('./response');\n\n/**\n * Expose `createApplication()`.\n */\n\nexports = module.exports = createApplication;\n\n/**\n * Create an express application.\n *\n * @return {Function}\n * @api public\n */\n\nfunction createApplication() {\n var app = function(req, res, next) {\n app.handle(req, res, next);\n };\n\n mixin(app, EventEmitter.prototype, false);\n mixin(app, proto, false);\n\n // expose the prototype that will get set on requests\n app.request = Object.create(req, {\n app: { configurable: true, enumerable: true, writable: true, value: app }\n })\n\n // expose the prototype that will get set on responses\n app.response = Object.create(res, {\n app: { configurable: true, enumerable: true, writable: true, value: app }\n })\n\n app.init();\n return app;\n}\n\n/**\n * Expose the prototypes.\n */\n\nexports.application = proto;\nexports.request = req;\nexports.response = res;\n\n/**\n * Expose constructors.\n */\n\nexports.Route = Route;\nexports.Router = Router;\n\n/**\n * Expose middleware\n */\n\nexports.json = bodyParser.json\nexports.query = require('./middleware/query');\nexports.raw = bodyParser.raw\nexports.static = require('serve-static');\nexports.text = bodyParser.text\nexports.urlencoded = bodyParser.urlencoded\n\n/**\n * Replace removed middleware with an appropriate error message.\n */\n\nvar removedMiddlewares = [\n 'bodyParser',\n 'compress',\n 'cookieSession',\n 'session',\n 'logger',\n 'cookieParser',\n 'favicon',\n 'responseTime',\n 'errorHandler',\n 'timeout',\n 'methodOverride',\n 'vhost',\n 'csrf',\n 'directory',\n 'limit',\n 'multipart',\n 'staticCache'\n]\n\nremovedMiddlewares.forEach(function (name) {\n Object.defineProperty(exports, name, {\n get: function () {\n throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');\n },\n configurable: true\n });\n});\n", "/*!\n * express\n * Copyright(c) 2009-2013 TJ Holowaychuk\n * Copyright(c) 2013 Roman Shtylman\n * Copyright(c) 2014-2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict';\n\nmodule.exports = require('./lib/express');\n", "/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n", "(function () {\n\n 'use strict';\n\n var assign = require('object-assign');\n var vary = require('vary');\n\n var defaults = {\n origin: '*',\n methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',\n preflightContinue: false,\n optionsSuccessStatus: 204\n };\n\n function isString(s) {\n return typeof s === 'string' || s instanceof String;\n }\n\n function isOriginAllowed(origin, allowedOrigin) {\n if (Array.isArray(allowedOrigin)) {\n for (var i = 0; i < allowedOrigin.length; ++i) {\n if (isOriginAllowed(origin, allowedOrigin[i])) {\n return true;\n }\n }\n return false;\n } else if (isString(allowedOrigin)) {\n return origin === allowedOrigin;\n } else if (allowedOrigin instanceof RegExp) {\n return allowedOrigin.test(origin);\n } else {\n return !!allowedOrigin;\n }\n }\n\n function configureOrigin(options, req) {\n var requestOrigin = req.headers.origin,\n headers = [],\n isAllowed;\n\n if (!options.origin || options.origin === '*') {\n // allow any origin\n headers.push([{\n key: 'Access-Control-Allow-Origin',\n value: '*'\n }]);\n } else if (isString(options.origin)) {\n // fixed origin\n headers.push([{\n key: 'Access-Control-Allow-Origin',\n value: options.origin\n }]);\n headers.push([{\n key: 'Vary',\n value: 'Origin'\n }]);\n } else {\n isAllowed = isOriginAllowed(requestOrigin, options.origin);\n // reflect origin\n headers.push([{\n key: 'Access-Control-Allow-Origin',\n value: isAllowed ? requestOrigin : false\n }]);\n headers.push([{\n key: 'Vary',\n value: 'Origin'\n }]);\n }\n\n return headers;\n }\n\n function configureMethods(options) {\n var methods = options.methods;\n if (methods.join) {\n methods = options.methods.join(','); // .methods is an array, so turn it into a string\n }\n return {\n key: 'Access-Control-Allow-Methods',\n value: methods\n };\n }\n\n function configureCredentials(options) {\n if (options.credentials === true) {\n return {\n key: 'Access-Control-Allow-Credentials',\n value: 'true'\n };\n }\n return null;\n }\n\n function configureAllowedHeaders(options, req) {\n var allowedHeaders = options.allowedHeaders || options.headers;\n var headers = [];\n\n if (!allowedHeaders) {\n allowedHeaders = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers\n headers.push([{\n key: 'Vary',\n value: 'Access-Control-Request-Headers'\n }]);\n } else if (allowedHeaders.join) {\n allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string\n }\n if (allowedHeaders && allowedHeaders.length) {\n headers.push([{\n key: 'Access-Control-Allow-Headers',\n value: allowedHeaders\n }]);\n }\n\n return headers;\n }\n\n function configureExposedHeaders(options) {\n var headers = options.exposedHeaders;\n if (!headers) {\n return null;\n } else if (headers.join) {\n headers = headers.join(','); // .headers is an array, so turn it into a string\n }\n if (headers && headers.length) {\n return {\n key: 'Access-Control-Expose-Headers',\n value: headers\n };\n }\n return null;\n }\n\n function configureMaxAge(options) {\n var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString()\n if (maxAge && maxAge.length) {\n return {\n key: 'Access-Control-Max-Age',\n value: maxAge\n };\n }\n return null;\n }\n\n function applyHeaders(headers, res) {\n for (var i = 0, n = headers.length; i < n; i++) {\n var header = headers[i];\n if (header) {\n if (Array.isArray(header)) {\n applyHeaders(header, res);\n } else if (header.key === 'Vary' && header.value) {\n vary(res, header.value);\n } else if (header.value) {\n res.setHeader(header.key, header.value);\n }\n }\n }\n }\n\n function cors(options, req, res, next) {\n var headers = [],\n method = req.method && req.method.toUpperCase && req.method.toUpperCase();\n\n if (method === 'OPTIONS') {\n // preflight\n headers.push(configureOrigin(options, req));\n headers.push(configureCredentials(options, req));\n headers.push(configureMethods(options, req));\n headers.push(configureAllowedHeaders(options, req));\n headers.push(configureMaxAge(options, req));\n headers.push(configureExposedHeaders(options, req));\n applyHeaders(headers, res);\n\n if (options.preflightContinue) {\n next();\n } else {\n // Safari (and potentially other browsers) need content-length 0,\n // for 204 or they just hang waiting for a body\n res.statusCode = options.optionsSuccessStatus;\n res.setHeader('Content-Length', '0');\n res.end();\n }\n } else {\n // actual response\n headers.push(configureOrigin(options, req));\n headers.push(configureCredentials(options, req));\n headers.push(configureExposedHeaders(options, req));\n applyHeaders(headers, res);\n next();\n }\n }\n\n function middlewareWrapper(o) {\n // if options are static (either via defaults or custom options passed in), wrap in a function\n var optionsCallback = null;\n if (typeof o === 'function') {\n optionsCallback = o;\n } else {\n optionsCallback = function (req, cb) {\n cb(null, o);\n };\n }\n\n return function corsMiddleware(req, res, next) {\n optionsCallback(req, function (err, options) {\n if (err) {\n next(err);\n } else {\n var corsOptions = assign({}, defaults, options);\n var originCallback = null;\n if (corsOptions.origin && typeof corsOptions.origin === 'function') {\n originCallback = corsOptions.origin;\n } else if (corsOptions.origin) {\n originCallback = function (origin, cb) {\n cb(null, corsOptions.origin);\n };\n }\n\n if (originCallback) {\n originCallback(req.headers.origin, function (err2, origin) {\n if (err2 || !origin) {\n next(err2);\n } else {\n corsOptions.origin = origin;\n cors(corsOptions, req, res, next);\n }\n });\n } else {\n next();\n }\n }\n });\n };\n }\n\n // can pass either an options hash, an options delegate, or nothing\n module.exports = middlewareWrapper;\n\n}());\n", "'use strict';\n\nif (typeof process === 'undefined' ||\n !process.version ||\n process.version.indexOf('v0.') === 0 ||\n process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n module.exports = { nextTick: nextTick };\n} else {\n module.exports = process\n}\n\nfunction nextTick(fn, arg1, arg2, arg3) {\n if (typeof fn !== 'function') {\n throw new TypeError('\"callback\" argument must be a function');\n }\n var len = arguments.length;\n var args, i;\n switch (len) {\n case 0:\n case 1:\n return process.nextTick(fn);\n case 2:\n return process.nextTick(function afterTickOne() {\n fn.call(null, arg1);\n });\n case 3:\n return process.nextTick(function afterTickTwo() {\n fn.call(null, arg1, arg2);\n });\n case 4:\n return process.nextTick(function afterTickThree() {\n fn.call(null, arg1, arg2, arg3);\n });\n default:\n args = new Array(len - 1);\n i = 0;\n while (i < args.length) {\n args[i++] = arguments[i];\n }\n return process.nextTick(function afterTick() {\n fn.apply(null, args);\n });\n }\n}\n\n", "var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n", "module.exports = require('stream');\n", "/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\n\nfunction isArray(arg) {\n if (Array.isArray) {\n return Array.isArray(arg);\n }\n return objectToString(arg) === '[object Array]';\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('buffer').Buffer.isBuffer;\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n", "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Buffer = require('safe-buffer').Buffer;\nvar util = require('util');\n\nfunction copyBuffer(src, target, offset) {\n src.copy(target, offset);\n}\n\nmodule.exports = function () {\n function BufferList() {\n _classCallCheck(this, BufferList);\n\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n BufferList.prototype.push = function push(v) {\n var entry = { data: v, next: null };\n if (this.length > 0) this.tail.next = entry;else this.head = entry;\n this.tail = entry;\n ++this.length;\n };\n\n BufferList.prototype.unshift = function unshift(v) {\n var entry = { data: v, next: this.head };\n if (this.length === 0) this.tail = entry;\n this.head = entry;\n ++this.length;\n };\n\n BufferList.prototype.shift = function shift() {\n if (this.length === 0) return;\n var ret = this.head.data;\n if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n --this.length;\n return ret;\n };\n\n BufferList.prototype.clear = function clear() {\n this.head = this.tail = null;\n this.length = 0;\n };\n\n BufferList.prototype.join = function join(s) {\n if (this.length === 0) return '';\n var p = this.head;\n var ret = '' + p.data;\n while (p = p.next) {\n ret += s + p.data;\n }return ret;\n };\n\n BufferList.prototype.concat = function concat(n) {\n if (this.length === 0) return Buffer.alloc(0);\n if (this.length === 1) return this.head.data;\n var ret = Buffer.allocUnsafe(n >>> 0);\n var p = this.head;\n var i = 0;\n while (p) {\n copyBuffer(p.data, ret, i);\n i += p.data.length;\n p = p.next;\n }\n return ret;\n };\n\n return BufferList;\n}();\n\nif (util && util.inspect && util.inspect.custom) {\n module.exports.prototype[util.inspect.custom] = function () {\n var obj = util.inspect({ length: this.length });\n return this.constructor.name + ' ' + obj;\n };\n}", "'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n// undocumented cb() API, needed for core, not for public API\nfunction destroy(err, cb) {\n var _this = this;\n\n var readableDestroyed = this._readableState && this._readableState.destroyed;\n var writableDestroyed = this._writableState && this._writableState.destroyed;\n\n if (readableDestroyed || writableDestroyed) {\n if (cb) {\n cb(err);\n } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {\n pna.nextTick(emitErrorNT, this, err);\n }\n return this;\n }\n\n // we set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n\n if (this._readableState) {\n this._readableState.destroyed = true;\n }\n\n // if this is a duplex stream mark the writable part as destroyed as well\n if (this._writableState) {\n this._writableState.destroyed = true;\n }\n\n this._destroy(err || null, function (err) {\n if (!cb && err) {\n pna.nextTick(emitErrorNT, _this, err);\n if (_this._writableState) {\n _this._writableState.errorEmitted = true;\n }\n } else if (cb) {\n cb(err);\n }\n });\n\n return this;\n}\n\nfunction undestroy() {\n if (this._readableState) {\n this._readableState.destroyed = false;\n this._readableState.reading = false;\n this._readableState.ended = false;\n this._readableState.endEmitted = false;\n }\n\n if (this._writableState) {\n this._writableState.destroyed = false;\n this._writableState.ended = false;\n this._writableState.ending = false;\n this._writableState.finished = false;\n this._writableState.errorEmitted = false;\n }\n}\n\nfunction emitErrorNT(self, err) {\n self.emit('error', err);\n}\n\nmodule.exports = {\n destroy: destroy,\n undestroy: undestroy\n};", "\n/**\n * For Node.js, simply re-export the core `util.deprecate` function.\n */\n\nmodule.exports = require('util').deprecate;\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Writable;\n\n/* */\nfunction WriteReq(chunk, encoding, cb) {\n this.chunk = chunk;\n this.encoding = encoding;\n this.callback = cb;\n this.next = null;\n}\n\n// It seems a linked list but it is not\n// there will be only 2 of these for each stream\nfunction CorkedRequest(state) {\n var _this = this;\n\n this.next = null;\n this.entry = null;\n this.finish = function () {\n onCorkedFinish(_this, state);\n };\n}\n/* */\n\n/**/\nvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nWritable.WritableState = WritableState;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar internalUtil = {\n deprecate: require('util-deprecate')\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\nvar destroyImpl = require('./internal/streams/destroy');\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n var hwm = options.highWaterMark;\n var writableHwm = options.writableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = function (er) {\n onwrite(stream, er);\n };\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n this.corkedRequestsFree = new CorkedRequest(this);\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\n(function () {\n try {\n Object.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function () {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')\n });\n } catch (_) {}\n})();\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function (object) {\n if (realHasInstance.call(this, object)) return true;\n if (this !== Writable) return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function (object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n return new Writable(options);\n }\n\n this._writableState = new WritableState(options, this);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function') this._write = options.write;\n\n if (typeof options.writev === 'function') this._writev = options.writev;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n\n if (typeof options.final === 'function') this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n this.emit('error', new Error('Cannot pipe, not readable'));\n};\n\nfunction writeAfterEnd(stream, cb) {\n var er = new Error('write after end');\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n pna.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var valid = true;\n var er = false;\n\n if (chunk === null) {\n er = new TypeError('May not write null values to stream');\n } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n if (er) {\n stream.emit('error', er);\n pna.nextTick(cb, er);\n valid = false;\n }\n return valid;\n}\n\nWritable.prototype.write = function (chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && _isUint8Array(chunk);\n\n if (isBuf && !Buffer.isBuffer(chunk)) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function') cb = nop;\n\n if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function () {\n var state = this._writableState;\n\n state.corked++;\n};\n\nWritable.prototype.uncork = function () {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk: chunk,\n encoding: encoding,\n isBuf: isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n pna.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n pna.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n onwriteStateUpdate(state);\n\n if (er) onwriteError(stream, state, sync, er, cb);else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n /**/\n asyncWrite(afterWrite, stream, state, finished, cb);\n /**/\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished) onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf) allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n state.corkedRequestsFree = new CorkedRequest(state);\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null) state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function (chunk, encoding, cb) {\n cb(new Error('_write() is not implemented'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function (chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending && !state.finished) endWritable(this, state, cb);\n};\n\nfunction needFinish(state) {\n return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n}\nfunction callFinal(stream, state) {\n stream._final(function (err) {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function') {\n state.pendingcb++;\n state.finalCalled = true;\n pna.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n if (state.corkedRequestsFree) {\n state.corkedRequestsFree.next = corkReq;\n } else {\n state.corkedRequestsFree = corkReq;\n }\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n get: function () {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function (err, cb) {\n this.end();\n cb(err);\n};", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\n/**/\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n keys.push(key);\n }return keys;\n};\n/**/\n\nmodule.exports = Duplex;\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nvar Readable = require('./_stream_readable');\nvar Writable = require('./_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // avoid scope creep, the keys array can then be collected\n var keys = objectKeys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n var method = keys[v];\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n\n if (options && options.readable === false) this.readable = false;\n\n if (options && options.writable === false) this.writable = false;\n\n this.allowHalfOpen = true;\n if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\n this.once('end', onend);\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._writableState.highWaterMark;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // if we allow half-open state, or if the writable side ended,\n // then we're ok.\n if (this.allowHalfOpen || this._writableState.ended) return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n pna.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined || this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\nDuplex.prototype._destroy = function (err, cb) {\n this.push(null);\n this.end();\n\n pna.nextTick(cb, err);\n};", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/**/\n\nvar pna = require('process-nextick-args');\n/**/\n\nmodule.exports = Readable;\n\n/**/\nvar isArray = require('isarray');\n/**/\n\n/**/\nvar Duplex;\n/**/\n\nReadable.ReadableState = ReadableState;\n\n/**/\nvar EE = require('events').EventEmitter;\n\nvar EElistenerCount = function (emitter, type) {\n return emitter.listeners(type).length;\n};\n/**/\n\n/**/\nvar Stream = require('./internal/streams/stream');\n/**/\n\n/**/\n\nvar Buffer = require('safe-buffer').Buffer;\nvar OurUint8Array = global.Uint8Array || function () {};\nfunction _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk);\n}\nfunction _isUint8Array(obj) {\n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;\n}\n\n/**/\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\n/**/\nvar debugUtil = require('util');\nvar debug = void 0;\nif (debugUtil && debugUtil.debuglog) {\n debug = debugUtil.debuglog('stream');\n} else {\n debug = function () {};\n}\n/**/\n\nvar BufferList = require('./internal/streams/BufferList');\nvar destroyImpl = require('./internal/streams/destroy');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream) {\n Duplex = Duplex || require('./_stream_duplex');\n\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n var isDuplex = stream instanceof Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n var hwm = options.highWaterMark;\n var readableHwm = options.readableHighWaterMark;\n var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;\n\n // cast to ints.\n this.highWaterMark = Math.floor(this.highWaterMark);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n this.buffer = new BufferList();\n this.length = 0;\n this.pipes = null;\n this.pipesCount = 0;\n this.flowing = null;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n Duplex = Duplex || require('./_stream_duplex');\n\n if (!(this instanceof Readable)) return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function') this._read = options.read;\n\n if (typeof options.destroy === 'function') this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n get: function () {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set: function (value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function (err, cb) {\n this.push(null);\n cb(err);\n};\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function (chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck) er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = _uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new Error('stream.push() after EOF'));\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n }\n }\n\n return needMoreData(state);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n stream.emit('data', chunk);\n stream.read(0);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\n if (state.needReadable) emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n er = new TypeError('Invalid non-string/buffer chunk');\n }\n return er;\n}\n\n// if it's past the high water mark, we can push in some more.\n// Also, if we have no data yet, we can stand some\n// more bytes. This is to work around cases where hwm=0,\n// such as the repl. Also, if the push() triggered a\n// readable event, and the user called read(largeNumber) such that\n// needReadable was set, then we ought to push more, so that another\n// 'readable' event will be triggered.\nfunction needMoreData(state) {\n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n}\n\nReadable.prototype.isPaused = function () {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n this._readableState.encoding = enc;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nvar MAX_HWM = 0x800000;\nfunction computeNewHighWaterMark(n) {\n if (n >= MAX_HWM) {\n n = MAX_HWM;\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || state.length === 0 && state.ended) return 0;\n if (state.objectMode) return 1;\n if (n !== n) {\n // Only flow one buffer at a time\n if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length) return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0) state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading) {\n doRead = false;\n debug('reading or ended', doRead);\n } else if (doRead) {\n debug('do read');\n state.reading = true;\n state.sync = true;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0) ret = fromList(n, state);else ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this);\n }\n\n if (ret !== null) this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n // emit 'readable' now to make sure it gets picked up.\n emitReadable(stream);\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);\n }\n}\n\nfunction emitReadable_(stream) {\n debug('emit readable');\n stream.emit('readable');\n flow(stream);\n}\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n pna.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;else len = state.length;\n }\n state.readingMore = false;\n}\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n this.emit('error', new Error('_read() is not implemented'));\n};\n\nReadable.prototype.pipe = function (dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n dest.removeListener('close', onclose);\n dest.removeListener('finish', onfinish);\n dest.removeListener('drain', ondrain);\n dest.removeListener('error', onerror);\n dest.removeListener('unpipe', onunpipe);\n src.removeListener('end', onend);\n src.removeListener('end', unpipe);\n src.removeListener('data', ondata);\n\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n }\n\n // If the user pushes more data while we're writing to dest then we'll end up\n // in ondata again. However, we only want to increase awaitDrain once because\n // dest will only emit one 'drain' event for the multiple writes.\n // => Introduce a guard on increasing awaitDrain.\n var increasedAwaitDrain = false;\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n increasedAwaitDrain = false;\n var ret = dest.write(chunk);\n if (false === ret && !increasedAwaitDrain) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n debug('false write response, pause', src._readableState.awaitDrain);\n src._readableState.awaitDrain++;\n increasedAwaitDrain = true;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function () {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain) state.awaitDrain--;\n if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\nReadable.prototype.unpipe = function (dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0) return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes) return this;\n\n if (!dest) dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest) dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n if (!dest) {\n // remove all.\n var dests = state.pipes;\n var len = state.pipesCount;\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n\n for (var i = 0; i < len; i++) {\n dests[i].emit('unpipe', this, unpipeInfo);\n }return this;\n }\n\n // try to find the right one.\n var index = indexOf(state.pipes, dest);\n if (index === -1) return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function (ev, fn) {\n var res = Stream.prototype.on.call(this, ev, fn);\n\n if (ev === 'data') {\n // Start flowing on next tick if stream isn't explicitly paused\n if (this._readableState.flowing !== false) this.resume();\n } else if (ev === 'readable') {\n var state = this._readableState;\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n if (!state.reading) {\n pna.nextTick(nReadingNextTick, this);\n } else if (state.length) {\n emitReadable(this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n state.flowing = true;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n pna.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n if (!state.reading) {\n debug('resume read 0');\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n state.awaitDrain = 0;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading) stream.read(0);\n}\n\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (false !== this._readableState.flowing) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n var state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null) {}\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n var _this = this;\n\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function () {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) _this.push(chunk);\n }\n\n _this.push(null);\n });\n\n stream.on('data', function (chunk) {\n debug('wrapped data');\n if (state.decoder) chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\n var ret = _this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function (method) {\n return function () {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = function (n) {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark;\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0) return null;\n\n var ret;\n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = fromListPartial(n, state.buffer, state.decoder);\n }\n\n return ret;\n}\n\n// Extracts only enough buffered data to satisfy the amount requested.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromListPartial(n, list, hasStrings) {\n var ret;\n if (n < list.head.data.length) {\n // slice is the same for buffers and strings\n ret = list.head.data.slice(0, n);\n list.head.data = list.head.data.slice(n);\n } else if (n === list.head.data.length) {\n // first chunk is a perfect match\n ret = list.shift();\n } else {\n // result spans more than one buffer\n ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n }\n return ret;\n}\n\n// Copies a specified amount of characters from the list of buffered data\n// chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBufferString(n, list) {\n var p = list.head;\n var c = 1;\n var ret = p.data;\n n -= ret.length;\n while (p = p.next) {\n var str = p.data;\n var nb = n > str.length ? str.length : n;\n if (nb === str.length) ret += str;else ret += str.slice(0, n);\n n -= nb;\n if (n === 0) {\n if (nb === str.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = str.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\n// Copies a specified amount of bytes from the list of buffered data chunks.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction copyFromBuffer(n, list) {\n var ret = Buffer.allocUnsafe(n);\n var p = list.head;\n var c = 1;\n p.data.copy(ret);\n n -= p.data.length;\n while (p = p.next) {\n var buf = p.data;\n var nb = n > buf.length ? buf.length : n;\n buf.copy(ret, ret.length - n, 0, nb);\n n -= nb;\n if (n === 0) {\n if (nb === buf.length) {\n ++c;\n if (p.next) list.head = p.next;else list.head = list.tail = null;\n } else {\n list.head = p;\n p.data = buf.slice(nb);\n }\n break;\n }\n ++c;\n }\n list.length -= c;\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n // If we get here before consuming all the bytes, then that is a\n // bug in node. Should never happen.\n if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\n if (!state.endEmitted) {\n state.ended = true;\n pna.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n // Check that we didn't get one last unshift.\n if (!state.endEmitted && state.length === 0) {\n state.endEmitted = true;\n stream.readable = false;\n stream.emit('end');\n }\n}\n\nfunction indexOf(xs, x) {\n for (var i = 0, l = xs.length; i < l; i++) {\n if (xs[i] === x) return i;\n }\n return -1;\n}", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\n\nvar Duplex = require('./_stream_duplex');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(Transform, Duplex);\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (!cb) {\n return this.emit('error', new Error('write callback called multiple times'));\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform;\n\n if (typeof options.flush === 'function') this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n var _this = this;\n\n if (typeof this._flush === 'function') {\n this._flush(function (er, data) {\n done(_this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function (chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function (chunk, encoding, cb) {\n throw new Error('_transform() is not implemented');\n};\n\nTransform.prototype._write = function (chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function (n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\nTransform.prototype._destroy = function (err, cb) {\n var _this2 = this;\n\n Duplex.prototype._destroy.call(this, err, function (err2) {\n cb(err2);\n _this2.emit('close');\n });\n};\n\nfunction done(stream, er, data) {\n if (er) return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');\n\n if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');\n\n return stream.push(null);\n}", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nvar Transform = require('./_stream_transform');\n\n/**/\nvar util = Object.create(require('core-util-is'));\nutil.inherits = require('inherits');\n/**/\n\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk);\n};", "var Stream = require('stream');\nif (process.env.READABLE_STREAM === 'disable' && Stream) {\n module.exports = Stream;\n exports = module.exports = Stream.Readable;\n exports.Readable = Stream.Readable;\n exports.Writable = Stream.Writable;\n exports.Duplex = Stream.Duplex;\n exports.Transform = Stream.Transform;\n exports.PassThrough = Stream.PassThrough;\n exports.Stream = Stream;\n} else {\n exports = module.exports = require('./lib/_stream_readable.js');\n exports.Stream = Stream || exports;\n exports.Readable = exports;\n exports.Writable = require('./lib/_stream_writable.js');\n exports.Duplex = require('./lib/_stream_duplex.js');\n exports.Transform = require('./lib/_stream_transform.js');\n exports.PassThrough = require('./lib/_stream_passthrough.js');\n}\n", "\"use strict\";\n\nexports.base64 = true;\nexports.array = true;\nexports.string = true;\nexports.arraybuffer = typeof ArrayBuffer !== \"undefined\" && typeof Uint8Array !== \"undefined\";\nexports.nodebuffer = typeof Buffer !== \"undefined\";\n// contains true if JSZip can read/generate Uint8Array, false otherwise.\nexports.uint8array = typeof Uint8Array !== \"undefined\";\n\nif (typeof ArrayBuffer === \"undefined\") {\n exports.blob = false;\n}\nelse {\n var buffer = new ArrayBuffer(0);\n try {\n exports.blob = new Blob([buffer], {\n type: \"application/zip\"\n }).size === 0;\n }\n catch (e) {\n try {\n var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n var builder = new Builder();\n builder.append(buffer);\n exports.blob = builder.getBlob(\"application/zip\").size === 0;\n }\n catch (e) {\n exports.blob = false;\n }\n }\n}\n\ntry {\n exports.nodestream = !!require(\"readable-stream\").Readable;\n} catch(e) {\n exports.nodestream = false;\n}\n", "\"use strict\";\nvar utils = require(\"./utils\");\nvar support = require(\"./support\");\n// private property\nvar _keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n\n// public method for encoding\nexports.encode = function(input) {\n var output = [];\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n var i = 0, len = input.length, remainingBytes = len;\n\n var isArray = utils.getTypeOf(input) !== \"string\";\n while (i < input.length) {\n remainingBytes = len - i;\n\n if (!isArray) {\n chr1 = input.charCodeAt(i++);\n chr2 = i < len ? input.charCodeAt(i++) : 0;\n chr3 = i < len ? input.charCodeAt(i++) : 0;\n } else {\n chr1 = input[i++];\n chr2 = i < len ? input[i++] : 0;\n chr3 = i < len ? input[i++] : 0;\n }\n\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64;\n enc4 = remainingBytes > 2 ? (chr3 & 63) : 64;\n\n output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));\n\n }\n\n return output.join(\"\");\n};\n\n// public method for decoding\nexports.decode = function(input) {\n var chr1, chr2, chr3;\n var enc1, enc2, enc3, enc4;\n var i = 0, resultIndex = 0;\n\n var dataUrlPrefix = \"data:\";\n\n if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {\n // This is a common error: people give a data url\n // (data:image/png;base64,iVBOR...) with a {base64: true} and\n // wonders why things don't work.\n // We can detect that the string input looks like a data url but we\n // *can't* be sure it is one: removing everything up to the comma would\n // be too dangerous.\n throw new Error(\"Invalid base64 input, it looks like a data url.\");\n }\n\n input = input.replace(/[^A-Za-z0-9+/=]/g, \"\");\n\n var totalLength = input.length * 3 / 4;\n if(input.charAt(input.length - 1) === _keyStr.charAt(64)) {\n totalLength--;\n }\n if(input.charAt(input.length - 2) === _keyStr.charAt(64)) {\n totalLength--;\n }\n if (totalLength % 1 !== 0) {\n // totalLength is not an integer, the length does not match a valid\n // base64 content. That can happen if:\n // - the input is not a base64 content\n // - the input is *almost* a base64 content, with a extra chars at the\n // beginning or at the end\n // - the input uses a base64 variant (base64url for example)\n throw new Error(\"Invalid base64 input, bad content length.\");\n }\n var output;\n if (support.uint8array) {\n output = new Uint8Array(totalLength|0);\n } else {\n output = new Array(totalLength|0);\n }\n\n while (i < input.length) {\n\n enc1 = _keyStr.indexOf(input.charAt(i++));\n enc2 = _keyStr.indexOf(input.charAt(i++));\n enc3 = _keyStr.indexOf(input.charAt(i++));\n enc4 = _keyStr.indexOf(input.charAt(i++));\n\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n\n output[resultIndex++] = chr1;\n\n if (enc3 !== 64) {\n output[resultIndex++] = chr2;\n }\n if (enc4 !== 64) {\n output[resultIndex++] = chr3;\n }\n\n }\n\n return output;\n};\n", "\"use strict\";\n\nmodule.exports = {\n /**\n * True if this is running in Nodejs, will be undefined in a browser.\n * In a browser, browserify won't include this file and the whole module\n * will be resolved an empty object.\n */\n isNode : typeof Buffer !== \"undefined\",\n /**\n * Create a new nodejs Buffer from an existing content.\n * @param {Object} data the data to pass to the constructor.\n * @param {String} encoding the encoding to use.\n * @return {Buffer} a new Buffer.\n */\n newBufferFrom: function(data, encoding) {\n if (Buffer.from && Buffer.from !== Uint8Array.from) {\n return Buffer.from(data, encoding);\n } else {\n if (typeof data === \"number\") {\n // Safeguard for old Node.js versions. On newer versions,\n // Buffer.from(number) / Buffer(number, encoding) already throw.\n throw new Error(\"The \\\"data\\\" argument must not be a number\");\n }\n return new Buffer(data, encoding);\n }\n },\n /**\n * Create a new nodejs Buffer with the specified size.\n * @param {Integer} size the size of the buffer.\n * @return {Buffer} a new Buffer.\n */\n allocBuffer: function (size) {\n if (Buffer.alloc) {\n return Buffer.alloc(size);\n } else {\n var buf = new Buffer(size);\n buf.fill(0);\n return buf;\n }\n },\n /**\n * Find out if an object is a Buffer.\n * @param {Object} b the object to test.\n * @return {Boolean} true if the object is a Buffer, false otherwise.\n */\n isBuffer : function(b){\n return Buffer.isBuffer(b);\n },\n\n isStream : function (obj) {\n return obj &&\n typeof obj.on === \"function\" &&\n typeof obj.pause === \"function\" &&\n typeof obj.resume === \"function\";\n }\n};\n", "'use strict';\nvar Mutation = global.MutationObserver || global.WebKitMutationObserver;\n\nvar scheduleDrain;\n\nif (process.browser) {\n if (Mutation) {\n var called = 0;\n var observer = new Mutation(nextTick);\n var element = global.document.createTextNode('');\n observer.observe(element, {\n characterData: true\n });\n scheduleDrain = function () {\n element.data = (called = ++called % 2);\n };\n } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {\n var channel = new global.MessageChannel();\n channel.port1.onmessage = nextTick;\n scheduleDrain = function () {\n channel.port2.postMessage(0);\n };\n } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {\n scheduleDrain = function () {\n\n // Create a