From f6eb1ed5c50c499d66cd8a3e9b9b3fafa46c2160 Mon Sep 17 00:00:00 2001 From: BinBashBanana <51469593+BinBashBanana@users.noreply.github.com> Date: Wed, 5 Mar 2025 10:39:43 -0800 Subject: [PATCH 1/2] Threaded emscripten improvements --- Makefile.emscripten | 71 ++- dist-scripts/dist-cores.sh | 17 +- emscripten/library_platform_emscripten.js | 88 +-- frontend/drivers/platform_emscripten.c | 459 +++++++++----- gfx/drivers_context/emscriptenegl_ctx.c | 24 +- gfx/drivers_context/emscriptenwebgl_ctx.c | 298 +++++---- input/drivers/rwebinput_input.c | 24 +- pkg/emscripten/libretro-thread/embed.html | 83 --- pkg/emscripten/libretro-thread/index.html | 401 ++++++------ .../libretro-thread/jsdeps/browserfs.min.js | 15 + .../libretro-thread/jsdeps/zip-full.min.js | 1 + pkg/emscripten/libretro-thread/libretro.css | 501 +++++++++++---- pkg/emscripten/libretro-thread/libretro.js | 599 ++++++++++++------ .../libretro-thread/libretro.worker.js | 448 +++++++++++-- .../libretro-thread/zip-no-worker.min.js | 2 - pkg/emscripten/libretro/libretro.css | 16 +- pkg/emscripten/libretro/libretro.js | 55 +- retroarch.c | 12 +- 18 files changed, 1965 insertions(+), 1149 deletions(-) delete mode 100644 pkg/emscripten/libretro-thread/embed.html create mode 100644 pkg/emscripten/libretro-thread/jsdeps/browserfs.min.js create mode 100644 pkg/emscripten/libretro-thread/jsdeps/zip-full.min.js delete mode 100644 pkg/emscripten/libretro-thread/zip-no-worker.min.js diff --git a/Makefile.emscripten b/Makefile.emscripten index b582d7e5d8..c2e8280803 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -13,8 +13,9 @@ EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option OS = Emscripten OBJ := -DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN -DEFINES += -DHAVE_FILTERS_BUILTIN +DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN -DEMSCRIPTEN -DNO_CANVAS_RESIZE +DEFINES += -DHAVE_FILTERS_BUILTIN -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORE_INFO + HAVE_PATCH = 1 HAVE_DSP_FILTER = 1 HAVE_VIDEO_FILTER = 1 @@ -29,7 +30,7 @@ HAVE_SCREENSHOTS = 1 HAVE_REWIND = 1 HAVE_AUDIOMIXER = 1 HAVE_CC_RESAMPLER = 1 -HAVE_EGL ?= 1 +HAVE_EGL ?= 0 HAVE_OPENGLES = 1 HAVE_RJPEG = 0 HAVE_RPNG = 1 @@ -54,13 +55,8 @@ HAVE_7ZIP = 1 HAVE_BSV_MOVIE = 1 HAVE_AL = 1 HAVE_CHD ?= 0 -HAVE_WASMFS ?= 0 -PROXY_TO_PTHREAD ?= 0 HAVE_NETPLAYDISCOVERY ?= 0 -DEFINES += -DHAVE_NETWORKING -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_COMPRESSION -DEFINES += -DHAVE_UPDATE_CORE_INFO - # WARNING -- READ BEFORE ENABLING # The rwebaudio driver is known to have several audio bugs, such as # minor crackling, or the entire page freezing/crashing. @@ -78,9 +74,13 @@ FS_DEBUG = 0 HAVE_OPENGLES ?= 1 HAVE_OPENGLES3 ?= 0 -ASYNC ?= 1 +HAVE_WASMFS ?= 0 +PROXY_TO_PTHREAD ?= 0 + +ASYNC ?= 0 LTO ?= 0 PTHREAD ?= 0 +PTHREAD_POOL_SIZE ?= 4 STACK_SIZE ?= 4194304 INITIAL_HEAP ?= 134217728 @@ -102,55 +102,57 @@ OBJDIR := obj-emscripten EXPORTED_FUNCTIONS = _main,_malloc,_free,_cmd_savefiles,_cmd_save_state,_cmd_load_state,_cmd_undo_save_state,_cmd_undo_load_state,_cmd_take_screenshot,\ _cmd_toggle_menu,_cmd_reload_config,_cmd_toggle_grab_mouse,_cmd_toggle_game_focus,_cmd_reset,_cmd_toggle_pause,_cmd_pause,_cmd_unpause,\ _cmd_set_volume,_cmd_set_shader,_cmd_cheat_set_code,_cmd_cheat_get_code,_cmd_cheat_toggle_index,_cmd_cheat_get_code_state,_cmd_cheat_realloc,\ -_cmd_cheat_get_size,_cmd_cheat_apply_cheats,EmscriptenSendCommand,EmscriptenReceiveCommandReply +_cmd_cheat_get_size,_cmd_cheat_apply_cheats,_update_canvas_dimensions,_update_window_hidden,_update_power_state,_update_memory_usage,\ +EmscriptenSendCommand,EmscriptenReceiveCommandReply -EXPORTS := callMain,FS,PATH,ERRNO_CODES,ENV,stringToNewUTF8,UTF8ToString,Browser,GL,EmscriptenSendCommand,EmscriptenReceiveCommandReply +EXPORTS := callMain,FS,PATH,ERRNO_CODES,ENV,stringToNewUTF8,UTF8ToString,Browser,EmscriptenSendCommand,EmscriptenReceiveCommandReply -LIBS := -s USE_ZLIB=1 -lbrowser.js +LIBS := -s USE_ZLIB=1 ifeq ($(HAVE_WASMFS), 1) - DEFINES += -DHAVE_WASMFS=1 - LIBS += -sWASMFS -sFORCE_FILESYSTEM=1 -lfetchfs.js -lopfs.js - EXPORTS := $(EXPORTS),FETCHFS,OPFS - ifeq ($(PTHREAD),0) - $(error ERROR: WASMFS requires threading support) + LIBS += -s WASMFS -s FORCE_FILESYSTEM=1 -lfetchfs.js -lopfs.js + DEFINES += -DHAVE_WASMFS + ifeq ($(PROXY_TO_PTHREAD), 0) + $(error ERROR: WASMFS requires PROXY_TO_PTHREAD) endif endif -ifeq ($(PROXY_TO_PTHREAD),1) - LIBS += -sENVIRONMENT=worker,web - LIBS += -sPROXY_TO_PTHREAD -sOFFSCREENCANVAS_SUPPORT - DEFINES += -DUSE_OFFSCREENCANVAS=1 -DPROXY_TO_PTHREAD=1 -else +# note: real PROXY_TO_PTHREAD is not used here; we do the pthread management ourselves +ifeq ($(PROXY_TO_PTHREAD), 1) + LIBS += -s OFFSCREENCANVAS_SUPPORT + DEFINES += -DPROXY_TO_PTHREAD -DEMSCRIPTEN_STACK_SIZE=$(STACK_SIZE) + override PTHREAD = 1 + override STACK_SIZE = 4194304 +else ifeq ($(HAVE_AL), 1) override ASYNC = 1 endif - + ifeq ($(HAVE_SDL2), 1) LIBS += -s USE_SDL=2 DEFINES += -DHAVE_SDL2 endif - LDFLAGS := -L. --no-heap-copy -s STACK_SIZE=$(STACK_SIZE) -s INITIAL_MEMORY=$(INITIAL_HEAP) \ -s EXPORTED_RUNTIME_METHODS=$(EXPORTS) \ -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="$(EXPORTED_FUNCTIONS)" \ -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="libretro_$(subst -,_,$(LIBRETRO))" \ -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 \ + -s ENVIRONMENT=web,worker \ --extern-pre-js emscripten/pre.js \ --js-library emscripten/library_rwebcam.js \ - -gsource-map -g2 \ --js-library emscripten/library_platform_emscripten.js ifeq ($(HAVE_OPENGLES), 1) ifeq ($(HAVE_OPENGLES3), 1) - LDFLAGS += -s FULL_ES3=1 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 -lGL + LDFLAGS += -s FULL_ES3=1 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 else - LDFLAGS += -s FULL_ES2=1 -s MIN_WEBGL_VERSION=1 -s MAX_WEBGL_VERSION=2 -lGL + LDFLAGS += -s FULL_ES2=1 -s MIN_WEBGL_VERSION=1 -s MAX_WEBGL_VERSION=2 endif endif ifeq ($(GL_DEBUG), 1) - LDFLAGS += -s GL_ASSERTIONS=1 -s GL_DEBUG=1 -DHAVE_GL_DEBUG_ES=1 + LDFLAGS += -s GL_ASSERTIONS=1 -s GL_DEBUG=1 + DEFINES += -DHAVE_GL_DEBUG_ES=1 endif ifeq ($(FS_DEBUG), 1) @@ -167,20 +169,19 @@ ifeq ($(HAVE_AL), 1) DEFINES += -DHAVE_AL endif -ifneq ($(PTHREAD), 0) - LDFLAGS += -s WASM_MEM_MAX=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD) +ifeq ($(PTHREAD), 1) + LDFLAGS += -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD_POOL_SIZE) CFLAGS += -pthread -s SHARED_MEMORY - HAVE_THREADS=1 + HAVE_THREADS = 1 else - HAVE_THREADS=0 + HAVE_THREADS = 0 endif - ifeq ($(ASYNC), 1) DEFINES += -DEMSCRIPTEN_ASYNCIFY - LDFLAGS += -s ASYNCIFY=$(ASYNC) -s ASYNCIFY_STACK_SIZE=8192 + LDFLAGS += -s ASYNCIFY=1 -s ASYNCIFY_STACK_SIZE=8192 ifeq ($(DEBUG), 1) - LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE + # LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE endif endif diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index 6c874a667a..5c91e70860 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -213,14 +213,16 @@ for f in `ls -v *_${platform}.${EXT}`; do big_stack="BIG_STACK=1" fi if [ $PLATFORM = "emscripten" ]; then - async=0 - pthread=${pthread:-0} - gles3=0 + async=${ASYNC:-0} + pthread=${PTHREAD:-0} + proxy_to_pthread=${PROXY_TO_PTHREAD:-0} + gles3=${HAVE_OPENGLES3:-0} stack_mem=4194304 heap_mem=134217728 if [ $name = "mupen64plus_next" ] ; then gles3=1 - async=1 + #async=1 + #proxy_to_pthread=0 stack_mem=134217728 heap_mem=268435456 elif [ $name = "parallel_n64" ] ; then @@ -248,6 +250,7 @@ for f in `ls -v *_${platform}.${EXT}`; do if [ $PLATFORM = "emscripten" ]; then echo ASYNC: $async echo PTHREAD: $pthread + echo PROXY_TO_PTHREAD: $proxy_to_pthread echo GLES3: $gles3 echo STACK_MEMORY: $stack_mem echo HEAP_MEMORY: $heap_mem @@ -270,8 +273,8 @@ for f in `ls -v *_${platform}.${EXT}`; do if [ $MAKEFILE_GRIFFIN = "yes" ]; then make -C ../ -f Makefile.griffin $OPTS platform=${platform} $whole_archive $big_stack -j3 || exit 1 elif [ $PLATFORM = "emscripten" ]; then - echo "BUILD COMMAND: make -C ../ -f Makefile.emscripten PTHREAD=$pthread ASYNC=$async LTO=$lto HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js" - make -C ../ -f Makefile.emscripten $OPTS PTHREAD=$pthread ASYNC=$async LTO=$lto HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js || exit 1 + echo "BUILD COMMAND: make -C ../ -f Makefile.emscripten $OPTS LTO=$lto ASYNC=$async PTHREAD=$pthread PROXY_TO_PTHREAD=$proxy_to_pthread HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js" + make -C ../ -f Makefile.emscripten $OPTS LTO=$lto ASYNC=$async PTHREAD=$pthread PROXY_TO_PTHREAD=$proxy_to_pthread HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js || exit 1 elif [ $PLATFORM = "unix" ]; then make -C ../ -f Makefile LINK=g++ $whole_archive $big_stack -j3 || exit 1 elif [ $PLATFORM = "ctr" ]; then @@ -338,7 +341,7 @@ for f in `ls -v *_${platform}.${EXT}`; do mkdir -p ../pkg/emscripten/ mv -f ../${name}_libretro.js ../pkg/emscripten/${name}_libretro.js mv -f ../${name}_libretro.wasm ../pkg/emscripten/${name}_libretro.wasm - if [ $pthread != 0 ] ; then + if [ -f ../${name}_libretro.worker.js ] ; then mv -f ../${name}_libretro.worker.js ../pkg/emscripten/${name}_libretro.worker.js fi if [ -f ../${name}_libretro.wasm.map ] ; then diff --git a/emscripten/library_platform_emscripten.js b/emscripten/library_platform_emscripten.js index a2d71057d3..305cd69f98 100644 --- a/emscripten/library_platform_emscripten.js +++ b/emscripten/library_platform_emscripten.js @@ -2,19 +2,54 @@ var LibraryPlatformEmscripten = { $RPE: { - powerState: { - supported: false, - dischargeTime: 0, - level: 0, - charging: false - }, powerStateChange: function(e) { - RPE.powerState.dischargeTime = Number.isFinite(e.target.dischargingTime) ? e.target.dischargingTime : 0x7FFFFFFF; - RPE.powerState.level = e.target.level; - RPE.powerState.charging = e.target.charging; + Module._update_power_state(true, Number.isFinite(e.target.dischargingTime) ? e.target.dischargingTime : 0x7FFFFFFF, e.target.level, e.target.charging); }, - command_queue:[], - command_reply_queue:[], + + updateMemoryUsage: function() { + // unfortunately this will be innacurate in threaded (worker) builds + var used = BigInt(performance.memory.usedJSHeapSize || 0); + var limit = BigInt(performance.memory.jsHeapSizeLimit || 0); + // emscripten currently only supports passing 32 bit ints, so pack it + Module._update_memory_usage(Number(used & 0xFFFFFFFFn), Number(used >> 32n), Number(limit & 0xFFFFFFFFn), Number(limit >> 32n)); + setTimeout(RPE.updateMemoryUsage, 5000); + }, + command_queue: [], + command_reply_queue: [] + }, + + PlatformEmscriptenWatchCanvasSizeAndDpr: function(dpr) { + if (RPE.observer) { + RPE.observer.unobserve(Module.canvas); + RPE.observer.observe(Module.canvas); + return; + } + RPE.observer = new ResizeObserver(function(e) { + var width, height; + var entry = e.find(i => i.target == Module.canvas); + if (!entry) return; + if (entry.devicePixelContentBoxSize) { + width = entry.devicePixelContentBoxSize[0].inlineSize; + height = entry.devicePixelContentBoxSize[0].blockSize; + } else { + width = Math.round(entry.contentRect.width * window.devicePixelRatio); + height = Math.round(entry.contentRect.height * window.devicePixelRatio); + } + // doubles are too big to pass as an argument to exported functions + {{{ makeSetValue("dpr", "0", "window.devicePixelRatio", "double") }}}; + Module._update_canvas_dimensions(width, height, dpr); + }); + RPE.observer.observe(Module.canvas); + window.addEventListener("resize", function() { + RPE.observer.unobserve(Module.canvas); + RPE.observer.observe(Module.canvas); + }, false); + }, + + PlatformEmscriptenWatchWindowVisibility: function() { + document.addEventListener("visibilitychange", function() { + Module._update_window_hidden(document.visibilityState == "hidden"); + }, false); }, PlatformEmscriptenPowerStateInit: function() { @@ -23,41 +58,20 @@ var LibraryPlatformEmscripten = { battery.addEventListener("chargingchange", RPE.powerStateChange); battery.addEventListener("levelchange", RPE.powerStateChange); RPE.powerStateChange({target: battery}); - RPE.powerState.supported = true; }); }, - PlatformEmscriptenPowerStateGetSupported: function() { - return RPE.powerState.supported; + PlatformEmscriptenMemoryUsageInit: function() { + if (!performance.memory) return; + RPE.updateMemoryUsage(); }, - PlatformEmscriptenPowerStateGetDischargeTime: function() { - return RPE.powerState.dischargeTime; - }, - - PlatformEmscriptenPowerStateGetLevel: function() { - return RPE.powerState.level; - }, - - PlatformEmscriptenPowerStateGetCharging: function() { - return RPE.powerState.charging; - }, - - PlatformEmscriptenGetTotalMem: function() { - if (!performance.memory) return 0; - return performance.memory.jsHeapSizeLimit || 0; - }, - - PlatformEmscriptenGetFreeMem: function() { - if (!performance.memory) return 0; - return (performance.memory.jsHeapSizeLimit || 0) - (performance.memory.usedJSHeapSize || 0); - }, - - $EmscriptenSendCommand__deps:["PlatformEmscriptenCommandRaiseFlag"], + $EmscriptenSendCommand__deps: ["PlatformEmscriptenCommandRaiseFlag"], $EmscriptenSendCommand: function(str) { RPE.command_queue.push(str); _PlatformEmscriptenCommandRaiseFlag(); }, + $EmscriptenReceiveCommandReply: function() { return RPE.command_reply_queue.shift(); } diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 0fce6b7ad4..ac27c0f9a6 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -17,10 +17,9 @@ #include #include -#if HAVE_WASMFS -#include -#endif #include +#include +#include #include #include #include @@ -55,69 +54,74 @@ #include "../../cheat_manager.h" #include "../../audio/audio_driver.h" -void emscripten_mainloop(void); -void PlatformEmscriptenWatchCanvasSize(void) { - MAIN_THREAD_ASYNC_EM_ASM( - RPE.observer = new ResizeObserver(function(_e) { - var container = Module.canvas.parentElement; - var width = container.offsetWidth; - var height = container.offsetHeight; - var w = Module.canvas.width; - var h = Module.canvas.height; - if (w == 0 || h == 0 || width == 0 || height == 0) { return; } - /* Module.print("Setting real canvas size: " + width + " x " + height); */ - var new_w = `${width}px`; - var new_h = `${height}px`; - if (Module.canvas.style.width != new_w || Module.canvas.style.height != new_h) { - Module.canvas.style.width = new_w; - Module.canvas.style.height = new_h; - } - if (!Module.canvas.controlTransferredOffscreen) { - Module.Browser.setCanvasSize(width, height); - } - }); - RPE.observer.observe(Module.canvas.parentElement); - window.addEventListener("resize", function(e) { - RPE.observer.unobserve(Module.canvas.parentElement); - RPE.observer.observe(Module.canvas.parentElement); - }, false); - ); -} -void PlatformEmscriptenPowerStateInit(void); -bool PlatformEmscriptenPowerStateGetSupported(void); -int PlatformEmscriptenPowerStateGetDischargeTime(void); -float PlatformEmscriptenPowerStateGetLevel(void); -bool PlatformEmscriptenPowerStateGetCharging(void); -uint64_t PlatformEmscriptenGetTotalMem(void); -uint64_t PlatformEmscriptenGetFreeMem(void); +#ifdef HAVE_WASMFS +#include +#endif + +#ifdef PROXY_TO_PTHREAD +#include +#include +#include +#define PLATFORM_SETVAL(type, addr, val) emscripten_atomic_store_##type(addr, val) +#else +#define PLATFORM_SETVAL(type, addr, val) *addr = val +#endif + +void emscripten_mainloop(void); +void PlatformEmscriptenWatchCanvasSizeAndDpr(double *dpr); +void PlatformEmscriptenWatchWindowVisibility(void); +void PlatformEmscriptenPowerStateInit(void); +void PlatformEmscriptenMemoryUsageInit(void); -void PlatformEmscriptenCommandReply(const char *msg, size_t len) { - MAIN_THREAD_EM_ASM({ - var message = UTF8ToString($0,$1); - RPE.command_reply_queue.push(message); - }, msg, len); -} static bool command_flag = false; -size_t PlatformEmscriptenCommandRead(char **into, size_t max_len) { - if(!command_flag) { return 0; } + +void PlatformEmscriptenCommandReply(const char *msg, size_t len) +{ + MAIN_THREAD_EM_ASM({ + var message = UTF8ToString($0, $1); + RPE.command_reply_queue.push(message); + }, msg, len); +} + +size_t PlatformEmscriptenCommandRead(char **into, size_t max_len) +{ + if (!command_flag) { return 0; } return MAIN_THREAD_EM_ASM_INT({ var next_command = RPE.command_queue.shift(); var length = lengthBytesUTF8(next_command); - if(length > $2) { - console.error("[CMD] Command too long, skipping",next_command); + if (length > $2) { + console.error("[CMD] Command too long, skipping", next_command); return 0; } stringToUTF8(next_command, $1, $2); - if(RPE.command_queue.length == 0) { + if (RPE.command_queue.length == 0) { setValue($0, 0, 'i8'); } return length; }, &command_flag, into, max_len); } -void PlatformEmscriptenCommandRaiseFlag() { - command_flag = true; + +void PlatformEmscriptenCommandRaiseFlag() +{ + command_flag = true; } +typedef struct +{ + uint64_t memory_used; + uint64_t memory_limit; + double device_pixel_ratio; + int canvas_width; + int canvas_height; + int power_state_discharge_time; + float power_state_level; + volatile bool power_state_charging; + volatile bool power_state_supported; + volatile bool window_hidden; +} emscripten_platform_data_t; + +static emscripten_platform_data_t *emscripten_platform_data = NULL; + /* begin exported functions */ /* saves and states */ @@ -246,50 +250,153 @@ void cmd_cheat_apply_cheats(void) config_get_ptr()->bools.notification_show_cheats_applied); } -/* end exported functions */ +/* javascript callbacks */ + +void update_canvas_dimensions(int width, int height, double *dpr) +{ + printf("[INFO] Setting real canvas size: %d x %d\n", width, height); + emscripten_set_canvas_element_size("#canvas", width, height); + if (!emscripten_platform_data) + return; + PLATFORM_SETVAL(u32, &emscripten_platform_data->canvas_width, width); + PLATFORM_SETVAL(u32, &emscripten_platform_data->canvas_height, height); + PLATFORM_SETVAL(f64, &emscripten_platform_data->device_pixel_ratio, *dpr); +} + +void update_window_hidden(bool hidden) +{ + if (!emscripten_platform_data) + return; + emscripten_platform_data->window_hidden = hidden; +} + +void update_power_state(bool supported, int discharge_time, float level, bool charging) +{ + if (!emscripten_platform_data) + return; + emscripten_platform_data->power_state_supported = supported; + emscripten_platform_data->power_state_charging = charging; + PLATFORM_SETVAL(u32, &emscripten_platform_data->power_state_discharge_time, discharge_time); + PLATFORM_SETVAL(f32, &emscripten_platform_data->power_state_level, level); +} + +void update_memory_usage(uint32_t used1, uint32_t used2, uint32_t limit1, uint32_t limit2) +{ + if (!emscripten_platform_data) + return; + PLATFORM_SETVAL(u64, &emscripten_platform_data->memory_used, used1 | ((uint64_t)used2 << 32)); + PLATFORM_SETVAL(u64, &emscripten_platform_data->memory_limit, limit1 | ((uint64_t)limit2 << 32)); +} + +/* platform specific c helpers */ + +void platform_emscripten_get_canvas_size(int *width, int *height) +{ + if (!emscripten_platform_data || + (emscripten_platform_data->canvas_width == 0 && emscripten_platform_data->canvas_height == 0)) + { + *width = 800; + *height = 600; + RARCH_ERR("[EMSCRIPTEN]: Could not get screen dimensions!\n"); + } + else + { + *width = emscripten_platform_data->canvas_width; + *height = emscripten_platform_data->canvas_height; + } +} + +double platform_emscripten_get_dpr(void) +{ + return emscripten_platform_data->device_pixel_ratio; +} + +bool platform_emscripten_is_window_hidden(void) +{ + return emscripten_platform_data->window_hidden; +} + +void platform_emscripten_run_on_browser_thread_sync(void (*func)(void*), void* arg) +{ +#ifdef PROXY_TO_PTHREAD + emscripten_proxy_sync(emscripten_proxy_get_system_queue(), emscripten_main_runtime_thread_id(), func, arg); +#else + func(arg); +#endif +} + +void platform_emscripten_run_on_browser_thread_async(void (*func)(void*), void* arg) +{ +#ifdef PROXY_TO_PTHREAD + emscripten_proxy_async(emscripten_proxy_get_system_queue(), emscripten_main_runtime_thread_id(), func, arg); +#else + // for now, not async + func(arg); +#endif +} + +/* frontend driver impl */ static void frontend_emscripten_get_env(int *argc, char *argv[], void *args, void *params_data) { char base_path[PATH_MAX]; char user_path[PATH_MAX]; - const char *home = getenv("HOME"); + char bundle_path[PATH_MAX]; + const char *home = getenv("HOME"); if (home) { size_t _len = strlcpy(base_path, home, sizeof(base_path)); strlcpy(base_path + _len, "/retroarch", sizeof(base_path) - _len); +#ifndef HAVE_WASMFS + /* can be removed when the new web player replaces the old one */ _len = strlcpy(user_path, home, sizeof(user_path)); strlcpy(user_path + _len, "/retroarch/userdata", sizeof(user_path) - _len); + _len = strlcpy(bundle_path, home, sizeof(bundle_path)); + strlcpy(bundle_path + _len, "/retroarch/bundle", sizeof(bundle_path) - _len); +#else + _len = strlcpy(user_path, home, sizeof(user_path)); + strlcpy(user_path + _len, "/retroarch", sizeof(user_path) - _len); + _len = strlcpy(bundle_path, home, sizeof(bundle_path)); + strlcpy(bundle_path + _len, "/retroarch", sizeof(bundle_path) - _len); +#endif } else { strlcpy(base_path, "retroarch", sizeof(base_path)); +#ifndef HAVE_WASMFS + /* can be removed when the new web player replaces the old one */ strlcpy(user_path, "retroarch/userdata", sizeof(user_path)); + strlcpy(bundle_path, "retroarch/bundle", sizeof(bundle_path)); +#else + strlcpy(user_path, "retroarch", sizeof(user_path)); + strlcpy(bundle_path, "retroarch", sizeof(bundle_path)); +#endif } fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); /* bundle data */ - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path, - "bundle/assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, - "bundle/autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path, - "bundle/database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, - "bundle/info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path, - "bundle/overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY], base_path, - "bundle/overlays/keyboards", sizeof(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path, - "bundle/shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], base_path, - "bundle/filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], base_path, - "bundle/filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], bundle_path, + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], bundle_path, + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], bundle_path, + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], bundle_path, + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], bundle_path, + "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY], bundle_path, + "overlays/keyboards", sizeof(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], bundle_path, + "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], bundle_path, + "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], bundle_path, + "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); /* user data dirs */ fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path, @@ -299,7 +406,7 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], user_path, "content", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path, - "content/downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], user_path, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], @@ -330,41 +437,82 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], #endif } -typedef struct args { - int argc; - char **argv; -} args_t; -static bool retro_started = false; -static bool filesystem_ready = false; +static enum frontend_powerstate frontend_emscripten_get_powerstate(int *seconds, int *percent) +{ + enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; -#if HAVE_WASMFS -void PlatformEmscriptenMountFilesystems(void *info) { - char *opfs_mount = getenv("OPFS"); + if (!emscripten_platform_data || !emscripten_platform_data->power_state_supported) + return ret; + + if (!emscripten_platform_data->power_state_charging) + ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; + else if (emscripten_platform_data->power_state_level == 1) + ret = FRONTEND_POWERSTATE_CHARGED; + else + ret = FRONTEND_POWERSTATE_CHARGING; + + *seconds = emscripten_platform_data->power_state_discharge_time; + *percent = (int)(emscripten_platform_data->power_state_level * 100); + + return ret; +} + +static uint64_t frontend_emscripten_get_total_mem(void) +{ + if (!emscripten_platform_data) + return 0; + return emscripten_platform_data->memory_limit; +} + +static uint64_t frontend_emscripten_get_free_mem(void) +{ + if (!emscripten_platform_data) + return 0; +#ifndef PROXY_TO_PTHREAD + uint64_t used = emscripten_platform_data->memory_used; +#else + uint64_t used = mallinfo().uordblks; +#endif + return (emscripten_platform_data->memory_limit - used); +} + +/* program entry and startup */ + +#ifdef HAVE_WASMFS +void platform_emscripten_mount_filesystems(void) +{ + char *opfs_mount = getenv("OPFS_MOUNT"); char *fetch_manifest = getenv("FETCH_MANIFEST"); - if(opfs_mount) { + if (opfs_mount) + { int res; printf("[OPFS] Mount OPFS at %s\n", opfs_mount); backend_t opfs = wasmfs_create_opfs_backend(); { char *parent = strdup(opfs_mount); path_parent_dir(parent, strlen(parent)); - if(!path_mkdir(parent)) { - printf("mkdir error %d\n",errno); + if (!path_mkdir(parent)) + { + printf("mkdir error %d\n", errno); abort(); } free(parent); } res = wasmfs_create_directory(opfs_mount, 0777, opfs); - if(res) { - printf("[OPFS] error result %d\n",res); - if(errno) { - printf("[OPFS] errno %d\n",errno); + if (res) + { + printf("[OPFS] error result %d\n", res); + if (errno) + { + printf("[OPFS] errno %d\n", errno); abort(); } abort(); } } - if(fetch_manifest) { +#if false + if (fetch_manifest) + { /* fetch_manifest should be a path to a manifest file. manifest files have this format: @@ -376,20 +524,23 @@ void PlatformEmscriptenMountFilesystems(void *info) { Where URL may not contain spaces, but PATH may. */ int max_line_len = 1024; - printf("[FetchFS] read fetch manifest from %s\n",fetch_manifest); + printf("[FetchFS] read fetch manifest from %s\n", fetch_manifest); FILE *file = fopen(fetch_manifest, "r"); - if(!file) { + if (!file) + { printf("[FetchFS] missing manifest file\n"); abort(); } char *line = calloc(sizeof(char), max_line_len); size_t len = max_line_len; - while (getline(&line, &len, file) != -1) { + while (getline(&line, &len, file) != -1) + { char *path = strstr(line, " "); backend_t fetch; int fd; - if(len <= 2 || !path) { - printf("[FetchFS] Manifest file has invalid line %s\n",line); + if (len <= 2 || !path) + { + printf("[FetchFS] Manifest file has invalid line %s\n", line); continue; } *path = '\0'; @@ -399,19 +550,22 @@ void PlatformEmscriptenMountFilesystems(void *info) { { char *parent = strdup(path); path_parent_dir(parent, strlen(parent)); - if(!path_mkdir(parent)) { - printf("[FetchFS] mkdir error %d\n",errno); + if (!path_mkdir(parent)) + { + printf("[FetchFS] mkdir error %d\n", errno); abort(); } free(parent); } fetch = wasmfs_create_fetch_backend(line, 16*1024*1024); - if(!fetch) { + if (!fetch) + { printf("[FetchFS] couldn't create fetch backend\n"); abort(); } fd = wasmfs_create_file(path, 0777, fetch); - if(!fd) { + if (!fd) + { printf("[FetchFS] couldn't create fetch file\n"); abort(); } @@ -421,91 +575,62 @@ void PlatformEmscriptenMountFilesystems(void *info) { fclose(file); free(line); } - filesystem_ready = true; -#if !PROXY_TO_PTHREAD - while (!retro_started) { - retro_sleep(1); - } #endif } #endif /* HAVE_WASMFS */ -static enum frontend_powerstate frontend_emscripten_get_powerstate(int *seconds, int *percent) +static int thread_main(int argc, char *argv[]) { - enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; +#ifdef HAVE_WASMFS + platform_emscripten_mount_filesystems(); +#endif - if (!PlatformEmscriptenPowerStateGetSupported()) - return ret; + emscripten_set_main_loop(emscripten_mainloop, 0, 0); + emscripten_set_main_loop_timing(EM_TIMING_RAF, 1); + rarch_main(argc, argv, NULL); - if (!PlatformEmscriptenPowerStateGetCharging()) - ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - else if (PlatformEmscriptenPowerStateGetLevel() == 1) - ret = FRONTEND_POWERSTATE_CHARGED; - else - ret = FRONTEND_POWERSTATE_CHARGING; - - *seconds = PlatformEmscriptenPowerStateGetDischargeTime(); - *percent = (int)(PlatformEmscriptenPowerStateGetLevel() * 100); - - return ret; + return 0; } -static uint64_t frontend_emscripten_get_total_mem(void) +#ifdef PROXY_TO_PTHREAD + +static int _main_argc; +static char** _main_argv; + +static void *main_pthread(void* arg) { - return PlatformEmscriptenGetTotalMem(); -} - -static uint64_t frontend_emscripten_get_free_mem(void) -{ - return PlatformEmscriptenGetFreeMem(); -} - -void emscripten_bootup_mainloop(void *argptr) { - if(retro_started) { - /* A stale extra call to bootup_mainloop for some reason */ - RARCH_ERR("[Emscripten] unexpected second call to bootup_mainloop after rarch_main called\n"); - return; - } - if(filesystem_ready) { - args_t *args = (args_t*)argptr; - emscripten_cancel_main_loop(); - emscripten_set_main_loop(emscripten_mainloop, 0, 0); - emscripten_set_main_loop_timing(EM_TIMING_RAF, 1); - rarch_main(args->argc, args->argv, NULL); - retro_started = true; - free(args); - } + emscripten_set_thread_name(pthread_self(), "Application main thread"); + thread_main(_main_argc, _main_argv); + return NULL; } +#endif int main(int argc, char *argv[]) { - args_t *args = calloc(sizeof(args_t), 1); - args->argc = argc; - args->argv = argv; - - PlatformEmscriptenWatchCanvasSize(); + int ret = 0; + // this never gets freed + emscripten_platform_data = (emscripten_platform_data_t *)calloc(1, sizeof(emscripten_platform_data_t)); + + PlatformEmscriptenWatchCanvasSizeAndDpr(malloc(sizeof(double))); + PlatformEmscriptenWatchWindowVisibility(); PlatformEmscriptenPowerStateInit(); + PlatformEmscriptenMemoryUsageInit(); - emscripten_set_canvas_element_size("#canvas", 800, 600); - emscripten_set_element_css_size("#canvas", 800.0, 600.0); -#if HAVE_WASMFS -#if PROXY_TO_PTHREAD - { - PlatformEmscriptenMountFilesystems(NULL); - } -#else /* !PROXY_TO_PTHREAD */ - { - sthread_t *thread = sthread_create(PlatformEmscriptenMountFilesystems, NULL); - sthread_detach(thread); - } -#endif /* PROXY_TO_PTHREAD */ -#else /* !HAVE_WASMFS */ - filesystem_ready = true; -#endif /* HAVE_WASMFS */ - emscripten_set_main_loop_arg(emscripten_bootup_mainloop, (void *)args, 0, 0); - emscripten_set_main_loop_timing(EM_TIMING_RAF, 1); - - return 0; +#ifdef PROXY_TO_PTHREAD + _main_argc = argc; + _main_argv = argv; + pthread_attr_t attr; + pthread_t thread; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_attr_setstacksize(&attr, EMSCRIPTEN_STACK_SIZE); + emscripten_pthread_attr_settransferredcanvases(&attr, (const char*)-1); + ret = pthread_create(&thread, &attr, main_pthread, NULL); + pthread_attr_destroy(&attr); +#else + ret = thread_main(argc, argv); +#endif + return ret; } frontend_ctx_driver_t frontend_ctx_emscripten = { diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index b1097498f1..c6659d6f83 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -33,6 +33,8 @@ #include "../common/egl_common.h" #endif +void platform_emscripten_get_canvas_size(int *width, int *height); + typedef struct { #ifdef HAVE_EGL @@ -50,18 +52,6 @@ static void gfx_ctx_emscripten_swap_interval(void *data, int interval) emscripten_set_main_loop_timing(EM_TIMING_RAF, interval); } -static void gfx_ctx_emscripten_get_canvas_size(int *width, int *height) -{ - EMSCRIPTEN_RESULT r = emscripten_get_canvas_element_size("#canvas", width, height); - - if (r != EMSCRIPTEN_RESULT_SUCCESS) - { - *width = 800; - *height = 600; - RARCH_ERR("[EMSCRIPTEN/EGL]: Could not get screen dimensions: %d\n",r); - } -} - static void gfx_ctx_emscripten_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height) { @@ -69,7 +59,8 @@ static void gfx_ctx_emscripten_check_window(void *data, bool *quit, int input_height; emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; - gfx_ctx_emscripten_get_canvas_size(&input_width, &input_height); + platform_emscripten_get_canvas_size(&input_width, &input_height); + *resize = (emscripten->fb_width != input_width || emscripten->fb_height != input_height); *width = emscripten->fb_width = (unsigned)input_width; *height = emscripten->fb_height = (unsigned)input_height; @@ -93,10 +84,9 @@ static void gfx_ctx_emscripten_get_video_size(void *data, if (!emscripten) return; - int w, h; - gfx_ctx_emscripten_get_canvas_size(&w, &h); - *width = w; - *height = h; + + *width = emscripten->fb_width; + *height = emscripten->fb_height; } static bool gfx_ctx_emscripten_get_metrics(void *data, diff --git a/gfx/drivers_context/emscriptenwebgl_ctx.c b/gfx/drivers_context/emscriptenwebgl_ctx.c index 32702a6510..43cf6ba200 100644 --- a/gfx/drivers_context/emscriptenwebgl_ctx.c +++ b/gfx/drivers_context/emscriptenwebgl_ctx.c @@ -29,6 +29,9 @@ #include "../../retroarch.h" #include "../../verbosity.h" +void platform_emscripten_get_canvas_size(int *width, int *height); +double platform_emscripten_get_dpr(void); + typedef struct { EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx; @@ -44,179 +47,40 @@ static void gfx_ctx_emscripten_webgl_swap_interval(void *data, int interval) emscripten_set_main_loop_timing(EM_TIMING_RAF, interval); } -static void gfx_ctx_emscripten_webgl_get_canvas_size(int *width, int *height) -{ - EmscriptenFullscreenChangeEvent fullscreen_status; - bool is_fullscreen = false; - EMSCRIPTEN_RESULT r = emscripten_get_fullscreen_status(&fullscreen_status); - - if (r == EMSCRIPTEN_RESULT_SUCCESS) - { - if (fullscreen_status.isFullscreen) - { - is_fullscreen = true; - *width = fullscreen_status.screenWidth; - *height = fullscreen_status.screenHeight; - } - } - if (!is_fullscreen) - { - double w, h; - r = emscripten_get_element_css_size("#canvas", &w, &h); - *width = (int)w; - *height = (int)h; - - if (r != EMSCRIPTEN_RESULT_SUCCESS) - { - *width = 800; - *height = 600; - RARCH_ERR("[EMSCRIPTEN/WebGL]: Could not get screen dimensions: %d\n",r); - } - } -} - static void gfx_ctx_emscripten_webgl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height) { - int input_width=0; - int input_height=0; + int input_width; + int input_height; emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; - gfx_ctx_emscripten_webgl_get_canvas_size(&input_width, &input_height); - *width = (unsigned)input_width; - *height = (unsigned)input_height; - *resize = (*width != emscripten->fb_width || *height != emscripten->fb_height); - emscripten->fb_width = *width; - emscripten->fb_height = *height; - *quit = false; + platform_emscripten_get_canvas_size(&input_width, &input_height); + + *resize = (emscripten->fb_width != input_width || emscripten->fb_height != input_height); + *width = emscripten->fb_width = (unsigned)input_width; + *height = emscripten->fb_height = (unsigned)input_height; + *quit = false; } static void gfx_ctx_emscripten_webgl_swap_buffers(void *data) { -#ifdef USE_OFFSCREENCANVAS +#ifdef PROXY_TO_PTHREAD emscripten_webgl_commit_frame(); +#else + (void)data; #endif } static void gfx_ctx_emscripten_webgl_get_video_size(void *data, unsigned *width, unsigned *height) -{ - emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; - int s_width, s_height; - if (!emscripten) - return; - gfx_ctx_emscripten_webgl_get_canvas_size(&s_width, &s_height); - *width = (unsigned)s_width; - *height = (unsigned)s_height; -} - -static void gfx_ctx_emscripten_webgl_destroy(void *data) { emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; if (!emscripten) return; - emscripten_webgl_destroy_context(emscripten->ctx); - - free(data); -} - -static void *gfx_ctx_emscripten_webgl_init(void *video_driver) -{ - int width, height; - emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*) - calloc(1, sizeof(*emscripten)); - - EmscriptenWebGLContextAttributes attrs={0}; - emscripten_webgl_init_context_attributes(&attrs); - attrs.alpha = false; - attrs.depth = true; - attrs.stencil = true; - attrs.antialias = false; - attrs.powerPreference = EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE; - attrs.majorVersion = 2; - attrs.minorVersion = 0; - attrs.enableExtensionsByDefault = true; -#ifdef USE_OFFSCREENCANVAS - attrs.explicitSwapControl = true; -#else - attrs.explicitSwapControl = false; -#endif - attrs.renderViaOffscreenBackBuffer = false; - attrs.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_DISALLOW; - - if (!emscripten) - return NULL; - - emscripten->ctx = emscripten_webgl_create_context("#canvas", &attrs); - if(!emscripten->ctx) { - RARCH_ERR("[EMSCRIPTEN/WEBGL]: Failed to initialize webgl\n"); - goto error; - } - emscripten_webgl_get_drawing_buffer_size(emscripten->ctx, &width, &height); - emscripten_webgl_make_context_current(emscripten->ctx); - emscripten->fb_width = (unsigned)width; - emscripten->fb_height = (unsigned)height; - - return emscripten; - -error: - gfx_ctx_emscripten_webgl_destroy(video_driver); - return NULL; -} - -static bool gfx_ctx_emscripten_webgl_set_video_mode(void *data, - unsigned width, unsigned height, - bool fullscreen) -{ - emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; - EMSCRIPTEN_RESULT r; - if(!emscripten || !emscripten->ctx) return false; - - if (width != 0 && height != 0) { - r = emscripten_set_canvas_element_size("#canvas", - (int)width, (int)height); - - if (r != EMSCRIPTEN_RESULT_SUCCESS) { - RARCH_ERR("[EMSCRIPTEN/WebGL]: error resizing canvas: %d\n", r); - return false; - } - } - emscripten->fb_width = width; - emscripten->fb_height = height; - - return true; -} - -bool gfx_ctx_emscripten_webgl_set_resize(void *data, unsigned width, unsigned height) { - emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; - EMSCRIPTEN_RESULT r; - if(!emscripten || !emscripten->ctx) return false; - r = emscripten_set_canvas_element_size("#canvas", - (int)width, (int)height); - if (r != EMSCRIPTEN_RESULT_SUCCESS) { - RARCH_ERR("[EMSCRIPTEN/WebGL]: error resizing canvas: %d\n", r); - return false; - } - return true; -} - -static enum gfx_ctx_api gfx_ctx_emscripten_webgl_get_api(void *data) { return GFX_CTX_OPENGL_ES_API; } - -static bool gfx_ctx_emscripten_webgl_bind_api(void *data, - enum gfx_ctx_api api, unsigned major, unsigned minor) -{ - return true; -} - -static void gfx_ctx_emscripten_webgl_input_driver(void *data, - const char *name, - input_driver_t **input, void **input_data) -{ - void *rwebinput = input_driver_init_wrap(&input_rwebinput, name); - *input = rwebinput ? &input_rwebinput : NULL; - *input_data = rwebinput; + *width = emscripten->fb_width; + *height = emscripten->fb_height; } static bool gfx_ctx_emscripten_webgl_get_metrics(void *data, @@ -238,7 +102,131 @@ static bool gfx_ctx_emscripten_webgl_get_metrics(void *data, return true; } -static bool gfx_ctx_emscripten_webgl_has_focus(void *data) { +static void gfx_ctx_emscripten_webgl_destroy(void *data) +{ + emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; + + if (!emscripten) + return; + + emscripten_webgl_destroy_context(emscripten->ctx); + + free(data); +} + +static void *gfx_ctx_emscripten_webgl_init(void *video_driver) +{ + int width, height; + emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*) + calloc(1, sizeof(*emscripten)); + + EmscriptenWebGLContextAttributes attrs = {0}; + emscripten_webgl_init_context_attributes(&attrs); + attrs.alpha = false; + attrs.depth = true; + attrs.stencil = true; + attrs.antialias = false; + attrs.powerPreference = EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE; +#ifdef HAVE_OPENGLES3 + attrs.majorVersion = 2; +#else + attrs.majorVersion = 1; +#endif + attrs.minorVersion = 0; + attrs.enableExtensionsByDefault = true; +#ifdef PROXY_TO_PTHREAD + attrs.explicitSwapControl = true; +#else + attrs.explicitSwapControl = false; +#endif + attrs.renderViaOffscreenBackBuffer = false; + attrs.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_DISALLOW; + + if (!emscripten) + return NULL; + + emscripten->ctx = emscripten_webgl_create_context("#canvas", &attrs); + if (!emscripten->ctx) + { + RARCH_ERR("[EMSCRIPTEN/WebGL]: Failed to initialize webgl\n"); + goto error; + } + emscripten_webgl_get_drawing_buffer_size(emscripten->ctx, &width, &height); + emscripten_webgl_make_context_current(emscripten->ctx); + emscripten->fb_width = (unsigned)width; + emscripten->fb_height = (unsigned)height; + RARCH_LOG("[EMSCRIPTEN/WebGL]: Dimensions: %ux%u\n", emscripten->fb_width, emscripten->fb_height); + + return emscripten; + +error: + gfx_ctx_emscripten_webgl_destroy(video_driver); + return NULL; +} + +static bool gfx_ctx_emscripten_webgl_set_canvas_size(int width, int height) +{ +#ifdef NO_CANVAS_RESIZE + return false; +#endif + double dpr = platform_emscripten_get_dpr(); + EMSCRIPTEN_RESULT r = emscripten_set_element_css_size("#canvas", (double)width / dpr, (double)height / dpr); + RARCH_LOG("[EMSCRIPTEN/WebGL]: set canvas size to %d, %d\n", width, height); + + if (r != EMSCRIPTEN_RESULT_SUCCESS) + { + RARCH_ERR("[EMSCRIPTEN/WebGL]: error resizing canvas: %d\n", r); + return false; + } + return true; +} + +static bool gfx_ctx_emscripten_webgl_set_video_mode(void *data, + unsigned width, unsigned height, + bool fullscreen) +{ + emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; + if (!emscripten || !emscripten->ctx) + return false; + + if (width != 0 && height != 0) + { + if (!gfx_ctx_emscripten_webgl_set_canvas_size(width, height)) + return false; + } + emscripten->fb_width = width; + emscripten->fb_height = height; + + return true; +} + +bool gfx_ctx_emscripten_webgl_set_resize(void *data, unsigned width, unsigned height) +{ + emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; + if (!emscripten || !emscripten->ctx) + return false; + return gfx_ctx_emscripten_webgl_set_canvas_size(width, height); +} + +static enum gfx_ctx_api gfx_ctx_emscripten_webgl_get_api(void *data) { return GFX_CTX_OPENGL_ES_API; } + +static bool gfx_ctx_emscripten_webgl_bind_api(void *data, + enum gfx_ctx_api api, unsigned major, unsigned minor) +{ + return true; +} + +static void gfx_ctx_emscripten_webgl_input_driver(void *data, + const char *name, + input_driver_t **input, void **input_data) +{ + void *rwebinput = input_driver_init_wrap(&input_rwebinput, name); + *input = rwebinput ? &input_rwebinput : NULL; + *input_data = rwebinput; +} + +static bool gfx_ctx_emscripten_webgl_has_focus(void *data) +{ emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; return emscripten && emscripten->ctx; } @@ -279,7 +267,7 @@ const gfx_ctx_driver_t gfx_ctx_emscripten_webgl = { gfx_ctx_emscripten_webgl_translate_aspect, NULL, /* update_title */ gfx_ctx_emscripten_webgl_check_window, - gfx_ctx_emscripten_webgl_set_resize, /* set_resize */ + gfx_ctx_emscripten_webgl_set_resize, gfx_ctx_emscripten_webgl_has_focus, gfx_ctx_emscripten_webgl_suppress_screensaver, false, @@ -294,5 +282,5 @@ const gfx_ctx_driver_t gfx_ctx_emscripten_webgl = { gfx_ctx_emscripten_webgl_set_flags, gfx_ctx_emscripten_webgl_bind_hw_render, NULL, /* get_context_data */ - NULL /* make_current */ + NULL /* make_current */ }; diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 914aa039d9..f0a2cb15fc 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -45,6 +45,8 @@ #define MAX_TOUCH 32 +double platform_emscripten_get_dpr(void); + typedef struct rwebinput_key_to_code_map_entry { const char *key; @@ -299,7 +301,7 @@ static EM_BOOL rwebinput_mouse_cb(int event_type, } else { - double dpr = emscripten_get_device_pixel_ratio(); + double dpr = platform_emscripten_get_dpr(); rwebinput->mouse.x = (int)(mouse_event->targetX * dpr); rwebinput->mouse.y = (int)(mouse_event->targetY * dpr); } @@ -317,7 +319,7 @@ static EM_BOOL rwebinput_wheel_cb(int event_type, { rwebinput_input_t *rwebinput = (rwebinput_input_t*)user_data; - double dpr = emscripten_get_device_pixel_ratio(); + double dpr = platform_emscripten_get_dpr(); rwebinput->mouse.pending_scroll_x += wheel_event->deltaX * dpr; rwebinput->mouse.pending_scroll_y += wheel_event->deltaY * dpr; @@ -341,7 +343,7 @@ static EM_BOOL rwebinput_touch_cb(int event_type, if (!(touch_event->touches[touch].isChanged) && rwebinput->pointer[touch].id == touch_event->touches[touch].identifier) continue; - double dpr = emscripten_get_device_pixel_ratio(); + double dpr = platform_emscripten_get_dpr(); rwebinput->pointer[touch].x = (int)(touch_event->touches[touch].targetX * dpr); rwebinput->pointer[touch].y = (int)(touch_event->touches[touch].targetY * dpr); rwebinput->pointer[touch].id = touch_event->touches[touch].identifier; @@ -416,8 +418,9 @@ static void *rwebinput_input_init(const char *joypad_driver) rwebinput_generate_lut(); - r = emscripten_set_keydown_callback( - "#canvas", rwebinput, false, + input_keymaps_init_keyboard_lut(rarch_key_map_rwebinput); + + r = emscripten_set_keydown_callback("#canvas", rwebinput, false, rwebinput_keyboard_cb); if (r != EMSCRIPTEN_RESULT_SUCCESS) { @@ -425,8 +428,7 @@ static void *rwebinput_input_init(const char *joypad_driver) "[EMSCRIPTEN/INPUT] failed to create keydown callback: %d\n", r); } - r = emscripten_set_keyup_callback( - "#canvas", rwebinput, false, + r = emscripten_set_keyup_callback("#canvas", rwebinput, false, rwebinput_keyboard_cb); if (r != EMSCRIPTEN_RESULT_SUCCESS) { @@ -434,8 +436,7 @@ static void *rwebinput_input_init(const char *joypad_driver) "[EMSCRIPTEN/INPUT] failed to create keyup callback: %d\n", r); } - r = emscripten_set_keypress_callback( - "#canvas", rwebinput, false, + r = emscripten_set_keypress_callback("#canvas", rwebinput, false, rwebinput_keyboard_cb); if (r != EMSCRIPTEN_RESULT_SUCCESS) { @@ -467,8 +468,7 @@ static void *rwebinput_input_init(const char *joypad_driver) "[EMSCRIPTEN/INPUT] failed to create mousemove callback: %d\n", r); } - r = emscripten_set_wheel_callback( - "#canvas", rwebinput, false, + r = emscripten_set_wheel_callback("#canvas", rwebinput, false, rwebinput_wheel_cb); if (r != EMSCRIPTEN_RESULT_SUCCESS) { @@ -517,8 +517,6 @@ static void *rwebinput_input_init(const char *joypad_driver) "[EMSCRIPTEN/INPUT] failed to create pointerlockchange callback: %d\n", r); } - input_keymaps_init_keyboard_lut(rarch_key_map_rwebinput); - return rwebinput; } diff --git a/pkg/emscripten/libretro-thread/embed.html b/pkg/emscripten/libretro-thread/embed.html deleted file mode 100644 index 77deb34fa8..0000000000 --- a/pkg/emscripten/libretro-thread/embed.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - RetroArch Web Player - - - - - - - - - - - - - -
-
-
- - RetroArch Logo -
-
-
- - - - - - - - -
- - Become a patron -
- - diff --git a/pkg/emscripten/libretro-thread/index.html b/pkg/emscripten/libretro-thread/index.html index 7329c270de..211adf914a 100644 --- a/pkg/emscripten/libretro-thread/index.html +++ b/pkg/emscripten/libretro-thread/index.html @@ -1,203 +1,202 @@ - + - - - RetroArch Web Player - - - - - - - - - - - - - -
-
-
- -
- - RetroArch Logo -
-
- - - - - - - - + + + RetroArch Web Player + + + + + + + + + + + + +
+ +
+
+ +
+
+ + diff --git a/pkg/emscripten/libretro-thread/jsdeps/browserfs.min.js b/pkg/emscripten/libretro-thread/jsdeps/browserfs.min.js new file mode 100644 index 0000000000..673df5ef93 --- /dev/null +++ b/pkg/emscripten/libretro-thread/jsdeps/browserfs.min.js @@ -0,0 +1,15 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BrowserFS=e():t.BrowserFS=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){(function(t,r,i,o){"use strict";function s(t){if(t)return t;throw new Fe(be.EIO,"Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem)")}function a(t,e){switch(typeof t){case"number":return t;case"string":var n=parseInt(t,8);return isNaN(n)?e:n;default:return e}}function c(t){if(t instanceof Date)return t;if("number"==typeof t)return new Date(1e3*t);throw new Fe(be.EINVAL,"Invalid time.")}function u(t){if(t.indexOf("\0")>=0)throw new Fe(be.EINVAL,"Path must be a string without null bytes.");if(""===t)throw new Fe(be.EINVAL,"Path must not be empty.");return ke.resolve(t)}function f(t,e,n,r){switch(typeof t){case"object":return{encoding:"undefined"!=typeof t.encoding?t.encoding:e,flag:"undefined"!=typeof t.flag?t.flag:n,mode:a(t.mode,r)};case"string":return{encoding:t,flag:n,mode:r};default:return{encoding:e,flag:n,mode:r}}}function h(){}function p(t,e,n,r,i){return tn?n+1:t+1:r===i?e:e+1}function l(t,e){if(t===e)return 0;if(t.length>e.length){var n=t;t=e,e=n}for(var r=t.length,i=e.length;r>0&&t.charCodeAt(r-1)===e.charCodeAt(i-1);)r--,i--;for(var o=0;ob?b+1:I+1:S===s[r+k]?u:u+1,u=I}}return b}function d(t,e,n){t&&console.warn("["+e+"] Direct file system constructor usage is deprecated for this file system, and will be removed in the next major version. Please use the '"+e+".Create("+JSON.stringify(n)+", callback)' method instead. See https://github.com/jvilk/BrowserFS/issues/176 for more details.")}function y(){throw new Error("BFS has reached an impossible code path; please file a bug.")}function g(t,e,n){n.existsSync(t)||(g(ke.dirname(t),e,n),n.mkdirSync(t,e))}function v(t){var e=m(t),n=e.byteOffset,r=e.byteLength;return 0===n&&r===e.buffer.byteLength?e.buffer:e.buffer.slice(n,n+r)}function m(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function _(e){return e instanceof t?e:e instanceof Uint8Array?w(e):t.from(e)}function w(e){return e instanceof t?e:0===e.byteOffset&&e.byteLength===e.buffer.byteLength?E(e.buffer):t.from(e.buffer,e.byteOffset,e.byteLength)}function E(e){return t.from(e)}function b(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=t.length),e<0||n<0||n>t.length||e>n)throw new TypeError("Invalid slice bounds on buffer of length "+t.length+": ["+e+", "+n+"]");if(0===t.length)return S();var r=m(t),i=t[0],o=(i+1)%255;return t[0]=o,r[0]===o?(r[0]=i,w(r.slice(e,n))):(t[0]=i,w(r.subarray(e,n)))}function S(){return je?je:je=t.alloc(0)}function k(e,n){t.isBuffer(e)?n():n(new Fe(be.EINVAL,"option must be a Buffer."))}function I(t,e,n){function r(t){a||(t&&(a=!0,n(t)),s--,0===s&&c&&n())}var i=t.Options,o=t.Name,s=0,a=!1,c=!1,u=function(t){if(i.hasOwnProperty(t)){var c=i[t],u=e[t];if(void 0===u||null===u){if(!c.optional){var f=Object.keys(e).filter(function(t){return!(t in i)}).map(function(e){return{str:e,distance:l(t,e)}}).filter(function(t){return t.distance<5}).sort(function(t,e){return t.distance-e.distance});return a?{}:(a=!0,{v:n(new Fe(be.EINVAL,"["+o+"] Required option '"+t+"' not provided."+(f.length>0?" You provided unrecognized option '"+f[0].str+"'; perhaps you meant to type '"+t+"'.":"")+"\nOption description: "+c.description))})}}else{var h=!1;if(h=Array.isArray(c.type)?c.type.indexOf(typeof u)!==-1:typeof u===c.type,!h)return a?{}:(a=!0,{v:n(new Fe(be.EINVAL,"["+o+"] Value provided for option "+t+" is not the proper type. Expected "+(Array.isArray(c.type)?"one of {"+c.type.join(", ")+"}":c.type)+", but received "+typeof u+"\nOption description: "+c.description))});c.validator&&(s++,c.validator(u,r))}}};for(var f in i){var h=u(f);if(h)return h.v}c=!0,0!==s||a||n()}function O(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function F(t,e,n){return e=Ge(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Ge(r.length-e,0),s=Array(o);++i-1&&t%1==0&&t<=vn}function U(t){return null!=t&&C(t.length)&&!P(t)}function M(){}function j(t){return function(){if(null!==t){var e=t;t=null,e.apply(this,arguments)}}}function B(t,e){for(var n=-1,r=Array(t);++n-1&&t%1==0&&t0?"/"+i.join("/"):e)}function St(t,e){if(null!==e&&"object"==typeof e){var n=e,r=n.path;r&&(r="/"+ke.relative(t,r),n.message=n.message.replace(n.path,r),n.path=r)}return e}function kt(t,e){return"function"==typeof e?function(n){arguments.length>0&&(arguments[0]=St(t,n)),e.apply(null,arguments)}:e}function It(t,e,n){return"Sync"!==t.slice(t.length-4)?function(){return arguments.length>0&&(e&&(arguments[0]=ke.join(this._folder,arguments[0])),n&&(arguments[1]=ke.join(this._folder,arguments[1])),arguments[arguments.length-1]=kt(this._folder,arguments[arguments.length-1])),this._wrapped[t].apply(this._wrapped,arguments)}:function(){try{return e&&(arguments[0]=ke.join(this._folder,arguments[0])),n&&(arguments[1]=ke.join(this._folder,arguments[1])),this._wrapped[t].apply(this._wrapped,arguments)}catch(t){throw St(this._folder,t)}}}function Ot(t){return t.isDirectory}function Ft(t,e,n,r){if("undefined"!=typeof navigator.webkitPersistentStorage)switch(t){case ti.PERSISTENT:navigator.webkitPersistentStorage.requestQuota(e,n,r);break;case ti.TEMPORARY:navigator.webkitTemporaryStorage.requestQuota(e,n,r);break;default:r(new TypeError("Invalid storage type: "+t))}else ti.webkitStorageInfo.requestQuota(t,e,n,r)}function Nt(t){return Array.prototype.slice.call(t||[],0)}function Rt(t,e,n){switch(t.name){case"PathExistsError":return Fe.EEXIST(e);case"QuotaExceededError":return Fe.FileError(be.ENOSPC,e);case"NotFoundError":return Fe.ENOENT(e);case"SecurityError":return Fe.FileError(be.EACCES,e);case"InvalidModificationError":return Fe.FileError(be.EPERM,e);case"TypeMismatchError":return Fe.FileError(n?be.ENOTDIR:be.EISDIR,e);case"EncodingError":case"InvalidStateError":case"NoModificationAllowedError":default:return Fe.FileError(be.EINVAL,e)}}function Lt(){return si?si:si=t.from("{}")}function Tt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"===t?e:3&e|8;return n.toString(16)})}function xt(t,e){return!t||(e(t),!1)}function At(t,e,n){return!t||(e.abort(function(){n(t)}),!1)}function Dt(t,e){switch(void 0===e&&(e=t.toString()),t.name){case"NotFoundError":return new Fe(be.ENOENT,e);case"QuotaExceededError":return new Fe(be.ENOSPC,e);default:return new Fe(be.EIO,e)}}function Pt(t,e,n){return void 0===e&&(e=be.EIO),void 0===n&&(n=null),function(r){r.preventDefault(),t(new Fe(e,null!==n?n:void 0))}}function Ct(t,e,n){return e?function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r=e[0],i=this._getFs(r);e[0]=i.path;try{return i.fs[t].apply(i.fs,e)}catch(t){throw this.standardizeError(t,i.path,r),t}}:function(){for(var e=this,n=[],r=arguments.length;r--;)n[r]=arguments[r];var i=n[0],o=this._getFs(i);if(n[0]=o.path,"function"==typeof n[n.length-1]){var s=n[n.length-1];n[n.length-1]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];t.length>0&&t[0]instanceof Fe&&e.standardizeError(t[0],o.path,i),s.apply(null,t)}}return o.fs[t].apply(o.fs,n)}}function Ut(t){return 146|t}function Mt(t){return Re.getFileFlag(t)}function jt(t){return{type:Wi.API_ERROR,errorData:Yt(t.writeToBuffer())}}function Bt(t){return Fe.fromBuffer(Xt(t.errorData))}function zt(t){return{type:Wi.ERROR,name:t.name,message:t.message,stack:t.stack}}function qt(t){var e=ti[t.name];"function"!=typeof e&&(e=Error);var n=new e(t.message);return n.stack=t.stack,n}function Vt(t){return{type:Wi.STATS,statsData:Yt(t.toBuffer())}}function Wt(t){return Te.fromBuffer(Xt(t.statsData))}function Ht(t){return{type:Wi.FILEFLAG,flagStr:t.getFlagString()}}function Zt(t){return Re.getFileFlag(t.flagStr)}function Yt(t){return v(t)}function Xt(t){return E(t)}function Kt(t){return{type:Wi.BUFFER,data:Yt(t)}}function Jt(t){return Xt(t.data)}function Gt(t){return t&&"object"==typeof t&&t.hasOwnProperty("browserfsMessage")&&t.browserfsMessage}function Qt(t){return t&&"object"==typeof t&&t.hasOwnProperty("browserfsMessage")&&t.browserfsMessage}function $t(e,n,r){var i=new XMLHttpRequest;i.open("GET",e,!0);var o=!0;switch(n){case"buffer":i.responseType="arraybuffer";break;case"json":try{i.responseType="json",o="json"===i.responseType}catch(t){o=!1}break;default:return r(new Fe(be.EINVAL,"Invalid download type: "+n))}i.onreadystatechange=function(e){if(4===i.readyState){if(200!==i.status)return r(new Fe(i.status,"XHR error."));switch(n){case"buffer":return r(null,i.response?t.from(i.response):S());case"json":return o?r(null,i.response):r(null,JSON.parse(i.responseText))}}},i.send()}function te(e,n){var r=new XMLHttpRequest;r.open("GET",e,!1);var i=null,o=null;if(r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(e){if(4===r.readyState){if(200!==r.status)return void(o=new Fe(r.status,"XHR error."));switch(n){case"buffer":var s=r.responseText;i=t.alloc(s.length);for(var a=0;a>5&15)-1,i=(e>>9)+1980,o=31&t,s=t>>5&63,a=t>>11;return new Date(i,r,n,a,s,o)}function ue(t,e,n,r){return 0===r?"":e?t.toString("utf8",n,n+r):eo.byte2str(t.slice(n,n+r))}function fe(t,e,n){return t.toString("ascii",e,e+n).trim()}function he(t,e,n){if(1===n)return String.fromCharCode(t[e]);for(var r=Math.floor(n/2),i=new Array(r),o=0;othis._buffer.length){var n=t.alloc(e-this._buffer.length,0);return this.writeSync(n,0,n.length,this._buffer.length),void(this._flag.isSynchronous()&&Pe.getRootFS().supportsSynch()&&this.syncSync())}this._stat.size=e;var r=t.alloc(e);this._buffer.copy(r,0,0,e),this._buffer=r,this._flag.isSynchronous()&&Pe.getRootFS().supportsSynch()&&this.syncSync()},n.prototype.write=function(t,e,n,r,i){try{i(null,this.writeSync(t,e,n,r),t)}catch(t){i(t)}},n.prototype.writeSync=function(e,n,r,i){if(this._dirty=!0,void 0!==i&&null!==i||(i=this.getPos()),!this._flag.isWriteable())throw new Fe(be.EPERM,"File not opened with a writeable mode.");var o=i+r;if(o>this._stat.size&&(this._stat.size=o,o>this._buffer.length)){var s=t.alloc(o);this._buffer.copy(s),this._buffer=s}var a=e.copy(this._buffer,i,n,n+r);return this._stat.mtime=new Date,this._flag.isSynchronous()?(this.syncSync(),a):(this.setPos(i+a),a)},n.prototype.read=function(t,e,n,r,i){try{i(null,this.readSync(t,e,n,r),t)}catch(t){i(t)}},n.prototype.readSync=function(t,e,n,r){if(!this._flag.isReadable())throw new Fe(be.EPERM,"File not opened with a readable mode.");void 0!==r&&null!==r||(r=this.getPos());var i=r+n;i>this._stat.size&&(n=this._stat.size-r);var o=this._buffer.copy(t,e,r,r+n);return this._stat.atime=new Date,this._pos=r+n,o},n.prototype.chmod=function(t,e){try{this.chmodSync(t),e()}catch(t){e(t)}},n.prototype.chmodSync=function(t){if(!this._fs.supportsProps())throw new Fe(be.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()},n.prototype.isDirty=function(){return this._dirty},n.prototype.resetDirty=function(){this._dirty=!1},n}(Ze),Xe=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){t()},e.prototype.syncSync=function(){},e.prototype.close=function(t){t()},e.prototype.closeSync=function(){},e}(Ye),Ke=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.syncSync=function(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())},e.prototype.closeSync=function(){this.syncSync()},e}(Ye),Je=function(t){function e(n,r,i){if(void 0===i&&(i=!0),t.call(this),this._queue=[],this._queueRunning=!1,this._isInitialized=!1,this._initializeCallbacks=[],this._sync=n,this._async=r,!n.supportsSynch())throw new Error("The first argument to AsyncMirror needs to be a synchronous file system.");d(i,e.Name,{sync:"sync file system instance",async:"async file system instance"})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){try{var r=new e(t.sync,t.async,!1);r.initialize(function(t){t?n(t):n(null,r)},!1)}catch(t){n(t)}},e.isAvailable=function(){return!0},e.prototype.getName=function(){return e.Name},e.prototype._syncSync=function(t){this._sync.writeFileSync(t.getPath(),t.getBuffer(),null,Re.getFileFlag("w"),t.getStats().mode),this.enqueueOp({apiMethod:"writeFile",arguments:[t.getPath(),t.getBuffer(),null,t.getFlag(),t.getStats().mode]})},e.prototype.initialize=function(t,e){var n=this;void 0===e&&(e=!0),e&&console.warn("[AsyncMirror] AsyncMirror.initialize() is deprecated and will be removed in the next major version. Please use 'AsyncMirror.Create({ sync: (sync file system instance), async: (async file system instance)}, cb)' to create and initialize AsyncMirror instances.");var r=this._initializeCallbacks,i=function(t){n._isInitialized=!t,n._initializeCallbacks=[],r.forEach(function(e){return e(t)})};if(this._isInitialized)t();else if(1===r.push(t)){var o=function(t,e,r){"/"!==t&&n._sync.mkdirSync(t,e),n._async.readdir(t,function(e,n){function i(e){e?r(e):o0){var r=e._queue.shift(),i=r.arguments;i.push(n),e._async[r.apiMethod].apply(e._async,i)}else e._queueRunning=!1};n()}},e}(He);Je.Name="AsyncMirror",Je.Options={sync:{type:"object",description:"The synchronous file system to mirror the asynchronous file system to."},async:{type:"object",description:"The asynchronous file system to mirror."}};var Ge=Math.max,Qe=function(t){return R(function(e){var n=e.pop();t.call(this,e,n)})},$e="object"==typeof r&&r&&r.Object===Object&&r,tn="object"==typeof self&&self&&self.Object===Object&&self,en=$e||tn||Function("return this")(),nn=en.Symbol,rn=Object.prototype,on=rn.hasOwnProperty,sn=rn.toString,an=nn?nn.toStringTag:void 0,cn=Object.prototype,un=cn.toString,fn="[object Null]",hn="[object Undefined]",pn=nn?nn.toStringTag:void 0,ln="[object AsyncFunction]",dn="[object Function]",yn="[object GeneratorFunction]",gn="[object Proxy]",vn=9007199254740991,mn={},_n="function"==typeof Symbol&&Symbol.iterator,wn=function(t){return _n&&t[_n]&&t[_n]()},En="[object Arguments]",bn=Object.prototype,Sn=bn.hasOwnProperty,kn=bn.propertyIsEnumerable,In=q(function(){return arguments}())?q:function(t){return z(t)&&Sn.call(t,"callee")&&!kn.call(t,"callee")},On=Array.isArray,Fn="object"==typeof e&&e&&!e.nodeType&&e,Nn=Fn&&"object"==typeof i&&i&&!i.nodeType&&i,Rn=Nn&&Nn.exports===Fn,Ln=Rn?en.Buffer:void 0,Tn=Ln?Ln.isBuffer:void 0,xn=Tn||V,An=9007199254740991,Dn=/^(?:0|[1-9]\d*)$/,Pn="[object Arguments]",Cn="[object Array]",Un="[object Boolean]",Mn="[object Date]",jn="[object Error]",Bn="[object Function]",zn="[object Map]",qn="[object Number]",Vn="[object Object]",Wn="[object RegExp]",Hn="[object Set]",Zn="[object String]",Yn="[object WeakMap]",Xn="[object ArrayBuffer]",Kn="[object DataView]",Jn="[object Float32Array]",Gn="[object Float64Array]",Qn="[object Int8Array]",$n="[object Int16Array]",tr="[object Int32Array]",er="[object Uint8Array]",nr="[object Uint8ClampedArray]",rr="[object Uint16Array]",ir="[object Uint32Array]",or={};or[Jn]=or[Gn]=or[Qn]=or[$n]=or[tr]=or[er]=or[nr]=or[rr]=or[ir]=!0,or[Pn]=or[Cn]=or[Xn]=or[Un]=or[Kn]=or[Mn]=or[jn]=or[Bn]=or[zn]=or[qn]=or[Vn]=or[Wn]=or[Hn]=or[Zn]=or[Yn]=!1;var sr="object"==typeof e&&e&&!e.nodeType&&e,ar=sr&&"object"==typeof i&&i&&!i.nodeType&&i,cr=ar&&ar.exports===sr,ur=cr&&$e.process,fr=function(){try{return ur&&ur.binding&&ur.binding("util")}catch(t){}}(),hr=fr&&fr.isTypedArray,pr=hr?Z(hr):H,lr=Object.prototype,dr=lr.hasOwnProperty,yr=Object.prototype,gr=K(Object.keys,Object),vr=Object.prototype,mr=vr.hasOwnProperty,_r=ot(it,1/0),wr=function(t,e,n){var r=U(t)?st:_r;r(t,e,n)},Er=at(ct);L(Er);var br=ut(ct),Sr=ot(br,1);L(Sr),R(function(t,e){return R(function(n){return t.apply(null,e.concat(n))})});var kr,Ir=(ht(),"\\ud800-\\udfff"),Or="\\u0300-\\u036f",Fr="\\ufe20-\\ufe2f",Nr="\\u20d0-\\u20ff",Rr=Or+Fr+Nr,Lr="\\ufe0e\\ufe0f",Tr="["+Ir+"]",xr="["+Rr+"]",Ar="\\ud83c[\\udffb-\\udfff]",Dr="(?:"+xr+"|"+Ar+")",Pr="[^"+Ir+"]",Cr="(?:\\ud83c[\\udde6-\\uddff]){2}",Ur="[\\ud800-\\udbff][\\udc00-\\udfff]",Mr="\\u200d",jr=Dr+"?",Br="["+Lr+"]?",zr=("(?:"+Mr+"(?:"+[Pr,Cr,Ur].join("|")+")"+Br+jr+")*","(?:"+[Pr+xr+"?",xr,Cr,Ur,Tr].join("|")+")","function"==typeof setImmediate&&setImmediate),qr="object"==typeof o&&"function"==typeof o.nextTick;kr=zr?setImmediate:qr?o.nextTick:pt,lt(kr);var Vr=ot(it,1),Wr=R(function(t){return R(function(e){var n=this,r=e[e.length-1];"function"==typeof r?e.pop():r=M,dt(t,e,function(t,e,r){e.apply(n,t.concat(R(function(t,e){r(t,e)})))},function(t,e){r.apply(n,[t].concat(e))})})});R(function(t){return Wr.apply(null,t.reverse())}),R(function(t){var e=[null].concat(t);return Qe(function(t,n){return n.apply(this,e)})}),yt("dir"),yt("log");var Hr;Hr=qr?o.nextTick:zr?setImmediate:pt,lt(Hr);var Zr,Yr=(Math.ceil,Math.max,function(t){this._cache={},this._client=t});Yr.prototype.readdir=function(t,e){var n=this,r=this.getCachedDirInfo(t);this._wrap(function(e){null!==r&&r.contents?n._client.readdir(t,{contentHash:r.stat.contentHash},e):n._client.readdir(t,e)},function(i,o,s,a){i?i.status===Dropbox.ApiError.NO_CONTENT&&null!==r?e(null,r.contents.slice(0)):e(i):(n.updateCachedDirInfo(t,s,o.slice(0)),a.forEach(function(e){n.updateCachedInfo(ke.join(t,e.name),e)}),e(null,o))})},Yr.prototype.remove=function(t,e){var n=this;this._wrap(function(e){n._client.remove(t,e)},function(r,i){r||n.updateCachedInfo(t,i),e(r)})},Yr.prototype.move=function(t,e,n){var r=this;this._wrap(function(n){r._client.move(t,e,n)},function(i,o){i||(r.deleteCachedInfo(t),r.updateCachedInfo(e,o)),n(i)})},Yr.prototype.stat=function(t,e){var n=this;this._wrap(function(e){n._client.stat(t,e)},function(r,i){r||n.updateCachedInfo(t,i),e(r,i)})},Yr.prototype.readFile=function(t,e){var n=this,r=this.getCachedFileInfo(t);null!==r&&null!==r.contents?this.stat(t,function(i,o){i?e(i):o.contentHash===r.stat.contentHash?e(i,r.contents.slice(0),r.stat):n.readFile(t,e)}):this._wrap(function(e){n._client.readFile(t,{arrayBuffer:!0},e)},function(r,i,o){r||n.updateCachedInfo(t,o,i.slice(0)),e(r,i,o)})},Yr.prototype.writeFile=function(t,e,n){var r=this;this._wrap(function(n){r._client.writeFile(t,e,n)},function(i,o){i||r.updateCachedInfo(t,o,e.slice(0)),n(i,o)})},Yr.prototype.mkdir=function(t,e){var n=this;this._wrap(function(e){n._client.mkdir(t,e)},function(r,i){r||n.updateCachedInfo(t,i,[]),e(r)})},Yr.prototype._wrap=function(t,e){var n=0,r=function(i){var o=2;if(i&&3>++n)switch(i.status){case Dropbox.ApiError.SERVER_ERROR:case Dropbox.ApiError.NETWORK_ERROR:case Dropbox.ApiError.RATE_LIMITED:setTimeout(function(){t(r)},1e3*o);break;default:e.apply(null,arguments)}else e.apply(null,arguments)};t(r)},Yr.prototype.getCachedInfo=function(t){return this._cache[t.toLowerCase()]},Yr.prototype.putCachedInfo=function(t,e){this._cache[t.toLowerCase()]=e},Yr.prototype.deleteCachedInfo=function(t){delete this._cache[t.toLowerCase()]},Yr.prototype.getCachedDirInfo=function(t){var e=this.getCachedInfo(t);return wt(e)?e:null},Yr.prototype.getCachedFileInfo=function(t){var e=this.getCachedInfo(t);return _t(e)?e:null},Yr.prototype.updateCachedDirInfo=function(t,e,n){void 0===n&&(n=null);var r=this.getCachedInfo(t);null===e.contentHash||void 0!==r&&r.stat.contentHash===e.contentHash||this.putCachedInfo(t,{stat:e,contents:n})},Yr.prototype.updateCachedFileInfo=function(t,e,n){void 0===n&&(n=null);var r=this.getCachedInfo(t);null===e.versionTag||void 0!==r&&r.stat.versionTag===e.versionTag||this.putCachedInfo(t,{stat:e,contents:n})},Yr.prototype.updateCachedInfo=function(t,e,n){void 0===n&&(n=null),e.isFile&&Et(n)?this.updateCachedFileInfo(t,e,n):e.isFolder&&Array.isArray(n)&&this.updateCachedDirInfo(t,e,n)};var Xr=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;if(this.isDirty()){var n=this.getBuffer(),r=v(n);this._fs._writeFileStrict(this.getPath(),r,function(n){n||e.resetDirty(),t(n)})}else t()},e.prototype.close=function(t){this.sync(t)},e}(Ye),Kr=function(t){function e(n,r){void 0===r&&(r=!0),t.call(this),this._client=new Yr(n),d(r,e.Name,{client:"authenticated dropbox client instance"}),mt()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){n(null,new e(t.client,!1))},e.isAvailable=function(){return"undefined"!=typeof Dropbox},e.prototype.getName=function(){return e.Name},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSymlinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!1},e.prototype.empty=function(t){var e=this;this._client.readdir("/",function(n,r){if(n)t(e.convert(n,"/"));else{var i=function(t,n){var r=ke.join("/",t);e._client.remove(r,function(t){n(t?e.convert(t,r):null)})},o=function(e){e?t(e):t()};vt(r,i,o)}})},e.prototype.rename=function(t,e,n){var r=this;this._client.move(t,e,function(i){i?r._client.stat(e,function(o,s){if(o||s.isFolder){var a=i.response.error.indexOf(t)>-1?t:e; +n(r.convert(i,a))}else r._client.remove(e,function(i){i?n(r.convert(i,e)):r.rename(t,e,n)})}):n()})},e.prototype.stat=function(t,e,n){var r=this;this._client.stat(t,function(e,i){if(e)n(r.convert(e,t));else{if(!i||!i.isRemoved){var o=new Te(r._statType(i),i.size);return n(null,o)}n(Fe.FileError(be.ENOENT,t))}})},e.prototype.open=function(t,e,n,r){var i=this;this._client.readFile(t,function(n,o,s){if(!n){var a;a=null===o?S():E(o);var c=i._makeFile(t,e,s,a);return r(null,c)}if(e.isReadable())r(i.convert(n,t));else switch(n.status){case Dropbox.ApiError.NOT_FOUND:var u=new ArrayBuffer(0);return i._writeFileStrict(t,u,function(n,o){if(n)r(n);else{var s=i._makeFile(t,e,o,E(u));r(null,s)}});default:return r(i.convert(n,t))}})},e.prototype._writeFileStrict=function(t,e,n){var r=this,i=ke.dirname(t);this.stat(i,!1,function(o,s){o?n(Fe.FileError(be.ENOENT,i)):r._client.writeFile(t,e,function(e,i){e?n(r.convert(e,t)):n(null,i)})})},e.prototype._statType=function(t){return t.isFile?Le.FILE:Le.DIRECTORY},e.prototype._makeFile=function(t,e,n,r){var i=this._statType(n),o=new Te(i,n.size);return new Xr(this,t,e,o,r)},e.prototype._remove=function(t,e,n){var r=this;this._client.stat(t,function(i,o){i?e(r.convert(i,t)):o.isFile&&!n?e(Fe.FileError(be.ENOTDIR,t)):!o.isFile&&n?e(Fe.FileError(be.EISDIR,t)):r._client.remove(t,function(n){e(n?r.convert(n,t):null)})})},e.prototype.unlink=function(t,e){this._remove(t,e,!0)},e.prototype.rmdir=function(t,e){this._remove(t,e,!1)},e.prototype.mkdir=function(t,e,n){var r=this,i=ke.dirname(t);this._client.stat(i,function(e,o){e?n(r.convert(e,i)):r._client.mkdir(t,function(e){n(e?Fe.FileError(be.EEXIST,t):null)})})},e.prototype.readdir=function(t,e){var n=this;this._client.readdir(t,function(t,r){return t?e(n.convert(t)):e(null,r)})},e.prototype.convert=function(t,e){void 0===e&&(e=null);var n=Zr[t.status];return void 0===n&&(n=be.EIO),e?Fe.FileError(n,e):new Fe(n)},e}(We);Kr.Name="Dropbox",Kr.Options={client:{type:"object",description:"An *authenticated* Dropbox client. Must be from the 0.10 JS SDK.",validator:function(t,e){t.isAuthenticated&&t.isAuthenticated()?e():e(new Fe(be.EINVAL,"'client' option must be an authenticated Dropbox client from the v0.10 JS SDK."))}}};var Jr=function(t){function e(e,n,r,i){t.call(this),this._fs=e,this._FS=n,this._path=r,this._stream=i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getPos=function(){},e.prototype.close=function(t){var e=null;try{this.closeSync()}catch(t){e=t}finally{t(e)}},e.prototype.closeSync=function(){try{this._FS.close(this._stream)}catch(t){throw bt(t,this._path)}},e.prototype.stat=function(t){try{t(null,this.statSync())}catch(e){t(e)}},e.prototype.statSync=function(){try{return this._fs.statSync(this._path,!1)}catch(t){throw bt(t,this._path)}},e.prototype.truncate=function(t,e){var n=null;try{this.truncateSync(t)}catch(t){n=t}finally{e(n)}},e.prototype.truncateSync=function(t){try{this._FS.ftruncate(this._stream.fd,t)}catch(t){throw bt(t,this._path)}},e.prototype.write=function(t,e,n,r,i){try{i(null,this.writeSync(t,e,n,r),t)}catch(t){i(t)}},e.prototype.writeSync=function(t,e,n,r){try{var i=m(t),o=null===r?void 0:r;return this._FS.write(this._stream,i,e,n,o)}catch(t){throw bt(t,this._path)}},e.prototype.read=function(t,e,n,r,i){try{i(null,this.readSync(t,e,n,r),t)}catch(t){i(t)}},e.prototype.readSync=function(t,e,n,r){try{var i=m(t),o=null===r?void 0:r;return this._FS.read(this._stream,i,e,n,o)}catch(t){throw bt(t,this._path)}},e.prototype.sync=function(t){t()},e.prototype.syncSync=function(){},e.prototype.chown=function(t,e,n){var r=null;try{this.chownSync(t,e)}catch(t){r=t}finally{n(r)}},e.prototype.chownSync=function(t,e){try{this._FS.fchown(this._stream.fd,t,e)}catch(t){throw bt(t,this._path)}},e.prototype.chmod=function(t,e){var n=null;try{this.chmodSync(t)}catch(t){n=t}finally{e(n)}},e.prototype.chmodSync=function(t){try{this._FS.fchmod(this._stream.fd,t)}catch(t){throw bt(t,this._path)}},e.prototype.utimes=function(t,e,n){var r=null;try{this.utimesSync(t,e)}catch(t){r=t}finally{n(r)}},e.prototype.utimesSync=function(t,e){this._fs.utimesSync(this._path,t,e)},e}(Ze),Gr=function(e){function n(t){e.call(this),this._FS=t}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.Create=function(t,e){e(null,new n(t.FS))},n.isAvailable=function(){return!0},n.prototype.getName=function(){return this._FS.DB_NAME()},n.prototype.isReadOnly=function(){return!1},n.prototype.supportsLinks=function(){return!0},n.prototype.supportsProps=function(){return!0},n.prototype.supportsSynch=function(){return!0},n.prototype.renameSync=function(t,e){try{this._FS.rename(t,e)}catch(n){throw n.errno===be.ENOENT?bt(n,this.existsSync(t)?e:t):bt(n)}},n.prototype.statSync=function(t,e){try{var n=e?this._FS.lstat(t):this._FS.stat(t),r=this.modeToFileType(n.mode);return new Te(r,n.size,n.mode,n.atime,n.mtime,n.ctime)}catch(e){throw bt(e,t)}},n.prototype.openSync=function(t,e,n){try{var r=this._FS.open(t,e.getFlagString(),n);if(this._FS.isDir(r.node.mode))throw this._FS.close(r),Fe.EISDIR(t);return new Jr(this,this._FS,t,r)}catch(e){throw bt(e,t)}},n.prototype.unlinkSync=function(t){try{this._FS.unlink(t)}catch(e){throw bt(e,t)}},n.prototype.rmdirSync=function(t){try{this._FS.rmdir(t)}catch(e){throw bt(e,t)}},n.prototype.mkdirSync=function(t,e){try{this._FS.mkdir(t,e)}catch(e){throw bt(e,t)}},n.prototype.readdirSync=function(t){try{return this._FS.readdir(t).filter(function(t){return"."!==t&&".."!==t})}catch(e){throw bt(e,t)}},n.prototype.truncateSync=function(t,e){try{this._FS.truncate(t,e)}catch(e){throw bt(e,t)}},n.prototype.readFileSync=function(t,e,n){try{var r=this._FS.readFile(t,{flags:n.getFlagString()}),i=w(r);return e?i.toString(e):i}catch(e){throw bt(e,t)}},n.prototype.writeFileSync=function(e,n,r,i,o){try{r&&(n=t.from(n,r));var s=m(n);this._FS.writeFile(e,s,{flags:i.getFlagString(),encoding:"binary"}),this._FS.chmod(e,o)}catch(t){throw bt(t,e)}},n.prototype.chmodSync=function(t,e,n){try{e?this._FS.lchmod(t,n):this._FS.chmod(t,n)}catch(e){throw bt(e,t)}},n.prototype.chownSync=function(t,e,n,r){try{e?this._FS.lchown(t,n,r):this._FS.chown(t,n,r)}catch(e){throw bt(e,t)}},n.prototype.symlinkSync=function(t,e,n){try{this._FS.symlink(t,e)}catch(t){throw bt(t)}},n.prototype.readlinkSync=function(t){try{return this._FS.readlink(t)}catch(e){throw bt(e,t)}},n.prototype.utimesSync=function(t,e,n){try{this._FS.utime(t,e.getTime(),n.getTime())}catch(e){throw bt(e,t)}},n.prototype.modeToFileType=function(t){if(this._FS.isDir(t))return Le.DIRECTORY;if(this._FS.isFile(t))return Le.FILE;if(this._FS.isLink(t))return Le.SYMLINK;throw Fe.EPERM("Invalid mode: "+t)},n}(He);Gr.Name="EmscriptenFileSystem",Gr.Options={FS:{type:"object",description:"The Emscripten file system to use (the `FS` variable)"}};var Qr=function(t){function e(e,n){t.call(this),this._folder=e,this._wrapped=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){n(null,new e(t.folder,t.wrapped))},e.isAvailable=function(){return!0},e.prototype.initialize=function(t){var e=this;this._wrapped.exists(this._folder,function(n){n?t():e._wrapped.isReadOnly()?t(Fe.ENOENT(e._folder)):e._wrapped.mkdir(e._folder,511,t)})},e.prototype.getName=function(){return this._wrapped.getName()},e.prototype.isReadOnly=function(){return this._wrapped.isReadOnly()},e.prototype.supportsProps=function(){return this._wrapped.supportsProps()},e.prototype.supportsSynch=function(){return this._wrapped.supportsSynch()},e.prototype.supportsLinks=function(){return!1},e}(We);Qr.Name="FolderAdapter",Qr.Options={folder:{type:"string",description:"The folder to use as the root directory"},wrapped:{type:"object",description:"The file system to wrap"}},["diskSpace","stat","statSync","open","openSync","unlink","unlinkSync","rmdir","rmdirSync","mkdir","mkdirSync","readdir","readdirSync","exists","existsSync","realpath","realpathSync","truncate","truncateSync","readFile","readFileSync","writeFile","writeFileSync","appendFile","appendFileSync","chmod","chmodSync","chown","chownSync","utimes","utimesSync","readlink","readlinkSync"].forEach(function(t){Qr.prototype[t]=It(t,!0,!1)}),["rename","renameSync","link","linkSync","symlink","symlinkSync"].forEach(function(t){Qr.prototype[t]=It(t,!0,!0)});var $r;$r="undefined"!=typeof window?window:"undefined"!=typeof self?self:r;var ti=$r,ei=ti.webkitRequestFileSystem||ti.requestFileSystem||null,ni=function(t){function e(e,n,r,i,o,s){t.call(this,e,r,i,o,s),this._entry=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;return this.isDirty()?void this._entry.createWriter(function(n){var r=e.getBuffer(),i=new Blob([v(r)]),o=i.size;n.onwriteend=function(r){n.onwriteend=null,n.onerror=null,n.truncate(o),e.resetDirty(),t()},n.onerror=function(n){t(Rt(n,e.getPath(),!1))},n.write(i)}):t()},e.prototype.close=function(t){this.sync(t)},e}(Ye),ri=function(t){function e(n,r,i){void 0===n&&(n=5),void 0===r&&(r=ti.PERSISTENT),void 0===i&&(i=!0),t.call(this),this.size=1048576*n,this.type=r,d(i,e.Name,{size:n,type:r})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){var r=new e(t.size,t.type,!1);r.allocate(function(t){return t?n(t):n(null,r)},!1)},e.isAvailable=function(){return!!ei},e.prototype.getName=function(){return e.Name},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSymlinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!1},e.prototype.allocate=function(t,e){var n=this;void 0===t&&(t=function(){}),void 0===e&&(e=!0),e&&console.warn("[HTML5FS] HTML5FS.allocate() is deprecated and will be removed in the next major release. Please use 'HTML5FS.Create({type: "+this.type+", size: "+this.size+"}, cb)' to create and allocate HTML5FS instances.");var r=function(e){n.fs=e,t()},i=function(e){t(Rt(e,"/",!0))};this.type===ti.PERSISTENT?Ft(this.type,this.size,function(t){ei(n.type,t,r,i)},i):ei(this.type,this.size,r,i)},e.prototype.empty=function(t){this._readdir("/",function(e,n){if(e)console.error("Failed to empty FS"),t(e);else{var r=function(n){e?(console.error("Failed to empty FS"),t(e)):t()},i=function(t,e){var n=function(){e()},r=function(n){e(Rt(n,t.fullPath,!t.isDirectory))};Ot(t)?t.removeRecursively(n,r):t.remove(n,r)};vt(n,i,r)}})},e.prototype.rename=function(t,e,n){var r=this,i=2,o=0,s=this.fs.root,a=t,c=function(t){--i<=0&&n(Rt(t,a,!1))},u=function(i){return 2===++o?n(new Fe(be.EINVAL,"Something was identified as both a file and a directory. This should never happen.")):t===e?n():(a=ke.dirname(e),void s.getDirectory(a,{},function(o){a=ke.basename(e),i.moveTo(o,a,function(t){n()},function(o){i.isDirectory?(a=e,r.unlink(e,function(i){i?c(o):r.rename(t,e,n)})):c(o)})},c))};s.getFile(t,{},u,c),s.getDirectory(t,{},u,c)},e.prototype.stat=function(t,e,n){var r=this,i={create:!1},o=function(t){var e=function(t){var e=new Te(Le.FILE,t.size);n(null,e)};t.file(e,a)},s=function(t){var e=4096,r=new Te(Le.DIRECTORY,e);n(null,r)},a=function(e){n(Rt(e,t,!1))},c=function(){r.fs.root.getDirectory(t,i,s,a)};this.fs.root.getFile(t,i,o,c)},e.prototype.open=function(t,e,n,r){var i=this,o=function(n){r("InvalidModificationError"===n.name&&e.isExclusive()?Fe.EEXIST(t):Rt(n,t,!1))};this.fs.root.getFile(t,{create:e.pathNotExistsAction()===Oe.CREATE_FILE,exclusive:e.isExclusive()},function(n){n.file(function(s){var a=new FileReader;a.onloadend=function(o){var c=i._makeFile(t,n,e,s,a.result);r(null,c)},a.onerror=function(t){o(a.error)},a.readAsArrayBuffer(s)},o)},o)},e.prototype.unlink=function(t,e){this._remove(t,e,!0)},e.prototype.rmdir=function(t,e){var n=this;this.readdir(t,function(r,i){r?e(r):i.length>0?e(Fe.ENOTEMPTY(t)):n._remove(t,e,!1)})},e.prototype.mkdir=function(t,e,n){var r={create:!0,exclusive:!0},i=function(t){n()},o=function(e){n(Rt(e,t,!0))};this.fs.root.getDirectory(t,r,i,o)},e.prototype.readdir=function(t,e){this._readdir(t,function(t,n){if(!n)return e(t);for(var r=[],i=0,o=n;i0)throw Fe.ENOTEMPTY(t);this.removeEntry(t,!0)},n.prototype.mkdirSync=function(e,n){var r=this.store.beginTransaction("readwrite"),i=t.from("{}");this.commitNewFile(r,e,Le.DIRECTORY,n,i)},n.prototype.readdirSync=function(t){var e=this.store.beginTransaction("readonly");return Object.keys(this.getDirListing(e,t,this.findINode(e,t)))},n.prototype._syncSync=function(t,e,n){var r=this.store.beginTransaction("readwrite"),i=this._findINode(r,ke.dirname(t),ke.basename(t)),o=this.getINode(r,t,i),s=o.update(n);try{r.put(o.id,e,!0),s&&r.put(i,o.toBuffer(),!0)}catch(t){throw r.abort(),t}r.commit()},n.prototype.makeRootDirectory=function(){var t=this.store.beginTransaction("readwrite");if(void 0===t.get(oi)){var e=(new Date).getTime(),n=new ii(Tt(),4096,511|Le.DIRECTORY,e,e,e);t.put(n.id,Lt(),!1),t.put(oi,n.toBuffer(),!1),t.commit()}},n.prototype._findINode=function(t,e,n){var r=this,i=function(i){var o=r.getDirListing(t,e,i);if(o[n])return o[n];throw Fe.ENOENT(ke.resolve(e,n))};return"/"===e?""===n?oi:i(this.getINode(t,e,oi)):i(this.getINode(t,e+ke.sep+n,this._findINode(t,ke.dirname(e),ke.basename(e))))},n.prototype.findINode=function(t,e){return this.getINode(t,e,this._findINode(t,ke.dirname(e),ke.basename(e)))},n.prototype.getINode=function(t,e,n){var r=t.get(n);if(void 0===r)throw Fe.ENOENT(e);return ii.fromBuffer(r)},n.prototype.getDirListing=function(t,e,n){if(!n.isDirectory())throw Fe.ENOTDIR(e);var r=t.get(n.id);if(void 0===r)throw Fe.ENOENT(e);return JSON.parse(r.toString())},n.prototype.addNewNode=function(t,e){for(var n,r=0;r<5;)try{return n=Tt(),t.put(n,e,!1),n}catch(t){}throw new Fe(be.EIO,"Unable to commit data to key-value store.")},n.prototype.commitNewFile=function(e,n,r,i,o){var s=ke.dirname(n),a=ke.basename(n),c=this.findINode(e,s),u=this.getDirListing(e,s,c),f=(new Date).getTime();if("/"===n)throw Fe.EEXIST(n);if(u[a])throw Fe.EEXIST(n);var h;try{var p=this.addNewNode(e,o);h=new ii(p,o.length,i|r,f,f,f);var l=this.addNewNode(e,h.toBuffer());u[a]=l,e.put(c.id,t.from(JSON.stringify(u)),!0)}catch(t){throw e.abort(),t}return e.commit(),h},n.prototype.removeEntry=function(e,n){var r=this.store.beginTransaction("readwrite"),i=ke.dirname(e),o=this.findINode(r,i),s=this.getDirListing(r,i,o),a=ke.basename(e);if(!s[a])throw Fe.ENOENT(e);var c=s[a];delete s[a];var u=this.getINode(r,e,c);if(!n&&u.isDirectory())throw Fe.EISDIR(e);if(n&&!u.isDirectory())throw Fe.ENOTDIR(e);try{r.del(u.id),r.del(c),r.put(o.id,t.from(JSON.stringify(s)),!0)}catch(t){throw r.abort(),t}r.commit()},n}(He),fi=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;this.isDirty()?this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),function(n){n||e.resetDirty(),t(n)}):t()},e.prototype.close=function(t){this.sync(t)},e}(Ye),hi=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.isAvailable=function(){return!0},n.prototype.init=function(t,e){this.store=t,this.makeRootDirectory(e)},n.prototype.getName=function(){return this.store.name()},n.prototype.isReadOnly=function(){return!1},n.prototype.supportsSymlinks=function(){return!1},n.prototype.supportsProps=function(){return!1},n.prototype.supportsSynch=function(){return!1},n.prototype.empty=function(t){var e=this;this.store.clear(function(n){xt(n,t)&&e.makeRootDirectory(t)})},n.prototype.rename=function(e,n,r){var i=this,o=this.store.beginTransaction("readwrite"),s=ke.dirname(e),a=ke.basename(e),c=ke.dirname(n),u=ke.basename(n),f={},h={},p=!1;if(0===(c+"/").indexOf(e+"/"))return r(new Fe(be.EBUSY,s));var l=function(){if(!p&&h.hasOwnProperty(s)&&h.hasOwnProperty(c)){var l=h[s],d=f[s],y=h[c],g=f[c];if(l[a]){var v=l[a];delete l[a];var m=function(){y[u]=v,o.put(d.id,t.from(JSON.stringify(l)),!0,function(e){At(e,o,r)&&(s===c?o.commit(r):o.put(g.id,t.from(JSON.stringify(y)),!0,function(t){At(t,o,r)&&o.commit(r)}))})};y[u]?i.getINode(o,n,y[u],function(t,e){At(t,o,r)&&(e.isFile()?o.del(e.id,function(t){At(t,o,r)&&o.del(y[u],function(t){At(t,o,r)&&m()})}):o.abort(function(t){r(Fe.EPERM(n))}))}):m()}else r(Fe.ENOENT(e))}},d=function(t){i.findINodeAndDirListing(o,t,function(e,n,i){e?p||(p=!0,o.abort(function(){r(e)})):(f[t]=n,h[t]=i,l())})};d(s),s!==c&&d(c)},n.prototype.stat=function(t,e,n){var r=this.store.beginTransaction("readonly");this.findINode(r,t,function(t,e){xt(t,n)&&n(null,e.toStats())})},n.prototype.createFile=function(t,e,n,r){var i=this,o=this.store.beginTransaction("readwrite"),s=S();this.commitNewFile(o,t,Le.FILE,n,s,function(n,o){xt(n,r)&&r(null,new fi(i,t,e,o.toStats(),s))})},n.prototype.openFile=function(t,e,n){var r=this,i=this.store.beginTransaction("readonly");this.findINode(i,t,function(o,s){xt(o,n)&&i.get(s.id,function(i,o){xt(i,n)&&(void 0===o?n(Fe.ENOENT(t)):n(null,new fi(r,t,e,s.toStats(),o)))})})},n.prototype.unlink=function(t,e){this.removeEntry(t,!1,e)},n.prototype.rmdir=function(t,e){var n=this;this.readdir(t,function(r,i){r?e(r):i.length>0?e(Fe.ENOTEMPTY(t)):n.removeEntry(t,!0,e)})},n.prototype.mkdir=function(e,n,r){var i=this.store.beginTransaction("readwrite"),o=t.from("{}");this.commitNewFile(i,e,Le.DIRECTORY,n,o,r)},n.prototype.readdir=function(t,e){var n=this,r=this.store.beginTransaction("readonly");this.findINode(r,t,function(i,o){xt(i,e)&&n.getDirListing(r,t,o,function(t,n){xt(t,e)&&e(null,Object.keys(n))})})},n.prototype._sync=function(t,e,n,r){var i=this,o=this.store.beginTransaction("readwrite");this._findINode(o,ke.dirname(t),ke.basename(t),function(s,a){At(s,o,r)&&i.getINode(o,t,a,function(t,i){if(At(t,o,r)){var s=i.update(n);o.put(i.id,e,!0,function(t){At(t,o,r)&&(s?o.put(a,i.toBuffer(),!0,function(t){At(t,o,r)&&o.commit(r)}):o.commit(r))})}})})},n.prototype.makeRootDirectory=function(t){var e=this.store.beginTransaction("readwrite");e.get(oi,function(n,r){if(n||void 0===r){var i=(new Date).getTime(),o=new ii(Tt(),4096,511|Le.DIRECTORY,i,i,i);e.put(o.id,Lt(),!1,function(n){At(n,e,t)&&e.put(oi,o.toBuffer(),!1,function(n){n?e.abort(function(){t(n)}):e.commit(t)})})}else e.commit(t)})},n.prototype._findINode=function(t,e,n,r){var i=this,o=function(t,i,o){t?r(t):o[n]?r(null,o[n]):r(Fe.ENOENT(ke.resolve(e,n)))};"/"===e?""===n?r(null,oi):this.getINode(t,e,oi,function(n,s){xt(n,r)&&i.getDirListing(t,e,s,function(t,e){o(t,s,e)})}):this.findINodeAndDirListing(t,e,o)},n.prototype.findINode=function(t,e,n){var r=this;this._findINode(t,ke.dirname(e),ke.basename(e),function(i,o){xt(i,n)&&r.getINode(t,e,o,n)})},n.prototype.getINode=function(t,e,n,r){t.get(n,function(t,n){xt(t,r)&&(void 0===n?r(Fe.ENOENT(e)):r(null,ii.fromBuffer(n)))})},n.prototype.getDirListing=function(t,e,n,r){n.isDirectory()?t.get(n.id,function(t,n){if(xt(t,r))try{r(null,JSON.parse(n.toString()))}catch(t){r(Fe.ENOENT(e))}}):r(Fe.ENOTDIR(e))},n.prototype.findINodeAndDirListing=function(t,e,n){var r=this;this.findINode(t,e,function(i,o){xt(i,n)&&r.getDirListing(t,e,o,function(t,e){xt(t,n)&&n(null,o,e)})})},n.prototype.addNewNode=function(t,e,n){var r,i=0,o=function(){5===++i?n(new Fe(be.EIO,"Unable to commit data to key-value store.")):(r=Tt(),t.put(r,e,!1,function(t,e){t||!e?o():n(null,r)}))};o()},n.prototype.commitNewFile=function(e,n,r,i,o,s){var a=this,c=ke.dirname(n),u=ke.basename(n),f=(new Date).getTime();return"/"===n?s(Fe.EEXIST(n)):void this.findINodeAndDirListing(e,c,function(c,h,p){At(c,e,s)&&(p[u]?e.abort(function(){s(Fe.EEXIST(n))}):a.addNewNode(e,o,function(n,c){if(At(n,e,s)){var l=new ii(c,o.length,i|r,f,f,f);a.addNewNode(e,l.toBuffer(),function(n,r){At(n,e,s)&&(p[u]=r,e.put(h.id,t.from(JSON.stringify(p)),!0,function(t){At(t,e,s)&&e.commit(function(t){At(t,e,s)&&s(null,l)})}))})}}))})},n.prototype.removeEntry=function(e,n,r){var i=this,o=this.store.beginTransaction("readwrite"),s=ke.dirname(e),a=ke.basename(e);this.findINodeAndDirListing(o,s,function(s,c,u){if(At(s,o,r))if(u[a]){var f=u[a];delete u[a],i.getINode(o,e,f,function(i,s){At(i,o,r)&&(!n&&s.isDirectory()?o.abort(function(){r(Fe.EISDIR(e))}):n&&!s.isDirectory()?o.abort(function(){r(Fe.ENOTDIR(e))}):o.del(s.id,function(e){At(e,o,r)&&o.del(f,function(e){At(e,o,r)&&o.put(c.id,t.from(JSON.stringify(u)),!0,function(t){At(t,o,r)&&o.commit(r)})})}))})}else o.abort(function(){r(Fe.ENOENT(e))})})},n}(We),pi=function(){this.store={}};pi.prototype.name=function(){return li.Name},pi.prototype.clear=function(){this.store={}},pi.prototype.beginTransaction=function(t){return new ai(this)},pi.prototype.get=function(t){return this.store[t]},pi.prototype.put=function(t,e,n){return!(!n&&this.store.hasOwnProperty(t))&&(this.store[t]=e,!0)},pi.prototype.del=function(t){delete this.store[t]};var li=function(t){function e(){t.call(this,{store:new pi})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){n(null,new e)},e}(ui);li.Name="InMemory",li.Options={};var di=ti.indexedDB||ti.mozIndexedDB||ti.webkitIndexedDB||ti.msIndexedDB,yi=function(t,e){this.tx=t,this.store=e};yi.prototype.get=function(t,e){try{var n=this.store.get(t);n.onerror=Pt(e),n.onsuccess=function(t){var n=t.target.result;void 0===n?e(null,n):e(null,E(n))}}catch(t){e(Dt(t))}};var gi=function(t){function e(e,n){t.call(this,e,n)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.put=function(t,e,n,r){try{var i,o=v(e);i=n?this.store.put(o,t):this.store.add(o,t),i.onerror=Pt(r),i.onsuccess=function(t){r(null,!0)}}catch(t){r(Dt(t))}},e.prototype.del=function(t,e){try{var n=this.store.delete(t);n.onerror=Pt(e),n.onsuccess=function(t){e()}}catch(t){e(Dt(t))}},e.prototype.commit=function(t){setTimeout(t,0)},e.prototype.abort=function(t){var e=null;try{this.tx.abort()}catch(t){e=Dt(t)}finally{t(e)}},e}(yi),vi=function(t,e){var n=this;void 0===e&&(e="browserfs"),this.storeName=e;var r=di.open(this.storeName,1);r.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(n.storeName)&&e.deleteObjectStore(n.storeName),e.createObjectStore(n.storeName)},r.onsuccess=function(e){n.db=e.target.result,t(null,n)},r.onerror=Pt(t,be.EACCES)};vi.prototype.name=function(){return mi.Name+" - "+this.storeName},vi.prototype.clear=function(t){try{var e=this.db.transaction(this.storeName,"readwrite"),n=e.objectStore(this.storeName),r=n.clear();r.onsuccess=function(e){setTimeout(t,0)},r.onerror=Pt(t)}catch(e){t(Dt(e))}},vi.prototype.beginTransaction=function(t){void 0===t&&(t="readonly");var e=this.db.transaction(this.storeName,t),n=e.objectStore(this.storeName);if("readwrite"===t)return new gi(e,n);if("readonly"===t)return new yi(e,n);throw new Fe(be.EINVAL,"Invalid transaction type.")};var mi=function(t){function e(n,r,i){var o=this;void 0===i&&(i=!0),t.call(this),this.store=new vi(function(t){t?n(t):o.init(o.store,function(t){n(t,o)})},r),d(i,e.Name,{storeName:r})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){new e(n,t.storeName,!1)},e.isAvailable=function(){try{return"undefined"!=typeof di&&null!==di.open("__browserfs_test__")}catch(t){return!1}},e}(hi);mi.Name="IndexedDB",mi.Options={storeName:{type:"string",optional:!0,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."}};var _i,wi=!1;try{ti.localStorage.setItem("__test__",String.fromCharCode(55296)),wi=ti.localStorage.getItem("__test__")===String.fromCharCode(55296)}catch(t){wi=!1}_i=wi?"binary_string":"binary_string_ie",t.isEncoding(_i)||(_i="base64");var Ei=function(){};Ei.prototype.name=function(){return bi.Name},Ei.prototype.clear=function(){ti.localStorage.clear()},Ei.prototype.beginTransaction=function(t){return new ai(this)},Ei.prototype.get=function(e){try{var n=ti.localStorage.getItem(e);if(null!==n)return t.from(n,_i)}catch(t){}},Ei.prototype.put=function(t,e,n){try{return!(!n&&null!==ti.localStorage.getItem(t))&&(ti.localStorage.setItem(t,e.toString(_i)),!0)}catch(t){throw new Fe(be.ENOSPC,"LocalStorage is full.")}},Ei.prototype.del=function(t){try{ti.localStorage.removeItem(t)}catch(e){throw new Fe(be.EIO,"Unable to delete key "+t+": "+e)}};var bi=function(t){function e(){t.call(this,{store:new Ei})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){n(null,new e)},e.isAvailable=function(){return"undefined"!=typeof ti.localStorage},e}(ui);bi.Name="LocalStorage",bi.Options={};var Si=function(t){function e(){t.call(this),this.mountList=[],this.mntMap={},this.rootFs=new li}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){var r=new e;Object.keys(t).forEach(function(e){r.mount(e,t[e])}),n(null,r)},e.isAvailable=function(){return!0},e.prototype.mount=function(t,e){if("/"!==t[0]&&(t="/"+t),t=ke.resolve(t),this.mntMap[t])throw new Fe(be.EINVAL,"Mount point "+t+" is already taken.");g(t,511,this.rootFs),this.mntMap[t]=e,this.mountList.push(t),this.mountList=this.mountList.sort(function(t,e){return e.length-t.length})},e.prototype.umount=function(t){var e=this;if("/"!==t[0]&&(t="/"+t),t=ke.resolve(t),!this.mntMap[t])throw new Fe(be.EINVAL,"Mount point "+t+" is already unmounted.");for(delete this.mntMap[t],this.mountList.splice(this.mountList.indexOf(t),1);"/"!==t&&0===e.rootFs.readdirSync(t).length;)e.rootFs.rmdirSync(t),t=ke.dirname(t)},e.prototype._getFs=function(t){for(var e=this,n=this.mountList,r=n.length,i=0;i1?o.length:0),""===t&&(t="/"),{fs:e.mntMap[o],path:t}}return{fs:this.rootFs,path:t}},e.prototype.getName=function(){return e.Name},e.prototype.diskSpace=function(t,e){e(0,0)},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.standardizeError=function(t,e,n){var r=t.message.indexOf(e);return r!==-1&&(t.message=t.message.substr(0,r)+n+t.message.substr(r+e.length),t.path=n),t},e.prototype.rename=function(t,e,n){var r=this,i=this._getFs(t),o=this._getFs(e);return i.fs===o.fs?i.fs.rename(i.path,o.path,function(s){s&&r.standardizeError(r.standardizeError(s,i.path,t),o.path,e),n(s)}):Pe.readFile(t,function(r,i){return r?n(r):void Pe.writeFile(e,i,function(e){return e?n(e):void Pe.unlink(t,n)})})},e.prototype.renameSync=function(t,e){var n=this._getFs(t),r=this._getFs(e);if(n.fs===r.fs)try{return n.fs.renameSync(n.path,r.path)}catch(i){ +throw this.standardizeError(this.standardizeError(i,n.path,t),r.path,e),i}var i=Pe.readFileSync(t);return Pe.writeFileSync(e,i),Pe.unlinkSync(t)},e.prototype.readdirSync=function(t){var e=this._getFs(t),n=null;if(e.fs!==this.rootFs)try{n=this.rootFs.readdirSync(t)}catch(t){}try{var r=e.fs.readdirSync(e.path);return null===n?r:r.concat(n.filter(function(t){return r.indexOf(t)===-1}))}catch(r){if(null===n)throw this.standardizeError(r,e.path,t);return n}},e.prototype.readdir=function(t,e){var n=this,r=this._getFs(t);r.fs.readdir(r.path,function(i,o){if(r.fs!==n.rootFs)try{var s=n.rootFs.readdirSync(t);o=o?o.concat(s.filter(function(t){return o.indexOf(t)===-1})):s}catch(o){if(i)return e(n.standardizeError(i,r.path,t))}else if(i)return e(n.standardizeError(i,r.path,t));e(null,o)})},e.prototype.rmdirSync=function(t){var e=this._getFs(t);if(this._containsMountPt(t))throw Fe.ENOTEMPTY(t);try{e.fs.rmdirSync(e.path)}catch(n){throw this.standardizeError(n,e.path,t)}},e.prototype.rmdir=function(t,e){var n=this,r=this._getFs(t);this._containsMountPt(t)?e(Fe.ENOTEMPTY(t)):r.fs.rmdir(r.path,function(i){e(i?n.standardizeError(i,r.path,t):null)})},e.prototype._containsMountPt=function(t){for(var e=this.mountList,n=e.length,r=0;r=t.length&&i.slice(0,t.length)===t)return!0}return!1},e}(We);Si.Name="MountableFileSystem",Si.Options={};for(var ki=[["exists","unlink","readlink"],["stat","mkdir","realpath","truncate"],["open","readFile","chmod","utimes"],["chown"],["writeFile","appendFile"]],Ii=0;Ii0)){var e=xi.shift();return e()}};Ti.addEventListener?Ti.addEventListener("message",Pi,!0):Ti.attachEvent("onmessage",Pi)}else if(Ti.MessageChannel){var Ci=new Ti.MessageChannel;Ci.port1.onmessage=function(t){if(xi.length>0)return xi.shift()()},Li=function(t){xi.push(t),Ci.port2.postMessage("")}}else Li=function(t){return setTimeout(t,0)}}var Ui=Li,Mi=function(){this._locked=!1,this._waiters=[]};Mi.prototype.lock=function(t){return this._locked?void this._waiters.push(t):(this._locked=!0,void t())},Mi.prototype.unlock=function(){if(!this._locked)throw new Error("unlock of a non-locked mutex");var t=this._waiters.shift();return t?void Ui(t):void(this._locked=!1)},Mi.prototype.tryLock=function(){return!this._locked&&(this._locked=!0,!0)},Mi.prototype.isLocked=function(){return this._locked};var ji=function(t){this._fs=t,this._mu=new Mi};ji.prototype.getName=function(){return"LockedFS<"+this._fs.getName()+">"},ji.prototype.getFSUnlocked=function(){return this._fs},ji.prototype.initialize=function(t){this._fs.initialize(t)},ji.prototype.diskSpace=function(t,e){this._fs.diskSpace(t,e)},ji.prototype.isReadOnly=function(){return this._fs.isReadOnly()},ji.prototype.supportsLinks=function(){return this._fs.supportsLinks()},ji.prototype.supportsProps=function(){return this._fs.supportsProps()},ji.prototype.supportsSynch=function(){return this._fs.supportsSynch()},ji.prototype.rename=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.rename(t,e,function(t){r._mu.unlock(),n(t)})})},ji.prototype.renameSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.renameSync(t,e)},ji.prototype.stat=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.stat(t,e,function(t,e){r._mu.unlock(),n(t,e)})})},ji.prototype.statSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.statSync(t,e)},ji.prototype.open=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.open(t,e,n,function(t,e){i._mu.unlock(),r(t,e)})})},ji.prototype.openSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.openSync(t,e,n)},ji.prototype.unlink=function(t,e){var n=this;this._mu.lock(function(){n._fs.unlink(t,function(t){n._mu.unlock(),e(t)})})},ji.prototype.unlinkSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.unlinkSync(t)},ji.prototype.rmdir=function(t,e){var n=this;this._mu.lock(function(){n._fs.rmdir(t,function(t){n._mu.unlock(),e(t)})})},ji.prototype.rmdirSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.rmdirSync(t)},ji.prototype.mkdir=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.mkdir(t,e,function(t){r._mu.unlock(),n(t)})})},ji.prototype.mkdirSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.mkdirSync(t,e)},ji.prototype.readdir=function(t,e){var n=this;this._mu.lock(function(){n._fs.readdir(t,function(t,r){n._mu.unlock(),e(t,r)})})},ji.prototype.readdirSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readdirSync(t)},ji.prototype.exists=function(t,e){var n=this;this._mu.lock(function(){n._fs.exists(t,function(t){n._mu.unlock(),e(t)})})},ji.prototype.existsSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.existsSync(t)},ji.prototype.realpath=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.realpath(t,e,function(t,e){r._mu.unlock(),n(t,e)})})},ji.prototype.realpathSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.realpathSync(t,e)},ji.prototype.truncate=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.truncate(t,e,function(t){r._mu.unlock(),n(t)})})},ji.prototype.truncateSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.truncateSync(t,e)},ji.prototype.readFile=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.readFile(t,e,n,function(t,e){i._mu.unlock(),r(t,e)})})},ji.prototype.readFileSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readFileSync(t,e,n)},ji.prototype.writeFile=function(t,e,n,r,i,o){var s=this;this._mu.lock(function(){s._fs.writeFile(t,e,n,r,i,function(t){s._mu.unlock(),o(t)})})},ji.prototype.writeFileSync=function(t,e,n,r,i){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.writeFileSync(t,e,n,r,i)},ji.prototype.appendFile=function(t,e,n,r,i,o){var s=this;this._mu.lock(function(){s._fs.appendFile(t,e,n,r,i,function(t){s._mu.unlock(),o(t)})})},ji.prototype.appendFileSync=function(t,e,n,r,i){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.appendFileSync(t,e,n,r,i)},ji.prototype.chmod=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.chmod(t,e,n,function(t){i._mu.unlock(),r(t)})})},ji.prototype.chmodSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chmodSync(t,e,n)},ji.prototype.chown=function(t,e,n,r,i){var o=this;this._mu.lock(function(){o._fs.chown(t,e,n,r,function(t){o._mu.unlock(),i(t)})})},ji.prototype.chownSync=function(t,e,n,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chownSync(t,e,n,r)},ji.prototype.utimes=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.utimes(t,e,n,function(t){i._mu.unlock(),r(t)})})},ji.prototype.utimesSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.utimesSync(t,e,n)},ji.prototype.link=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.link(t,e,function(t){r._mu.unlock(),n(t)})})},ji.prototype.linkSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.linkSync(t,e)},ji.prototype.symlink=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.symlink(t,e,n,function(t){i._mu.unlock(),r(t)})})},ji.prototype.symlinkSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.symlinkSync(t,e,n)},ji.prototype.readlink=function(t,e){var n=this;this._mu.lock(function(){n._fs.readlink(t,function(t,r){n._mu.unlock(),e(t,r)})})},ji.prototype.readlinkSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readlinkSync(t)};var Bi="/.deletedFiles.log",zi=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;return this.isDirty()?void this._fs._syncAsync(this,function(n){e.resetDirty(),t(n)}):void t(null)},e.prototype.syncSync=function(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())},e.prototype.close=function(t){this.sync(t)},e.prototype.closeSync=function(){this.syncSync()},e}(Ye),qi=function(t){function e(e,n){if(t.call(this),this._isInitialized=!1,this._initializeCallbacks=[],this._deletedFiles={},this._deleteLog="",this._deleteLogUpdatePending=!1,this._deleteLogUpdateNeeded=!1,this._deleteLogError=null,this._writable=e,this._readable=n,this._writable.isReadOnly())throw new Fe(be.EINVAL,"Writable file system must be writable.")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.isAvailable=function(){return!0},e.prototype.getOverlayedFileSystems=function(){return{readable:this._readable,writable:this._writable}},e.prototype._syncAsync=function(t,e){var n=this;this.createParentDirectoriesAsync(t.getPath(),function(r){return r?e(r):void n._writable.writeFile(t.getPath(),t.getBuffer(),null,Mt("w"),t.getStats().mode,e)})},e.prototype._syncSync=function(t){this.createParentDirectories(t.getPath()),this._writable.writeFileSync(t.getPath(),t.getBuffer(),null,Mt("w"),t.getStats().mode)},e.prototype.getName=function(){return Vi.Name},e.prototype.initialize=function(t){var e=this,n=this._initializeCallbacks,r=function(t){e._isInitialized=!t,e._initializeCallbacks=[],n.forEach(function(e){return e(t)})};return this._isInitialized?t():(n.push(t),void(1===n.length&&this._writable.readFile(Bi,"utf8",Mt("r"),function(t,n){if(t){if(t.errno!==be.ENOENT)return r(t)}else e._deleteLog=n;e._reparseDeletionLog(),r()})))},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSynch=function(){return this._readable.supportsSynch()&&this._writable.supportsSynch()},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return this._readable.supportsProps()&&this._writable.supportsProps()},e.prototype.getDeletionLog=function(){return this._deleteLog},e.prototype.restoreDeletionLog=function(t){this._deleteLog=t,this._reparseDeletionLog(),this.updateLog("")},e.prototype.rename=function(t,e,n){var r=this;if(this.checkInitAsync(n)&&!this.checkPathAsync(t,n)&&!this.checkPathAsync(e,n))return t===Bi||e===Bi?n(Fe.EPERM("Cannot rename deletion log.")):t===e?n():void this.stat(t,!1,function(i,o){return i?n(i):r.stat(e,!1,function(i,s){function a(r){var i=r.shift();if(!i)return n();var o=ke.resolve(t,i),s=ke.resolve(e,i);c.rename(o,s,function(t){return t?n(t):void a(r)})}var c=r,u=511;if(o.isDirectory()){if(i)return i.errno!==be.ENOENT?n(i):r._writable.exists(t,function(i){return i?r._writable.rename(t,e,n):void r._writable.mkdir(e,u,function(e){return e?n(e):void r._readable.readdir(t,function(t,e){return t?n():void a(e)})})});if(u=s.mode,!s.isDirectory())return n(Fe.ENOTDIR(e));r.readdir(e,function(i,o){return o&&o.length?n(Fe.ENOTEMPTY(e)):void r._readable.readdir(t,function(t,e){return t?n():void a(e)})})}return s&&s.isDirectory()?n(Fe.EISDIR(e)):void r.readFile(t,null,Mt("r"),function(i,s){return i?n(i):r.writeFile(e,s,null,Mt("w"),o.mode,function(e){return e?n(e):r.unlink(t,n)})})})})},e.prototype.renameSync=function(t,e){var n=this;if(this.checkInitialized(),this.checkPath(t),this.checkPath(e),t===Bi||e===Bi)throw Fe.EPERM("Cannot rename deletion log.");var r=this.statSync(t,!1);if(r.isDirectory()){if(t===e)return;var i=511;if(this.existsSync(e)){var o=this.statSync(e,!1);if(i=o.mode,!o.isDirectory())throw Fe.ENOTDIR(e);if(this.readdirSync(e).length>0)throw Fe.ENOTEMPTY(e)}this._writable.existsSync(t)?this._writable.renameSync(t,e):this._writable.existsSync(e)||this._writable.mkdirSync(e,i),this._readable.existsSync(t)&&this._readable.readdirSync(t).forEach(function(r){n.renameSync(ke.resolve(t,r),ke.resolve(e,r))})}else{if(this.existsSync(e)&&this.statSync(e,!1).isDirectory())throw Fe.EISDIR(e);this.writeFileSync(e,this.readFileSync(t,null,Mt("r")),null,Mt("w"),r.mode)}t!==e&&this.existsSync(t)&&this.unlinkSync(t)},e.prototype.stat=function(t,e,n){var r=this;this.checkInitAsync(n)&&this._writable.stat(t,e,function(i,o){i&&i.errno===be.ENOENT?(r._deletedFiles[t]&&n(Fe.ENOENT(t)),r._readable.stat(t,e,function(t,e){e&&(e=e.clone(),e.mode=Ut(e.mode)),n(t,e)})):n(i,o)})},e.prototype.statSync=function(t,e){this.checkInitialized();try{return this._writable.statSync(t,e)}catch(r){if(this._deletedFiles[t])throw Fe.ENOENT(t);var n=this._readable.statSync(t,e).clone();return n.mode=Ut(n.mode),n}},e.prototype.open=function(t,e,n,r){var i=this;this.checkInitAsync(r)&&!this.checkPathAsync(t,r)&&this.stat(t,!1,function(o,s){if(s)switch(e.pathExistsAction()){case Oe.TRUNCATE_FILE:return i.createParentDirectoriesAsync(t,function(o){return o?r(o):void i._writable.open(t,e,n,r)});case Oe.NOP:return i._writable.exists(t,function(o){o?i._writable.open(t,e,n,r):(s=s.clone(),s.mode=n,i._readable.readFile(t,null,Mt("r"),function(n,o){if(n)return r(n);s.size===-1&&(s.size=o.length);var a=new zi(i,t,e,s,o);r(null,a)}))});default:return r(Fe.EEXIST(t))}else switch(e.pathNotExistsAction()){case Oe.CREATE_FILE:return i.createParentDirectoriesAsync(t,function(o){return o?r(o):i._writable.open(t,e,n,r)});default:return r(Fe.ENOENT(t))}})},e.prototype.openSync=function(t,e,n){if(this.checkInitialized(),this.checkPath(t),t===Bi)throw Fe.EPERM("Cannot open deletion log.");if(this.existsSync(t))switch(e.pathExistsAction()){case Oe.TRUNCATE_FILE:return this.createParentDirectories(t),this._writable.openSync(t,e,n);case Oe.NOP:if(this._writable.existsSync(t))return this._writable.openSync(t,e,n);var r=this._readable.readFileSync(t,null,Mt("r")),i=this._readable.statSync(t,!1).clone();return i.mode=n,new zi(this,t,e,i,r);default:throw Fe.EEXIST(t)}else switch(e.pathNotExistsAction()){case Oe.CREATE_FILE:return this.createParentDirectories(t),this._writable.openSync(t,e,n);default:throw Fe.ENOENT(t)}},e.prototype.unlink=function(t,e){var n=this;this.checkInitAsync(e)&&!this.checkPathAsync(t,e)&&this.exists(t,function(r){return r?void n._writable.exists(t,function(r){return r?n._writable.unlink(t,function(r){return r?e(r):void n.exists(t,function(r){r&&n.deletePath(t),e(null)})}):(n.deletePath(t),void e(null))}):e(Fe.ENOENT(t))})},e.prototype.unlinkSync=function(t){if(this.checkInitialized(),this.checkPath(t),!this.existsSync(t))throw Fe.ENOENT(t);this._writable.existsSync(t)&&this._writable.unlinkSync(t),this.existsSync(t)&&this.deletePath(t)},e.prototype.rmdir=function(t,e){var n=this;if(this.checkInitAsync(e)){var r=function(){n.readdir(t,function(r,i){return r?e(r):i.length?e(Fe.ENOTEMPTY(t)):(n.deletePath(t),void e(null))})};this.exists(t,function(i){return i?void n._writable.exists(t,function(i){i?n._writable.rmdir(t,function(i){return i?e(i):void n._readable.exists(t,function(t){t?r():e()})}):r()}):e(Fe.ENOENT(t))})}},e.prototype.rmdirSync=function(t){if(this.checkInitialized(),!this.existsSync(t))throw Fe.ENOENT(t);if(this._writable.existsSync(t)&&this._writable.rmdirSync(t),this.existsSync(t)){if(this.readdirSync(t).length>0)throw Fe.ENOTEMPTY(t);this.deletePath(t)}},e.prototype.mkdir=function(t,e,n){var r=this;this.checkInitAsync(n)&&this.exists(t,function(i){return i?n(Fe.EEXIST(t)):void r.createParentDirectoriesAsync(t,function(i){return i?n(i):void r._writable.mkdir(t,e,n)})})},e.prototype.mkdirSync=function(t,e){if(this.checkInitialized(),this.existsSync(t))throw Fe.EEXIST(t);this.createParentDirectories(t),this._writable.mkdirSync(t,e)},e.prototype.readdir=function(t,e){var n=this;this.checkInitAsync(e)&&this.stat(t,!1,function(r,i){return r?e(r):i.isDirectory()?void n._writable.readdir(t,function(r,i){return r&&"ENOENT"!==r.code?e(r):(!r&&i||(i=[]),void n._readable.readdir(t,function(r,o){!r&&o||(o=[]);var s={},a=i.concat(o.filter(function(e){return!n._deletedFiles[t+"/"+e]})).filter(function(t){var e=!s[t];return s[t]=!0,e});e(null,a)}))}):e(Fe.ENOTDIR(t))})},e.prototype.readdirSync=function(t){var e=this;this.checkInitialized();var n=this.statSync(t,!1);if(!n.isDirectory())throw Fe.ENOTDIR(t);var r=[];try{r=r.concat(this._writable.readdirSync(t))}catch(t){}try{r=r.concat(this._readable.readdirSync(t).filter(function(n){return!e._deletedFiles[t+"/"+n]}))}catch(t){}var i={};return r.filter(function(t){var e=!i[t];return i[t]=!0,e})},e.prototype.exists=function(t,e){var n=this;this.checkInitialized(),this._writable.exists(t,function(r){return r?e(!0):void n._readable.exists(t,function(r){e(r&&n._deletedFiles[t]!==!0)})})},e.prototype.existsSync=function(t){return this.checkInitialized(),this._writable.existsSync(t)||this._readable.existsSync(t)&&this._deletedFiles[t]!==!0},e.prototype.chmod=function(t,e,n,r){var i=this;this.checkInitAsync(r)&&this.operateOnWritableAsync(t,function(o){return o?r(o):void i._writable.chmod(t,e,n,r)})},e.prototype.chmodSync=function(t,e,n){var r=this;this.checkInitialized(),this.operateOnWritable(t,function(){r._writable.chmodSync(t,e,n)})},e.prototype.chown=function(t,e,n,r,i){var o=this;this.checkInitAsync(i)&&this.operateOnWritableAsync(t,function(s){return s?i(s):void o._writable.chown(t,e,n,r,i)})},e.prototype.chownSync=function(t,e,n,r){var i=this;this.checkInitialized(),this.operateOnWritable(t,function(){i._writable.chownSync(t,e,n,r)})},e.prototype.utimes=function(t,e,n,r){var i=this;this.checkInitAsync(r)&&this.operateOnWritableAsync(t,function(o){return o?r(o):void i._writable.utimes(t,e,n,r)})},e.prototype.utimesSync=function(t,e,n){var r=this;this.checkInitialized(),this.operateOnWritable(t,function(){r._writable.utimesSync(t,e,n)})},e.prototype.deletePath=function(t){this._deletedFiles[t]=!0,this.updateLog("d"+t+"\n")},e.prototype.updateLog=function(t){var e=this;this._deleteLog+=t,this._deleteLogUpdatePending?this._deleteLogUpdateNeeded=!0:(this._deleteLogUpdatePending=!0,this._writable.writeFile(Bi,this._deleteLog,"utf8",Re.getFileFlag("w"),420,function(t){e._deleteLogUpdatePending=!1,t?e._deleteLogError=t:e._deleteLogUpdateNeeded&&(e._deleteLogUpdateNeeded=!1,e.updateLog(""))}))},e.prototype._reparseDeletionLog=function(){var t=this;this._deletedFiles={},this._deleteLog.split("\n").forEach(function(e){t._deletedFiles[e.slice(1)]="d"===e.slice(0,1)})},e.prototype.checkInitialized=function(){if(!this._isInitialized)throw new Fe(be.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.");if(null!==this._deleteLogError){var t=this._deleteLogError;throw this._deleteLogError=null,t}},e.prototype.checkInitAsync=function(t){if(!this._isInitialized)return t(new Fe(be.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.")),!1;if(null!==this._deleteLogError){var e=this._deleteLogError;return this._deleteLogError=null,t(e),!1}return!0},e.prototype.checkPath=function(t){if(t===Bi)throw Fe.EPERM(t)},e.prototype.checkPathAsync=function(t,e){return t===Bi&&(e(Fe.EPERM(t)),!0)},e.prototype.createParentDirectoriesAsync=function(t,e){function n(t,e){t?(o.push(i),i=ke.dirname(i),s._writable.stat(i,!1,n)):r()}function r(){if(!o.length)return e();var t=o.pop();s._readable.stat(t,!1,function(n,i){return i?void s._writable.mkdir(t,i.mode,function(t){return t?e(t):void r()}):e()})}var i=ke.dirname(t),o=[],s=this;this._writable.stat(i,!1,n)},e.prototype.createParentDirectories=function(t){for(var e=this,n=ke.dirname(t),r=[];!this._writable.existsSync(n);)r.push(n),n=ke.dirname(n);r=r.reverse(),r.forEach(function(t){e._writable.mkdirSync(t,e.statSync(t,!1).mode)})},e.prototype.operateOnWritable=function(t,e){if(!this.existsSync(t))throw Fe.ENOENT(t);this._writable.existsSync(t)||this.copyToWritable(t),e()},e.prototype.operateOnWritableAsync=function(t,e){var n=this;this.exists(t,function(r){return r?void n._writable.exists(t,function(r){return r?void e():n.copyToWritableAsync(t,e)}):e(Fe.ENOENT(t))})},e.prototype.copyToWritable=function(t){var e=this.statSync(t,!1);e.isDirectory()?this._writable.mkdirSync(t,e.mode):this.writeFileSync(t,this._readable.readFileSync(t,null,Mt("r")),null,Mt("w"),this.statSync(t,!1).mode)},e.prototype.copyToWritableAsync=function(t,e){var n=this;this.stat(t,!1,function(r,i){return r?e(r):i.isDirectory()?n._writable.mkdir(t,i.mode,e):void n._readable.readFile(t,null,Mt("r"),function(r,o){return r?e(r):void n.writeFile(t,o,null,Mt("w"),i.mode,e)})})},e}(We),Vi=function(t){function e(n,r,i){void 0===i&&(i=!0),t.call(this,new qi(n,r)),d(i,e.Name,{readable:"readable file system",writable:"writable file system"})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){try{var r=new e(t.writable,t.readable,!1);r.initialize(function(t){n(t,r)},!1)}catch(t){n(t)}},e.isAvailable=function(){return qi.isAvailable()},e.prototype.initialize=function(e,n){void 0===n&&(n=!0),n&&console.warn("[OverlayFS] OverlayFS.initialize() is deprecated and will be removed in the next major release. Please use 'OverlayFS.Create({readable: readable file system instance, writable: writable file system instance}, cb)' to create and initialize OverlayFS instances."),t.prototype.initialize.call(this,e)},e.prototype.getOverlayedFileSystems=function(){return t.prototype.getFSUnlocked.call(this).getOverlayedFileSystems()},e.prototype.unwrap=function(){return t.prototype.getFSUnlocked.call(this)},e}(ji);Vi.Name="OverlayFS",Vi.Options={writable:{type:"object",description:"The file system to write modified files to."},readable:{type:"object",description:"The file system that initially populates this file system."}};var Wi;!function(t){t[t.CB=0]="CB",t[t.FD=1]="FD",t[t.API_ERROR=2]="API_ERROR",t[t.STATS=3]="STATS",t[t.PROBE=4]="PROBE",t[t.FILEFLAG=5]="FILEFLAG",t[t.BUFFER=6]="BUFFER",t[t.ERROR=7]="ERROR"}(Wi||(Wi={}));var Hi=function(){this._callbacks={},this._nextId=0};Hi.prototype.toRemoteArg=function(t){var e=this._nextId++;return this._callbacks[e]=t,{type:Wi.CB,id:e}},Hi.prototype.toLocalArg=function(t){var e=this._callbacks[t];return delete this._callbacks[t],e};var Zi=function(){this._fileDescriptors={},this._nextId=0};Zi.prototype.toRemoteArg=function(e,n,r,i){var o,s,a=this._nextId++;this._fileDescriptors[a]=e,e.stat(function(c,u){c?i(c):(s=Yt(u.toBuffer()),r.isReadable()?e.read(t.alloc(u.size),0,u.size,0,function(t,e,c){t?i(t):(o=Yt(c),i(null,{type:Wi.FD,id:a,data:o,stat:s,path:n,flag:r.getFlagString()}))}):i(null,{type:Wi.FD,id:a,data:new ArrayBuffer(0),stat:s,path:n,flag:r.getFlagString()}))})},Zi.prototype.applyFdAPIRequest=function(t,e){var n=this,r=t.args[0];this._applyFdChanges(r,function(i,o){i?e(i):o[t.method](function(i){"close"===t.method&&delete n._fileDescriptors[r.id],e(i)})})},Zi.prototype._applyFdChanges=function(t,e){var n=this._fileDescriptors[t.id],r=Xt(t.data),i=Te.fromBuffer(Xt(t.stat)),o=Re.getFileFlag(t.flag);o.isWriteable()?n.write(r,0,r.length,o.isAppendable()?n.getPos():0,function(t){function s(){n.stat(function(t,r){t?e(t):r.mode!==i.mode?n.chmod(i.mode,function(t){e(t,n)}):e(t,n)})}t?e(t):o.isAppendable()?s():n.truncate(r.length,function(){s()})}):e(null,n)};var Yi=function(t){function e(e,n,r,i,o,s){t.call(this,e,n,r,i,s),this._remoteFdId=o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getRemoteFdId=function(){return this._remoteFdId},e.prototype.toRemoteArg=function(){return{type:Wi.FD,id:this._remoteFdId,data:Yt(this.getBuffer()),stat:Yt(this.getStats().toBuffer()),path:this.getPath(),flag:this.getFlag().getFlagString()}},e.prototype.sync=function(t){this._syncClose("sync",t)},e.prototype.close=function(t){this._syncClose("close",t)},e.prototype._syncClose=function(t,e){var n=this;this.isDirty()?this._fs.syncClose(t,this,function(t){t||n.resetDirty(),e(t)}):e()},e}(Ye),Xi=function(e){function n(t,r){var i=this;void 0===r&&(r=!0),e.call(this),this._callbackConverter=new Hi,this._isInitialized=!1,this._isReadOnly=!1,this._supportLinks=!1,this._supportProps=!1,this._worker=t,d(r,n.Name,{worker:"Web Worker instance"}),this._worker.addEventListener("message",function(t){var e=t.data;if(Qt(e)){var n,r=e.args,o=new Array(r.length);for(n=0;n0&&(u=-1,s={browserfsMessage:!0,cbId:o,args:[jt(t)]},e.postMessage(s))}var i,s,a=arguments,c=new Array(arguments.length),u=arguments.length;for(i=0;i0;){var i=void 0,o=r.pop(),s=o[0],a=o[1],c=o[2];for(var u in a)if(a.hasOwnProperty(u)){var f=a[u],h=s+"/"+u;f?(e._index[h]=i=new $i,r.push([h,f,i])):i=new Qi(new Te(Le.FILE,-1,365)),c&&(c._ls[u]=i)}}return e},Gi.prototype.fileIterator=function(t){var e=this;for(var n in e._index)if(e._index.hasOwnProperty(n))for(var r=e._index[n],i=r.getListing(),o=0,s=i;o0&&"/"!==r.charAt(r.length-1)&&(r+="/"),this.prefixUrl=r;var o=null;if("string"==typeof n){if(o=this._requestFileSync(n,"json"),!o)throw new Error("Unable to find listing at URL: ${listingUrlOrObj}")}else o=n;d(i,e.Name,{index:"string"==typeof n?n:"file index as an object",baseUrl:r}),this._index=Gi.fromListing(o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){void 0===t.index&&(t.index="index.json"),"string"==typeof t.index?e.FromURL(t.index,n,t.baseUrl,!1):n(null,new e(t.index,t.baseUrl,!1))},e.isAvailable=function(){return"undefined"!=typeof XMLHttpRequest&&null!==XMLHttpRequest},e.FromURL=function(t,n,r,i){void 0===r&&(r=t.slice(0,t.lastIndexOf("/")+1)),void 0===i&&(i=!0),i&&console.warn("[XmlHttpRequest] XmlHttpRequest.FromURL() is deprecated and will be removed in the next major release. Please use 'XmlHttpRequest.Create({ index: \""+t+'", baseUrl: "'+r+"\" }, cb)' instead."),Ki(t,"json",function(t,i){t?n(t):n(null,new e(i,r,!1))})},e.prototype.empty=function(){this._index.fileIterator(function(t){t.fileData=null})},e.prototype.getName=function(){return e.Name},e.prototype.diskSpace=function(t,e){e(0,0)},e.prototype.isReadOnly=function(){return!0},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.preloadFile=function(t,e){var n=this._index.getInode(t);if(!oe(n))throw Fe.EISDIR(t);if(null===n)throw Fe.ENOENT(t);var r=n.getData();r.size=e.length,r.fileData=e},e.prototype.stat=function(t,e,n){var r=this._index.getInode(t);if(null===r)return n(Fe.ENOENT(t));var i;oe(r)?(i=r.getData(),i.size<0?this._requestFileSizeAsync(t,function(t,e){return t?n(t):(i.size=e,void n(null,i.clone()))}):n(null,i.clone())):se(r)?(i=r.getStats(),n(null,i)):n(Fe.FileError(be.EINVAL,t))},e.prototype.statSync=function(t,e){var n=this._index.getInode(t);if(null===n)throw Fe.ENOENT(t);var r;if(oe(n))r=n.getData(),r.size<0&&(r.size=this._requestFileSizeSync(t));else{if(!se(n))throw Fe.FileError(be.EINVAL,t);r=n.getStats()}return r},e.prototype.open=function(t,e,n,r){if(e.isWriteable())return r(new Fe(be.EPERM,t));var i=this,o=this._index.getInode(t);if(null===o)return r(Fe.ENOENT(t));if(!oe(o))return r(Fe.EISDIR(t));var s=o.getData();switch(e.pathExistsAction()){case Oe.THROW_EXCEPTION:case Oe.TRUNCATE_FILE:return r(Fe.EEXIST(t));case Oe.NOP:if(s.fileData)return r(null,new Xe(i,t,e,s.clone(),s.fileData));this._requestFileAsync(t,"buffer",function(n,o){return n?r(n):(s.size=o.length,s.fileData=o,r(null,new Xe(i,t,e,s.clone(),o)))});break;default:return r(new Fe(be.EINVAL,"Invalid FileMode object."))}},e.prototype.openSync=function(t,e,n){if(e.isWriteable())throw new Fe(be.EPERM,t);var r=this._index.getInode(t);if(null===r)throw Fe.ENOENT(t);if(!oe(r))throw Fe.EISDIR(t);var i=r.getData();switch(e.pathExistsAction()){case Oe.THROW_EXCEPTION:case Oe.TRUNCATE_FILE:throw Fe.EEXIST(t);case Oe.NOP:if(i.fileData)return new Xe(this,t,e,i.clone(),i.fileData);var o=this._requestFileSync(t,"buffer");return i.size=o.length,i.fileData=o,new Xe(this,t,e,i.clone(),o);default:throw new Fe(be.EINVAL,"Invalid FileMode object.")}},e.prototype.readdir=function(t,e){try{e(null,this.readdirSync(t))}catch(t){e(t)}},e.prototype.readdirSync=function(t){var e=this._index.getInode(t);if(null===e)throw Fe.ENOENT(t);if(se(e))return e.getListing();throw Fe.ENOTDIR(t)},e.prototype.readFile=function(t,e,n,r){var i=r;this.open(t,n,420,function(t,n){if(t)return r(t);r=function(t,e){n.close(function(n){return t||(t=n),i(t,e)})};var o=n,s=o.getBuffer();null===e?r(t,b(s)):ae(s,e,r)})},e.prototype.readFileSync=function(t,e,n){var r=this.openSync(t,n,420);try{var i=r,o=i.getBuffer();return null===e?b(o):o.toString(e)}finally{r.closeSync()}},e.prototype.getXhrPath=function(t){return"/"===t.charAt(0)&&(t=t.slice(1)),this.prefixUrl+t},e.prototype._requestFileAsync=function(t,e,n){Ki(this.getXhrPath(t),e,n)},e.prototype._requestFileSync=function(t,e){return Ji(this.getXhrPath(t),e)},e.prototype._requestFileSizeAsync=function(t,e){ie(this.getXhrPath(t),e)},e.prototype._requestFileSizeSync=function(t){return re(this.getXhrPath(t))},e}(We);to.Name="XmlHttpRequest",to.Options={index:{type:["string","object"],optional:!0,description:"URL to a file index as a JSON file or the file index object itself, generated with the make_xhrfs_index script. Defaults to `index.json`."},baseUrl:{type:"string",optional:!0,description:"Used as the URL prefix for fetched files. Default: Fetch files relative to the index."}};var eo=function(){};eo.str2byte=function(t,e){for(var n=t.length>e.length?e.length:t.length,r=0;r127){var o=eo.extendedChars.indexOf(t.charAt(r));o>-1&&(i=o+128)}e[i]=r}return n},eo.byte2str=function(t){for(var e=new Array(t.length),n=0;n127?e[n]=eo.extendedChars[r-128]:e[n]=String.fromCharCode(r)}return e.join("")},eo.byteLength=function(t){return t.length},eo.extendedChars=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];var no,ro=n(23).inflateRaw,io={};!function(t){t[t.MSDOS=0]="MSDOS",t[t.AMIGA=1]="AMIGA",t[t.OPENVMS=2]="OPENVMS",t[t.UNIX=3]="UNIX",t[t.VM_CMS=4]="VM_CMS",t[t.ATARI_ST=5]="ATARI_ST",t[t.OS2_HPFS=6]="OS2_HPFS",t[t.MAC=7]="MAC",t[t.Z_SYSTEM=8]="Z_SYSTEM",t[t.CP_M=9]="CP_M",t[t.NTFS=10]="NTFS",t[t.MVS=11]="MVS",t[t.VSE=12]="VSE",t[t.ACORN_RISC=13]="ACORN_RISC",t[t.VFAT=14]="VFAT",t[t.ALT_MVS=15]="ALT_MVS",t[t.BEOS=16]="BEOS",t[t.TANDEM=17]="TANDEM",t[t.OS_400=18]="OS_400",t[t.OSX=19]="OSX"}(no||(no={}));var oo;!function(t){t[t.STORED=0]="STORED",t[t.SHRUNK=1]="SHRUNK",t[t.REDUCED_1=2]="REDUCED_1",t[t.REDUCED_2=3]="REDUCED_2",t[t.REDUCED_3=4]="REDUCED_3",t[t.REDUCED_4=5]="REDUCED_4",t[t.IMPLODE=6]="IMPLODE",t[t.DEFLATE=8]="DEFLATE",t[t.DEFLATE64=9]="DEFLATE64",t[t.TERSE_OLD=10]="TERSE_OLD",t[t.BZIP2=12]="BZIP2",t[t.LZMA=14]="LZMA",t[t.TERSE_NEW=18]="TERSE_NEW",t[t.LZ77=19]="LZ77",t[t.WAVPACK=97]="WAVPACK",t[t.PPMD=98]="PPMD"}(oo||(oo={}));var so=function(t){if(this.data=t,67324752!==t.readUInt32LE(0))throw new Fe(be.EINVAL,"Invalid Zip file: Local file header has invalid signature: "+this.data.readUInt32LE(0))};so.prototype.versionNeeded=function(){return this.data.readUInt16LE(4)},so.prototype.flags=function(){return this.data.readUInt16LE(6)},so.prototype.compressionMethod=function(){return this.data.readUInt16LE(8)},so.prototype.lastModFileTime=function(){return ce(this.data.readUInt16LE(10),this.data.readUInt16LE(12))},so.prototype.rawLastModFileTime=function(){return this.data.readUInt32LE(10)},so.prototype.crc32=function(){return this.data.readUInt32LE(14)},so.prototype.fileNameLength=function(){return this.data.readUInt16LE(26)},so.prototype.extraFieldLength=function(){return this.data.readUInt16LE(28)},so.prototype.fileName=function(){return ue(this.data,this.useUTF8(),30,this.fileNameLength())},so.prototype.extraField=function(){var t=30+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())},so.prototype.totalSize=function(){return 30+this.fileNameLength()+this.extraFieldLength()},so.prototype.useUTF8=function(){return 2048===(2048&this.flags())};var ao=function(t,e,n){this.header=t,this.record=e,this.data=n};ao.prototype.decompress=function(){var t=this.header.compressionMethod(),e=io[t];if(e)return e(this.data,this.record.compressedSize(),this.record.uncompressedSize(),this.record.flag());var n=oo[t];throw n||(n="Unknown: "+t),new Fe(be.EINVAL,"Invalid compression method on file '"+this.header.fileName()+"': "+n)},ao.prototype.getHeader=function(){return this.header},ao.prototype.getRecord=function(){return this.record},ao.prototype.getRawData=function(){return this.data};var co=function(t){this.data=t};co.prototype.crc32=function(){return this.data.readUInt32LE(0)},co.prototype.compressedSize=function(){return this.data.readUInt32LE(4)},co.prototype.uncompressedSize=function(){return this.data.readUInt32LE(8)};var uo=function(t){if(this.data=t,134630224!==this.data.readUInt32LE(0))throw new Fe(be.EINVAL,"Invalid archive extra data record signature: "+this.data.readUInt32LE(0))};uo.prototype.length=function(){return this.data.readUInt32LE(4)},uo.prototype.extraFieldData=function(){return this.data.slice(8,8+this.length())};var fo=function(t){if(this.data=t,84233040!==this.data.readUInt32LE(0))throw new Fe(be.EINVAL,"Invalid digital signature signature: "+this.data.readUInt32LE(0))};fo.prototype.size=function(){return this.data.readUInt16LE(4)},fo.prototype.signatureData=function(){return this.data.slice(6,6+this.size())};var ho=function(t,e){if(this.zipData=t,this.data=e,33639248!==this.data.readUInt32LE(0))throw new Fe(be.EINVAL,"Invalid Zip file: Central directory record has invalid signature: "+this.data.readUInt32LE(0));this._filename=this.produceFilename()};ho.prototype.versionMadeBy=function(){return this.data.readUInt16LE(4)},ho.prototype.versionNeeded=function(){return this.data.readUInt16LE(6)},ho.prototype.flag=function(){return this.data.readUInt16LE(8)},ho.prototype.compressionMethod=function(){return this.data.readUInt16LE(10)},ho.prototype.lastModFileTime=function(){return ce(this.data.readUInt16LE(12),this.data.readUInt16LE(14))},ho.prototype.rawLastModFileTime=function(){return this.data.readUInt32LE(12)},ho.prototype.crc32=function(){return this.data.readUInt32LE(16)},ho.prototype.compressedSize=function(){return this.data.readUInt32LE(20)},ho.prototype.uncompressedSize=function(){return this.data.readUInt32LE(24)},ho.prototype.fileNameLength=function(){return this.data.readUInt16LE(28)},ho.prototype.extraFieldLength=function(){return this.data.readUInt16LE(30)},ho.prototype.fileCommentLength=function(){return this.data.readUInt16LE(32)},ho.prototype.diskNumberStart=function(){return this.data.readUInt16LE(34)},ho.prototype.internalAttributes=function(){return this.data.readUInt16LE(36)},ho.prototype.externalAttributes=function(){return this.data.readUInt32LE(38)},ho.prototype.headerRelativeOffset=function(){return this.data.readUInt32LE(42)},ho.prototype.produceFilename=function(){var t=ue(this.data,this.useUTF8(),46,this.fileNameLength());return t.replace(/\\/g,"/")},ho.prototype.fileName=function(){return this._filename},ho.prototype.rawFileName=function(){return this.data.slice(46,46+this.fileNameLength())},ho.prototype.extraField=function(){var t=44+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())},ho.prototype.fileComment=function(){var t=46+this.fileNameLength()+this.extraFieldLength();return ue(this.data,this.useUTF8(),t,this.fileCommentLength())},ho.prototype.rawFileComment=function(){var t=46+this.fileNameLength()+this.extraFieldLength();return this.data.slice(t,t+this.fileCommentLength())},ho.prototype.totalSize=function(){return 46+this.fileNameLength()+this.extraFieldLength()+this.fileCommentLength()},ho.prototype.isDirectory=function(){var t=this.fileName();return!!(16&this.externalAttributes())||"/"===t.charAt(t.length-1)},ho.prototype.isFile=function(){return!this.isDirectory()},ho.prototype.useUTF8=function(){return 2048===(2048&this.flag())},ho.prototype.isEncrypted=function(){return 1===(1&this.flag())},ho.prototype.getFileData=function(){var t=this.headerRelativeOffset(),e=new so(this.zipData.slice(t));return new ao(e,this,this.zipData.slice(t+e.totalSize()))},ho.prototype.getData=function(){return this.getFileData().decompress()},ho.prototype.getRawData=function(){return this.getFileData().getRawData()},ho.prototype.getStats=function(){return new Te(Le.FILE,this.uncompressedSize(),365,new Date,this.lastModFileTime())};var po=function(t){if(this.data=t,101010256!==this.data.readUInt32LE(0))throw new Fe(be.EINVAL,"Invalid Zip file: End of central directory record has invalid signature: "+this.data.readUInt32LE(0))};po.prototype.diskNumber=function(){return this.data.readUInt16LE(4)},po.prototype.cdDiskNumber=function(){return this.data.readUInt16LE(6)},po.prototype.cdDiskEntryCount=function(){return this.data.readUInt16LE(8)},po.prototype.cdTotalEntryCount=function(){return this.data.readUInt16LE(10)},po.prototype.cdSize=function(){return this.data.readUInt32LE(12)},po.prototype.cdOffset=function(){return this.data.readUInt32LE(16)},po.prototype.cdZipCommentLength=function(){return this.data.readUInt16LE(20)},po.prototype.cdZipComment=function(){return ue(this.data,!0,22,this.cdZipCommentLength())},po.prototype.rawCdZipComment=function(){return this.data.slice(22,22+this.cdZipCommentLength())};var lo=function(t,e,n,r){this.index=t,this.directoryEntries=e,this.eocd=n,this.data=r},yo=function(t){function e(n,r,i){void 0===r&&(r=""),void 0===i&&(i=!0),t.call(this),this.name=r,this._index=new Gi,this._directoryEntries=[],this._eocd=null,d(i,e.Name,{zipData:"zip data as a Buffer",name:r}),n instanceof lo?(this._index=n.index,this._directoryEntries=n.directoryEntries,this._eocd=n.eocd,this.data=n.data):(this.data=n,this.populateIndex())}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){try{e.computeIndex(t.zipData,function(r){var i=new e(r,t.name,!1);n(null,i)},!1)}catch(t){n(t)}},e.isAvailable=function(){return!0},e.RegisterDecompressionMethod=function(t,e){io[t]=e},e.computeIndex=function(t,n,r){void 0===r&&(r=!0),r&&console.warn("[ZipFS] ZipFS.computeIndex is now deprecated, and will be removed in the next major release. Please update your code to use 'ZipFS.Create({ zipData: zip file as a Buffer}, cb)' instead.");var i=new Gi,o=e.getEOCD(t);if(o.diskNumber()!==o.cdDiskNumber())throw new Fe(be.EINVAL,"ZipFS does not support spanned zip files.");var s=o.cdOffset();if(4294967295===s)throw new Fe(be.EINVAL,"ZipFS does not support Zip64.");var a=s+o.cdSize();e.computeIndexResponsive(t,i,s,a,n,[],o)},e.getEOCD=function(t){for(var e=22,n=Math.min(e+65535,t.length-1),r=e;r-1},Eo.prototype.getRockRidgeOffset=function(){return this._rockRidgeOffset},Eo.prototype.rootCheckForRockRidge=function(t){var e=this.getDirectory(t);this._rockRidgeOffset=e.getDotEntry(t)._getRockRidgeOffset(t),this._rockRidgeOffset>-1&&(this._fileOrDir=null)},Eo.prototype.length=function(){return this._data[0]},Eo.prototype.extendedAttributeRecordLength=function(){return this._data[1]},Eo.prototype.lba=function(){return 2048*this._data.readUInt32LE(2)},Eo.prototype.dataLength=function(){return this._data.readUInt32LE(10)},Eo.prototype.recordingDate=function(){return le(this._data,18)},Eo.prototype.fileFlags=function(){return this._data[25]},Eo.prototype.fileUnitSize=function(){return this._data[26]},Eo.prototype.interleaveGapSize=function(){return this._data[27]},Eo.prototype.volumeSequenceNumber=function(){return this._data.readUInt16LE(28)},Eo.prototype.identifier=function(){return this._getString(33,this._data[32])},Eo.prototype.fileName=function(t){if(this.hasRockRidge()){var e=this._rockRidgeFilename(t);if(null!==e)return e}var n=this.identifier();if(this.isDirectory(t))return n;var r=n.indexOf(";");return r===-1?n:"."===n[r-1]?n.slice(0,r-1):n.slice(0,r)},Eo.prototype.isDirectory=function(t){var e=!!(2&this.fileFlags());return!e&&this.hasRockRidge()&&(e=this.getSUEntries(t).filter(function(t){return t instanceof Uo}).length>0),e},Eo.prototype.isSymlink=function(t){return this.hasRockRidge()&&this.getSUEntries(t).filter(function(t){return t instanceof Do}).length>0},Eo.prototype.getSymlinkPath=function(t){for(var e="",n=this.getSUEntries(t),r=this._getGetString(),i=0,o=n;i1&&"/"===e[e.length-1]?e.slice(0,e.length-1):e},Eo.prototype.getFile=function(t){if(this.isDirectory(t))throw new Error("Tried to get a File from a directory.");return null===this._fileOrDir&&(this._fileOrDir=t.slice(this.lba(),this.lba()+this.dataLength())),this._fileOrDir},Eo.prototype.getDirectory=function(t){if(!this.isDirectory(t))throw new Error("Tried to get a Directory from a file.");return null===this._fileOrDir&&(this._fileOrDir=this._constructDirectory(t)),this._fileOrDir},Eo.prototype.getSUEntries=function(t){return this._suEntries||this._constructSUEntries(t),this._suEntries},Eo.prototype._rockRidgeFilename=function(t){var e=this.getSUEntries(t).filter(function(t){return t instanceof Co});if(0===e.length||6&e[0].flags())return null;for(var n="",r=this._getGetString(),i=0,o=e;i0){var n=e[0];if(n instanceof Fo&&n.checkBytesPass())for(var r=1;r + * @license MIT + */ +"use strict";function r(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}function i(e){if(e>J)throw new RangeError("Invalid typed array length");var n=new Uint8Array(e);return n.__proto__=t.prototype,n}function t(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(t)}return o(t,e,n)}function o(t,e,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return H(t)?h(t,e,n):"string"==typeof t?u(t,e):p(t)}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function a(t,e,n){return s(t),t<=0?i(t):void 0!==e?"string"==typeof n?i(t).fill(e,n):i(t).fill(e):i(t)}function c(t){return s(t),i(t<0?0:0|l(t))}function u(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!t.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|y(e,n),o=i(r),s=o.write(e,n);return s!==r&&(o=o.slice(0,s)),o}function f(t){for(var e=t.length<0?0:0|l(t.length),n=i(e),r=0;r=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|t}function d(e){return+e!=e&&(e=0),t.alloc(+e)}function y(e,n){if(t.isBuffer(e))return e.length;if(Z(e)||H(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var i=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(e).length;default:if(i)return B(e).length;n=(""+n).toLowerCase(),i=!0}}function g(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,n);case"utf8":case"utf-8":return F(this,e,n);case"ascii":return R(this,e,n);case"latin1":case"binary":return L(this,e,n);case"base64":return O(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function v(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function m(e,n,r,i,o){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Y(r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof n&&(n=t.from(n,i)),t.isBuffer(n))return 0===n.length?-1:_(e,n,r,i,o);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,n,r):Uint8Array.prototype.lastIndexOf.call(e,n,r):_(e,[n],r,i,o);throw new TypeError("val must be string, number or Buffer")}function _(t,e,n,r,i){function o(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,c=e.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}var u;if(i){var f=-1;for(u=n;ua&&(n=a-c),u=n;u>=0;u--){for(var h=!0,p=0;pi&&(r=i)):r=i;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s239?4:o>223?3:o>191?2:1;if(i+a<=n){var c,u,f,h;switch(a){case 1:o<128&&(s=o);break;case 2:c=t[i+1],128===(192&c)&&(h=(31&o)<<6|63&c,h>127&&(s=h));break;case 3:c=t[i+1],u=t[i+2],128===(192&c)&&128===(192&u)&&(h=(15&o)<<12|(63&c)<<6|63&u,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:c=t[i+1],u=t[i+2],f=t[i+3],128===(192&c)&&128===(192&u)&&128===(192&f)&&(h=(15&o)<<18|(63&c)<<12|(63&u)<<6|63&f,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=a}return N(r)}function N(t){var e=t.length;if(e<=G)return String.fromCharCode.apply(String,t);for(var n="",r=0;rr)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function D(e,n,r,i,o,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>o||ne.length)throw new RangeError("Index out of range")}function P(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function C(t,e,n,r,i){return e=+e,n>>>=0,i||P(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,i){return e=+e,n>>>=0,i||P(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,n,r,52,8),n+8}function M(t){if(t=t.trim().replace(Q,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function B(t,e){e=e||1/0;for(var n,r=t.length,i=null,o=[],s=0;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function z(t){for(var e=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function V(t){return X.toByteArray(M(t))}function W(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function H(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function Z(t){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(t)}function Y(t){return t!==t}var X=n(18),K=n(21);e.Buffer=t,e.SlowBuffer=d,e.INSPECT_MAX_BYTES=50;var J=2147483647;e.kMaxLength=J,t.TYPED_ARRAY_SUPPORT=r(),t.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),t.poolSize=8192,t.from=function(t,e,n){return o(t,e,n)},t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,t.alloc=function(t,e,n){return a(t,e,n)},t.allocUnsafe=function(t){return c(t)},t.allocUnsafeSlow=function(t){return c(t)},t.isBuffer=function(t){return null!=t&&t._isBuffer===!0},t.compare=function(e,n){if(!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(e===n)return 0;for(var r=e.length,i=n.length,o=0,s=Math.min(r,i);o0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},t.prototype.compare=function(e,n,r,i,o){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===o&&(o=this.length),n<0||r>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&n>=r)return 0;if(i>=o)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,i>>>=0,o>>>=0,this===e)return 0;for(var s=o-i,a=r-n,c=Math.min(s,a),u=this.slice(i,o),f=e.slice(n,r),h=0;h>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return w(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":return b(this,t,e,n);case"latin1":case"binary":return S(this,t,e,n);case"base64":return k(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var G=4096;t.prototype.slice=function(e,n){var r=this.length;e=~~e,n=void 0===n?r:~~n,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t],i=1,o=0;++o>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},t.prototype.readUInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t],i=1,o=0;++o=i&&(r-=Math.pow(2,8*e)),r},t.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},t.prototype.readInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){t>>>=0,e||A(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(t,e){t>>>=0,e||A(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return t>>>=0,e||A(t,4,this.length),K.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return t>>>=0,e||A(t,4,this.length),K.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return t>>>=0,e||A(t,8,this.length),K.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return t>>>=0,e||A(t,8,this.length),K.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){var i=Math.pow(2,8*n)-1;D(this,t,e,n,i,0)}var o=1,s=0;for(this[e]=255&t;++s>>=0,n>>>=0,!r){var i=Math.pow(2,8*n)-1;D(this,t,e,n,i,0)}var o=n-1,s=1;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+n},t.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,1,255,0),this[e]=255&t,e+1},t.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},t.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},t.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},t.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},t.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+n},t.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+n},t.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},t.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},t.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},t.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},t.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},t.prototype.writeFloatLE=function(t,e,n){return C(this,t,e,!0,n)},t.prototype.writeFloatBE=function(t,e,n){return C(this,t,e,!1,n)},t.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},t.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},t.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var s;if("number"==typeof e)for(s=n;s0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,i,s,a;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,i=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(a=s;a-- >0;)if(n[a]===e||n[a].listener&&n[a].listener===e){i=a;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(r(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,n){t.exports=n(1).Buffer},function(t,e){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var r={arraySet:function(t,e,n,r,i){if(e.subarray&&t.subarray)return void t.set(e.subarray(n,n+r),i);for(var o=0;os)throw new RangeError("size is too large");var r=n,o=e;void 0===o&&(r=void 0,o=0);var a=new i(t);if("string"==typeof o)for(var c=new i(o,r),u=c.length,f=-1;++fs)throw new RangeError("size is too large");return new i(t)},e.from=function(e,n,r){if("function"==typeof i.from&&(!t.Uint8Array||Uint8Array.from!==i.from))return i.from(e,n,r);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new i(e,n);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var o=n;if(1===arguments.length)return new i(e);"undefined"==typeof o&&(o=0);var s=r;if("undefined"==typeof s&&(s=e.byteLength-o),o>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(s>e.byteLength-o)throw new RangeError("'length' is out of bounds");return new i(e.slice(o,o+s))}if(i.isBuffer(e)){var a=new i(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new i(e);if("Buffer"===e.type&&Array.isArray(e.data))return new i(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},e.allocUnsafeSlow=function(t){if("function"==typeof i.allocUnsafeSlow)return i.allocUnsafeSlow(t);if("number"!=typeof t)throw new TypeError("size must be a number");if(t>=s)throw new RangeError("size is too large");return new o(t)}}).call(e,function(){return this}())},function(t,e,n){(function(e){"use strict";function n(t,n,r,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,i)});default:for(o=new Array(a-1),s=0;s-1?setImmediate:k;s.WritableState=o;var O=n(5);O.inherits=n(4);var F,N={deprecate:n(40)};!function(){try{F=n(9)}catch(t){}finally{F||(F=n(6).EventEmitter)}}();var R=n(1).Buffer,L=n(10);O.inherits(s,F),o.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(o.prototype,"buffer",{get:N.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(t){}}();var T;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(T=Function.prototype[Symbol.hasInstance],Object.defineProperty(s,Symbol.hasInstance,{value:function(t){return!!T.call(this,t)||t&&t._writableState instanceof o}})):T=function(t){return t instanceof this},s.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},s.prototype.write=function(t,e,n){var i=this._writableState,o=!1,s=R.isBuffer(t);return"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=r),i.ended?a(this,n):(s||c(this,i,t,n))&&(i.pendingcb++,o=f(this,i,s,t,e,n)),o},s.prototype.cork=function(){var t=this._writableState;t.corked++},s.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||v(this,t))},s.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},s.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},s.prototype._writev=null,s.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||E(this,r,n)}}).call(e,n(3))},function(t,e,n){(function(e){"use strict";function n(t){var e=r.exec(t);return e.shift(),e}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(){function t(){}return t.normalize=function(e){""===e&&(e=".");var n=e.charAt(0)===t.sep;e=t._removeDuplicateSeps(e);for(var r=e.split(t.sep),i=[],o=0;o0&&".."!==i[0])?i.pop():i.push(s))}if(!n&&i.length<2)switch(i.length){case 1:""===i[0]&&i.unshift(".");break;default:i.push(".")}return e=i.join(t.sep),n&&e.charAt(0)!==t.sep&&(e=t.sep+e),e},t.join=function(){for(var e=[],n=0;n1&&a.charAt(a.length-1)===t.sep)return a.substr(0,a.length-1);if(a.charAt(0)!==t.sep){"."!==a.charAt(0)||1!==a.length&&a.charAt(1)!==t.sep||(a=1===a.length?"":a.substr(2));var c=e.cwd();a=""!==a?this.normalize(c+("/"!==c?t.sep:"")+a):c}return a},t.relative=function(e,n){var r;e=t.resolve(e),n=t.resolve(n);var i=e.split(t.sep),o=n.split(t.sep);o.shift(),i.shift();var s=0,a=[];for(r=0;ri.length&&(s=i.length);var u="";for(r=0;r1&&u.charAt(u.length-1)===t.sep&&(u=u.substr(0,u.length-1)),u},t.dirname=function(e){e=t._removeDuplicateSeps(e);var n=e.charAt(0)===t.sep,r=e.split(t.sep);return""===r.pop()&&r.length>0&&r.pop(),r.length>1||1===r.length&&!n?r.join(t.sep):n?t.sep:"."},t.basename=function(e,n){if(void 0===n&&(n=""),""===e)return e;e=t.normalize(e);var r=e.split(t.sep),i=r[r.length-1];if(""===i&&r.length>1)return r[r.length-2];if(n.length>0){var o=i.substr(i.length-n.length);if(o===n)return i.substr(0,i.length-n.length)}return i},t.extname=function(e){e=t.normalize(e);var n=e.split(t.sep);if(e=n.pop(),""===e&&n.length>0&&(e=n.pop()),".."===e)return"";var r=e.lastIndexOf(".");return r===-1||0===r?"":e.substr(r)},t.isAbsolute=function(e){return e.length>0&&e.charAt(0)===t.sep},t._makeLong=function(t){return t},t.parse=function(t){var e=n(t);return{root:e[0],dir:e[0]+e[1].slice(0,-1),base:e[2],ext:e[3],name:e[2].slice(0,e[2].length-e[3].length)}},t.format=function(e){if(null===e||"object"!=typeof e)throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var n=e.root||"";if("string"!=typeof n)throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);var r=e.dir?e.dir+t.sep:"",i=e.base||"";return r+i},t._removeDuplicateSeps=function(t){return t=t.replace(this._replaceRegex,this.sep)},t.sep="/",t._replaceRegex=new RegExp("//+","g"),t.delimiter=":",t.posix=t,t.win32=t,t}();t.exports=i}).call(e,n(3))},function(t,e,n){"use strict";function r(t){return this instanceof r?void i.call(this,t):new r(t)}t.exports=r;var i=n(12),o=n(5);o.inherits=n(4),o.inherits(r,i),r.prototype._transform=function(t,e,n){n(null,t)}},function(t,e,n){(function(e){"use strict";function r(t,e,n){return"function"==typeof t.prependListener?t.prependListener(e,n):void(t._events&&t._events[e]?T(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n))}function i(t,e){R=R||n(2),t=t||{},this.objectMode=!!t.objectMode,e instanceof R&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var r=t.highWaterMark,i=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i,this.highWaterMark=~~this.highWaterMark,this.buffer=new B,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(j||(j=n(17).StringDecoder),this.decoder=new j(t.encoding),this.encoding=t.encoding)}function o(t){return R=R||n(2),this instanceof o?(this._readableState=new i(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),void x.call(this)):new o(t)}function s(t,e,n,r,i){var o=f(e,n);if(o)t.emit("error",o);else if(null===n)e.reading=!1,h(t,e);else if(e.objectMode||n&&n.length>0)if(e.ended&&!i){var s=new Error("stream.push() after EOF");t.emit("error",s)}else if(e.endEmitted&&i){var c=new Error("stream.unshift() after end event");t.emit("error",c)}else{var u;!e.decoder||i||r||(n=e.decoder.write(n),u=!e.objectMode&&0===n.length),i||(e.reading=!1),u||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,i?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&p(t))),d(t,e)}else i||(e.reading=!1);return a(e)}function a(t){return!t.ended&&(t.needReadable||t.length=z?t=z:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function u(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=c(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function f(t,e){var n=null;return D.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function h(t,e){if(!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,p(t)}}function p(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(M("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?L(l,t):l(t))}function l(t){M("emit readable"),t.emit("readable"),w(t)}function d(t,e){e.readingMore||(e.readingMore=!0,L(y,t,e))}function y(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=b(t,e.buffer,e.decoder),n}function b(t,e,n){var r;return to.length?o.length:t;if(i+=s===o.length?o:o.slice(0,t),t-=s,0===t){s===o.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++r}return e.length-=r,i}function k(t,e){var n=P.allocUnsafe(t),r=e.head,i=1;for(r.data.copy(n),t-=r.data.length;r=r.next;){var o=r.data,s=t>o.length?o.length:t;if(o.copy(n,n.length-t,0,s),t-=s,0===t){s===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++i}return e.length-=i,n}function I(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,L(O,e,t))}function O(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function F(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return M("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?I(this):p(this),null;if(t=u(t,e),0===t&&e.ended)return 0===e.length&&I(this),null;var r=e.needReadable;M("need readable",r),(0===e.length||e.length-t0?E(t,e):null,null===i?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&I(this)),null!==i&&this.emit("data",i),i},o.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},o.prototype.pipe=function(t,n){function i(t){M("onunpipe"),t===p&&s()}function o(){M("onend"),t.end()}function s(){M("cleanup"),t.removeListener("close",u),t.removeListener("finish",f),t.removeListener("drain",v),t.removeListener("error",c),t.removeListener("unpipe",i),p.removeListener("end",o),p.removeListener("end",s),p.removeListener("data",a),m=!0,!l.awaitDrain||t._writableState&&!t._writableState.needDrain||v()}function a(e){M("ondata"),_=!1;var n=t.write(e);!1!==n||_||((1===l.pipesCount&&l.pipes===t||l.pipesCount>1&&N(l.pipes,t)!==-1)&&!m&&(M("false write response, pause",p._readableState.awaitDrain),p._readableState.awaitDrain++,_=!0),p.pause())}function c(e){M("onerror",e),h(),t.removeListener("error",c),0===A(t,"error")&&t.emit("error",e)}function u(){t.removeListener("finish",f),h()}function f(){M("onfinish"),t.removeListener("close",u),h()}function h(){M("unpipe"),p.unpipe(t)}var p=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=t;break;case 1:l.pipes=[l.pipes,t];break;default:l.pipes.push(t)}l.pipesCount+=1,M("pipe count=%d opts=%j",l.pipesCount,n);var d=(!n||n.end!==!1)&&t!==e.stdout&&t!==e.stderr,y=d?o:s;l.endEmitted?L(y):p.once("end",y),t.on("unpipe",i);var v=g(p);t.on("drain",v);var m=!1,_=!1;return p.on("data",a),r(t,"error",c),t.once("close",u),t.once("finish",f),t.emit("pipe",p),l.flowing||(M("pipe resume"),p.resume()),t},o.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var i=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),e+=t.toString(this.encoding,0,i);var i=e.length-1,r=e.charCodeAt(i);if(r>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},u.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(1==e&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},u.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e}},function(t,e){"use strict";function n(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function r(t){return 3*t.length/4-n(t)}function i(t){var e,r,i,o,s,a,c=t.length;s=n(t),a=new f(3*c/4-s),i=s>0?c-4:c;var h=0;for(e=0,r=0;e>16&255,a[h++]=o>>8&255,a[h++]=255&o;return 2===s?(o=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,a[h++]=255&o):1===s&&(o=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,a[h++]=o>>8&255,a[h++]=255&o),a}function o(t){return c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[63&t]}function s(t,e,n){for(var r,i=[],s=e;sf?f:u+a));return 1===r?(e=t[n-1],i+=c[e>>2],i+=c[e<<4&63],i+="=="):2===r&&(e=(t[n-2]<<8)+t[n-1],i+=c[e>>10],i+=c[e>>4&63],i+=c[e<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=r,e.toByteArray=i,e.fromByteArray=a;for(var c=[],u=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,l=h.length;p0&&(this._waitingForWrites=this.push(this._bufferedWrites.shift()),this._waitingForWrites););},n}(i.Duplex);t.exports=o}).call(e,n(7))},function(t,e){e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,c=(1<>1,f=-7,h=n?i-1:0,p=n?-1:1,l=t[e+h];for(h+=p,o=l&(1<<-f)-1,l>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=p,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[e+h],h+=p,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:(l?-1:1)*(1/0);s+=Math.pow(2,r),o-=u}return(l?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:o-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),e+=s+h>=1?p/c:p*Math.pow(2,1-h),e*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[n+l]=255&a,l+=d,a/=256,i-=8);for(s=s<0;t[n+l]=255&s,l+=d,s/=256,u-=8);t[n+l-d]|=128*y}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";function r(t){if(!(this instanceof r))return new r(t);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0===(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var n=s.inflateInit2(this.strm,e.windowBits);if(n!==u.Z_OK)throw new Error(f[n]);this.header=new p,s.inflateGetHeader(this.strm,this.header)}function i(t,e){var n=new r(e);if(n.push(t,!0),n.err)throw n.msg||f[n.err];return n.result}function o(t,e){return e=e||{},e.raw=!0,i(t,e)}var s=n(30),a=n(8),c=n(24),u=n(26),f=n(32),h=n(33),p=n(28),l=Object.prototype.toString;r.prototype.push=function(t,e){var n,r,i,o,f,h,p=this.strm,d=this.options.chunkSize,y=this.options.dictionary,g=!1;if(this.ended)return!1;r=e===~~e?e:e===!0?u.Z_FINISH:u.Z_NO_FLUSH,"string"==typeof t?p.input=c.binstring2buf(t):"[object ArrayBuffer]"===l.call(t)?p.input=new Uint8Array(t):p.input=t,p.next_in=0,p.avail_in=p.input.length;do{if(0===p.avail_out&&(p.output=new a.Buf8(d),p.next_out=0,p.avail_out=d),n=s.inflate(p,u.Z_NO_FLUSH),n===u.Z_NEED_DICT&&y&&(h="string"==typeof y?c.string2buf(y):"[object ArrayBuffer]"===l.call(y)?new Uint8Array(y):y,n=s.inflateSetDictionary(this.strm,h)),n===u.Z_BUF_ERROR&&g===!0&&(n=u.Z_OK,g=!1),n!==u.Z_STREAM_END&&n!==u.Z_OK)return this.onEnd(n),this.ended=!0,!1;p.next_out&&(0!==p.avail_out&&n!==u.Z_STREAM_END&&(0!==p.avail_in||r!==u.Z_FINISH&&r!==u.Z_SYNC_FLUSH)||("string"===this.options.to?(i=c.utf8border(p.output,p.next_out),o=p.next_out-i,f=c.buf2string(p.output,i),p.next_out=o,p.avail_out=d-o,o&&a.arraySet(p.output,p.output,i,o,0),this.onData(f)):this.onData(a.shrinkBuf(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(g=!0)}while((p.avail_in>0||0===p.avail_out)&&n!==u.Z_STREAM_END);return n===u.Z_STREAM_END&&(r=u.Z_FINISH),r===u.Z_FINISH?(n=s.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===u.Z_OK):r!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),p.avail_out=0,!0)},r.prototype.onData=function(t){this.chunks.push(t)},r.prototype.onEnd=function(t){t===u.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=r,e.inflate=i,e.inflateRaw=o,e.ungzip=i},function(t,e,n){"use strict";function r(t,e){if(e<65537&&(t.subarray&&s||!t.subarray&&o))return String.fromCharCode.apply(null,i.shrinkBuf(t,e));for(var n="",r=0;r=252?6:c>=248?5:c>=240?4:c>=224?3:c>=192?2:1;a[254]=a[254]=1,e.string2buf=function(t){var e,n,r,o,s,a=t.length,c=0;for(o=0;o>>6,e[s++]=128|63&n):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|63&n):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|63&n);return e},e.buf2binstring=function(t){return r(t,t.length)},e.binstring2buf=function(t){for(var e=new i.Buf8(t.length),n=0,r=e.length;n4)u[i++]=65533,n+=s-1;else{for(o&=2===s?31:3===s?15:7;s>1&&n1?u[i++]=65533:o<65536?u[i++]=o:(o-=65536,u[i++]=55296|o>>10&1023,u[i++]=56320|1023&o)}return r(u,i)},e.utf8border=function(t,e){ +var n;for(e=e||t.length,e>t.length&&(e=t.length),n=e-1;n>=0&&128===(192&t[n]);)n--;return n<0?e:0===n?e:n+a[t[n]]>e?n:e}},function(t,e){"use strict";function n(t,e,n,r){for(var i=65535&t|0,o=t>>>16&65535|0,s=0;0!==n;){s=n>2e3?2e3:n,n-=s;do i=i+e[r++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0}t.exports=n},function(t,e){"use strict";t.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}},function(t,e){"use strict";function n(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}function r(t,e,n,r){var o=i,s=r+n;t^=-1;for(var a=r;a>>8^o[255&(t^e[a])];return t^-1}var i=n();t.exports=r},function(t,e){"use strict";function n(){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=!1}t.exports=n},function(t,e){"use strict";var n=30,r=12;t.exports=function(t,e){var i,o,s,a,c,u,f,h,p,l,d,y,g,v,m,_,w,E,b,S,k,I,O,F,N;i=t.state,o=t.next_in,F=t.input,s=o+(t.avail_in-5),a=t.next_out,N=t.output,c=a-(e-t.avail_out),u=a+(t.avail_out-257),f=i.dmax,h=i.wsize,p=i.whave,l=i.wnext,d=i.window,y=i.hold,g=i.bits,v=i.lencode,m=i.distcode,_=(1<>>24,y>>>=b,g-=b,b=E>>>16&255,0===b)N[a++]=65535&E;else{if(!(16&b)){if(0===(64&b)){E=v[(65535&E)+(y&(1<>>=b,g-=b),g<15&&(y+=F[o++]<>>24,y>>>=b,g-=b,b=E>>>16&255,!(16&b)){if(0===(64&b)){E=m[(65535&E)+(y&(1<f){t.msg="invalid distance too far back",i.mode=n;break t}if(y>>>=b,g-=b,b=a-c,k>b){if(b=k-b,b>p&&i.sane){t.msg="invalid distance too far back",i.mode=n;break t}if(I=0,O=d,0===l){if(I+=h-b,b2;)N[a++]=O[I++],N[a++]=O[I++],N[a++]=O[I++],S-=3;S&&(N[a++]=O[I++],S>1&&(N[a++]=O[I++]))}else{I=a-k;do N[a++]=N[I++],N[a++]=N[I++],N[a++]=N[I++],S-=3;while(S>2);S&&(N[a++]=N[I++],S>1&&(N[a++]=N[I++]))}break}}break}}while(o>3,o-=S,g-=S<<3,y&=(1<>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function i(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,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 m.Buf16(320),this.work=new m.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function o(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=U,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new m.Buf32(yt),e.distcode=e.distdyn=new m.Buf32(gt),e.sane=1,e.back=-1,R):x}function s(t){var e;return t&&t.state?(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,o(t)):x}function a(t,e){var n,r;return t&&t.state?(r=t.state,e<0?(n=0,e=-e):(n=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?x:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,s(t))):x}function c(t,e){var n,r;return t?(r=new i,t.state=r,r.window=null,n=a(t,e),n!==R&&(t.state=null),n):x}function u(t){return c(t,mt)}function f(t){if(_t){var e;for(g=new m.Buf32(512),v=new m.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(b(k,t.lens,0,288,g,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;b(I,t.lens,0,32,v,0,t.work,{bits:5}),_t=!1}t.lencode=g,t.lenbits=9,t.distcode=v,t.distbits=5}function h(t,e,n,r){var i,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(m.arraySet(o.window,e,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),m.arraySet(o.window,e,n-r,i,o.wnext),r-=i,r?(m.arraySet(o.window,e,n-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=w(n.check,Ft,2,0),p=0,l=0,n.mode=M;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&p)<<8)+(p>>8))%31){t.msg="incorrect header check",n.mode=pt;break}if((15&p)!==C){t.msg="unknown compression method",n.mode=pt;break}if(p>>>=4,l-=4,bt=(15&p)+8,0===n.wbits)n.wbits=bt;else if(bt>n.wbits){t.msg="invalid window size",n.mode=pt;break}n.dmax=1<>8&1),512&n.flags&&(Ft[0]=255&p,Ft[1]=p>>>8&255,n.check=w(n.check,Ft,2,0)),p=0,l=0,n.mode=j;case j:for(;l<32;){if(0===c)break t;c--,p+=i[s++]<>>8&255,Ft[2]=p>>>16&255,Ft[3]=p>>>24&255,n.check=w(n.check,Ft,4,0)),p=0,l=0,n.mode=B;case B:for(;l<16;){if(0===c)break t;c--,p+=i[s++]<>8),512&n.flags&&(Ft[0]=255&p,Ft[1]=p>>>8&255,n.check=w(n.check,Ft,2,0)),p=0,l=0,n.mode=z;case z:if(1024&n.flags){for(;l<16;){if(0===c)break t;c--,p+=i[s++]<>>8&255,n.check=w(n.check,Ft,2,0)),p=0,l=0}else n.head&&(n.head.extra=null);n.mode=q;case q:if(1024&n.flags&&(g=n.length,g>c&&(g=c),g&&(n.head&&(bt=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),m.arraySet(n.head.extra,i,s,g,bt)),512&n.flags&&(n.check=w(n.check,i,g,s)),c-=g,s+=g,n.length-=g),n.length))break t;n.length=0,n.mode=V;case V:if(2048&n.flags){if(0===c)break t;g=0;do bt=i[s+g++],n.head&&bt&&n.length<65536&&(n.head.name+=String.fromCharCode(bt));while(bt&&g>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=X;break;case Z:for(;l<32;){if(0===c)break t;c--,p+=i[s++]<>>=7&l,l-=7&l,n.mode=ut;break}for(;l<3;){if(0===c)break t;c--,p+=i[s++]<>>=1,l-=1,3&p){case 0:n.mode=J;break;case 1:if(f(n),n.mode=nt,e===N){p>>>=2,l-=2;break t}break;case 2:n.mode=$;break;case 3:t.msg="invalid block type",n.mode=pt}p>>>=2,l-=2;break;case J:for(p>>>=7&l,l-=7&l;l<32;){if(0===c)break t;c--,p+=i[s++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=pt;break}if(n.length=65535&p,p=0,l=0,n.mode=G,e===N)break t;case G:n.mode=Q;case Q:if(g=n.length){if(g>c&&(g=c),g>u&&(g=u),0===g)break t;m.arraySet(o,i,s,g,a),c-=g,s+=g,u-=g,a+=g,n.length-=g;break}n.mode=X;break;case $:for(;l<14;){if(0===c)break t;c--,p+=i[s++]<>>=5,l-=5,n.ndist=(31&p)+1,p>>>=5,l-=5,n.ncode=(15&p)+4,p>>>=4,l-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=pt;break}n.have=0,n.mode=tt;case tt:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[Nt[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,kt={bits:n.lenbits},St=b(S,n.lens,0,19,n.lencode,0,n.work,kt),n.lenbits=kt.bits,St){t.msg="invalid code lengths set",n.mode=pt;break}n.have=0,n.mode=et;case et:for(;n.have>>24,vt=Ot>>>16&255,mt=65535&Ot,!(gt<=l);){if(0===c)break t;c--,p+=i[s++]<>>=gt,l-=gt,n.lens[n.have++]=mt;else{if(16===mt){for(It=gt+2;l>>=gt,l-=gt,0===n.have){t.msg="invalid bit length repeat",n.mode=pt;break}bt=n.lens[n.have-1],g=3+(3&p),p>>>=2,l-=2}else if(17===mt){for(It=gt+3;l>>=gt,l-=gt,bt=0,g=3+(7&p),p>>>=3,l-=3}else{for(It=gt+7;l>>=gt,l-=gt,bt=0,g=11+(127&p),p>>>=7,l-=7}if(n.have+g>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=pt;break}for(;g--;)n.lens[n.have++]=bt}}if(n.mode===pt)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=pt;break}if(n.lenbits=9,kt={bits:n.lenbits},St=b(k,n.lens,0,n.nlen,n.lencode,0,n.work,kt),n.lenbits=kt.bits,St){t.msg="invalid literal/lengths set",n.mode=pt;break}if(n.distbits=6,n.distcode=n.distdyn,kt={bits:n.distbits},St=b(I,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,kt),n.distbits=kt.bits,St){t.msg="invalid distances set",n.mode=pt;break}if(n.mode=nt,e===N)break t;case nt:n.mode=rt;case rt:if(c>=6&&u>=258){t.next_out=a,t.avail_out=u,t.next_in=s,t.avail_in=c,n.hold=p,n.bits=l,E(t,y),a=t.next_out,o=t.output,u=t.avail_out,s=t.next_in,i=t.input,c=t.avail_in,p=n.hold,l=n.bits,n.mode===X&&(n.back=-1);break}for(n.back=0;Ot=n.lencode[p&(1<>>24,vt=Ot>>>16&255,mt=65535&Ot,!(gt<=l);){if(0===c)break t;c--,p+=i[s++]<>_t)],gt=Ot>>>24,vt=Ot>>>16&255,mt=65535&Ot,!(_t+gt<=l);){if(0===c)break t;c--,p+=i[s++]<>>=_t,l-=_t,n.back+=_t}if(p>>>=gt,l-=gt,n.back+=gt,n.length=mt,0===vt){n.mode=ct;break}if(32&vt){n.back=-1,n.mode=X;break}if(64&vt){t.msg="invalid literal/length code",n.mode=pt;break}n.extra=15&vt,n.mode=it;case it:if(n.extra){for(It=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ot;case ot:for(;Ot=n.distcode[p&(1<>>24,vt=Ot>>>16&255,mt=65535&Ot,!(gt<=l);){if(0===c)break t;c--,p+=i[s++]<>_t)],gt=Ot>>>24,vt=Ot>>>16&255,mt=65535&Ot,!(_t+gt<=l);){if(0===c)break t;c--,p+=i[s++]<>>=_t,l-=_t,n.back+=_t}if(p>>>=gt,l-=gt,n.back+=gt,64&vt){t.msg="invalid distance code",n.mode=pt;break}n.offset=mt,n.extra=15&vt,n.mode=st;case st:if(n.extra){for(It=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=pt;break}n.mode=at;case at:if(0===u)break t;if(g=y-u,n.offset>g){if(g=n.offset-g,g>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=pt;break}g>n.wnext?(g-=n.wnext,v=n.wsize-g):v=n.wnext-g,g>n.length&&(g=n.length),yt=n.window}else yt=o,v=a-n.offset,g=n.length;g>u&&(g=u),u-=g,n.length-=g;do o[a++]=yt[v++];while(--g);0===n.length&&(n.mode=rt);break;case ct:if(0===u)break t;o[a++]=n.length,u--,n.mode=rt;break;case ut:if(n.wrap){for(;l<32;){if(0===c)break t;c--,p|=i[s++]<=1&&0===z[x];x--);if(A>x&&(A=x),0===x)return y[g++]=20971520,y[g++]=20971520,m.bits=1,0;for(T=1;T0&&(t===a||1!==x))return-1;for(q[1]=0,R=1;Ro||t===u&&U>s)return 1;for(;;){I=R-P,v[L]k?(O=V[W+v[L]],F=j[B+v[L]]):(O=96,F=0),_=1<>P)+w]=I<<24|O<<16|F|0;while(0!==w);for(_=1<>=1;if(0!==_?(M&=_-1,M+=_):M=0,L++,0===--z[R]){if(R===x)break;R=e[n+v[L]]}if(R>A&&(M&b)!==E){for(0===P&&(P=A),S+=T,D=R-P,C=1<o||t===u&&U>s)return 1;E=M&b,y[E]=A<<24|D<<16|S-g|0}}return 0!==M&&(y[S+M]=R-P<<24|64<<16|0),m.bits=A,0}},function(t,e){"use strict";t.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"}},function(t,e){"use strict";function n(){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}t.exports=n},function(t,e,n){t.exports=n(2)},function(t,e,n){"use strict";function r(){this.head=null,this.tail=null,this.length=0}var i=(n(1).Buffer,n(10));t.exports=r,r.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},r.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},r.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},r.prototype.clear=function(){this.head=this.tail=null,this.length=0},r.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},r.prototype.concat=function(t){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var e=i.allocUnsafe(t>>>0),n=this.head,r=0;n;)n.data.copy(e,r),r+=n.data.length,n=n.next;return e}},function(t,e,n){t.exports=n(15)},function(t,e,n){(function(r){var i=function(){try{return n(9)}catch(t){}}();e=t.exports=n(16),e.Stream=i||e,e.Readable=e,e.Writable=n(13),e.Duplex=n(2),e.Transform=n(12),e.PassThrough=n(15),!r.browser&&"disable"===r.env.READABLE_STREAM&&i&&(t.exports=i)}).call(e,n(3))},function(t,e,n){t.exports=n(12)},function(t,e,n){t.exports=n(13)},function(t,e){(function(e){function n(t,e){function n(){if(!i){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),i=!0}return t.apply(this,arguments)}if(r("noDeprecation"))return t;var i=!1;return n}function r(t){try{if(!e.localStorage)return!1}catch(t){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(e,function(){return this}())},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){}])}); +//# sourceMappingURL=browserfs.min.js.map \ No newline at end of file diff --git a/pkg/emscripten/libretro-thread/jsdeps/zip-full.min.js b/pkg/emscripten/libretro-thread/jsdeps/zip-full.min.js new file mode 100644 index 0000000000..9270310200 --- /dev/null +++ b/pkg/emscripten/libretro-thread/jsdeps/zip-full.min.js @@ -0,0 +1 @@ +((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zip={})})(this,(function(e){"use strict";const{Array:t,Object:n,String:r,Number:i,BigInt:s,Math:a,Date:o,Map:l,Set:c,Response:u,URL:f,Error:d,Uint8Array:w,Uint16Array:h,Uint32Array:p,DataView:g,Blob:_,Promise:m,TextEncoder:b,TextDecoder:y,document:x,crypto:k,btoa:S,TransformStream:v,ReadableStream:z,WritableStream:A,CompressionStream:C,DecompressionStream:D,navigator:E,Worker:F}="undefined"!=typeof globalThis?globalThis:this||self;var W=void 0!==x?x.currentScript:null;const R=-2;function T(e){return L(e.map((([e,n])=>new t(e).fill(n,0,e))))}function L(e){return e.reduce(((e,n)=>e.concat(t.isArray(n)?L(n):n)),[])}const U=[0,1,2,3].concat(...T([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function I(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.build_tree=n=>{const r=e.dyn_tree,i=e.stat_desc.static_tree,s=e.stat_desc.elems;let o,l,c,u=-1;for(n.heap_len=0,n.heap_max=573,o=0;s>o;o++)0!==r[2*o]?(n.heap[++n.heap_len]=u=o,n.depth[o]=0):r[2*o+1]=0;for(;2>n.heap_len;)c=n.heap[++n.heap_len]=2>u?++u:0,r[2*c]=1,n.depth[c]=0,n.opt_len--,i&&(n.static_len-=i[2*c+1]);for(e.max_code=u,o=a.floor(n.heap_len/2);o>=1;o--)n.pqdownheap(r,o);c=s;do{o=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(r,1),l=n.heap[1],n.heap[--n.heap_max]=o,n.heap[--n.heap_max]=l,r[2*c]=r[2*o]+r[2*l],n.depth[c]=a.max(n.depth[o],n.depth[l])+1,r[2*o+1]=r[2*l+1]=c,n.heap[1]=c++,n.pqdownheap(r,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],(t=>{const n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,a=e.stat_desc.max_length;let o,l,c,u,f,d,w=0;for(u=0;15>=u;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,o=t.heap_max+1;573>o;o++)l=t.heap[o],u=n[2*n[2*l+1]+1]+1,u>a&&(u=a,w++),n[2*l+1]=u,l>e.max_code||(t.bl_count[u]++,f=0,s>l||(f=i[l-s]),d=n[2*l],t.opt_len+=d*(u+f),r&&(t.static_len+=d*(r[2*l+1]+f)));if(0!==w){do{for(u=a-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[a]--,w-=2}while(w>0);for(u=a;0!==u;u--)for(l=t.bl_count[u];0!==l;)c=t.heap[--o],c>e.max_code||(n[2*c+1]!=u&&(t.opt_len+=(u-n[2*c+1])*n[2*c],n[2*c+1]=u),l--)}})(n),((e,n,r)=>{const i=[];let s,a,o,l=0;for(s=1;15>=s;s++)i[s]=l=l+r[s-1]<<1;for(a=0;n>=a;a++)o=e[2*a+1],0!==o&&(e[2*a]=t(i[o]++,o))})(r,e.max_code,n.bl_count)}}function N(e,t,n,r,i){const s=this;s.static_tree=e,s.extra_bits=t,s.extra_base=n,s.elems=r,s.max_length=i}I._length_code=[0,1,2,3,4,5,6,7].concat(...T([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),I.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],I.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],I.d_code=e=>256>e?U[e]:U[256+(e>>>7)],I.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],I.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],I.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const q=T([[144,8],[112,9],[24,7],[8,8]]);N.static_ltree=L([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,q[t]])));const O=T([[30,5]]);function P(e,t,n,r,i){const s=this;s.good_length=e,s.max_lazy=t,s.nice_length=n,s.max_chain=r,s.func=i}N.static_dtree=L([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,O[t]]))),N.static_l_desc=new N(N.static_ltree,I.extra_lbits,257,286,15),N.static_d_desc=new N(N.static_dtree,I.extra_dbits,0,30,15),N.static_bl_desc=new N(null,I.extra_blbits,0,19,7);const H=[new P(0,0,0,0,0),new P(4,4,8,4,1),new P(4,5,16,8,1),new P(4,6,32,32,1),new P(4,4,16,16,2),new P(8,16,32,32,2),new P(8,16,128,128,2),new P(8,32,128,256,2),new P(32,128,258,1024,2),new P(32,258,258,4096,2)],M=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],B=113,V=666,Z=262;function K(e,t,n,r){const i=e[2*t],s=e[2*n];return s>i||i==s&&r[t]<=r[n]}function G(){const e=this;let t,n,r,i,s,o,l,c,u,f,d,p,g,_,m,b,y,x,k,S,v,z,A,C,D,E,F,W,T,L,U,q,O;const P=new I,G=new I,X=new I;let Y,j,J,Q,$,ee;function te(){let t;for(t=0;286>t;t++)U[2*t]=0;for(t=0;30>t;t++)q[2*t]=0;for(t=0;19>t;t++)O[2*t]=0;U[512]=1,e.opt_len=e.static_len=0,j=J=0}function ne(e,t){let n,r=-1,i=e[1],s=0,a=7,o=4;0===i&&(a=138,o=3),e[2*(t+1)+1]=65535;for(let l=0;t>=l;l++)n=i,i=e[2*(l+1)+1],++ss?O[2*n]+=s:0!==n?(n!=r&&O[2*n]++,O[32]++):s>10?O[36]++:O[34]++,s=0,r=n,0===i?(a=138,o=3):n==i?(a=6,o=3):(a=7,o=4))}function re(t){e.pending_buf[e.pending++]=t}function ie(e){re(255&e),re(e>>>8&255)}function se(e,t){let n;const r=t;ee>16-r?(n=e,$|=n<>>16-ee,ee+=r-16):($|=e<=n;n++)if(r=s,s=e[2*(n+1)+1],++a>=o||r!=s){if(l>a)do{ae(r,O)}while(0!=--a);else 0!==r?(r!=i&&(ae(r,O),a--),ae(16,O),se(a-3,2)):a>10?(ae(18,O),se(a-11,7)):(ae(17,O),se(a-3,3));a=0,i=r,0===s?(o=138,l=3):r==s?(o=6,l=3):(o=7,l=4)}}function le(){16==ee?(ie($),$=0,ee=0):8>ee||(re(255&$),$>>>=8,ee-=8)}function ce(t,n){let r,i,s;if(e.dist_buf[j]=t,e.lc_buf[j]=255&n,j++,0===t?U[2*n]++:(J++,t--,U[2*(I._length_code[n]+256+1)]++,q[2*I.d_code(t)]++),!(8191&j)&&F>2){for(r=8*j,i=v-y,s=0;30>s;s++)r+=q[2*s]*(5+I.extra_dbits[s]);if(r>>>=3,Jo);ae(256,t),Q=t[513]}function fe(){ee>8?ie($):ee>0&&re(255&$),$=0,ee=0}function de(t,n,r){se(0+(r?1:0),3),((t,n)=>{fe(),Q=8,ie(n),ie(~n),e.pending_buf.set(c.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function we(n){((t,n,r)=>{let i,s,a=0;F>0?(P.build_tree(e),G.build_tree(e),a=(()=>{let t;for(ne(U,P.max_code),ne(q,G.max_code),X.build_tree(e),t=18;t>=3&&0===O[2*I.bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(),i=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s>i||(i=s)):i=s=n+5,n+4>i||-1==t?s==i?(se(2+(r?1:0),3),ue(N.static_ltree,N.static_dtree)):(se(4+(r?1:0),3),((e,t,n)=>{let r;for(se(e-257,5),se(t-1,5),se(n-4,4),r=0;n>r;r++)se(O[2*I.bl_order[r]+1],3);oe(U,e-1),oe(q,t-1)})(P.max_code+1,G.max_code+1,a+1),ue(U,q)):de(t,n,r),te(),r&&fe()})(0>y?-1:y,v-y,n),y=v,t.flush_pending()}function he(){let e,n,r,i;do{if(i=u-A-v,0===i&&0===v&&0===A)i=s;else if(-1==i)i--;else if(v>=s+s-Z){c.set(c.subarray(s,s+s),0),z-=s,v-=s,y-=s,e=g,r=e;do{n=65535&d[--r],d[r]=s>n?0:n-s}while(0!=--e);e=s,r=e;do{n=65535&f[--r],f[r]=s>n?0:n-s}while(0!=--e);i+=s}if(0===t.avail_in)return;e=t.read_buf(c,v+A,i),A+=e,3>A||(p=255&c[v],p=(p<A&&0!==t.avail_in)}function pe(e){let t,n,r=D,i=v,a=C;const o=v>s-Z?v-(s-Z):0;let u=L;const d=l,w=v+258;let h=c[i+a-1],p=c[i+a];T>C||(r>>=2),u>A&&(u=A);do{if(t=e,c[t+a]==p&&c[t+a-1]==h&&c[t]==c[i]&&c[++t]==c[i+1]){i+=2,t++;do{}while(c[++i]==c[++t]&&c[++i]==c[++t]&&c[++i]==c[++t]&&c[++i]==c[++t]&&c[++i]==c[++t]&&c[++i]==c[++t]&&c[++i]==c[++t]&&c[++i]==c[++t]&&w>i);if(n=258-(w-i),i=w-258,n>a){if(z=e,a=n,n>=u)break;h=c[i+a-1],p=c[i+a]}}}while((e=65535&f[e&d])>o&&0!=--r);return a>A?A:a}e.depth=[],e.bl_count=[],e.heap=[],U=[],q=[],O=[],e.pqdownheap=(t,n)=>{const r=e.heap,i=r[n];let s=n<<1;for(;s<=e.heap_len&&(s(I||(I=8),M||(M=8),V||(V=0),t.msg=null,-1==k&&(k=6),1>M||M>9||8!=I||9>z||z>15||0>k||k>9||0>V||V>2?R:(t.dstate=e,o=z,s=1<(t.total_in=t.total_out=0,t.msg=null,e.pending=0,e.pending_out=0,n=B,i=0,P.dyn_tree=U,P.stat_desc=N.static_l_desc,G.dyn_tree=q,G.stat_desc=N.static_d_desc,X.dyn_tree=O,X.stat_desc=N.static_bl_desc,$=0,ee=0,Q=8,te(),(()=>{u=2*s,d[g-1]=0;for(let e=0;g-1>e;e++)d[e]=0;E=H[F].max_lazy,T=H[F].good_length,L=H[F].nice_length,D=H[F].max_chain,v=0,y=0,A=0,x=C=2,S=0,p=0})(),0))(t))),e.deflateEnd=()=>42!=n&&n!=B&&n!=V?R:(e.lc_buf=null,e.dist_buf=null,e.pending_buf=null,d=null,f=null,c=null,e.dstate=null,n==B?-3:0),e.deflateParams=(e,t,n)=>{let r=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?R:(H[F].func!=H[t].func&&0!==e.total_in&&(r=e.deflate(1)),F!=t&&(F=t,E=H[F].max_lazy,T=H[F].good_length,L=H[F].nice_length,D=H[F].max_chain),W=n,r)},e.deflateSetDictionary=(e,t,r)=>{let i,a=r,o=0;if(!t||42!=n)return R;if(3>a)return 0;for(a>s-Z&&(a=s-Z,o=r-a),c.set(t.subarray(o,o+a),0),v=a,y=a,p=255&c[0],p=(p<=i;i++)p=(p<{let w,h,_,D,T;if(u>4||0>u)return R;if(!a.next_out||!a.next_in&&0!==a.avail_in||n==V&&4!=u)return a.msg=M[4],R;if(0===a.avail_out)return a.msg=M[7],-5;var L;if(t=a,D=i,i=u,42==n&&(h=8+(o-8<<4)<<8,_=(F-1&255)>>1,_>3&&(_=3),h|=_<<6,0!==v&&(h|=32),h+=31-h%31,n=B,re((L=h)>>8&255),re(255&L)),0!==e.pending){if(t.flush_pending(),0===t.avail_out)return i=-1,0}else if(0===t.avail_in&&D>=u&&4!=u)return t.msg=M[7],-5;if(n==V&&0!==t.avail_in)return a.msg=M[7],-5;if(0!==t.avail_in||0!==A||0!=u&&n!=V){switch(T=-1,H[F].func){case 0:T=(e=>{let n,i=65535;for(i>r-5&&(i=r-5);;){if(1>=A){if(he(),0===A&&0==e)return 0;if(0===A)break}if(v+=A,A=0,n=y+i,(0===v||v>=n)&&(A=v-n,v=n,we(!1),0===t.avail_out))return 0;if(v-y>=s-Z&&(we(!1),0===t.avail_out))return 0}return we(4==e),0===t.avail_out?4==e?2:0:4==e?3:1})(u);break;case 1:T=(e=>{let n,r=0;for(;;){if(Z>A){if(he(),Z>A&&0==e)return 0;if(0===A)break}if(3>A||(p=(p<s-Z||2!=W&&(x=pe(r)),3>x)n=ce(0,255&c[v]),A--,v++;else if(n=ce(v-z,x-3),A-=x,x>E||3>A)v+=x,x=0,p=255&c[v],p=(p<{let n,r,i=0;for(;;){if(Z>A){if(he(),Z>A&&0==e)return 0;if(0===A)break}if(3>A||(p=(p<C&&s-Z>=(v-i&65535)&&(2!=W&&(x=pe(i)),5>=x&&(1==W||3==x&&v-z>4096)&&(x=2)),3>C||x>C)if(0!==S){if(n=ce(0,255&c[v-1]),n&&we(!1),v++,A--,0===t.avail_out)return 0}else S=1,v++,A--;else{r=v+A-3,n=ce(v-1-k,C-3),A-=C-1,C-=2;do{++v>r||(p=(p<1+Q+10-ee&&(se(2,3),ae(256,N.static_ltree),le()),Q=7;else if(de(0,0,!1),3==u)for(w=0;g>w;w++)d[w]=0;if(t.flush_pending(),0===t.avail_out)return i=-1,0}}return 4!=u?0:1}}function X(){const e=this;e.next_in_index=0,e.next_out_index=0,e.avail_in=0,e.total_in=0,e.avail_out=0,e.total_out=0}X.prototype={deflateInit(e,t){const n=this;return n.dstate=new G,t||(t=15),n.dstate.deflateInit(n,e,t)},deflate(e){const t=this;return t.dstate?t.dstate.deflate(t,e):R},deflateEnd(){const e=this;if(!e.dstate)return R;const t=e.dstate.deflateEnd();return e.dstate=null,t},deflateParams(e,t){const n=this;return n.dstate?n.dstate.deflateParams(n,e,t):R},deflateSetDictionary(e,t){const n=this;return n.dstate?n.dstate.deflateSetDictionary(n,e,t):R},read_buf(e,t,n){const r=this;let i=r.avail_in;return i>n&&(i=n),0===i?0:(r.avail_in-=i,e.set(r.next_in.subarray(r.next_in_index,r.next_in_index+i),t),r.next_in_index+=i,r.total_in+=i,i)},flush_pending(){const e=this;let t=e.dstate.pending;t>e.avail_out&&(t=e.avail_out),0!==t&&(e.next_out.set(e.dstate.pending_buf.subarray(e.dstate.pending_out,e.dstate.pending_out+t),e.next_out_index),e.next_out_index+=t,e.dstate.pending_out+=t,e.total_out+=t,e.avail_out-=t,e.dstate.pending-=t,0===e.dstate.pending&&(e.dstate.pending_out=0))}};const Y=-2,j=-3,J=-5,Q=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],$=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],ee=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],te=[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],ne=[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,112,112],re=[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],ie=[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];function se(){let e,t,n,r,i,s;function a(e,t,a,o,l,c,u,f,d,w,h){let p,g,_,m,b,y,x,k,S,v,z,A,C,D,E;v=0,b=a;do{n[e[t+v]]++,v++,b--}while(0!==b);if(n[0]==a)return u[0]=-1,f[0]=0,0;for(k=f[0],y=1;15>=y&&0===n[y];y++);for(x=y,y>k&&(k=y),b=15;0!==b&&0===n[b];b--);for(_=b,k>b&&(k=b),f[0]=k,D=1<y;y++,D<<=1)if(0>(D-=n[y]))return j;if(0>(D-=n[b]))return j;for(n[b]+=D,s[1]=y=0,v=1,C=2;0!=--b;)s[C]=y+=n[v],C++,v++;b=0,v=0;do{0!==(y=e[t+v])&&(h[s[y]++]=b),v++}while(++b=x;x++)for(p=n[x];0!=p--;){for(;x>A+k;){if(m++,A+=k,E=_-A,E=E>k?k:E,(g=1<<(y=x-A))>p+1&&(g-=p+1,C=x,E>y))for(;++yn[++C];)g-=n[C];if(E=1<1440)return j;i[m]=z=w[0],w[0]+=E,0!==m?(s[m]=b,r[0]=y,r[1]=k,y=b>>>A-k,r[2]=z-i[m-1]-y,d.set(r,3*(i[m-1]+y))):u[0]=z}for(r[1]=x-A,a>v?h[v]h[v]?0:96,r[2]=h[v++]):(r[0]=c[h[v]-o]+16+64,r[2]=l[h[v++]-o]):r[0]=192,g=1<>>A;E>y;y+=g)d.set(r,3*(z+y));for(y=1<>>=1)b^=y;for(b^=y,S=(1<o;o++)t[o]=0;for(o=0;16>o;o++)n[o]=0;for(o=0;3>o;o++)r[o]=0;i.set(n.subarray(0,15),0),s.set(n.subarray(0,16),0)}this.inflate_trees_bits=(n,r,i,s,l)=>{let c;return o(19),e[0]=0,c=a(n,0,19,19,null,null,i,r,s,e,t),c==j?l.msg="oversubscribed dynamic bit lengths tree":c!=J&&0!==r[0]||(l.msg="incomplete dynamic bit lengths tree",c=j),c},this.inflate_trees_dynamic=(n,r,i,s,l,c,u,f,d)=>{let w;return o(288),e[0]=0,w=a(i,0,n,257,te,ne,c,s,f,e,t),0!=w||0===s[0]?(w==j?d.msg="oversubscribed literal/length tree":-4!=w&&(d.msg="incomplete literal/length tree",w=j),w):(o(288),w=a(i,n,r,0,re,ie,u,l,f,e,t),0!=w||0===l[0]&&n>257?(w==j?d.msg="oversubscribed distance tree":w==J?(d.msg="incomplete distance tree",w=j):-4!=w&&(d.msg="empty distance tree with lengths",w=j),w):0)}}function ae(){const e=this;let t,n,r,i,s=0,a=0,o=0,l=0,c=0,u=0,f=0,d=0,w=0,h=0;function p(e,t,n,r,i,s,a,o){let l,c,u,f,d,w,h,p,g,_,m,b,y,x,k,S;h=o.next_in_index,p=o.avail_in,d=a.bitb,w=a.bitk,g=a.write,_=gw;)p--,d|=(255&o.read_byte(h++))<>=c[S+1],w-=c[S+1],16&f){for(f&=15,y=c[S+2]+(d&Q[f]),d>>=f,w-=f;15>w;)p--,d|=(255&o.read_byte(h++))<>=c[S+1],w-=c[S+1],16&f){for(f&=15;f>w;)p--,d|=(255&o.read_byte(h++))<>=f,w-=f,_-=y,x>g){k=g-x;do{k+=a.end}while(0>k);if(f=a.end-k,y>f){if(y-=f,g-k>0&&f>g-k)do{a.win[g++]=a.win[k++]}while(0!=--f);else a.win.set(a.win.subarray(k,k+f),g),g+=f,k+=f,f=0;k=0}}else k=g-x,g-k>0&&2>g-k?(a.win[g++]=a.win[k++],a.win[g++]=a.win[k++],y-=2):(a.win.set(a.win.subarray(k,k+2),g),g+=2,k+=2,y-=2);if(g-k>0&&y>g-k)do{a.win[g++]=a.win[k++]}while(0!=--y);else a.win.set(a.win.subarray(k,k+y),g),g+=y,k+=y,y=0;break}if(64&f)return o.msg="invalid distance code",y=o.avail_in-p,y=y>w>>3?w>>3:y,p+=y,h-=y,w-=y<<3,a.bitb=d,a.bitk=w,o.avail_in=p,o.total_in+=h-o.next_in_index,o.next_in_index=h,a.write=g,j;l+=c[S+2],l+=d&Q[f],S=3*(u+l),f=c[S]}break}if(64&f)return 32&f?(y=o.avail_in-p,y=y>w>>3?w>>3:y,p+=y,h-=y,w-=y<<3,a.bitb=d,a.bitk=w,o.avail_in=p,o.total_in+=h-o.next_in_index,o.next_in_index=h,a.write=g,1):(o.msg="invalid literal/length code",y=o.avail_in-p,y=y>w>>3?w>>3:y,p+=y,h-=y,w-=y<<3,a.bitb=d,a.bitk=w,o.avail_in=p,o.total_in+=h-o.next_in_index,o.next_in_index=h,a.write=g,j);if(l+=c[S+2],l+=d&Q[f],S=3*(u+l),0===(f=c[S])){d>>=c[S+1],w-=c[S+1],a.win[g++]=c[S+2],_--;break}}else d>>=c[S+1],w-=c[S+1],a.win[g++]=c[S+2],_--}while(_>=258&&p>=10);return y=o.avail_in-p,y=y>w>>3?w>>3:y,p+=y,h-=y,w-=y<<3,a.bitb=d,a.bitk=w,o.avail_in=p,o.total_in+=h-o.next_in_index,o.next_in_index=h,a.write=g,0}e.init=(e,s,a,o,l,c)=>{t=0,f=e,d=s,r=a,w=o,i=l,h=c,n=null},e.proc=(e,g,_)=>{let m,b,y,x,k,S,v,z=0,A=0,C=0;for(C=g.next_in_index,x=g.avail_in,z=e.bitb,A=e.bitk,k=e.write,S=k=258&&x>=10&&(e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,_=p(f,d,r,w,i,h,e,g),C=g.next_in_index,x=g.avail_in,z=e.bitb,A=e.bitk,k=e.write,S=kA;){if(0===x)return e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,e.inflate_flush(g,_);_=0,x--,z|=(255&g.read_byte(C++))<>>=n[b+1],A-=n[b+1],y=n[b],0===y){l=n[b+2],t=6;break}if(16&y){c=15&y,s=n[b+2],t=2;break}if(!(64&y)){o=y,a=b/3+n[b+2];break}if(32&y){t=7;break}return t=9,g.msg="invalid literal/length code",_=j,e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,e.inflate_flush(g,_);case 2:for(m=c;m>A;){if(0===x)return e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,e.inflate_flush(g,_);_=0,x--,z|=(255&g.read_byte(C++))<>=m,A-=m,o=d,n=i,a=h,t=3;case 3:for(m=o;m>A;){if(0===x)return e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,e.inflate_flush(g,_);_=0,x--,z|=(255&g.read_byte(C++))<>=n[b+1],A-=n[b+1],y=n[b],16&y){c=15&y,u=n[b+2],t=4;break}if(!(64&y)){o=y,a=b/3+n[b+2];break}return t=9,g.msg="invalid distance code",_=j,e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,e.inflate_flush(g,_);case 4:for(m=c;m>A;){if(0===x)return e.bitb=z,e.bitk=A,g.avail_in=x,g.total_in+=C-g.next_in_index,g.next_in_index=C,e.write=k,e.inflate_flush(g,_);_=0,x--,z|=(255&g.read_byte(C++))<>=m,A-=m,t=5;case 5:for(v=k-u;0>v;)v+=e.end;for(;0!==s;){if(0===S&&(k==e.end&&0!==e.read&&(k=0,S=k7&&(A-=8,x++,C--),e.write=k,_=e.inflate_flush(g,_),k=e.write,S=k{}}se.inflate_trees_fixed=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=$,r[0]=ee,0);const oe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function le(e,t){const n=this;let r,i=0,s=0,a=0,o=0;const l=[0],c=[0],u=new ae;let f=0,d=new Int32Array(4320);const h=new se;n.bitk=0,n.bitb=0,n.win=new w(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==i&&u.free(e),i=0,n.bitk=0,n.bitb=0,n.read=n.write=0},n.reset(e,null),n.inflate_flush=(e,t)=>{let r,i,s;return i=e.next_out_index,s=n.read,r=(s>n.write?n.end:n.write)-s,r>e.avail_out&&(r=e.avail_out),0!==r&&t==J&&(t=0),e.avail_out-=r,e.total_out+=r,e.next_out.set(n.win.subarray(s,s+r),i),i+=r,s+=r,s==n.end&&(s=0,n.write==n.end&&(n.write=0),r=n.write-s,r>e.avail_out&&(r=e.avail_out),0!==r&&t==J&&(t=0),e.avail_out-=r,e.total_out+=r,e.next_out.set(n.win.subarray(s,s+r),i),i+=r,s+=r),e.next_out_index=i,n.read=s,t},n.proc=(e,t)=>{let w,p,g,_,m,b,y,x;for(_=e.next_in_index,m=e.avail_in,p=n.bitb,g=n.bitk,b=n.write,y=bg;){if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);t=0,m--,p|=(255&e.read_byte(_++))<>>1){case 0:p>>>=3,g-=3,w=7&g,p>>>=w,g-=w,i=1;break;case 1:k=[],S=[],v=[[]],z=[[]],se.inflate_trees_fixed(k,S,v,z),u.init(k[0],S[0],v[0],0,z[0],0),p>>>=3,g-=3,i=6;break;case 2:p>>>=3,g-=3,i=3;break;case 3:return p>>>=3,g-=3,i=9,e.msg="invalid block type",t=j,n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t)}break;case 1:for(;32>g;){if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);t=0,m--,p|=(255&e.read_byte(_++))<>>16&65535)!=(65535&p))return i=9,e.msg="invalid stored block lengths",t=j,n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);s=65535&p,p=g=0,i=0!==s?2:0!==f?7:0;break;case 2:if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);if(0===y&&(b==n.end&&0!==n.read&&(b=0,y=bm&&(w=m),w>y&&(w=y),n.win.set(e.read_buf(_,w),b),_+=w,m-=w,b+=w,y-=w,0!=(s-=w))break;i=0!==f?7:0;break;case 3:for(;14>g;){if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);t=0,m--,p|=(255&e.read_byte(_++))<29||(w>>5&31)>29)return i=9,e.msg="too many length or distance symbols",t=j,n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);if(w=258+(31&w)+(w>>5&31),!r||r.lengthx;x++)r[x]=0;p>>>=14,g-=14,o=0,i=4;case 4:for(;4+(a>>>10)>o;){for(;3>g;){if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);t=0,m--,p|=(255&e.read_byte(_++))<>>=3,g-=3}for(;19>o;)r[oe[o++]]=0;if(l[0]=7,w=h.inflate_trees_bits(r,l,c,d,e),0!=w)return(t=w)==j&&(r=null,i=9),n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);o=0,i=5;case 5:for(;w=a,258+(31&w)+(w>>5&31)>o;){let s,u;for(w=l[0];w>g;){if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);t=0,m--,p|=(255&e.read_byte(_++))<u)p>>>=w,g-=w,r[o++]=u;else{for(x=18==u?7:u-14,s=18==u?11:3;w+x>g;){if(0===m)return n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);t=0,m--,p|=(255&e.read_byte(_++))<>>=w,g-=w,s+=p&Q[x],p>>>=x,g-=x,x=o,w=a,x+s>258+(31&w)+(w>>5&31)||16==u&&1>x)return r=null,i=9,e.msg="invalid bit length repeat",t=j,n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);u=16==u?r[x-1]:0;do{r[x++]=u}while(0!=--s);o=x}}if(c[0]=-1,A=[],C=[],D=[],E=[],A[0]=9,C[0]=6,w=a,w=h.inflate_trees_dynamic(257+(31&w),1+(w>>5&31),r,A,C,D,E,d,e),0!=w)return w==j&&(r=null,i=9),t=w,n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,n.inflate_flush(e,t);u.init(A[0],C[0],d,D[0],d,E[0]),i=6;case 6:if(n.bitb=p,n.bitk=g,e.avail_in=m,e.total_in+=_-e.next_in_index,e.next_in_index=_,n.write=b,1!=(t=u.proc(n,e,t)))return n.inflate_flush(e,t);if(t=0,u.free(e),_=e.next_in_index,m=e.avail_in,p=n.bitb,g=n.bitk,b=n.write,y=b{n.reset(e,null),n.win=null,d=null},n.set_dictionary=(e,t,r)=>{n.win.set(e.subarray(t,t+r),0),n.read=n.write=r},n.sync_point=()=>1==i?1:0}const ce=13,ue=[0,0,255,255];function fe(){const e=this;function t(e){return e&&e.istate?(e.total_in=e.total_out=0,e.msg=null,e.istate.mode=7,e.istate.blocks.reset(e,null),0):Y}e.mode=0,e.method=0,e.was=[0],e.need=0,e.marker=0,e.wbits=0,e.inflateEnd=t=>(e.blocks&&e.blocks.free(t),e.blocks=null,0),e.inflateInit=(n,r)=>(n.msg=null,e.blocks=null,8>r||r>15?(e.inflateEnd(n),Y):(e.wbits=r,n.istate.blocks=new le(n,1<{let n,r;if(!e||!e.istate||!e.next_in)return Y;const i=e.istate;for(t=4==t?J:0,n=J;;)switch(i.mode){case 0:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,8!=(15&(i.method=e.read_byte(e.next_in_index++)))){i.mode=ce,e.msg="unknown compression method",i.marker=5;break}if(8+(i.method>>4)>i.wbits){i.mode=ce,e.msg="invalid win size",i.marker=5;break}i.mode=1;case 1:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,r=255&e.read_byte(e.next_in_index++),((i.method<<8)+r)%31!=0){i.mode=ce,e.msg="incorrect header check",i.marker=5;break}if(!(32&r)){i.mode=7;break}i.mode=2;case 2:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,i.need=(255&e.read_byte(e.next_in_index++))<<24&4278190080,i.mode=3;case 3:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,i.need+=(255&e.read_byte(e.next_in_index++))<<16&16711680,i.mode=4;case 4:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,i.need+=(255&e.read_byte(e.next_in_index++))<<8&65280,i.mode=5;case 5:return 0===e.avail_in?n:(n=t,e.avail_in--,e.total_in++,i.need+=255&e.read_byte(e.next_in_index++),i.mode=6,2);case 6:return i.mode=ce,e.msg="need dictionary",i.marker=0,Y;case 7:if(n=i.blocks.proc(e,n),n==j){i.mode=ce,i.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,i.blocks.reset(e,i.was),i.mode=12;case 12:return e.avail_in=0,1;case ce:return j;default:return Y}},e.inflateSetDictionary=(e,t,n)=>{let r=0,i=n;if(!e||!e.istate||6!=e.istate.mode)return Y;const s=e.istate;return i<1<{let n,r,i,s,a;if(!e||!e.istate)return Y;const o=e.istate;if(o.mode!=ce&&(o.mode=ce,o.marker=0),0===(n=e.avail_in))return J;for(r=e.next_in_index,i=o.marker;0!==n&&4>i;)e.read_byte(r)==ue[i]?i++:i=0!==e.read_byte(r)?0:4-i,r++,n--;return e.total_in+=r-e.next_in_index,e.next_in_index=r,e.avail_in=n,o.marker=i,4!=i?j:(s=e.total_in,a=e.total_out,t(e),e.total_in=s,e.total_out=a,o.mode=7,0)},e.inflateSyncPoint=e=>e&&e.istate&&e.istate.blocks?e.istate.blocks.sync_point():Y}function de(){}de.prototype={inflateInit(e){const t=this;return t.istate=new fe,e||(e=15),t.istate.inflateInit(t,e)},inflate(e){const t=this;return t.istate?t.istate.inflate(t,e):Y},inflateEnd(){const e=this;if(!e.istate)return Y;const t=e.istate.inflateEnd(e);return e.istate=null,t},inflateSync(){const e=this;return e.istate?e.istate.inflateSync(e):Y},inflateSetDictionary(e,t){const n=this;return n.istate?n.istate.inflateSetDictionary(n,e,t):Y},read_byte(e){return this.next_in[e]},read_buf(e,t){return this.next_in.subarray(e,e+t)}};const we=4294967295,he=65535,pe=67324752,ge=134695760,_e=ge,me=33639248,be=101010256,ye=101075792,xe=117853008,ke=22,Se=21589,ve=2048,ze="/",Ae=new o(2107,11,31),Ce=new o(1980,0,1),De=void 0,Ee="undefined",Fe="function";class We{constructor(e){return class extends v{constructor(t,n){const r=new e(n);super({transform(e,t){t.enqueue(r.append(e))},flush(e){const t=r.flush();t&&e.enqueue(t)}})}}}}let Re=2;try{typeof E!=Ee&&E.hardwareConcurrency&&(Re=E.hardwareConcurrency)}catch(e){}const Te={chunkSize:524288,maxWorkers:Re,terminateWorkerTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,workerScripts:De,CompressionStreamNative:typeof C!=Ee&&C,DecompressionStreamNative:typeof D!=Ee&&D},Le=n.assign({},Te);function Ue(){return Le}function Ie(e){return a.max(e.chunkSize,64)}function Ne(e){const{baseURL:n,chunkSize:r,maxWorkers:i,terminateWorkerTimeout:s,useCompressionStream:a,useWebWorkers:o,Deflate:l,Inflate:c,CompressionStream:u,DecompressionStream:f,workerScripts:w}=e;if(qe("baseURL",n),qe("chunkSize",r),qe("maxWorkers",i),qe("terminateWorkerTimeout",s),qe("useCompressionStream",a),qe("useWebWorkers",o),l&&(Le.CompressionStream=new We(l)),c&&(Le.DecompressionStream=new We(c)),qe("CompressionStream",u),qe("DecompressionStream",f),w!==De){const{deflate:e,inflate:n}=w;if((e||n)&&(Le.workerScripts||(Le.workerScripts={})),e){if(!t.isArray(e))throw new d("workerScripts.deflate must be an array");Le.workerScripts.deflate=e}if(n){if(!t.isArray(n))throw new d("workerScripts.inflate must be an array");Le.workerScripts.inflate=n}}}function qe(e,t){t!==De&&(Le[e]=t)}function Oe(e,t,r){return class{constructor(i){const s=this;var a,o;a=i,o="level",(typeof n.hasOwn===Fe?n.hasOwn(a,o):a.hasOwnProperty(o))&&i.level===De&&delete i.level,s.codec=new e(n.assign({},t,i)),r(s.codec,(e=>{if(s.pendingData){const t=s.pendingData;s.pendingData=new w(t.length+e.length);const{pendingData:n}=s;n.set(t,0),n.set(e,t.length)}else s.pendingData=new w(e)}))}append(e){return this.codec.push(e),i(this)}flush(){return this.codec.push(new w,!0),i(this)}};function i(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new w}}const Pe=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;Pe[e]=t}class He{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^Pe[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class Me extends v{constructor(){let e;const t=new He;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new w(4);new g(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}function Be(e){if(typeof b==Ee){const t=new w((e=unescape(encodeURIComponent(e))).length);for(let n=0;n0&&t&&(e[n-1]=Ve.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>a.round(e/1099511627776)||32,_shiftRight(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let i=0;i>>t),n=e[i]<<32-t;const i=e.length?e[e.length-1]:0,s=Ve.getPartial(i);return r.push(Ve.partial(t+s&31,t+s>32?n:r.pop(),1)),r}},Ze={bytes:{fromBits(e){const t=Ve.bitLength(e)/8,n=new w(t);let r;for(let i=0;t>i;i++)3&i||(r=e[i/4]),n[i]=r>>>24,r<<=8;return n},toBits(e){const t=[];let n,r=0;for(n=0;n9007199254740991)throw new d("Cannot hash more than 2^53 - 1 bits");const s=new p(n);let a=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);i>=e;e+=t.blockSize)t._block(s.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=Ve.concat(t,[Ve.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(a.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,r){return e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r}_S(e,t){return t<>>32-e}_block(e){const n=this,r=n._h,i=t(80);for(let t=0;16>t;t++)i[t]=e[t];let s=r[0],o=r[1],l=r[2],c=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(i[e]=n._S(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=n._S(5,s)+n._f(e,o,l,c)+u+i[e]+n._key[a.floor(e/20)]|0;u=c,c=l,l=n._S(30,o),o=s,s=t}r[0]=r[0]+s|0,r[1]=r[1]+o|0,r[2]=r[2]+l|0,r[3]=r[3]+c|0,r[4]=r[4]+u|0}},Ge={getRandomValues(e){const t=new p(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(a.random()>.5?1:-1))};for(let r,i=0;inew Xe.hmacSha1(Ze.bytes.toBits(e)),pbkdf2(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new d("invalid params to pbkdf2");const i=1+(r>>5)<<2;let s,a,o,l,c;const u=new ArrayBuffer(i),f=new g(u);let w=0;const h=Ve;for(t=Ze.bytes.toBits(t),c=1;(i||1)>w;c++){for(s=a=e.encrypt(h.concat(t,[c])),o=1;n>o;o++)for(a=e.encrypt(a),l=0;lw&&oi&&(e=(new n).update(e).finalize());for(let t=0;i>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t._baseHash[0].update(r[0]),t._baseHash[1].update(r[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new d("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},Ye=typeof k!=Ee&&typeof k.getRandomValues==Fe,je="Invalid password",Je="Invalid signature",Qe="zipjs-abort-check-password";function $e(e){return Ye?k.getRandomValues(e):Ge.getRandomValues(e)}const et=16,tt={name:"PBKDF2"},nt=n.assign({hash:{name:"HMAC"}},tt),rt=n.assign({iterations:1e3,hash:{name:"SHA-1"}},tt),it=["deriveBits"],st=[8,12,16],at=[16,24,32],ot=10,lt=[0,0,0,0],ct=typeof k!=Ee,ut=ct&&k.subtle,ft=ct&&typeof ut!=Ee,dt=Ze.bytes,wt=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],r=t._tables[1],i=e.length;let s,a,o,l=1;if(4!==i&&6!==i&&8!==i)throw new d("invalid aes key size");for(t._key=[a=e.slice(0),o=[]],s=i;4*i+28>s;s++){let e=a[s-1];(s%i==0||8===i&&s%i==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],s%i==0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),a[s]=a[s-i]^e}for(let e=0;s;e++,s--){const t=a[3&e?s:s-4];o[e]=4>=s||4>e?t:r[0][n[t>>>24]]^r[1][n[t>>16&255]]^r[2][n[t>>8&255]]^r[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],r=t[4],i=[],s=[];let a,o,l,c;for(let e=0;256>e;e++)s[(i[e]=e<<1^283*(e>>7))^e]=e;for(let u=a=0;!n[u];u^=o||1,a=s[a]||1){let s=a^a<<1^a<<2^a<<3^a<<4;s=s>>8^255&s^99,n[u]=s,r[s]=u,c=i[l=i[o=i[u]]];let f=16843009*c^65537*l^257*o^16843008*u,d=257*i[s]^16843008*s;for(let n=0;4>n;n++)e[n][u]=d=d<<24^d>>>8,t[n][s]=f=f<<24^f>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new d("invalid aes block size");const n=this._key[t],r=n.length/4-2,i=[0,0,0,0],s=this._tables[t],a=s[0],o=s[1],l=s[2],c=s[3],u=s[4];let f,w,h,p=e[0]^n[0],g=e[t?3:1]^n[1],_=e[2]^n[2],m=e[t?1:3]^n[3],b=4;for(let e=0;r>e;e++)f=a[p>>>24]^o[g>>16&255]^l[_>>8&255]^c[255&m]^n[b],w=a[g>>>24]^o[_>>16&255]^l[m>>8&255]^c[255&p]^n[b+1],h=a[_>>>24]^o[m>>16&255]^l[p>>8&255]^c[255&g]^n[b+2],m=a[m>>>24]^o[p>>16&255]^l[g>>8&255]^c[255&_]^n[b+3],b+=4,p=f,g=w,_=h;for(let e=0;4>e;e++)i[t?3&-e:e]=u[p>>>24]<<24^u[g>>16&255]<<16^u[_>>8&255]<<8^u[255&m]^n[b++],f=p,p=g,g=_,_=m,m=f;return i}},ht=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let r;if(!(r=t.length))return[];const i=Ve.bitLength(t);for(let i=0;r>i;i+=4){this.incCounter(n);const r=e.encrypt(n);t[i]^=r[0],t[i+1]^=r[1],t[i+2]^=r[2],t[i+3]^=r[3]}return Ve.clamp(t,i)}},pt=Xe.hmacSha1;let gt=ct&&ft&&typeof ut.importKey==Fe,_t=ct&&ft&&typeof ut.deriveBits==Fe;class mt extends v{constructor({password:e,rawPassword:t,signed:r,encryptionStrength:i,checkPasswordOnly:s}){super({start(){n.assign(this,{ready:new m((e=>this.resolveReady=e)),password:kt(e,t),signed:r,strength:i-1,pending:new w})},async transform(e,t){const n=this,{password:r,strength:i,resolveReady:a,ready:o}=n;r?(await(async(e,t,n,r)=>{const i=await xt(e,t,n,vt(r,0,st[t])),s=vt(r,st[t]);if(i[0]!=s[0]||i[1]!=s[1])throw new d(je)})(n,i,r,vt(e,0,st[i]+2)),e=vt(e,st[i]+2),s?t.error(new d(Qe)):a()):await o;const l=new w(e.length-ot-(e.length-ot)%et);t.enqueue(yt(n,e,l,0,ot,!0))},async flush(e){const{signed:t,ctr:n,hmac:r,pending:i,ready:s}=this;if(r&&n){await s;const a=vt(i,0,i.length-ot),o=vt(i,i.length-ot);let l=new w;if(a.length){const e=At(dt,a);r.update(e);const t=n.update(e);l=zt(dt,t)}if(t){const e=vt(zt(dt,r.digest()),0,ot);for(let t=0;ot>t;t++)if(e[t]!=o[t])throw new d(Je)}e.enqueue(l)}}})}}class bt extends v{constructor({password:e,rawPassword:t,encryptionStrength:r}){let i;super({start(){n.assign(this,{ready:new m((e=>this.resolveReady=e)),password:kt(e,t),strength:r-1,pending:new w})},async transform(e,t){const n=this,{password:r,strength:i,resolveReady:s,ready:a}=n;let o=new w;r?(o=await(async(e,t,n)=>{const r=$e(new w(st[t]));return St(r,await xt(e,t,n,r))})(n,i,r),s()):await a;const l=new w(o.length+e.length-e.length%et);l.set(o,0),t.enqueue(yt(n,e,l,o.length,0))},async flush(e){const{ctr:t,hmac:n,pending:r,ready:s}=this;if(n&&t){await s;let a=new w;if(r.length){const e=t.update(At(dt,r));n.update(e),a=zt(dt,e)}i.signature=zt(dt,n.digest()).slice(0,ot),e.enqueue(St(a,i.signature))}}}),i=this}}function yt(e,t,n,r,i,s){const{ctr:a,hmac:o,pending:l}=e,c=t.length-i;let u;for(l.length&&(t=St(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new w(t)).set(n,0)}return e})(n,c-c%et)),u=0;c-et>=u;u+=et){const e=At(dt,vt(t,u,u+et));s&&o.update(e);const i=a.update(e);s||o.update(i),n.set(zt(dt,i),u+r)}return e.pending=vt(t,u),n}async function xt(e,r,i,s){e.password=null;const a=await(async(e,t,n,r,i)=>{if(!gt)return Xe.importKey(t);try{return await ut.importKey("raw",t,n,!1,i)}catch(e){return gt=!1,Xe.importKey(t)}})(0,i,nt,0,it),o=await(async(e,t,n)=>{if(!_t)return Xe.pbkdf2(t,e.salt,rt.iterations,n);try{return await ut.deriveBits(e,t,n)}catch(r){return _t=!1,Xe.pbkdf2(t,e.salt,rt.iterations,n)}})(n.assign({salt:s},rt),a,8*(2*at[r]+2)),l=new w(o),c=At(dt,vt(l,0,at[r])),u=At(dt,vt(l,at[r],2*at[r])),f=vt(l,2*at[r]);return n.assign(e,{keys:{key:c,authentication:u,passwordVerification:f},ctr:new ht(new wt(c),t.from(lt)),hmac:new pt(u)}),f}function kt(e,t){return t===De?Be(e):t}function St(e,t){let n=e;return e.length+t.length&&(n=new w(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function vt(e,t,n){return e.subarray(t,n)}function zt(e,t){return e.fromBits(t)}function At(e,t){return e.toBits(t)}class Ct extends v{constructor({password:e,passwordVerification:t,checkPasswordOnly:r}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Wt(this,e)},transform(e,t){const n=this;if(n.password){const t=Et(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new d(je);e=e.subarray(12)}r?t.error(new d(Qe)):t.enqueue(Et(n,e))}})}}class Dt extends v{constructor({password:e,passwordVerification:t}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Wt(this,e)},transform(e,t){const n=this;let r,i;if(n.password){n.password=null;const t=$e(new w(12));t[11]=n.passwordVerification,r=new w(e.length+t.length),r.set(Ft(n,t),0),i=12}else r=new w(e.length),i=0;r.set(Ft(n,e),i),t.enqueue(r)}})}}function Et(e,t){const n=new w(t.length);for(let r=0;r>>24]),i=~e.crcKey2.get(),e.keys=[n,r,i]}function Tt(e){const t=2|e.keys[2];return Lt(a.imul(t,1^t)>>>8)}function Lt(e){return 255&e}function Ut(e){return 4294967295&e}const It="deflate-raw";class Nt extends v{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:r}){super({});const{compressed:i,encrypted:s,useCompressionStream:a,zipCrypto:o,signed:l,level:c}=e,u=this;let f,d,w=Ot(super.readable);s&&!o||!l||(f=new Me,w=Mt(w,f)),i&&(w=Ht(w,a,{level:c,chunkSize:t},r,n)),s&&(o?w=Mt(w,new Dt(e)):(d=new bt(e),w=Mt(w,d))),Pt(u,w,(()=>{let e;s&&!o&&(e=d.signature),s&&!o||!l||(e=new g(f.value.buffer).getUint32(0)),u.signature=e}))}}class qt extends v{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:r}){super({});const{zipCrypto:i,encrypted:s,signed:a,signature:o,compressed:l,useCompressionStream:c}=e;let u,f,w=Ot(super.readable);s&&(i?w=Mt(w,new Ct(e)):(f=new mt(e),w=Mt(w,f))),l&&(w=Ht(w,c,{chunkSize:t},r,n)),s&&!i||!a||(u=new Me,w=Mt(w,u)),Pt(this,w,(()=>{if((!s||i)&&a){const e=new g(u.value.buffer);if(o!=e.getUint32(0,!1))throw new d(Je)}}))}}function Ot(e){return Mt(e,new v({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function Pt(e,t,r){t=Mt(t,new v({flush:r})),n.defineProperty(e,"readable",{get:()=>t})}function Ht(e,t,n,r,i){try{e=Mt(e,new(t&&r?r:i)(It,n))}catch(r){if(!t)return e;try{e=Mt(e,new i(It,n))}catch(t){return e}}return e}function Mt(e,t){return e.pipeThrough(t)}const Bt="data",Vt="close",Zt="deflate",Kt="inflate";class Gt extends v{constructor(e,t){super({});const r=this,{codecType:i}=e;let s;i.startsWith(Zt)?s=Nt:i.startsWith(Kt)&&(s=qt);let a=0,o=0;const l=new s(e,t),c=super.readable,u=new v({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){n.assign(r,{inputSize:o})}}),f=new v({transform(e,t){e&&e.length&&(a+=e.length,t.enqueue(e))},flush(){const{signature:e}=l;n.assign(r,{signature:e,outputSize:a,inputSize:o})}});n.defineProperty(r,"readable",{get:()=>c.pipeThrough(u).pipeThrough(l).pipeThrough(f)})}}class Xt extends v{constructor(e){let t;super({transform:function n(r,i){if(t){const e=new w(t.length+r.length);e.set(t),e.set(r,t.length),r=e,t=null}r.length>e?(i.enqueue(r.slice(0,e)),n(r.slice(e),i)):t=r},flush(e){t&&t.length&&e.enqueue(t)}})}}let Yt=typeof F!=Ee;class jt{constructor(e,{readable:t,writable:r},{options:i,config:s,streamOptions:a,useWebWorkers:o,transferStreams:l,scripts:c},u){const{signal:f}=a;return n.assign(e,{busy:!0,readable:t.pipeThrough(new Xt(s.chunkSize)).pipeThrough(new Jt(t,a),{signal:f}),writable:r,options:n.assign({},i),scripts:c,transferStreams:l,terminate:()=>new m((t=>{const{worker:n,busy:r}=e;n?(r?e.resolveTerminated=t:(n.terminate(),t()),e.interface=null):t()})),onTaskFinished(){const{resolveTerminated:t}=e;t&&(e.resolveTerminated=null,e.terminated=!0,e.worker.terminate(),t()),e.busy=!1,u(e)}}),(o&&Yt?en:$t)(e,s)}}class Jt extends v{constructor(e,{onstart:t,onprogress:n,size:r,onend:i}){let s=0;super({async start(){t&&await Qt(t,r)},async transform(e,t){s+=e.length,n&&await Qt(n,s,r),t.enqueue(e)},async flush(){e.size=s,i&&await Qt(i,s)}})}}async function Qt(e,...t){try{await e(...t)}catch(e){}}function $t(e,t){return{run:()=>(async({options:e,readable:t,writable:n,onTaskFinished:r},i)=>{try{const r=new Gt(e,i);await t.pipeThrough(r).pipeTo(n,{preventClose:!0,preventAbort:!0});const{signature:s,inputSize:a,outputSize:o}=r;return{signature:s,inputSize:a,outputSize:o}}finally{r()}})(e,t)}}function en(e,t){const{baseURL:r,chunkSize:i}=t;if(!e.interface){let s;try{s=((e,t,r)=>{const i={type:"module"};let s,a;typeof e==Fe&&(e=e());try{s=new f(e,t)}catch(t){s=e}if(tn)try{a=new F(s)}catch(e){tn=!1,a=new F(s,i)}else a=new F(s,i);return a.addEventListener("message",(e=>(async({data:e},t)=>{const{type:r,value:i,messageId:s,result:a,error:o}=e,{reader:l,writer:c,resolveResult:u,rejectResult:f,onTaskFinished:h}=t;try{if(o){const{message:e,stack:t,code:r,name:i}=o,s=new d(e);n.assign(s,{stack:t,code:r,name:i}),p(s)}else{if("pull"==r){const{value:e,done:n}=await l.read();rn({type:Bt,value:e,done:n,messageId:s},t)}r==Bt&&(await c.ready,await c.write(new w(i)),rn({type:"ack",messageId:s},t)),r==Vt&&p(null,a)}}catch(o){rn({type:Vt,messageId:s},t),p(o)}function p(e,t){e?f(e):u(t),c&&c.releaseLock(),h()}})(e,r))),a})(e.scripts[0],r,e)}catch(n){return Yt=!1,$t(e,t)}n.assign(e,{worker:s,interface:{run:()=>(async(e,t)=>{let r,i;const s=new m(((e,t)=>{r=e,i=t}));n.assign(e,{reader:null,writer:null,resolveResult:r,rejectResult:i,result:s});const{readable:a,options:o,scripts:l}=e,{writable:c,closed:u}=(e=>{let t;const n=new m((e=>t=e));return{writable:new A({async write(t){const n=e.getWriter();await n.ready,await n.write(t),n.releaseLock()},close(){t()},abort:t=>e.getWriter().abort(t)}),closed:n}})(e.writable),f=rn({type:"start",scripts:l.slice(1),options:o,config:t,readable:a,writable:c},e);f||n.assign(e,{reader:a.getReader(),writer:c.getWriter()});const d=await s;return f||await c.getWriter().close(),await u,d})(e,{chunkSize:i})}})}return e.interface}let tn=!0,nn=!0;function rn(e,{worker:t,writer:n,onTaskFinished:r,transferStreams:i}){try{const{value:n,readable:r,writable:s}=e,a=[];if(n&&(n.byteLength{const n=sn.find((e=>!e.busy));if(n)return cn(n),new jt(n,e,t,p);if(sn.lengthan.push({resolve:n,stream:e,workerOptions:t})))})()).run();function p(e){if(an.length){const[{resolve:t,stream:n,workerOptions:r}]=an.splice(0,1);t(new jt(e,n,r,p))}else e.worker?(cn(e),((e,t)=>{const{config:n}=t,{terminateWorkerTimeout:r}=n;i.isFinite(r)&&r>=0&&(e.terminated?e.terminated=!1:e.terminateTimeout=setTimeout((async()=>{sn=sn.filter((t=>t!=e));try{await e.terminate()}catch(e){}}),r))})(e,t)):sn=sn.filter((t=>t!=e))}}function cn(e){const{terminateTimeout:t}=e;t&&(clearTimeout(t),e.terminateTimeout=null)}const un="HTTP error ",fn="HTTP Range not supported",dn="Writer iterator completed too soon",wn="Range",hn="GET",pn="bytes",gn=65536,_n="writable";class mn{constructor(){this.size=0}init(){this.initialized=!0}}class bn extends mn{get readable(){const e=this,{chunkSize:t=gn}=e,n=new z({start(){this.chunkOffset=0},async pull(r){const{offset:i=0,size:s,diskNumberStart:o}=n,{chunkOffset:l}=this;r.enqueue(await Mn(e,i+l,a.min(t,s-l),o)),l+t>s?r.close():this.chunkOffset+=t}});return n}}class yn extends mn{constructor(){super();const e=this,t=new A({write:t=>e.writeUint8Array(t)});n.defineProperty(e,_n,{get:()=>t})}writeUint8Array(){}}class xn extends bn{constructor(e){super(),n.assign(this,{blob:e,size:e.size})}async readUint8Array(e,t){const n=this,r=e+t,i=e||rt&&(s=s.slice(e,r)),new w(s)}}class kn extends mn{constructor(e){super();const t=new v,r=[];e&&r.push(["Content-Type",e]),n.defineProperty(this,_n,{get:()=>t.writable}),this.blob=new u(t.readable,{headers:r}).blob()}getData(){return this.blob}}class Sn extends bn{constructor(e,t){super(),zn(this,e,t)}async init(){await An(this,Ln,Fn),super.init()}readUint8Array(e,t){return Cn(this,e,t,Ln,Fn)}}class vn extends bn{constructor(e,t){super(),zn(this,e,t)}async init(){await An(this,Un,Wn),super.init()}readUint8Array(e,t){return Cn(this,e,t,Un,Wn)}}function zn(e,t,r){const{preventHeadRequest:i,useRangeHeader:s,forceRangeRequests:a,combineSizeEocd:o}=r;delete(r=n.assign({},r)).preventHeadRequest,delete r.useRangeHeader,delete r.forceRangeRequests,delete r.combineSizeEocd,delete r.useXHR,n.assign(e,{url:t,options:r,preventHeadRequest:i,useRangeHeader:s,forceRangeRequests:a,combineSizeEocd:o})}async function An(e,t,n){const{url:r,preventHeadRequest:s,useRangeHeader:a,forceRangeRequests:o,combineSizeEocd:l}=e;if((e=>{const{baseURL:t}=Ue(),{protocol:n}=new f(e,t);return"http:"==n||"https:"==n})(r)&&(a||o)&&(void 0===s||s)){const r=await t(hn,e,Dn(e,l?-22:void 0));if(!o&&r.headers.get("Accept-Ranges")!=pn)throw new d(fn);{let s;l&&(e.eocdCache=new w(await r.arrayBuffer()));const a=r.headers.get("Content-Range");if(a){const e=a.trim().split(/\s*\/\s*/);if(e.length){const t=e[1];t&&"*"!=t&&(s=i(t))}}s===De?await Tn(e,t,n):e.size=s}}else await Tn(e,t,n)}async function Cn(e,t,n,r,i){const{useRangeHeader:s,forceRangeRequests:a,eocdCache:o,size:l,options:c}=e;if(s||a){if(o&&t==l-ke&&n==ke)return o;const i=await r(hn,e,Dn(e,t,n));if(206!=i.status)throw new d(fn);return new w(await i.arrayBuffer())}{const{data:r}=e;return r||await i(e,c),new w(e.data.subarray(t,t+n))}}function Dn(e,t=0,r=1){return n.assign({},En(e),{[wn]:pn+"="+(0>t?t:t+"-"+(t+r-1))})}function En({options:e}){const{headers:t}=e;if(t)return Symbol.iterator in t?n.fromEntries(t):t}async function Fn(e){await Rn(e,Ln)}async function Wn(e){await Rn(e,Un)}async function Rn(e,t){const n=await t(hn,e,En(e));e.data=new w(await n.arrayBuffer()),e.size||(e.size=e.data.length)}async function Tn(e,t,n){if(e.preventHeadRequest)await n(e,e.options);else{const r=(await t("HEAD",e,En(e))).headers.get("Content-Length");r?e.size=i(r):await n(e,e.options)}}async function Ln(e,{options:t,url:r},i){const s=await fetch(r,n.assign({},t,{method:e,headers:i}));if(400>s.status)return s;throw 416==s.status?new d(fn):new d(un+(s.statusText||s.status))}function Un(e,{url:t},r){return new m(((i,s)=>{const a=new XMLHttpRequest;if(a.addEventListener("load",(()=>{if(400>a.status){const e=[];a.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach((t=>{const n=t.trim().split(/\s*:\s*/);n[0]=n[0].trim().replace(/^[a-z]|-[a-z]/g,(e=>e.toUpperCase())),e.push(n)})),i({status:a.status,arrayBuffer:()=>a.response,headers:new l(e)})}else s(416==a.status?new d(fn):new d(un+(a.statusText||a.status)))}),!1),a.addEventListener("error",(e=>s(e.detail?e.detail.error:new d("Network error"))),!1),a.open(e,t),r)for(const e of n.entries(r))a.setRequestHeader(e[0],e[1]);a.responseType="arraybuffer",a.send()}))}class In extends bn{constructor(e,t={}){super(),n.assign(this,{url:e,reader:t.useXHR?new vn(e,t):new Sn(e,t)})}set size(e){}get size(){return this.reader.size}async init(){await this.reader.init(),super.init()}readUint8Array(e,t){return this.reader.readUint8Array(e,t)}}class Nn extends bn{constructor(e){super(),this.readers=e}async init(){const e=this,{readers:t}=e;e.lastDiskNumber=0,e.lastDiskOffset=0,await m.all(t.map((async(n,r)=>{await n.init(),r!=t.length-1&&(e.lastDiskOffset+=n.size),e.size+=n.size}))),super.init()}async readUint8Array(e,t,n=0){const r=this,{readers:i}=this;let s,o=n;-1==o&&(o=i.length-1);let l=e;for(;l>=i[o].size;)l-=i[o].size,o++;const c=i[o],u=c.size;if(l+t>u){const i=u-l;s=new w(t),s.set(await Mn(c,l,i)),s.set(await r.readUint8Array(e+i,t-i,n),i)}else s=await Mn(c,l,t);return r.lastDiskNumber=a.max(o,r.lastDiskNumber),s}}class qn extends mn{constructor(e,t=4294967295){super();const r=this;let i,s,a;n.assign(r,{diskNumber:0,diskOffset:0,size:0,maxSize:t,availableSize:t});const o=new A({async write(t){const{availableSize:n}=r;if(a)t.lengtho})}}async function On(e,t){if(!e.init||e.initialized)return m.resolve();await e.init(t)}function Pn(e){return t.isArray(e)&&(e=new Nn(e)),e instanceof z&&(e={readable:e}),e}function Hn(e){e.writable===De&&typeof e.next==Fe&&(e=new qn(e)),e instanceof A&&(e={writable:e});const{writable:t}=e;return t.size===De&&(t.size=0),e instanceof qn||n.assign(e,{diskNumber:0,diskOffset:0,availableSize:1/0,maxSize:1/0}),e}function Mn(e,t,n,r){return e.readUint8Array(t,n,r)}const Bn=Nn,Vn=qn,Zn="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");function Kn(e,t){return t&&"cp437"==t.trim().toLowerCase()?(e=>{{let t="";for(let n=0;nthis[t]=e[t]))}}const br="File format is not recognized",yr="End of central directory not found",xr="End of Zip64 central directory locator not found",kr="Central directory header not found",Sr="Local file header not found",vr="Zip64 extra field not found",zr="File contains encrypted entry",Ar="Encryption method not supported",Cr="Compression method not supported",Dr="Split zip file",Er="utf-8",Fr="cp437",Wr=[[Jn,we],[Qn,we],[$n,we],[er,he]],Rr={[he]:{getValue:Br,bytes:4},[we]:{getValue:Vr,bytes:8}};class Tr{constructor(e,t={}){n.assign(this,{reader:Pn(e),options:t,config:Ue()})}async*getEntriesGenerator(e={}){const t=this;let{reader:r}=t;const{config:i}=t;if(await On(r),r.size!==De&&r.readUint8Array||(r=new xn(await new u(r.readable).blob()),await On(r)),r.size{const r=new w(4);var i;return i=t,Zr(r).setUint32(0,i,!0),await s(22)||await s(a.min(1048582,n));async function s(t){const i=n-t,s=await Mn(e,i,t);for(let e=s.length-22;e>=0;e--)if(s[e]==r[0]&&s[e+1]==r[1]&&s[e+2]==r[2]&&s[e+3]==r[3])return{offset:i+e,buffer:s.slice(e,e+22).buffer}}})(r,be,r.size);if(!s)throw Br(Zr(await Mn(r,0,4)))==ge?new d(Dr):new d(yr);const o=Zr(s);let l=Br(o,12),c=Br(o,16);const f=s.offset,h=Mr(o,20),p=f+ke+h;let g=Mr(o,4);const _=r.lastDiskNumber||0;let m=Mr(o,6),b=Mr(o,8),y=0,x=0;if(c==we||l==we||b==he||m==he){const e=Zr(await Mn(r,s.offset-20,20));if(Br(e,0)==xe){c=Vr(e,8);let t=await Mn(r,c,56,-1),n=Zr(t);const i=s.offset-20-56;if(Br(n,0)!=ye&&c!=i){const e=c;c=i,y=c-e,t=await Mn(r,c,56,-1),n=Zr(t)}if(Br(n,0)!=ye)throw new d(xr);g==he&&(g=Br(n,16)),m==he&&(m=Br(n,20)),b==he&&(b=Vr(n,32)),l==we&&(l=Vr(n,40)),c-=l}}if(cc)throw new d(br);let k=0,S=await Mn(r,c,l,m),v=Zr(S);if(l){const e=s.offset-l;if(Br(v,k)!=me&&c!=e){const t=c;c=e,y+=c-t,S=await Mn(r,c,l,m),v=Zr(S)}}const z=s.offset-c-(r.lastDiskOffset||0);if(l==z||0>z||(l=z,S=await Mn(r,c,l,m),v=Zr(S)),0>c||c>=r.size)throw new d(br);const A=qr(t,e,"filenameEncoding"),C=qr(t,e,"commentEncoding");for(let s=0;b>s;s++){const o=new Lr(r,i,t.options);if(Br(v,k)!=me)throw new d(kr);Ur(o,v,k+6);const l=!!o.bitFlag.languageEncodingFlag,c=k+46,u=c+o.filenameLength,f=u+o.extraFieldLength,w=Mr(v,k+4),h=!(w>>8),p=w>>8==3,g=S.subarray(c,u),_=Mr(v,k+32),m=f+_,z=S.subarray(f,m),D=l,E=l,F=Br(v,k+38),W=h&&!(16&~Hr(v,k+38))||p&&!(16384&~(F>>16))||g.length&&47==g[g.length-1],R=p&&!(73&~(F>>16)),T=Br(v,k+42)+y;n.assign(o,{versionMadeBy:w,msDosCompatible:h,compressedSize:0,uncompressedSize:0,commentLength:_,directory:W,offset:T,diskNumberStart:Mr(v,k+34),internalFileAttributes:Mr(v,k+36),externalFileAttributes:F,rawFilename:g,filenameUTF8:D,commentUTF8:E,rawExtraField:S.subarray(u,f),executable:R}),o.internalFileAttribute=o.internalFileAttributes,o.externalFileAttribute=o.externalFileAttributes;const L=qr(t,e,"decodeText")||Kn,U=D?Er:A||Fr,I=E?Er:C||Fr;let N=L(g,U);N===De&&(N=Kn(g,U));let q=L(z,I);q===De&&(q=Kn(z,I)),n.assign(o,{rawComment:z,filename:N,comment:q,directory:W||N.endsWith(ze)}),x=a.max(T,x),Ir(o,o,v,k+6),o.zipCrypto=o.encrypted&&!o.extraFieldAES;const O=new mr(o);O.getData=(e,t)=>o.getData(e,O,t),k=m;const{onprogress:P}=e;if(P)try{await P(s+1,b,new mr(o))}catch(e){}yield O}const D=qr(t,e,"extractPrependedData"),E=qr(t,e,"extractAppendedData");return D&&(t.prependedData=x>0?await Mn(r,0,x):new w),t.comment=h?await Mn(r,f+ke,h):new w,E&&(t.appendedData=p>>8&255:h>>>24&255),signature:h,compressed:0!=c&&!k,encrypted:i.encrypted&&!k,useWebWorkers:qr(i,r,"useWebWorkers"),useCompressionStream:qr(i,r,"useCompressionStream"),transferStreams:qr(i,r,"transferStreams"),checkPasswordOnly:F},config:u,streamOptions:{signal:E,size:C,onstart:R,onprogress:T,onend:L}};let I=0;try{({outputSize:I}=await ln({readable:D,writable:W},U))}catch(e){if(!F||e.message!=Qe)throw e}finally{const e=qr(i,r,"preventClose");W.size+=I,e||W.locked||await W.getWriter().close()}return F?De:e.getData?e.getData():W}}function Ur(e,t,r){const i=e.rawBitFlag=Mr(t,r+2),s=!(1&~i),a=Br(t,r+6);n.assign(e,{encrypted:s,version:Mr(t,r),bitFlag:{level:(6&i)>>1,dataDescriptor:!(8&~i),languageEncodingFlag:(i&ve)==ve},rawLastModDate:a,lastModDate:Or(a),filenameLength:Mr(t,r+22),extraFieldLength:Mr(t,r+24)})}function Ir(e,t,r,i,s){const{rawExtraField:a}=t,c=t.extraField=new l,u=Zr(new w(a));let f=0;try{for(;f{t.zip64=!0;const n=Zr(e.data),r=Wr.filter((([e,n])=>t[e]==n));for(let i=0,s=0;i{const i=Zr(e.data),s=Hr(i,4);n.assign(e,{vendorVersion:Hr(i,0),vendorId:Hr(i,2),strength:s,originalCompressionMethod:r,compressionMethod:Mr(i,5)}),t.compressionMethod=e.compressionMethod})(m,t,h),t.extraFieldAES=m):t.compressionMethod=h;const b=c.get(10);b&&(((e,t)=>{const r=Zr(e.data);let i,s=4;try{for(;s{const r=Zr(e.data),i=Hr(r,0),s=[],a=[];n?(1&~i||(s.push(tr),a.push(nr)),2&~i||(s.push(rr),a.push("rawLastAccessDate")),4&~i||(s.push(ir),a.push("rawCreationDate"))):5>e.data.length||(s.push(tr),a.push(nr));let l=1;s.forEach(((n,i)=>{if(e.data.length>=l+4){const s=Br(r,l);t[n]=e[n]=new o(1e3*s);const c=a[i];e[c]=s}l+=4}))})(y,t,s),t.extraFieldExtendedTimestamp=y);const x=c.get(6534);x&&(t.extraFieldUSDZ=x)}function Nr(e,t,r,i,s){const a=Zr(e.data),o=new He;o.append(s[r]);const l=Zr(new w(4));l.setUint32(0,o.get(),!0);const c=Br(a,1);n.assign(e,{version:Hr(a,0),[t]:Kn(e.data.subarray(5)),valid:!s.bitFlag.languageEncodingFlag&&c==Br(l,0)}),e.valid&&(i[t]=e[t],i[t+"UTF8"]=!0)}function qr(e,t,n){return t[n]===De?e.options[n]:t[n]}function Or(e){const t=(4294901760&e)>>16,n=65535&e;try{return new o(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}function Pr(e){return new o(i(e/s(1e4)-s(116444736e5)))}function Hr(e,t){return e.getUint8(t)}function Mr(e,t){return e.getUint16(t,!0)}function Br(e,t){return e.getUint32(t,!0)}function Vr(e,t){return i(e.getBigUint64(t,!0))}function Zr(e){return new g(e.buffer)}const Kr="File already exists",Gr="Zip file comment exceeds 64KB",Xr="File entry comment exceeds 64KB",Yr="File entry name exceeds 64KB",jr="Version exceeds 65535",Jr="The strength must equal 1, 2, or 3",Qr="Extra field type exceeds 65535",$r="Extra field data exceeds 64KB",ei="Zip64 is not supported (make sure 'keepOrder' is set to 'true')",ti="Undefined uncompressed size",ni=new w([7,0,2,0,65,69,3,0,0]);let ri=0;const ii=[];class si{constructor(e,t={}){const r=(e=Hn(e)).availableSize!==De&&e.availableSize>0&&e.availableSize!==1/0&&e.maxSize!==De&&e.maxSize>0&&e.maxSize!==1/0;n.assign(this,{writer:e,addSplitZipSignature:r,options:t,config:Ue(),files:new l,filenames:new c,offset:t.offset===De?e.writable.size:t.offset,pendingEntriesSize:0,pendingAddFileCalls:new c,bufferedWrites:0})}async add(e="",r,i={}){const l=this,{pendingAddFileCalls:c,config:f}=l;let _;riii.push(e)));try{if(e=e.trim(),l.filenames.has(e))throw new d(Kr);return l.filenames.add(e),_=(async(e,r,i,l)=>{r=r.trim();const c=li(e,l,cr),f=li(e,l,wr,c?20:768),_=li(e,l,gr);if(f>he)throw new d(jr);let b=li(e,l,lr,0);0===b&&(b=li(e,l,or,0)),!l.directory&&r.endsWith(ze)&&(l.directory=!0),li(e,l,pr)?(r.endsWith(ze)||(r+=ze),0===b&&(b=c?16:1073741824)):c||0!==b||(b=_?493<<16:27525120);const y=li(e,l,"encodeText",Be);let x=y(r);if(x===De&&(x=Be(r)),gi(x)>he)throw new d(Yr);const k=l.comment||"";let S=y(k);if(S===De&&(S=Be(k)),gi(S)>he)throw new d(Xr);const z=li(e,l,dr,20);if(z>he)throw new d(jr);const A=li(e,l,tr,new o),C=li(e,l,rr),D=li(e,l,ir);let E=li(e,l,ar,0);0===E&&(E=li(e,l,sr,0));const F=li(e,l,"passThrough");let W,R;F||(W=li(e,l,"password"),R=li(e,l,"rawPassword"));const T=li(e,l,"encryptionStrength",3),L=li(e,l,hr),U=li(e,l,"extendedTimestamp",!0),I=li(e,l,"keepOrder",!0),N=li(e,l,"level"),q=li(e,l,"useWebWorkers"),O=li(e,l,"bufferedWrite"),P=li(e,l,"dataDescriptorSignature",!1),H=li(e,l,"signal"),M=li(e,l,"useUnicodeFileNames",!0),B=li(e,l,"useCompressionStream"),V=li(e,l,"compressionMethod");let Z=li(e,l,"dataDescriptor",!0),K=li(e,l,ur);if(!L&&(W!==De||R!==De)&&(1>T||T>3))throw new d(Jr);let G=new w;const{extraField:X}=l;if(X){let e=0,t=0;X.forEach((t=>e+=4+gi(t))),G=new w(e),X.forEach(((e,n)=>{if(n>he)throw new d(Qr);if(gi(e)>he)throw new d($r);hi(G,new h([n]),t),hi(G,new h([gi(e)]),t+2),hi(G,e,t+4),t+=4+gi(e)}))}let Y=0,j=0,J=0;if(F&&(({uncompressedSize:J}=l),J===De))throw new d(ti);const Q=!0===K;i&&(i=Pn(i),await On(i),F?Y=ci(J):i.size===De?(Z=!0,(K||K===De)&&(K=!0,J=Y=4294967296)):(J=i.size,Y=ci(J)));const{diskOffset:$,diskNumber:ee,maxSize:te}=e.writer,ne=Q||J>we,re=Q||Y>we,ie=Q||e.offset+e.pendingEntriesSize-$>we,se=li(e,l,"supportZip64SplitFile",!0)&&Q||ee+a.ceil(e.pendingEntriesSize/te)>he;if(ie||ne||re||se){if(!1===K||!I)throw new d(ei);K=!0}K=K||!1;const ae=li(e,l,fr),{signature:oe}=l,le=(e=>{const{rawFilename:t,lastModDate:n,lastAccessDate:r,creationDate:i,level:s,zip64:o,zipCrypto:l,useUnicodeFileNames:c,dataDescriptor:u,directory:f,rawExtraField:d,encryptionStrength:h,extendedTimestamp:g,encrypted:_}=e;let{version:m,compressionMethod:b}=e;const y=!f&&(s>0||s===De&&0!==b);let x,k,S,v;if(_&&!l){x=new w(gi(ni)+2);const e=pi(x);fi(e,0,39169),hi(x,ni,2),ui(e,8,h)}else x=new w;if(g){S=new w(9+(r?4:0)+(i?4:0));const e=pi(S);fi(e,0,Se),fi(e,2,gi(S)-4),v=1+(r?2:0)+(i?4:0),ui(e,4,v);let t=5;di(e,t,a.floor(n.getTime()/1e3)),t+=4,r&&(di(e,t,a.floor(r.getTime()/1e3)),t+=4),i&&di(e,t,a.floor(i.getTime()/1e3));try{k=new w(36);const e=pi(k),t=oi(n);fi(e,0,10),fi(e,2,32),fi(e,8,1),fi(e,10,24),wi(e,12,t),wi(e,20,oi(r)||t),wi(e,28,oi(i)||t)}catch(e){k=new w}}else k=S=new w;let z=0;c&&(z|=ve),u&&(z|=8),b===De&&(b=y?8:0),8==b&&(s>=1&&3>s&&(z|=6),s>=3&&5>s&&(z|=1),9===s&&(z|=2)),o&&(m=m>45?m:45),_&&(z|=1,l||(m=m>51?m:51,x[9]=b,b=99));const A=new w(26),C=pi(A);fi(C,0,m),fi(C,2,z),fi(C,4,b);const D=new p(1),E=pi(D);let F;F=Ce>n?Ce:n>Ae?Ae:n,fi(E,0,(F.getHours()<<6|F.getMinutes())<<5|F.getSeconds()/2),fi(E,2,(F.getFullYear()-1980<<4|F.getMonth()+1)<<5|F.getDate());const W=D[0];di(C,6,W),fi(C,22,gi(t));const R=gi(x,S,k,d);fi(C,24,R);const T=new w(30+gi(t)+R);return di(pi(T),0,pe),hi(T,A,4),hi(T,t,30),hi(T,x,30+gi(t)),hi(T,S,30+gi(t,x)),hi(T,k,30+gi(t,x,S)),hi(T,d,30+gi(t,x,S,k)),{localHeaderArray:T,headerArray:A,headerView:C,lastModDate:n,rawLastModDate:W,encrypted:_,compressed:y,version:m,compressionMethod:b,extraFieldExtendedTimestampFlag:v,rawExtraFieldExtendedTimestamp:S,rawExtraFieldNTFS:k,rawExtraFieldAES:x,extraFieldLength:R}})(l=n.assign({},l,{rawFilename:x,rawComment:S,version:z,versionMadeBy:f,lastModDate:A,lastAccessDate:C,creationDate:D,rawExtraField:G,zip64:K,zip64UncompressedSize:ne,zip64CompressedSize:re,zip64Offset:ie,zip64DiskNumberStart:se,password:W,rawPassword:R,level:B||e.config.CompressionStream!==De||e.config.CompressionStreamNative!==De?N:0,useWebWorkers:q,encryptionStrength:T,extendedTimestamp:U,zipCrypto:L,bufferedWrite:O,keepOrder:I,useUnicodeFileNames:M,dataDescriptor:Z,dataDescriptorSignature:P,signal:H,msDosCompatible:c,internalFileAttribute:E,internalFileAttributes:E,externalFileAttribute:b,externalFileAttributes:b,useCompressionStream:B,passThrough:F,encrypted:!!(W&&gi(W)||R&&gi(R))||F&&ae,signature:oe,compressionMethod:V})),ce=(e=>{const{zip64:t,dataDescriptor:n,dataDescriptorSignature:r}=e;let i,s=new w,a=0;return n&&(s=new w(t?r?24:20:r?16:12),i=pi(s),r&&(a=4,di(i,0,_e))),{dataDescriptorArray:s,dataDescriptorView:i,dataDescriptorOffset:a}})(l),ue=gi(le.localHeaderArray,ce.dataDescriptorArray);let fe;j=ue+Y,e.options.usdz&&(j+=j+64),e.pendingEntriesSize+=j;try{fe=await(async(e,r,i,a,o)=>{const{files:l,writer:c}=e,{keepOrder:f,dataDescriptor:h,signal:p}=o,{headerInfo:_}=a,{usdz:b}=e.options,y=t.from(l.values()).pop();let x,k,S,z,A,C,D,E={};l.set(r,E);try{let t;f&&(t=y&&y.lock,E.lock=new m((e=>S=e))),!(o.bufferedWrite||e.writerLocked||e.bufferedWrites&&f)&&h||b?(C=c,await F()):(C=new v,D=new u(C.readable).blob(),C.writable.size=0,x=!0,e.bufferedWrites++,await On(c)),await On(C);const{writable:_}=c;let{diskOffset:k}=c;if(e.addSplitZipSignature){delete e.addSplitZipSignature;const t=new w(4);di(pi(t),0,ge),await ai(_,t),e.offset+=4}b&&((e,t)=>{const{headerInfo:n}=e;let{localHeaderArray:r,extraFieldLength:i}=n,s=pi(r),a=64-(t+gi(r))%64;4>a&&(a+=64);const o=new w(a),l=pi(o);fi(l,0,6534),fi(l,2,a-2);const c=r;n.localHeaderArray=r=new w(gi(c)+a),hi(r,c),hi(r,o,gi(c)),s=pi(r),fi(s,28,i+a),e.metadataSize+=a})(a,e.offset-k),x||(await t,await W(_));const{diskNumber:R}=c;if(A=!0,E.diskNumberStart=R,E=await(async(e,t,{diskNumberStart:r,lock:i},a,o,l)=>{const{headerInfo:c,dataDescriptorInfo:u,metadataSize:f}=a,{localHeaderArray:d,headerArray:h,lastModDate:p,rawLastModDate:g,encrypted:_,compressed:m,version:b,compressionMethod:y,rawExtraFieldExtendedTimestamp:x,extraFieldExtendedTimestampFlag:k,rawExtraFieldNTFS:S,rawExtraFieldAES:v}=c,{dataDescriptorArray:z}=u,{rawFilename:A,lastAccessDate:C,creationDate:D,password:E,rawPassword:F,level:W,zip64:R,zip64UncompressedSize:T,zip64CompressedSize:L,zip64Offset:U,zip64DiskNumberStart:I,zipCrypto:N,dataDescriptor:q,directory:O,executable:P,versionMadeBy:H,rawComment:M,rawExtraField:B,useWebWorkers:V,onstart:Z,onprogress:K,onend:G,signal:X,encryptionStrength:Y,extendedTimestamp:j,msDosCompatible:J,internalFileAttributes:Q,externalFileAttributes:$,useCompressionStream:ee,passThrough:te}=l,ne={lock:i,versionMadeBy:H,zip64:R,directory:!!O,executable:!!P,filenameUTF8:!0,rawFilename:A,commentUTF8:!0,rawComment:M,rawExtraFieldExtendedTimestamp:x,rawExtraFieldNTFS:S,rawExtraFieldAES:v,rawExtraField:B,extendedTimestamp:j,msDosCompatible:J,internalFileAttributes:Q,externalFileAttributes:$,diskNumberStart:r};let{signature:re,uncompressedSize:ie}=l,se=0;te||(ie=0);const{writable:ae}=t;if(e){e.chunkSize=Ie(o),await ai(ae,d);const t=e.readable,n=t.size=e.size,r={options:{codecType:Zt,level:W,rawPassword:F,password:E,encryptionStrength:Y,zipCrypto:_&&N,passwordVerification:_&&N&&g>>8&255,signed:!te,compressed:m&&!te,encrypted:_&&!te,useWebWorkers:V,useCompressionStream:ee,transferStreams:!1},config:o,streamOptions:{signal:X,size:n,onstart:Z,onprogress:K,onend:G}},i=await ln({readable:t,writable:ae},r);se=i.outputSize,te||(ie=i.inputSize,re=i.signature),ae.size+=ie}else await ai(ae,d);let oe;if(R){let e=4;T&&(e+=8),L&&(e+=8),U&&(e+=8),I&&(e+=4),oe=new w(e)}else oe=new w;return((e,t)=>{const{signature:n,rawExtraFieldZip64:r,compressedSize:i,uncompressedSize:a,headerInfo:o,dataDescriptorInfo:l}=e,{headerView:c,encrypted:u}=o,{dataDescriptorView:f,dataDescriptorOffset:d}=l,{zip64:w,zip64UncompressedSize:h,zip64CompressedSize:p,zipCrypto:g,dataDescriptor:_}=t;if(u&&!g||n===De||(di(c,10,n),_&&di(f,d,n)),w){const e=pi(r);fi(e,0,1),fi(e,2,gi(r)-4);let t=4;h&&(di(c,18,we),wi(e,t,s(a)),t+=8),p&&(di(c,14,we),wi(e,t,s(i))),_&&(wi(f,d+4,s(i)),wi(f,d+12,s(a)))}else di(c,14,i),di(c,18,a),_&&(di(f,d+4,i),di(f,d+8,a))})({signature:re,rawExtraFieldZip64:oe,compressedSize:se,uncompressedSize:ie,headerInfo:c,dataDescriptorInfo:u},l),q&&await ai(ae,z),n.assign(ne,{uncompressedSize:ie,compressedSize:se,lastModDate:p,rawLastModDate:g,creationDate:D,lastAccessDate:C,encrypted:_,zipCrypto:N,size:f+se,compressionMethod:y,version:b,headerArray:h,signature:re,rawExtraFieldZip64:oe,extraFieldExtendedTimestampFlag:k,zip64UncompressedSize:T,zip64CompressedSize:L,zip64Offset:U,zip64DiskNumberStart:I}),ne})(i,C,E,a,e.config,o),A=!1,l.set(r,E),E.filename=r,x){await C.writable.getWriter().close();let e=await D;await t,await F(),z=!0,h||(e=await(async(e,t,n,{zipCrypto:r})=>{let i;i=await t.slice(0,26).arrayBuffer(),26!=i.byteLength&&(i=i.slice(0,26));const s=new g(i);return e.encrypted&&!r||di(s,14,e.signature),e.zip64?(di(s,18,we),di(s,22,we)):(di(s,18,e.compressedSize),di(s,22,e.uncompressedSize)),await ai(n,new w(i)),t.slice(i.byteLength)})(E,e,_,o)),await W(_),E.diskNumberStart=c.diskNumber,k=c.diskOffset,await e.stream().pipeTo(_,{preventClose:!0,preventAbort:!0,signal:p}),_.size+=e.size,z=!1}if(E.offset=e.offset-k,E.zip64)((e,t)=>{const{rawExtraFieldZip64:n,offset:r,diskNumberStart:i}=e,{zip64UncompressedSize:a,zip64CompressedSize:o,zip64Offset:l,zip64DiskNumberStart:c}=t,u=pi(n);let f=4;a&&(f+=8),o&&(f+=8),l&&(wi(u,f,s(r)),f+=8),c&&di(u,f,i)})(E,o);else if(E.offset>we)throw new d(ei);return e.offset+=E.size,E}catch(t){if(x&&z||!x&&A){if(e.hasCorruptedEntries=!0,t)try{t.corruptedEntry=!0}catch(e){}x?e.offset+=C.writable.size:e.offset=C.writable.size}throw l.delete(r),t}finally{x&&e.bufferedWrites--,S&&S(),k&&k()}async function F(){e.writerLocked=!0;const{lockWriter:t}=e;e.lockWriter=new m((t=>k=()=>{e.writerLocked=!1,t()})),await t}async function W(e){gi(_.localHeaderArray)>c.availableSize&&(c.availableSize=0,await ai(e,new w))}})(e,r,i,{headerInfo:le,dataDescriptorInfo:ce,metadataSize:ue},l)}finally{e.pendingEntriesSize-=j}return n.assign(fe,{name:r,comment:k,extraField:X}),new mr(fe)})(l,e,r,i),c.add(_),await _}catch(t){throw l.filenames.delete(e),t}finally{c.delete(_);const e=ii.shift();e?e():ri--}}async close(e=new w,n={}){const{pendingAddFileCalls:r,writer:i}=this,{writable:o}=i;for(;r.size;)await m.allSettled(t.from(r));return await(async(e,n,r)=>{const{files:i,writer:o}=e,{diskOffset:l,writable:c}=o;let{diskNumber:u}=o,f=0,h=0,p=e.offset-l,g=i.size;for(const[,e]of i){const{rawFilename:t,rawExtraFieldZip64:n,rawExtraFieldAES:r,rawComment:i,rawExtraFieldNTFS:s,rawExtraField:o,extendedTimestamp:l,extraFieldExtendedTimestampFlag:c,lastModDate:u}=e;let f;if(l){f=new w(9);const e=pi(f);fi(e,0,Se),fi(e,2,5),ui(e,4,c),di(e,5,a.floor(u.getTime()/1e3))}else f=new w;e.rawExtraFieldCDExtendedTimestamp=f,h+=46+gi(t,i,n,r,s,f,o)}const _=new w(h),m=pi(_);await On(o);let b=0;for(const[e,n]of t.from(i.values()).entries()){const{offset:t,rawFilename:s,rawExtraFieldZip64:a,rawExtraFieldAES:l,rawExtraFieldCDExtendedTimestamp:u,rawExtraFieldNTFS:d,rawExtraField:w,rawComment:h,versionMadeBy:p,headerArray:g,zip64:y,zip64UncompressedSize:x,zip64CompressedSize:k,zip64DiskNumberStart:S,zip64Offset:v,internalFileAttributes:z,externalFileAttributes:A,diskNumberStart:C,uncompressedSize:D,compressedSize:E}=n,F=gi(a,l,u,d,w);di(m,f,me),fi(m,f+4,p);const W=pi(g);x||di(W,18,D),k||di(W,14,E),hi(_,g,f+6),fi(m,f+30,F),fi(m,f+32,gi(h)),fi(m,f+34,y&&S?he:C),fi(m,f+36,z),A&&di(m,f+38,A),di(m,f+42,y&&v?we:t),hi(_,s,f+46),hi(_,a,f+46+gi(s)),hi(_,l,f+46+gi(s,a)),hi(_,u,f+46+gi(s,a,l)),hi(_,d,f+46+gi(s,a,l,u)),hi(_,w,f+46+gi(s,a,l,u,d)),hi(_,h,f+46+gi(s)+F);const R=46+gi(s,h)+F;if(f-b>o.availableSize&&(o.availableSize=0,await ai(c,_.slice(b,f)),b=f),f+=R,r.onprogress)try{await r.onprogress(e+1,i.size,new mr(n))}catch(e){}}await ai(c,b?_.slice(b):_);let y=o.diskNumber;const{availableSize:x}=o;ke>x&&y++;let k=li(e,r,ur);if(p>we||h>we||g>he||y>he){if(!1===k)throw new d(ei);k=!0}const S=new w(k?98:ke),v=pi(S);f=0,k&&(di(v,0,ye),wi(v,4,s(44)),fi(v,12,45),fi(v,14,45),di(v,16,y),di(v,20,u),wi(v,24,s(g)),wi(v,32,s(g)),wi(v,40,s(h)),wi(v,48,s(p)),di(v,56,xe),wi(v,64,s(p)+s(h)),di(v,72,y+1),li(e,r,"supportZip64SplitFile",!0)&&(y=he,u=he),g=he,p=we,h=we,f+=76),di(v,f,be),fi(v,f+4,y),fi(v,f+6,u),fi(v,f+8,g),fi(v,f+10,g),di(v,f+12,h),di(v,f+16,p);const z=gi(n);if(z){if(z>he)throw new d(Gr);fi(v,f+20,z)}await ai(c,S),z&&await ai(c,n)})(this,e,n),li(this,n,"preventClose")||await o.getWriter().close(),i.getData?i.getData():o}}async function ai(e,t){const n=e.getWriter();try{await n.ready,e.size+=gi(t),await n.write(t)}finally{n.releaseLock()}}function oi(e){if(e)return(s(e.getTime())+s(116444736e5))*s(1e4)}function li(e,t,n,r){const i=t[n]===De?e.options[n]:t[n];return i===De?r:i}function ci(e){return e+5*(a.floor(e/16383)+1)}function ui(e,t,n){e.setUint8(t,n)}function fi(e,t,n){e.setUint16(t,n,!0)}function di(e,t,n){e.setUint32(t,n,!0)}function wi(e,t,n){e.setBigUint64(t,n,!0)}function hi(e,t,n){e.set(t,n)}function pi(e){return new g(e.buffer)}function gi(...e){let t=0;return e.forEach((e=>e&&(t+=e.length))),t}let _i;try{_i=void 0===x&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:void 0===x?location.href:W&&"SCRIPT"===W.tagName.toUpperCase()&&W.src||new f("zip-full.min.js",x.baseURI).href}catch(e){}((e,t={})=>{const n='const{Array:e,Object:t,Number:n,Math:r,Error:s,Uint8Array:i,Uint16Array:o,Uint32Array:c,Int32Array:f,Map:a,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:d,TransformStream:p,ReadableStream:y,WritableStream:m,CompressionStream:b,DecompressionStream:g}=self,k=void 0,v="undefined",S="function";class z{constructor(e){return class extends p{constructor(t,n){const r=new e(n);super({transform(e,t){t.enqueue(r.append(e))},flush(e){const t=r.flush();t&&e.enqueue(t)}})}}}}const C=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;C[e]=t}class x{constructor(e){this.t=e||-1}append(e){let t=0|this.t;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^C[255&(t^e[n])];this.t=t}get(){return~this.t}}class A extends p{constructor(){let e;const t=new x;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new i(4);new l(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const _={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=_.i(n);return 32===r?e.concat(t):_.o(t,r,0|n,e.slice(0,e.length-1))},l(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+_.i(n)},u(e,t){if(32*e.length0&&t&&(e[n-1]=_.h(t,e[n-1]&2147483648>>t-1,1)),e},h:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,i:e=>r.round(e/1099511627776)||32,o(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,i=_.i(s);return r.push(_.h(t+i&31,t+i>32?n:r.pop(),1)),r}},I={bytes:{p(e){const t=_.l(e)/8,n=new i(t);let r;for(let s=0;t>s;s++)3&s||(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},m(e){const t=[];let n,r=0;for(n=0;n9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const o=new c(n);let f=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);i>=e;e+=t.blockSize)t.I(o.subarray(16*f,16*(f+1))),f+=1;return n.splice(0,16*f),t}P(){const e=this;let t=e.C;const n=e.S;t=_.concat(t,[_.h(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(r.floor(e.A/4294967296)),t.push(0|e.A);t.length;)e.I(t.splice(0,16));return e.reset(),n}D(e,t,n,r){return e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r}V(e,t){return t<>>32-e}I(t){const n=this,s=n.S,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let o=s[0],c=s[1],f=s[2],a=s[3],l=s[4];for(let e=0;79>=e;e++){16>e||(i[e]=n.V(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=n.V(5,o)+n.D(e,c,f,a)+l+i[e]+n.v[r.floor(e/20)]|0;l=a,a=f,f=n.V(30,c),c=o,o=t}s[0]=s[0]+o|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+a|0,s[4]=s[4]+l|0}},D={getRandomValues(e){const t=new c(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(r.random()>.5?1:-1))};for(let s,i=0;inew V.R(I.bytes.m(e)),B(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const i=1+(r>>5)<<2;let o,c,f,a,u;const w=new ArrayBuffer(i),h=new l(w);let d=0;const p=_;for(t=I.bytes.m(t),u=1;(i||1)>d;u++){for(o=c=e.encrypt(p.concat(t,[u])),f=1;n>f;f++)for(c=e.encrypt(c),a=0;ad&&fs&&(e=(new n).update(e).P());for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t.U[0].update(r[0]),t.U[1].update(r[1]),t.K=new n(t.U[0])}reset(){const e=this;e.K=new e.M(e.U[0]),e.N=!1}update(e){this.N=!0,this.K.update(e)}digest(){const e=this,t=e.K.P(),n=new e.M(e.U[1]).update(t).P();return e.reset(),n}encrypt(e){if(this.N)throw new s("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},R=typeof h!=v&&typeof h.getRandomValues==S,B="Invalid password",E="Invalid signature",M="zipjs-abort-check-password";function U(e){return R?h.getRandomValues(e):D.getRandomValues(e)}const K=16,N={name:"PBKDF2"},O=t.assign({hash:{name:"HMAC"}},N),T=t.assign({iterations:1e3,hash:{name:"SHA-1"}},N),W=["deriveBits"],j=[8,12,16],H=[16,24,32],L=10,F=[0,0,0,0],q=typeof h!=v,G=q&&h.subtle,J=q&&typeof G!=v,Q=I.bytes,X=class{constructor(e){const t=this;t.O=[[[],[],[],[],[]],[[],[],[],[],[]]],t.O[0][0][0]||t.T();const n=t.O[0][4],r=t.O[1],i=e.length;let o,c,f,a=1;if(4!==i&&6!==i&&8!==i)throw new s("invalid aes key size");for(t.v=[c=e.slice(0),f=[]],o=i;4*i+28>o;o++){let e=c[o-1];(o%i==0||8===i&&o%i==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%i==0&&(e=e<<8^e>>>24^a<<24,a=a<<1^283*(a>>7))),c[o]=c[o-i]^e}for(let e=0;o;e++,o--){const t=c[3&e?o:o-4];f[e]=4>=o||4>e?t:r[0][n[t>>>24]]^r[1][n[t>>16&255]]^r[2][n[t>>8&255]]^r[3][n[255&t]]}}encrypt(e){return this.W(e,0)}decrypt(e){return this.W(e,1)}T(){const e=this.O[0],t=this.O[1],n=e[4],r=t[4],s=[],i=[];let o,c,f,a;for(let e=0;256>e;e++)i[(s[e]=e<<1^283*(e>>7))^e]=e;for(let l=o=0;!n[l];l^=c||1,o=i[o]||1){let i=o^o<<1^o<<2^o<<3^o<<4;i=i>>8^255&i^99,n[l]=i,r[i]=l,a=s[f=s[c=s[l]]];let u=16843009*a^65537*f^257*c^16843008*l,w=257*s[i]^16843008*i;for(let n=0;4>n;n++)e[n][l]=w=w<<24^w>>>8,t[n][i]=u=u<<24^u>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}W(e,t){if(4!==e.length)throw new s("invalid aes block size");const n=this.v[t],r=n.length/4-2,i=[0,0,0,0],o=this.O[t],c=o[0],f=o[1],a=o[2],l=o[3],u=o[4];let w,h,d,p=e[0]^n[0],y=e[t?3:1]^n[1],m=e[2]^n[2],b=e[t?1:3]^n[3],g=4;for(let e=0;r>e;e++)w=c[p>>>24]^f[y>>16&255]^a[m>>8&255]^l[255&b]^n[g],h=c[y>>>24]^f[m>>16&255]^a[b>>8&255]^l[255&p]^n[g+1],d=c[m>>>24]^f[b>>16&255]^a[p>>8&255]^l[255&y]^n[g+2],b=c[b>>>24]^f[p>>16&255]^a[y>>8&255]^l[255&m]^n[g+3],g+=4,p=w,y=h,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=u[p>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&b]^n[g++],w=p,p=y,y=m,m=b,b=w;return i}},Y=class{constructor(e,t){this.j=e,this.H=t,this.L=t}reset(){this.L=this.H}update(e){return this.F(this.j,e,this.L)}q(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}return e}G(e){0===(e[0]=this.q(e[0]))&&(e[1]=this.q(e[1]))}F(e,t,n){let r;if(!(r=t.length))return[];const s=_.l(t);for(let s=0;r>s;s+=4){this.G(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return _.u(t,s)}},Z=V.R;let $=q&&J&&typeof G.importKey==S,ee=q&&J&&typeof G.deriveBits==S;class te extends p{constructor({password:e,rawPassword:n,signed:r,encryptionStrength:o,checkPasswordOnly:c}){super({start(){t.assign(this,{ready:new u((e=>this.J=e)),password:ie(e,n),signed:r,X:o-1,pending:new i})},async transform(e,t){const n=this,{password:r,X:o,J:f,ready:a}=n;r?(await(async(e,t,n,r)=>{const i=await se(e,t,n,ce(r,0,j[t])),o=ce(r,j[t]);if(i[0]!=o[0]||i[1]!=o[1])throw new s(B)})(n,o,r,ce(e,0,j[o]+2)),e=ce(e,j[o]+2),c?t.error(new s(M)):f()):await a;const l=new i(e.length-L-(e.length-L)%K);t.enqueue(re(n,e,l,0,L,!0))},async flush(e){const{signed:t,Y:n,Z:r,pending:o,ready:c}=this;if(r&&n){await c;const f=ce(o,0,o.length-L),a=ce(o,o.length-L);let l=new i;if(f.length){const e=ae(Q,f);r.update(e);const t=n.update(e);l=fe(Q,t)}if(t){const e=ce(fe(Q,r.digest()),0,L);for(let t=0;L>t;t++)if(e[t]!=a[t])throw new s(E)}e.enqueue(l)}}})}}class ne extends p{constructor({password:e,rawPassword:n,encryptionStrength:r}){let s;super({start(){t.assign(this,{ready:new u((e=>this.J=e)),password:ie(e,n),X:r-1,pending:new i})},async transform(e,t){const n=this,{password:r,X:s,J:o,ready:c}=n;let f=new i;r?(f=await(async(e,t,n)=>{const r=U(new i(j[t]));return oe(r,await se(e,t,n,r))})(n,s,r),o()):await c;const a=new i(f.length+e.length-e.length%K);a.set(f,0),t.enqueue(re(n,e,a,f.length,0))},async flush(e){const{Y:t,Z:n,pending:r,ready:o}=this;if(n&&t){await o;let c=new i;if(r.length){const e=t.update(ae(Q,r));n.update(e),c=fe(Q,e)}s.signature=fe(Q,n.digest()).slice(0,L),e.enqueue(oe(c,s.signature))}}}),s=this}}function re(e,t,n,r,s,o){const{Y:c,Z:f,pending:a}=e,l=t.length-s;let u;for(a.length&&(t=oe(a,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new i(t)).set(n,0)}return e})(n,l-l%K)),u=0;l-K>=u;u+=K){const e=ae(Q,ce(t,u,u+K));o&&f.update(e);const s=c.update(e);o||f.update(s),n.set(fe(Q,s),u+r)}return e.pending=ce(t,u),n}async function se(n,r,s,o){n.password=null;const c=await(async(e,t,n,r,s)=>{if(!$)return V.importKey(t);try{return await G.importKey("raw",t,n,!1,s)}catch(e){return $=!1,V.importKey(t)}})(0,s,O,0,W),f=await(async(e,t,n)=>{if(!ee)return V.B(t,e.salt,T.iterations,n);try{return await G.deriveBits(e,t,n)}catch(r){return ee=!1,V.B(t,e.salt,T.iterations,n)}})(t.assign({salt:o},T),c,8*(2*H[r]+2)),a=new i(f),l=ae(Q,ce(a,0,H[r])),u=ae(Q,ce(a,H[r],2*H[r])),w=ce(a,2*H[r]);return t.assign(n,{keys:{key:l,$:u,passwordVerification:w},Y:new Y(new X(l),e.from(F)),Z:new Z(u)}),w}function ie(e,t){return t===k?(e=>{if(typeof w==v){const t=new i((e=unescape(encodeURIComponent(e))).length);for(let n=0;n>>24]),i=~e.te.get(),e.keys=[n,s,i]}function ye(e){const t=2|e.keys[2];return me(r.imul(t,1^t)>>>8)}function me(e){return 255&e}function be(e){return 4294967295&e}const ge="deflate-raw";class ke extends p{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:r}){super({});const{compressed:s,encrypted:i,useCompressionStream:o,zipCrypto:c,signed:f,level:a}=e,u=this;let w,h,d=Se(super.readable);i&&!c||!f||(w=new A,d=xe(d,w)),s&&(d=Ce(d,o,{level:a,chunkSize:t},r,n)),i&&(c?d=xe(d,new ue(e)):(h=new ne(e),d=xe(d,h))),ze(u,d,(()=>{let e;i&&!c&&(e=h.signature),i&&!c||!f||(e=new l(w.value.buffer).getUint32(0)),u.signature=e}))}}class ve extends p{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:r}){super({});const{zipCrypto:i,encrypted:o,signed:c,signature:f,compressed:a,useCompressionStream:u}=e;let w,h,d=Se(super.readable);o&&(i?d=xe(d,new le(e)):(h=new te(e),d=xe(d,h))),a&&(d=Ce(d,u,{chunkSize:t},r,n)),o&&!i||!c||(w=new A,d=xe(d,w)),ze(this,d,(()=>{if((!o||i)&&c){const e=new l(w.value.buffer);if(f!=e.getUint32(0,!1))throw new s(E)}}))}}function Se(e){return xe(e,new p({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function ze(e,n,r){n=xe(n,new p({flush:r})),t.defineProperty(e,"readable",{get:()=>n})}function Ce(e,t,n,r,s){try{e=xe(e,new(t&&r?r:s)(ge,n))}catch(r){if(!t)return e;try{e=xe(e,new s(ge,n))}catch(t){return e}}return e}function xe(e,t){return e.pipeThrough(t)}const Ae="data",_e="close";class Ie extends p{constructor(e,n){super({});const r=this,{codecType:s}=e;let i;s.startsWith("deflate")?i=ke:s.startsWith("inflate")&&(i=ve);let o=0,c=0;const f=new i(e,n),a=super.readable,l=new p({transform(e,t){e&&e.length&&(c+=e.length,t.enqueue(e))},flush(){t.assign(r,{inputSize:c})}}),u=new p({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){const{signature:e}=f;t.assign(r,{signature:e,outputSize:o,inputSize:c})}});t.defineProperty(r,"readable",{get:()=>a.pipeThrough(l).pipeThrough(f).pipeThrough(u)})}}class Pe extends p{constructor(e){let t;super({transform:function n(r,s){if(t){const e=new i(t.length+r.length);e.set(t),e.set(r,t.length),r=e,t=null}r.length>e?(s.enqueue(r.slice(0,e)),n(r.slice(e),s)):t=r},flush(e){t&&t.length&&e.enqueue(t)}})}}const De=new a,Ve=new a;let Re,Be=0,Ee=!0;async function Me(e){try{const{options:t,scripts:r,config:s}=e;if(r&&r.length)try{Ee?importScripts.apply(k,r):await Ue(r)}catch(e){Ee=!1,await Ue(r)}self.initCodec&&self.initCodec(),s.CompressionStreamNative=self.CompressionStream,s.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(s.CompressionStream=new z(self.Deflate)),self.Inflate&&(s.DecompressionStream=new z(self.Inflate));const i={highWaterMark:1},o=e.readable||new y({async pull(e){const t=new u((e=>De.set(Be,e)));Ke({type:"pull",messageId:Be}),Be=(Be+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await t;e.enqueue(r),s&&e.close()}},i),c=e.writable||new m({async write(e){let t;const r=new u((e=>t=e));Ve.set(Be,t),Ke({type:Ae,value:e,messageId:Be}),Be=(Be+1)%n.MAX_SAFE_INTEGER,await r}},i),f=new Ie(t,s);Re=new AbortController;const{signal:a}=Re;await o.pipeThrough(f).pipeThrough(new Pe(s.chunkSize)).pipeTo(c,{signal:a,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{signature:l,inputSize:w,outputSize:h}=f;Ke({type:_e,result:{signature:l,inputSize:w,outputSize:h}})}catch(e){Ne(e)}}async function Ue(e){for(const t of e)await import(t)}function Ke(e){let{value:t}=e;if(t)if(t.length)try{t=new i(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function Ne(e=new s("Unknown error")){const{message:t,stack:n,code:r,name:i}=e;d({error:{message:t,stack:n,code:r,name:i}})}addEventListener("message",(({data:e})=>{const{type:t,messageId:n,value:r,done:s}=e;try{if("start"==t&&Me(e),t==Ae){const e=De.get(n);De.delete(n),e({value:new i(r),done:s})}if("ack"==t){const e=Ve.get(n);Ve.delete(n),e()}t==_e&&Re.abort()}catch(e){Ne(e)}}));const Oe=-2;function Te(t){return We(t.map((([t,n])=>new e(t).fill(n,0,t))))}function We(t){return t.reduce(((t,n)=>t.concat(e.isArray(n)?We(n):n)),[])}const je=[0,1,2,3].concat(...Te([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function He(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.ne=n=>{const s=e.re,i=e.ie.se,o=e.ie.oe;let c,f,a,l=-1;for(n.ce=0,n.fe=573,c=0;o>c;c++)0!==s[2*c]?(n.ae[++n.ce]=l=c,n.le[c]=0):s[2*c+1]=0;for(;2>n.ce;)a=n.ae[++n.ce]=2>l?++l:0,s[2*a]=1,n.le[a]=0,n.ue--,i&&(n.we-=i[2*a+1]);for(e.he=l,c=r.floor(n.ce/2);c>=1;c--)n.de(s,c);a=o;do{c=n.ae[1],n.ae[1]=n.ae[n.ce--],n.de(s,1),f=n.ae[1],n.ae[--n.fe]=c,n.ae[--n.fe]=f,s[2*a]=s[2*c]+s[2*f],n.le[a]=r.max(n.le[c],n.le[f])+1,s[2*c+1]=s[2*f+1]=a,n.ae[1]=a++,n.de(s,1)}while(n.ce>=2);n.ae[--n.fe]=n.ae[1],(t=>{const n=e.re,r=e.ie.se,s=e.ie.pe,i=e.ie.ye,o=e.ie.me;let c,f,a,l,u,w,h=0;for(l=0;15>=l;l++)t.be[l]=0;for(n[2*t.ae[t.fe]+1]=0,c=t.fe+1;573>c;c++)f=t.ae[c],l=n[2*n[2*f+1]+1]+1,l>o&&(l=o,h++),n[2*f+1]=l,f>e.he||(t.be[l]++,u=0,i>f||(u=s[f-i]),w=n[2*f],t.ue+=w*(l+u),r&&(t.we+=w*(r[2*f+1]+u)));if(0!==h){do{for(l=o-1;0===t.be[l];)l--;t.be[l]--,t.be[l+1]+=2,t.be[o]--,h-=2}while(h>0);for(l=o;0!==l;l--)for(f=t.be[l];0!==f;)a=t.ae[--c],a>e.he||(n[2*a+1]!=l&&(t.ue+=(l-n[2*a+1])*n[2*a],n[2*a+1]=l),f--)}})(n),((e,n,r)=>{const s=[];let i,o,c,f=0;for(i=1;15>=i;i++)s[i]=f=f+r[i-1]<<1;for(o=0;n>=o;o++)c=e[2*o+1],0!==c&&(e[2*o]=t(s[c]++,c))})(s,e.he,n.be)}}function Le(e,t,n,r,s){const i=this;i.se=e,i.pe=t,i.ye=n,i.oe=r,i.me=s}He.ge=[0,1,2,3,4,5,6,7].concat(...Te([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),He.ke=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],He.ve=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],He.Se=e=>256>e?je[e]:je[256+(e>>>7)],He.ze=[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],He.Ce=[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],He.xe=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],He.Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const Fe=Te([[144,8],[112,9],[24,7],[8,8]]);Le._e=We([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,Fe[t]])));const qe=Te([[30,5]]);function Ge(e,t,n,r,s){const i=this;i.Ie=e,i.Pe=t,i.De=n,i.Ve=r,i.Re=s}Le.Be=We([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,qe[t]]))),Le.Ee=new Le(Le._e,He.ze,257,286,15),Le.Me=new Le(Le.Be,He.Ce,0,30,15),Le.Ue=new Le(null,He.xe,0,19,7);const Je=[new Ge(0,0,0,0,0),new Ge(4,4,8,4,1),new Ge(4,5,16,8,1),new Ge(4,6,32,32,1),new Ge(4,4,16,16,2),new Ge(8,16,32,32,2),new Ge(8,16,128,128,2),new Ge(8,32,128,256,2),new Ge(32,128,258,1024,2),new Ge(32,258,258,4096,2)],Qe=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],Xe=113,Ye=666,Ze=262;function $e(e,t,n,r){const s=e[2*t],i=e[2*n];return i>s||s==i&&r[t]<=r[n]}function et(){const e=this;let t,n,s,c,f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,z,C,x,A,_,I,P,D,V,R,B,E,M,U;const K=new He,N=new He,O=new He;let T,W,j,H,L,F;function q(){let t;for(t=0;286>t;t++)E[2*t]=0;for(t=0;30>t;t++)M[2*t]=0;for(t=0;19>t;t++)U[2*t]=0;E[512]=1,e.ue=e.we=0,W=j=0}function G(e,t){let n,r=-1,s=e[1],i=0,o=7,c=4;0===s&&(o=138,c=3),e[2*(t+1)+1]=65535;for(let f=0;t>=f;f++)n=s,s=e[2*(f+1)+1],++ii?U[2*n]+=i:0!==n?(n!=r&&U[2*n]++,U[32]++):i>10?U[36]++:U[34]++,i=0,r=n,0===s?(o=138,c=3):n==s?(o=6,c=3):(o=7,c=4))}function J(t){e.Ke[e.pending++]=t}function Q(e){J(255&e),J(e>>>8&255)}function X(e,t){let n;const r=t;F>16-r?(n=e,L|=n<>>16-F,F+=r-16):(L|=e<=n;n++)if(r=i,i=e[2*(n+1)+1],++o>=c||r!=i){if(f>o)do{Y(r,U)}while(0!=--o);else 0!==r?(r!=s&&(Y(r,U),o--),Y(16,U),X(o-3,2)):o>10?(Y(18,U),X(o-11,7)):(Y(17,U),X(o-3,3));o=0,s=r,0===i?(c=138,f=3):r==i?(c=6,f=3):(c=7,f=4)}}function $(){16==F?(Q(L),L=0,F=0):8>F||(J(255&L),L>>>=8,F-=8)}function ee(t,n){let s,i,o;if(e.Ne[W]=t,e.Oe[W]=255&n,W++,0===t?E[2*n]++:(j++,t--,E[2*(He.ge[n]+256+1)]++,M[2*He.Se(t)]++),!(8191&W)&&D>2){for(s=8*W,i=C-k,o=0;30>o;o++)s+=M[2*o]*(5+He.Ce[o]);if(s>>>=3,jc);Y(256,t),H=t[513]}function ne(){F>8?Q(L):F>0&&J(255&L),L=0,F=0}function re(t,n,r){X(0+(r?1:0),3),((t,n)=>{ne(),H=8,Q(n),Q(~n),e.Ke.set(u.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function se(n){((t,n,r)=>{let s,i,o=0;D>0?(K.ne(e),N.ne(e),o=(()=>{let t;for(G(E,K.he),G(M,N.he),O.ne(e),t=18;t>=3&&0===U[2*He.Ae[t]+1];t--);return e.ue+=14+3*(t+1),t})(),s=e.ue+3+7>>>3,i=e.we+3+7>>>3,i>s||(s=i)):s=i=n+5,n+4>s||-1==t?i==s?(X(2+(r?1:0),3),te(Le._e,Le.Be)):(X(4+(r?1:0),3),((e,t,n)=>{let r;for(X(e-257,5),X(t-1,5),X(n-4,4),r=0;n>r;r++)X(U[2*He.Ae[r]+1],3);Z(E,e-1),Z(M,t-1)})(K.he+1,N.he+1,o+1),te(E,M)):re(t,n,r),q(),r&&ne()})(0>k?-1:k,C-k,n),k=C,t.Te()}function ie(){let e,n,r,s;do{if(s=w-A-C,0===s&&0===C&&0===A)s=f;else if(-1==s)s--;else if(C>=f+f-Ze){u.set(u.subarray(f,f+f),0),x-=f,C-=f,k-=f,e=y,r=e;do{n=65535&d[--r],d[r]=f>n?0:n-f}while(0!=--e);e=f,r=e;do{n=65535&h[--r],h[r]=f>n?0:n-f}while(0!=--e);s+=f}if(0===t.We)return;e=t.je(u,C+A,s),A+=e,3>A||(p=255&u[C],p=(p<A&&0!==t.We)}function oe(e){let t,n,r=I,s=C,i=_;const o=C>f-Ze?C-(f-Ze):0;let c=B;const a=l,w=C+258;let d=u[s+i-1],p=u[s+i];R>_||(r>>=2),c>A&&(c=A);do{if(t=e,u[t+i]==p&&u[t+i-1]==d&&u[t]==u[s]&&u[++t]==u[s+1]){s+=2,t++;do{}while(u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&w>s);if(n=258-(w-s),s=w-258,n>i){if(x=e,i=n,n>=c)break;d=u[s+i-1],p=u[s+i]}}}while((e=65535&h[e&a])>o&&0!=--r);return i>A?A:i}e.le=[],e.be=[],e.ae=[],E=[],M=[],U=[],e.de=(t,n)=>{const r=e.ae,s=r[n];let i=n<<1;for(;i<=e.ce&&(i(W||(W=8),j||(j=8),G||(G=0),t.Le=null,-1==S&&(S=6),1>j||j>9||8!=W||9>x||x>15||0>S||S>9||0>G||G>2?Oe:(t.Fe=e,a=x,f=1<(t.qe=t.Ge=0,t.Le=null,e.pending=0,e.Je=0,n=Xe,c=0,K.re=E,K.ie=Le.Ee,N.re=M,N.ie=Le.Me,O.re=U,O.ie=Le.Ue,L=0,F=0,H=8,q(),(()=>{w=2*f,d[y-1]=0;for(let e=0;y-1>e;e++)d[e]=0;P=Je[D].Pe,R=Je[D].Ie,B=Je[D].De,I=Je[D].Ve,C=0,k=0,A=0,v=_=2,z=0,p=0})(),0))(t))),e.Qe=()=>42!=n&&n!=Xe&&n!=Ye?Oe:(e.Oe=null,e.Ne=null,e.Ke=null,d=null,h=null,u=null,e.Fe=null,n==Xe?-3:0),e.Xe=(e,t,n)=>{let r=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?Oe:(Je[D].Re!=Je[t].Re&&0!==e.qe&&(r=e.Ye(1)),D!=t&&(D=t,P=Je[D].Pe,R=Je[D].Ie,B=Je[D].De,I=Je[D].Ve),V=n,r)},e.Ze=(e,t,r)=>{let s,i=r,o=0;if(!t||42!=n)return Oe;if(3>i)return 0;for(i>f-Ze&&(i=f-Ze,o=r-i),u.set(t.subarray(o,o+i),0),C=i,k=i,p=255&u[0],p=(p<=s;s++)p=(p<{let o,w,m,I,R;if(i>4||0>i)return Oe;if(!r.$e||!r.et&&0!==r.We||n==Ye&&4!=i)return r.Le=Qe[4],Oe;if(0===r.tt)return r.Le=Qe[7],-5;var B;if(t=r,I=c,c=i,42==n&&(w=8+(a-8<<4)<<8,m=(D-1&255)>>1,m>3&&(m=3),w|=m<<6,0!==C&&(w|=32),w+=31-w%31,n=Xe,J((B=w)>>8&255),J(255&B)),0!==e.pending){if(t.Te(),0===t.tt)return c=-1,0}else if(0===t.We&&I>=i&&4!=i)return t.Le=Qe[7],-5;if(n==Ye&&0!==t.We)return r.Le=Qe[7],-5;if(0!==t.We||0!==A||0!=i&&n!=Ye){switch(R=-1,Je[D].Re){case 0:R=(e=>{let n,r=65535;for(r>s-5&&(r=s-5);;){if(1>=A){if(ie(),0===A&&0==e)return 0;if(0===A)break}if(C+=A,A=0,n=k+r,(0===C||C>=n)&&(A=C-n,C=n,se(!1),0===t.tt))return 0;if(C-k>=f-Ze&&(se(!1),0===t.tt))return 0}return se(4==e),0===t.tt?4==e?2:0:4==e?3:1})(i);break;case 1:R=(e=>{let n,r=0;for(;;){if(Ze>A){if(ie(),Ze>A&&0==e)return 0;if(0===A)break}if(3>A||(p=(p<f-Ze||2!=V&&(v=oe(r)),3>v)n=ee(0,255&u[C]),A--,C++;else if(n=ee(C-x,v-3),A-=v,v>P||3>A)C+=v,v=0,p=255&u[C],p=(p<{let n,r,s=0;for(;;){if(Ze>A){if(ie(),Ze>A&&0==e)return 0;if(0===A)break}if(3>A||(p=(p<_&&f-Ze>=(C-s&65535)&&(2!=V&&(v=oe(s)),5>=v&&(1==V||3==v&&C-x>4096)&&(v=2)),3>_||v>_)if(0!==z){if(n=ee(0,255&u[C-1]),n&&se(!1),C++,A--,0===t.tt)return 0}else z=1,C++,A--;else{r=C+A-3,n=ee(C-1-S,_-3),A-=_-1,_-=2;do{++C>r||(p=(p<1+H+10-F&&(X(2,3),Y(256,Le._e),$()),H=7;else if(re(0,0,!1),3==i)for(o=0;y>o;o++)d[o]=0;if(t.Te(),0===t.tt)return c=-1,0}}return 4!=i?0:1}}function tt(){const e=this;e.nt=0,e.rt=0,e.We=0,e.qe=0,e.tt=0,e.Ge=0}function nt(e){const t=new tt,n=(o=e&&e.chunkSize?e.chunkSize:65536)+5*(r.floor(o/16383)+1);var o;const c=new i(n);let f=e?e.level:-1;void 0===f&&(f=-1),t.He(f),t.$e=c,this.append=(e,r)=>{let o,f,a=0,l=0,u=0;const w=[];if(e.length){t.nt=0,t.et=e,t.We=e.length;do{if(t.rt=0,t.tt=n,o=t.Ye(0),0!=o)throw new s("deflating: "+t.Le);t.rt&&(t.rt==n?w.push(new i(c)):w.push(c.subarray(0,t.rt))),u+=t.rt,r&&t.nt>0&&t.nt!=a&&(r(t.nt),a=t.nt)}while(t.We>0||0===t.tt);return w.length>1?(f=new i(u),w.forEach((e=>{f.set(e,l),l+=e.length}))):f=w[0]?new i(w[0]):new i,f}},this.flush=()=>{let e,r,o=0,f=0;const a=[];do{if(t.rt=0,t.tt=n,e=t.Ye(4),1!=e&&0!=e)throw new s("deflating: "+t.Le);n-t.tt>0&&a.push(c.slice(0,t.rt)),f+=t.rt}while(t.We>0||0===t.tt);return t.Qe(),r=new i(f),a.forEach((e=>{r.set(e,o),o+=e.length})),r}}tt.prototype={He(e,t){const n=this;return n.Fe=new et,t||(t=15),n.Fe.He(n,e,t)},Ye(e){const t=this;return t.Fe?t.Fe.Ye(t,e):Oe},Qe(){const e=this;if(!e.Fe)return Oe;const t=e.Fe.Qe();return e.Fe=null,t},Xe(e,t){const n=this;return n.Fe?n.Fe.Xe(n,e,t):Oe},Ze(e,t){const n=this;return n.Fe?n.Fe.Ze(n,e,t):Oe},je(e,t,n){const r=this;let s=r.We;return s>n&&(s=n),0===s?0:(r.We-=s,e.set(r.et.subarray(r.nt,r.nt+s),t),r.nt+=s,r.qe+=s,s)},Te(){const e=this;let t=e.Fe.pending;t>e.tt&&(t=e.tt),0!==t&&(e.$e.set(e.Fe.Ke.subarray(e.Fe.Je,e.Fe.Je+t),e.rt),e.rt+=t,e.Fe.Je+=t,e.Ge+=t,e.tt-=t,e.Fe.pending-=t,0===e.Fe.pending&&(e.Fe.Je=0))}};const rt=-2,st=-3,it=-5,ot=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],ct=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],ft=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],at=[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],lt=[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,112,112],ut=[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],wt=[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];function ht(){let e,t,n,r,s,i;function o(e,t,o,c,f,a,l,u,w,h,d){let p,y,m,b,g,k,v,S,z,C,x,A,_,I,P;C=0,g=o;do{n[e[t+C]]++,C++,g--}while(0!==g);if(n[0]==o)return l[0]=-1,u[0]=0,0;for(S=u[0],k=1;15>=k&&0===n[k];k++);for(v=k,k>S&&(S=k),g=15;0!==g&&0===n[g];g--);for(m=g,S>g&&(S=g),u[0]=S,I=1<k;k++,I<<=1)if(0>(I-=n[k]))return st;if(0>(I-=n[g]))return st;for(n[g]+=I,i[1]=k=0,C=1,_=2;0!=--g;)i[_]=k+=n[C],_++,C++;g=0,C=0;do{0!==(k=e[t+C])&&(d[i[k]++]=g),C++}while(++g=v;v++)for(p=n[v];0!=p--;){for(;v>A+S;){if(b++,A+=S,P=m-A,P=P>S?S:P,(y=1<<(k=v-A))>p+1&&(y-=p+1,_=v,P>k))for(;++kn[++_];)y-=n[_];if(P=1<1440)return st;s[b]=x=h[0],h[0]+=P,0!==b?(i[b]=g,r[0]=k,r[1]=S,k=g>>>A-S,r[2]=x-s[b-1]-k,w.set(r,3*(s[b-1]+k))):l[0]=x}for(r[1]=v-A,o>C?d[C]d[C]?0:96,r[2]=d[C++]):(r[0]=a[d[C]-c]+16+64,r[2]=f[d[C++]-c]):r[0]=192,y=1<>>A;P>k;k+=y)w.set(r,3*(x+k));for(k=1<>>=1)g^=k;for(g^=k,z=(1<c;c++)t[c]=0;for(c=0;16>c;c++)n[c]=0;for(c=0;3>c;c++)r[c]=0;s.set(n.subarray(0,15),0),i.set(n.subarray(0,16),0)}this.st=(n,r,s,i,f)=>{let a;return c(19),e[0]=0,a=o(n,0,19,19,null,null,s,r,i,e,t),a==st?f.Le="oversubscribed dynamic bit lengths tree":a!=it&&0!==r[0]||(f.Le="incomplete dynamic bit lengths tree",a=st),a},this.it=(n,r,s,i,f,a,l,u,w)=>{let h;return c(288),e[0]=0,h=o(s,0,n,257,at,lt,a,i,u,e,t),0!=h||0===i[0]?(h==st?w.Le="oversubscribed literal/length tree":-4!=h&&(w.Le="incomplete literal/length tree",h=st),h):(c(288),h=o(s,n,r,0,ut,wt,l,f,u,e,t),0!=h||0===f[0]&&n>257?(h==st?w.Le="oversubscribed distance tree":h==it?(w.Le="incomplete distance tree",h=st):-4!=h&&(w.Le="empty distance tree with lengths",h=st),h):0)}}function dt(){const e=this;let t,n,r,s,i=0,o=0,c=0,f=0,a=0,l=0,u=0,w=0,h=0,d=0;function p(e,t,n,r,s,i,o,c){let f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,z;d=c.nt,p=c.We,w=o.ot,h=o.ct,y=o.write,m=yh;)p--,w|=(255&c.ft(d++))<>=a[z+1],h-=a[z+1],16&u){for(u&=15,k=a[z+2]+(w&ot[u]),w>>=u,h-=u;15>h;)p--,w|=(255&c.ft(d++))<>=a[z+1],h-=a[z+1],16&u){for(u&=15;u>h;)p--,w|=(255&c.ft(d++))<>=u,h-=u,m-=k,v>y){S=y-v;do{S+=o.end}while(0>S);if(u=o.end-S,k>u){if(k-=u,y-S>0&&u>y-S)do{o.lt[y++]=o.lt[S++]}while(0!=--u);else o.lt.set(o.lt.subarray(S,S+u),y),y+=u,S+=u,u=0;S=0}}else S=y-v,y-S>0&&2>y-S?(o.lt[y++]=o.lt[S++],o.lt[y++]=o.lt[S++],k-=2):(o.lt.set(o.lt.subarray(S,S+2),y),y+=2,S+=2,k-=2);if(y-S>0&&k>y-S)do{o.lt[y++]=o.lt[S++]}while(0!=--k);else o.lt.set(o.lt.subarray(S,S+k),y),y+=k,S+=k,k=0;break}if(64&u)return c.Le="invalid distance code",k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,st;f+=a[z+2],f+=w&ot[u],z=3*(l+f),u=a[z]}break}if(64&u)return 32&u?(k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,1):(c.Le="invalid literal/length code",k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,st);if(f+=a[z+2],f+=w&ot[u],z=3*(l+f),0===(u=a[z])){w>>=a[z+1],h-=a[z+1],o.lt[y++]=a[z+2],m--;break}}else w>>=a[z+1],h-=a[z+1],o.lt[y++]=a[z+2],m--}while(m>=258&&p>=10);return k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,0}e.init=(e,i,o,c,f,a)=>{t=0,u=e,w=i,r=o,h=c,s=f,d=a,n=null},e.ut=(e,y,m)=>{let b,g,k,v,S,z,C,x=0,A=0,_=0;for(_=y.nt,v=y.We,x=e.ot,A=e.ct,S=e.write,z=S=258&&v>=10&&(e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,m=p(u,w,r,h,s,d,e,y),_=y.nt,v=y.We,x=e.ot,A=e.ct,S=e.write,z=SA;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>>=n[g+1],A-=n[g+1],k=n[g],0===k){f=n[g+2],t=6;break}if(16&k){a=15&k,i=n[g+2],t=2;break}if(!(64&k)){c=k,o=g/3+n[g+2];break}if(32&k){t=7;break}return t=9,y.Le="invalid literal/length code",m=st,e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);case 2:for(b=a;b>A;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>=b,A-=b,c=w,n=s,o=d,t=3;case 3:for(b=c;b>A;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>=n[g+1],A-=n[g+1],k=n[g],16&k){a=15&k,l=n[g+2],t=4;break}if(!(64&k)){c=k,o=g/3+n[g+2];break}return t=9,y.Le="invalid distance code",m=st,e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);case 4:for(b=a;b>A;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>=b,A-=b,t=5;case 5:for(C=S-l;0>C;)C+=e.end;for(;0!==i;){if(0===z&&(S==e.end&&0!==e.read&&(S=0,z=S7&&(A-=8,v++,_--),e.write=S,m=e.wt(y,m),S=e.write,z=S{}}ht.dt=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=ct,r[0]=ft,0);const pt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function yt(e,t){const n=this;let r,s=0,o=0,c=0,a=0;const l=[0],u=[0],w=new dt;let h=0,d=new f(4320);const p=new ht;n.ct=0,n.ot=0,n.lt=new i(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==s&&w.ht(e),s=0,n.ct=0,n.ot=0,n.read=n.write=0},n.reset(e,null),n.wt=(e,t)=>{let r,s,i;return s=e.rt,i=n.read,r=(i>n.write?n.end:n.write)-i,r>e.tt&&(r=e.tt),0!==r&&t==it&&(t=0),e.tt-=r,e.Ge+=r,e.$e.set(n.lt.subarray(i,i+r),s),s+=r,i+=r,i==n.end&&(i=0,n.write==n.end&&(n.write=0),r=n.write-i,r>e.tt&&(r=e.tt),0!==r&&t==it&&(t=0),e.tt-=r,e.Ge+=r,e.$e.set(n.lt.subarray(i,i+r),s),s+=r,i+=r),e.rt=s,n.read=i,t},n.ut=(e,t)=>{let i,f,y,m,b,g,k,v;for(m=e.nt,b=e.We,f=n.ot,y=n.ct,g=n.write,k=gy;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>1){case 0:f>>>=3,y-=3,i=7&y,f>>>=i,y-=i,s=1;break;case 1:S=[],z=[],C=[[]],x=[[]],ht.dt(S,z,C,x),w.init(S[0],z[0],C[0],0,x[0],0),f>>>=3,y-=3,s=6;break;case 2:f>>>=3,y-=3,s=3;break;case 3:return f>>>=3,y-=3,s=9,e.Le="invalid block type",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t)}break;case 1:for(;32>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>16&65535)!=(65535&f))return s=9,e.Le="invalid stored block lengths",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);o=65535&f,f=y=0,s=0!==o?2:0!==h?7:0;break;case 2:if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);if(0===k&&(g==n.end&&0!==n.read&&(g=0,k=gb&&(i=b),i>k&&(i=k),n.lt.set(e.je(m,i),g),m+=i,b-=i,g+=i,k-=i,0!=(o-=i))break;s=0!==h?7:0;break;case 3:for(;14>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<29||(i>>5&31)>29)return s=9,e.Le="too many length or distance symbols",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);if(i=258+(31&i)+(i>>5&31),!r||r.lengthv;v++)r[v]=0;f>>>=14,y-=14,a=0,s=4;case 4:for(;4+(c>>>10)>a;){for(;3>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>=3,y-=3}for(;19>a;)r[pt[a++]]=0;if(l[0]=7,i=p.st(r,l,u,d,e),0!=i)return(t=i)==st&&(r=null,s=9),n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);a=0,s=5;case 5:for(;i=c,258+(31&i)+(i>>5&31)>a;){let o,w;for(i=l[0];i>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<w)f>>>=i,y-=i,r[a++]=w;else{for(v=18==w?7:w-14,o=18==w?11:3;i+v>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>=i,y-=i,o+=f&ot[v],f>>>=v,y-=v,v=a,i=c,v+o>258+(31&i)+(i>>5&31)||16==w&&1>v)return r=null,s=9,e.Le="invalid bit length repeat",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);w=16==w?r[v-1]:0;do{r[v++]=w}while(0!=--o);a=v}}if(u[0]=-1,A=[],_=[],I=[],P=[],A[0]=9,_[0]=6,i=c,i=p.it(257+(31&i),1+(i>>5&31),r,A,_,I,P,d,e),0!=i)return i==st&&(r=null,s=9),t=i,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);w.init(A[0],_[0],d,I[0],d,P[0]),s=6;case 6:if(n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,1!=(t=w.ut(n,e,t)))return n.wt(e,t);if(t=0,w.ht(e),m=e.nt,b=e.We,f=n.ot,y=n.ct,g=n.write,k=g{n.reset(e,null),n.lt=null,d=null},n.yt=(e,t,r)=>{n.lt.set(e.subarray(t,t+r),0),n.read=n.write=r},n.bt=()=>1==s?1:0}const mt=13,bt=[0,0,255,255];function gt(){const e=this;function t(e){return e&&e.gt?(e.qe=e.Ge=0,e.Le=null,e.gt.mode=7,e.gt.kt.reset(e,null),0):rt}e.mode=0,e.method=0,e.vt=[0],e.St=0,e.marker=0,e.zt=0,e.Ct=t=>(e.kt&&e.kt.ht(t),e.kt=null,0),e.xt=(n,r)=>(n.Le=null,e.kt=null,8>r||r>15?(e.Ct(n),rt):(e.zt=r,n.gt.kt=new yt(n,1<{let n,r;if(!e||!e.gt||!e.et)return rt;const s=e.gt;for(t=4==t?it:0,n=it;;)switch(s.mode){case 0:if(0===e.We)return n;if(n=t,e.We--,e.qe++,8!=(15&(s.method=e.ft(e.nt++)))){s.mode=mt,e.Le="unknown compression method",s.marker=5;break}if(8+(s.method>>4)>s.zt){s.mode=mt,e.Le="invalid win size",s.marker=5;break}s.mode=1;case 1:if(0===e.We)return n;if(n=t,e.We--,e.qe++,r=255&e.ft(e.nt++),((s.method<<8)+r)%31!=0){s.mode=mt,e.Le="incorrect header check",s.marker=5;break}if(!(32&r)){s.mode=7;break}s.mode=2;case 2:if(0===e.We)return n;n=t,e.We--,e.qe++,s.St=(255&e.ft(e.nt++))<<24&4278190080,s.mode=3;case 3:if(0===e.We)return n;n=t,e.We--,e.qe++,s.St+=(255&e.ft(e.nt++))<<16&16711680,s.mode=4;case 4:if(0===e.We)return n;n=t,e.We--,e.qe++,s.St+=(255&e.ft(e.nt++))<<8&65280,s.mode=5;case 5:return 0===e.We?n:(n=t,e.We--,e.qe++,s.St+=255&e.ft(e.nt++),s.mode=6,2);case 6:return s.mode=mt,e.Le="need dictionary",s.marker=0,rt;case 7:if(n=s.kt.ut(e,n),n==st){s.mode=mt,s.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,s.kt.reset(e,s.vt),s.mode=12;case 12:return e.We=0,1;case mt:return st;default:return rt}},e._t=(e,t,n)=>{let r=0,s=n;if(!e||!e.gt||6!=e.gt.mode)return rt;const i=e.gt;return s<1<{let n,r,s,i,o;if(!e||!e.gt)return rt;const c=e.gt;if(c.mode!=mt&&(c.mode=mt,c.marker=0),0===(n=e.We))return it;for(r=e.nt,s=c.marker;0!==n&&4>s;)e.ft(r)==bt[s]?s++:s=0!==e.ft(r)?0:4-s,r++,n--;return e.qe+=r-e.nt,e.nt=r,e.We=n,c.marker=s,4!=s?st:(i=e.qe,o=e.Ge,t(e),e.qe=i,e.Ge=o,c.mode=7,0)},e.Pt=e=>e&&e.gt&&e.gt.kt?e.gt.kt.bt():rt}function kt(){}function vt(e){const t=new kt,n=e&&e.chunkSize?r.floor(2*e.chunkSize):131072,o=new i(n);let c=!1;t.xt(),t.$e=o,this.append=(e,r)=>{const f=[];let a,l,u=0,w=0,h=0;if(0!==e.length){t.nt=0,t.et=e,t.We=e.length;do{if(t.rt=0,t.tt=n,0!==t.We||c||(t.nt=0,c=!0),a=t.At(0),c&&a===it){if(0!==t.We)throw new s("inflating: bad input")}else if(0!==a&&1!==a)throw new s("inflating: "+t.Le);if((c||1===a)&&t.We===e.length)throw new s("inflating: bad input");t.rt&&(t.rt===n?f.push(new i(o)):f.push(o.subarray(0,t.rt))),h+=t.rt,r&&t.nt>0&&t.nt!=u&&(r(t.nt),u=t.nt)}while(t.We>0||0===t.tt);return f.length>1?(l=new i(h),f.forEach((e=>{l.set(e,w),w+=e.length}))):l=f[0]?new i(f[0]):new i,l}},this.flush=()=>{t.Ct()}}kt.prototype={xt(e){const t=this;return t.gt=new gt,e||(e=15),t.gt.xt(t,e)},At(e){const t=this;return t.gt?t.gt.At(t,e):rt},Ct(){const e=this;if(!e.gt)return rt;const t=e.gt.Ct(e);return e.gt=null,t},It(){const e=this;return e.gt?e.gt.It(e):rt},_t(e,t){const n=this;return n.gt?n.gt._t(n,e,t):rt},ft(e){return this.et[e]},je(e,t){return this.et.subarray(e,e+t)}},self.initCodec=()=>{self.Deflate=nt,self.Inflate=vt};\n',r=()=>t.useDataURI?"data:text/javascript,"+encodeURIComponent(n):f.createObjectURL(new _([n],{type:"text/javascript"}));e({workerScripts:{inflate:[r],deflate:[r]}})})(Ne),Ne({Deflate:function(e){const t=new X,n=(r=e&&e.chunkSize?e.chunkSize:65536)+5*(a.floor(r/16383)+1);var r;const i=new w(n);let s=e?e.level:-1;void 0===s&&(s=-1),t.deflateInit(s),t.next_out=i,this.append=(e,r)=>{let s,a,o=0,l=0,c=0;const u=[];if(e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,s=t.deflate(0),0!=s)throw new d("deflating: "+t.msg);t.next_out_index&&(t.next_out_index==n?u.push(new w(i)):u.push(i.subarray(0,t.next_out_index))),c+=t.next_out_index,r&&t.next_in_index>0&&t.next_in_index!=o&&(r(t.next_in_index),o=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return u.length>1?(a=new w(c),u.forEach((e=>{a.set(e,l),l+=e.length}))):a=u[0]?new w(u[0]):new w,a}},this.flush=()=>{let e,r,s=0,a=0;const o=[];do{if(t.next_out_index=0,t.avail_out=n,e=t.deflate(4),1!=e&&0!=e)throw new d("deflating: "+t.msg);n-t.avail_out>0&&o.push(i.slice(0,t.next_out_index)),a+=t.next_out_index}while(t.avail_in>0||0===t.avail_out);return t.deflateEnd(),r=new w(a),o.forEach((e=>{r.set(e,s),s+=e.length})),r}},Inflate:function(e){const t=new de,n=e&&e.chunkSize?a.floor(2*e.chunkSize):131072,r=new w(n);let i=!1;t.inflateInit(),t.next_out=r,this.append=(e,s)=>{const a=[];let o,l,c=0,u=0,f=0;if(0!==e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,0!==t.avail_in||i||(t.next_in_index=0,i=!0),o=t.inflate(0),i&&o===J){if(0!==t.avail_in)throw new d("inflating: bad input")}else if(0!==o&&1!==o)throw new d("inflating: "+t.msg);if((i||1===o)&&t.avail_in===e.length)throw new d("inflating: bad input");t.next_out_index&&(t.next_out_index===n?a.push(new w(r)):a.push(r.subarray(0,t.next_out_index))),f+=t.next_out_index,s&&t.next_in_index>0&&t.next_in_index!=c&&(s(t.next_in_index),c=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return a.length>1?(l=new w(f),a.forEach((e=>{l.set(e,u),u+=e.length}))):l=a[0]?new w(a[0]):new w,l}},this.flush=()=>{t.inflateEnd()}},baseURL:_i}),e.BlobReader=xn,e.BlobWriter=kn,e.Data64URIReader=class extends bn{constructor(e){super();let t=e.length;for(;"="==e.charAt(t-1);)t--;const r=e.indexOf(",")+1;n.assign(this,{dataURI:e,dataStart:r,size:a.floor(.75*(t-r))})}readUint8Array(e,t){const{dataStart:n,dataURI:r}=this,i=new w(t),s=4*a.floor(e/3),o=atob(r.substring(s+n,4*a.ceil((e+t)/3)+n)),l=e-3*a.floor(s/4);for(let e=l;l+t>e;e++)i[e-l]=o.charCodeAt(e);return i}},e.Data64URIWriter=class extends yn{constructor(e){super(),n.assign(this,{data:"data:"+(e||"")+";base64,",pending:[]})}writeUint8Array(e){const t=this;let n=0,i=t.pending;const s=t.pending.length;for(t.pending="",n=0;n<3*a.floor((s+e.length)/3)-s;n++)i+=r.fromCharCode(e[n]);for(;n2?t.data+=S(i):t.pending=i}getData(){return this.data+S(this.pending)}},e.ERR_BAD_FORMAT=br,e.ERR_CENTRAL_DIRECTORY_NOT_FOUND=kr,e.ERR_DUPLICATED_NAME=Kr,e.ERR_ENCRYPTED=zr,e.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=xr,e.ERR_EOCDR_NOT_FOUND=yr,e.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=vr,e.ERR_HTTP_RANGE=fn,e.ERR_INVALID_COMMENT=Gr,e.ERR_INVALID_ENCRYPTION_STRENGTH=Jr,e.ERR_INVALID_ENTRY_COMMENT=Xr,e.ERR_INVALID_ENTRY_NAME=Yr,e.ERR_INVALID_EXTRAFIELD_DATA=$r,e.ERR_INVALID_EXTRAFIELD_TYPE=Qr,e.ERR_INVALID_PASSWORD=je,e.ERR_INVALID_SIGNATURE=Je,e.ERR_INVALID_VERSION=jr,e.ERR_ITERATOR_COMPLETED_TOO_SOON=dn,e.ERR_LOCAL_FILE_HEADER_NOT_FOUND=Sr,e.ERR_SPLIT_ZIP_FILE=Dr,e.ERR_UNDEFINED_UNCOMPRESSED_SIZE=ti,e.ERR_UNSUPPORTED_COMPRESSION=Cr,e.ERR_UNSUPPORTED_ENCRYPTION=Ar,e.ERR_UNSUPPORTED_FORMAT=ei,e.HttpRangeReader=class extends In{constructor(e,t={}){t.useRangeHeader=!0,super(e,t)}},e.HttpReader=In,e.Reader=bn,e.SplitDataReader=Nn,e.SplitDataWriter=qn,e.SplitZipReader=Bn,e.SplitZipWriter=Vn,e.TextReader=class extends xn{constructor(e){super(new _([e],{type:"text/plain"}))}},e.TextWriter=class extends kn{constructor(e){super(e),n.assign(this,{encoding:e,utf8:!e||"utf-8"==e.toLowerCase()})}async getData(){const{encoding:e,utf8:t}=this,r=await super.getData();if(r.text&&t)return r.text();{const t=new FileReader;return new m(((i,s)=>{n.assign(t,{onload:({target:e})=>i(e.result),onerror:()=>s(t.error)}),t.readAsText(r,e)}))}}},e.Uint8ArrayReader=class extends bn{constructor(e){super(),n.assign(this,{array:e,size:e.length})}readUint8Array(e,t){return this.array.slice(e,e+t)}},e.Uint8ArrayWriter=class extends yn{init(e=0){n.assign(this,{offset:0,array:new w(e)}),super.init()}writeUint8Array(e){const t=this;if(t.offset+e.length>t.array.length){const n=t.array;t.array=new w(n.length+e.length),t.array.set(n)}t.array.set(e,t.offset),t.offset+=e.length}getData(){return this.array}},e.Writer=yn,e.ZipReader=Tr,e.ZipReaderStream=class{constructor(e={}){const{readable:t,writable:n}=new v,r=new Tr(t,e).getEntriesGenerator();this.readable=new z({async pull(e){const{done:t,value:n}=await r.next();if(t)return e.close();const i={...n,readable:(()=>{const{readable:e,writable:t}=new v;if(n.getData)return n.getData(t),e})()};delete i.getData,e.enqueue(i)}}),this.writable=n}},e.ZipWriter=si,e.ZipWriterStream=class{constructor(e={}){const{readable:t,writable:n}=new v;this.readable=t,this.zipWriter=new si(n,e)}transform(e){const{readable:t,writable:n}=new v({flush:()=>{this.zipWriter.close()}});return this.zipWriter.add(e,t),{readable:this.readable,writable:n}}writable(e){const{readable:t,writable:n}=new v;return this.zipWriter.add(e,t),n}close(e,t={}){return this.zipWriter.close(e,t)}},e.configure=Ne,e.getMimeType=()=>"application/octet-stream",e.initReader=Pn,e.initShimAsyncCodec=(e,t={},n)=>({Deflate:Oe(e.Deflate,t.deflate,n),Inflate:Oe(e.Inflate,t.inflate,n)}),e.initStream=On,e.initWriter=Hn,e.readUint8Array=Mn,e.terminateWorkers=async()=>{await m.allSettled(sn.map((e=>(cn(e),e.terminate()))))}})); diff --git a/pkg/emscripten/libretro-thread/libretro.css b/pkg/emscripten/libretro-thread/libretro.css index be5ad14f30..cf08d09936 100644 --- a/pkg/emscripten/libretro-thread/libretro.css +++ b/pkg/emscripten/libretro-thread/libretro.css @@ -4,94 +4,103 @@ * This provides the basic styling for the RetroArch web player. */ -/** - * Make sure the background of the player is black. - * Also make sure line height is 0 so there's no extra space on the bottom. - */ -.webplayer-container { - background-color: black; - line-height: 0; -} +@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&display=swap"); -/** - * Webplayer Preview when not loaded. - */ -.webplayer-preview { - margin: 0 auto; - cursor: wait; - opacity: 0.2; - transition: all 0.8s; - -webkit-animation: loading 0.8s ease-in-out infinite alternate; - -moz-animation: loading 0.8s ease-in-out infinite alternate; - animation: loading 0.8s ease-in-out infinite alternate; -} -.webplayer-preview.loaded { - cursor: pointer; - opacity: 1; - -webkit-animation: loaded 0.8s ease-in-out; - -moz-animation: loaded 0.8s ease-in-out; - animation: loaded 0.8s ease-in-out; -} @keyframes loaded { - from { - opacity: 0.2; - } - to { - opacity: 1; - } -} -@-moz-keyframes loaded { - from { - opacity: 0.2; - } - to { - opacity: 1; - } -} -@-webkit-keyframes loaded { - from { - opacity: 0.2; - } - to { - opacity: 1; - } -} -@keyframes loading{ - from { - opacity: 0.2; - } - to { - opacity: 0.35; - } -} -@-moz-keyframes loading{ - from { - opacity: 0.2; - } - to { - opacity: 0.35; - } -} -@-webkit-keyframes loading { - from { - opacity: 0.2; - } - to { - opacity: 0.35; - } + from { + opacity: 0.2; + } + to { + opacity: 1; + } } -canvas.webplayer { - border: none; - outline: none; - width: 800px; - height: 600px; +@keyframes loading { + from { + opacity: 0.2; + } + to { + opacity: 0.35; + } } -#canvas_div { - width: 100%; - height: 100%; - position: absolute; +/* real ozone */ +@keyframes hover { + from { + box-shadow: 0px 0px 1px 1px #198AC6, inset 0px 0px 1px 1px #198AC6; + } + to { + box-shadow: 0px 0px 1px 1px #89F1F2, inset 0px 0px 1px 1px #89F1F2; + } +} + +@keyframes hover-danger { + from { + box-shadow: 0px 0px 1px 1px #C7261A, inset 0px 0px 1px 1px #C7261A; + } + to { + box-shadow: 0px 0px 1px 1px #F75C4A, inset 0px 0px 1px 1px #F75C4A; + } +} + +body { + margin: 0px; + background-color: black; + font-family: "Inter", sans-serif; + font-variant-ligatures: no-contextual; + scrollbar-color: #505050 #2e2e2e; + + --menuheight: 65px; + --menumarginy: 14px; + --menumarginx: 7px; + --menupaddingy: 8px; + --menupaddingx: 16px; + --submarginy: 0px; + --submarginx: 0px; + --subpaddingy: 5px; + --subpaddingx: 8px; + --rounding: 1px; + --barcolor: #2e2e2e; + --subcolor: #282828; + --barbuttoncolor: var(--barcolor); + --barbuttonhovercolor: #212227; + --barbuttonoutline: 1px; + --barbuttonoutlinecolor: #51514f; + --barfontcolor: #ffffff; + --bardisabledfontcolor: #b6b6b6; + + /* do not modify */ + --actualmenuheight: var(--menuheight); + --menubuttonbordery: calc(var(--menuheight) - calc(var(--menumarginy) * 2)); + --menubuttoncontenty: calc(var(--menubuttonbordery) - calc(var(--menupaddingy) * 2)); +} + +canvas.webplayer, #webplayer-preview { + display: block; + position: fixed; + top: var(--actualmenuheight); + width: 100vw; + height: calc(100vh - var(--actualmenuheight)); + outline: none; + z-index: 4; +} + +#webplayer-preview { + background-image: url(media/canvas.png); + background-size: contain; + background-repeat: no-repeat; + background-position: center; + cursor: wait; + opacity: 0.2; + transition: opacity 0.8s; + animation: loading 0.8s ease-in-out infinite alternate; + z-index: 5; +} + +#webplayer-preview.loaded { + cursor: pointer; + opacity: 1; + animation: loaded 0.8s ease-in-out; } /** @@ -99,38 +108,310 @@ canvas.webplayer { * Foiled again! */ :fullscreen canvas.webplayer { - min-width: 100vw; - max-width: 100vw; - min-height: 100vh; - max-height: 100vh; + top: 0px; + min-width: 100vw; + max-width: 100vw; + min-height: 100vh; + max-height: 100vh; } -textarea { - font-family: monospace; - font-size: 0.7em; - height: 95%; - width: 95%; - border-style: none; - border-color: transparent; - overflow: auto; - resize: none; +a { + color: #3ec3f0; } -/** - * Toggle Top Navigation - */ -.toggleMenu { - float: right; -} -.showMenu { - position: absolute; - right: 0; - cursor: pointer; -} -#icnShowMenu { - color: #565656 !important; +/* menu bar */ + +#navbar { + position: fixed; + width: 100vw; + height: var(--actualmenuheight); + background-color: var(--barcolor); + color: var(--barfontcolor); + z-index: 20; + user-select: none; } -.navbar { - box-shadow: none; +#menu { + float: left; + list-style: none; + margin: 0px; + width: max-content; + height: 100%; + padding: 0px var(--menumarginx); +} + +.progressContainer { + width: 100%; + float: left; +} + +.progressBar { + width: 100%; + height: 0px; + --progressbarpercent: 0%; + --progressbarcolor: #1fb01a; +} + +.progressBar::after { + content: ""; + display: block; + width: var(--progressbarpercent); + height: 100%; + transition: width 0.2s ease-out; + background-color: var(--progressbarcolor); +} + +.progressText { + padding: 0px 4px; +} + +#menu li { + white-space: nowrap; + max-width: 500px; + position: relative; + outline: none; +} + +#menu>li { + margin: var(--menumarginy) var(--menumarginx); + display: inline-block; + float: left; + height: var(--menubuttoncontenty); + line-height: var(--menubuttoncontenty); + border-radius: var(--rounding); + background-color: var(--barbuttoncolor); + outline: var(--barbuttonoutline) solid var(--barbuttonoutlinecolor); + font-size: 12pt; +} + +.dropdown-parent { + height: var(--menubuttonbordery) !important; +} + +.dropdown-parent>label { + display: inline-block; +} + +#menu>li:not(.dropdown-parent), +.dropdown-parent>label { + padding: var(--menupaddingy) var(--menupaddingx); +} + +label { + cursor: inherit; +} + +.ozone-list { + background-color: var(--subcolor); + width: max-content; + padding: 1px; +} + +.dropdown-child { + position: absolute; + overflow: hidden auto; + max-height: calc(100vh - var(--actualmenuheight)); + display: none; + top: calc(100% + 1px); + left: 0px; + border-radius: var(--rounding); + box-sizing: border-box; + z-index: 1; +} + +#fileManagerPanel { + margin: auto; + margin-top: 10px; +} + +.ozone-list>* { + display: block; + border-radius: var(--rounding); + text-decoration: none; + color: inherit; + margin: var(--submarginy) var(--submarginx); + padding: 8px 12px; + line-height: initial; + font-size: 10pt; + outline: none; + user-select: none; +} + +.dropdown-child>* { + padding: var(--subpaddingy) var(--subpaddingx); +} + +.ozone-list>*:not(:last-child) { + box-shadow: 0px 2px 0px -1px var(--barbuttonoutlinecolor); +} + +#menu>li:not(.disabled), +.ozone-list>*:not(.disabled) { + cursor: pointer; +} + +#menu .disabled, +.ozone-list .disabled { + cursor: not-allowed !important; + color: var(--bardisabledfontcolor); +} + +#menu>li:not(.disabled):not(.dropdown-parent:has(.dropdown-child:hover)):hover, +.ozone-list>*:hover, +.ozone-list>*:focus, +#menuhider:not(:checked) ~ .menuhiderlabel:hover { + background-color: var(--barbuttonhovercolor); + outline: none; + animation: hover 0.5s ease-in-out infinite alternate; +} + +.ozone-list>.danger:hover, +.ozone-list>.danger:focus { + animation: hover-danger 0.5s ease-in-out infinite alternate; +} + +/* hide/show the menu */ + +.menuhiderlabel { + position: absolute; + top: 0px; + right: 0px; + width: 45px; + height: 45px; + cursor: pointer; + z-index: 1; +} + +#menuhider:not(:checked) ~ .menuhiderlabel { + margin: var(--menumarginy) 0px; + margin-right: calc(var(--menumarginx) * 2); + width: var(--menubuttonbordery) !important; + height: var(--menubuttonbordery) !important; + border-radius: var(--rounding); + background-color: var(--barbuttoncolor); + outline: var(--barbuttonoutline) solid var(--barbuttonoutlinecolor); +} + +.menuhiderlabel span { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + transition: transform 0.2s ease; +} + +#menuhider:checked ~ .menuhiderlabel span { + transform: translate(-50%, -50%) scaleY(-1); + color: #dfdfdf !important; +} + +#menuhider:checked ~ .menuhiderlabel:hover { + background-color: rgba(0, 0, 0, 0.1) !important; +} + +.hide, +#dropdown-box, +#menuhider, +#menuhider:checked ~ #menu { + display: none !important; +} + +#dropdown-box:checked ~ .dropdown-child { + display: block; +} + +/* modals */ + +#modals { + display: none; + background-color: rgba(0, 0, 0, 0.4); + backdrop-filter: blur(6px); + position: fixed; + width: 100vw; + height: 100vh; + z-index: 30; +} + +#modal-window { + background-color: var(--barcolor); + color: var(--barfontcolor); + position: fixed; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + max-height: calc(100vh - 40px); + max-width: calc(100vw - 40px); + width: 750px; + overflow: hidden; +} + +.modal-header { + height: 50px; + line-height: 30px; +} + +.modal-header .progressContainer { + position: absolute; + top: 50px; +} + +.modal-header .progressText { + white-space: nowrap; + font-size: 10pt; +} + +#modal-title { + display: inline-block; + margin: 10px; +} + +#modal-close { + float: right; + width: 30px; + text-align: center; + cursor: pointer; + font-size: 24px; + margin: 10px; +} + +.modal-body { + display: none; + width: calc(100% - 40px); + max-height: calc(100vh - 135px); + padding: 20px; + padding-top: 0px; + margin-top: 25px; + overflow: auto; +} + +.modal-body>*:first-child { + margin-top: 0px; +} + +/* mobile */ + +@media only screen and (max-width: 720px) { + body { + --subpaddingy: 8px; + } + + #menu { + width: calc(100% - calc(var(--menumarginx) * 2)); + height: max-content; + padding-bottom: var(--menumarginy); + background-color: var(--barcolor); + } + + #menu>li { + margin-bottom: 0px; + } + + .dropdown-child { + max-width: calc(100vw - calc(var(--menumarginx) * 4)); + width: max-content; + } + + .dropdown-child a { + white-space: normal; + } } diff --git a/pkg/emscripten/libretro-thread/libretro.js b/pkg/emscripten/libretro-thread/libretro.js index 4c42933f8e..e1ec07ebb1 100644 --- a/pkg/emscripten/libretro-thread/libretro.js +++ b/pkg/emscripten/libretro-thread/libretro.js @@ -4,237 +4,416 @@ * This provides the basic JavaScript for the RetroArch web player. */ -var filesystem_ready = false; -var retroarch_ready = false; -var setImmediate; +const canvas = document.getElementById("canvas"); +const webplayerPreview = document.getElementById("webplayer-preview"); +const menuBar = document.getElementById("navbar"); +const menuHider = document.getElementById("menuhider"); +const coreSelector = document.getElementById("core-selector"); +const coreSelectorCurrent = document.getElementById("current-core"); +const dropdownBox = document.getElementById("dropdown-box"); +const btnFiles = document.getElementById("btnFiles"); +const btnRun = document.getElementById("btnRun"); +const btnMenu = document.getElementById("btnMenu"); +const btnFullscreen = document.getElementById("btnFullscreen"); +const btnHelp = document.getElementById("btnHelp"); +const btnAdd = document.getElementById("btnAdd"); +const icnRun = document.getElementById("icnRun"); +const icnAdd = document.getElementById("icnAdd"); +const modalContainer = document.getElementById("modals"); +const modalWindow = document.getElementById("modal-window"); +const modalTitle = document.getElementById("modal-title"); +const modalClose = document.getElementById("modal-close"); +const fileManagerPanel = document.getElementById("fileManagerPanel"); -var Module = { - noInitialRun: true, - arguments: ["-v", "--menu"], - noImageDecoding: true, - noAudioDecoding: true, - - retroArchSend: function(msg) { - this.EmscriptenSendCommand(msg); - }, - retroArchRecv: function() { - return this.EmscriptenReceiveCommandReply(); - }, - preRun: [ - function(module) { - Module.ENV['OPFS'] = "/home/web_user/retroarch"; - } - ], - postRun: [], - onRuntimeInitialized: function() { - retroarch_ready = true; - appInitialized(); - }, - print: function(text) { - console.log("stdout:", text); - }, - printErr: function(text) { - console.log("stderr:", text); - }, - canvas: document.getElementById("canvas"), - totalDependencies: 0, - monitorRunDependencies: function(left) { - this.totalDependencies = Math.max(this.totalDependencies, left); - } +const progressTrackers = { + "main": {bar: document.getElementById("progressBarMain"), text: document.getElementById("progressTextMain")}, + "modal": {bar: document.getElementById("progressBarModal"), text: document.getElementById("progressTextModal")} }; +const modals = { + "help": {title: "Basics", width: "750px", element: document.getElementById("helpModal")}, + "files": {title: "File Management", width: "400px", element: document.getElementById("filesModal")} +}; -async function cleanupStorage() -{ - localStorage.clear(); - const root = await navigator.storage.getDirectory(); - for await (const handle of root.values()) { - await root.removeEntry(handle.name, {recursive: true}); - } - document.getElementById("btnClean").disabled = true; +// Attempt to disable some default browser keys. +const disableKeys = { + 9: "tab", + 13: "enter", + 16: "shift", + 18: "alt", + 27: "esc", + 33: "rePag", + 34: "avPag", + 35: "end", + 36: "home", + 37: "left", + 38: "up", + 39: "right", + 40: "down", + 112: "F1", + 113: "F2", + 114: "F3", + 115: "F4", + 116: "F5", + 117: "F6", + 118: "F7", + 119: "F8", + 120: "F9", + 121: "F10", + 122: "F11", + 123: "F12" +}; + +let fsLoadPromise; + +// all methods provided by the worker that we may require +const workerHandlers = {FS: ["init", "writeFile", "readFile", "mkdirTree", "readdir", "readdirTree", "rm", "stat"], helper: ["loadFS", "zipDirs"]}; + +const worker = new Worker("libretro.worker.js"); +let workerMessageQueue = []; +worker.onmessage = (msg) => { + switch (msg.data?.type) { + case "noReturn": + window[msg.data?.func]?.apply(null, msg.data?.args); + break; + case "ret": + const ind = workerMessageQueue.findIndex(i => msg.data?.id in i); + if (ind < 0) break; + const promise = workerMessageQueue.splice(ind, 1)[0][msg.data.id]; + if (msg.data.err) { + promise.reject(msg.data?.ret); + } else { + promise.resolve(msg.data?.ret); + } + break; + } } -function appInitialized() -{ - /* Need to wait for the wasm runtime to load before enabling the Run button. */ - if (retroarch_ready && filesystem_ready) - { - preLoadingComplete(); - } - } - -function preLoadingComplete() { - $('#icnRun').removeClass('fa-spinner').removeClass('fa-spin'); - $('#icnRun').addClass('fa-play'); - // Make the Preview image clickable to start RetroArch. - $('.webplayer-preview').addClass('loaded').click(function() { - startRetroArch(); - return false; - }); - $('#btnRun').removeClass('disabled').removeAttr("disabled").click(function() { - startRetroArch(); - return false; - }); +function handleWorkerFunc(handler, method, args) { + return new Promise((resolve, reject) => { + const id = "" + Math.random(); + workerMessageQueue.push({[id]: {resolve: resolve, reject: reject}}); + worker.postMessage({id: id, handler: handler, method: method, args: args}); + }); } -// Retrieve the value of the given GET parameter. -function getParam(name) { - var results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href); - if (results) { - return results[1] || null; - } +// add the global functions from workerHandlers +// this makes the methods here appear identical to the implementation in the worker +for (let [handler, methods] of Object.entries(workerHandlers)) { + let methodHandlers = {}; + for (let method of methods) { + methodHandlers[method] = async function() { + return await handleWorkerFunc(handler, method, Array.from(arguments)); + } + } + window[handler] = methodHandlers; +} + +// console.log alias for worker to use +function debugLog() { + console.log.apply(null, Array.from(arguments)); +} + +// n is the name of the bar ("main" or "modal") +// progress in range [0, 1] +function setProgress(n, progress) { + const progressBar = progressTrackers[n]?.bar; + if (!progressBar) return; + if (isNaN(progress)) progress = 0; + progressBar.style.height = progress ? "4px" : "0px"; + progressBar.style.setProperty("--progressbarpercent", (progress * 100) + "%"); +} + +function setProgressColor(n, color) { + const progressBar = progressTrackers[n]?.bar; + if (!progressBar) return; + progressBar.style.setProperty("--progressbarcolor", color || "#1fb01a"); +} + +function setProgressText(n, text) { + const progressText = progressTrackers[n]?.text; + if (!progressText) return; + progressText.textContent = text ?? ""; +} + +// "help" or "files" +function openModal(which) { + if (which in modals) { + for (const modal of Object.values(modals)) { + modal.element.style.display = "none"; + } + modalTitle.textContent = modals[which].title ?? ""; + modalWindow.style.width = modals[which].width ?? "750px"; + modals[which].element.style.display = "block"; + modalContainer.style.display = "block"; + } +} + +modalClose.addEventListener("click", function() { + modalContainer.style.display = "none"; +}); + +var Module = { + noInitialRun: true, + arguments: ["-v", "--menu"], + noImageDecoding: true, + noAudioDecoding: true, + + retroArchSend: function(msg) { + this.EmscriptenSendCommand(msg); + }, + retroArchRecv: function() { + return this.EmscriptenReceiveCommandReply(); + }, + preRun: [ + function(module) { + module.ENV["OPFS_MOUNT"] = "/home/web_user"; + } + ], + onRuntimeInitialized: function() { + appInitialized(); + }, + print: function(text) { + console.log("stdout:", text); + }, + printErr: function(text) { + console.log("stderr:", text); + }, + canvas: canvas, + totalDependencies: 0, + monitorRunDependencies: function(left) { + this.totalDependencies = Math.max(this.totalDependencies, left); + } +}; + +// read File object to an ArrayBuffer +function readFile(file) { + return new Promise((resolve, reject) => { + let reader = new FileReader(); + reader.onload = function() { + resolve(this.result); + } + reader.onerror = function(e) { + reject(e); + } + reader.readAsArrayBuffer(file); + }); +} + +// accept (optional) can be used to specify file extensions (string, comma delimited) +// returns an array of {path: String, data: ArrayBuffer} +function uploadFiles(accept) { + return new Promise((resolve, reject) => { + let input = document.createElement("input"); + input.type = "file"; + input.setAttribute("multiple", ""); + if (accept) input.accept = accept; + input.onchange = async function() { + let files = []; + for (const file of this.files) { + files.push({path: file.name, data: await readFile(file)}); + } + resolve(files); + } + input.oncancel = function() { + resolve([]); + } + input.click(); + }); +} + +// prompt user to upload file(s) to a dir in OPFS, e.g. "/retroarch/content" +async function uploadFilesToDir(dir, accept) { + const files = await uploadFiles(accept); + for (const file of files) { + await FS.writeFile(dir + "/" + file.path, new Uint8Array(file.data)); + console.log("file upload complete: " + file.path); + } +} + +// download data (ArrayBuffer/DataView) with file name and optional mime type +function downloadFile(data, name, mime) { + let a = document.createElement("a"); + a.download = name; + a.href = URL.createObjectURL(new Blob([data], {type: mime || "application/octet-stream"})); + a.click(); + window.setTimeout(function() { + URL.revokeObjectURL(a.href); + }, 2000); +} + +// click handler for the file manager modal +async function fileManagerEvent(target) { + const action = target?.dataset?.action; + if (!action) return; + target.classList.add("disabled"); + let data; + switch (action) { + case "upload_saves": + await uploadFilesToDir("/retroarch/saves"); + break; + case "upload_states": + await uploadFilesToDir("/retroarch/states"); + break; + case "upload_system": + await uploadFilesToDir("/retroarch/system"); + break; + case "download_sss": + data = await helper.zipDirs("/retroarch/saves", "/retroarch/states", "/retroarch/screenshots"); + downloadFile(data, "saves_states_screenshots.zip", "application/zip"); + break; + case "download_all": + data = await helper.zipDirs("/retroarch/saves", "/retroarch/states", "/retroarch/screenshots", "/retroarch/content"); + downloadFile(data, "all.zip", "application/zip"); + break; + case "delete_sss": + await FS.rm("/retroarch/saves", "/retroarch/states", "/retroarch/screenshots"); + break; + case "delete_content": + await FS.rm("/retroarch/content"); + break; + case "delete_config": + await FS.rm("/.config/retroarch"); + break; + case "delete_assets": + await FS.rm("/retroarch/.bundle-timestamp", "/retroarch/assets", "/retroarch/autoconfig", + "/retroarch/database", "/retroarch/filters", "/retroarch/info", "/retroarch/overlays", "/retroarch/shaders"); + break; + case "delete_all": + await FS.rm("/retroarch", "/.config/retroarch"); + break; + } + target.classList.remove("disabled"); +} + +function appIsSmallScreen() { + return window.matchMedia("(max-width: 720px)").matches; +} + +// used for the menu hider +function adjustMenuHeight() { + const actualMenuHeight = menuHider.checked ? 0 : 65; + document.body.style.setProperty("--actualmenuheight", actualMenuHeight + "px", "important") } function startRetroArch() { - $('.webplayer').show(); - $('.webplayer-preview').hide(); - document.getElementById("btnRun").disabled = true; + // show the "changes you made may not be saved" warning + window.addEventListener("beforeunload", function(e) { e.preventDefault(); }); - $('#btnAdd').removeClass("disabled").removeAttr("disabled").click(function() { - $('#btnRom').click(); - }); - $('#btnRom').removeAttr("disabled").change(function(e) { - selectFiles(e.target.files); - }); - $('#btnMenu').removeClass("disabled").removeAttr("disabled").click(function() { - Module._cmd_toggle_menu(); - Module.canvas.focus(); - }); - $('#btnFullscreen').removeClass("disabled").removeAttr("disabled").click(function() { - Module.requestFullscreen(false); - Module.canvas.focus(); - }); - Module.canvas.focus(); - Module.canvas.addEventListener("pointerdown", function() { - Module.canvas.focus(); - }, false); - Module.callMain(Module.arguments); + window.addEventListener("keydown", function(e) { + if (disableKeys[e.which]) e.preventDefault(); + }); + + webplayerPreview.classList.add("hide"); + btnRun.classList.add("hide"); + + btnMenu.classList.remove("disabled"); + btnMenu.addEventListener("click", function() { + Module._cmd_toggle_menu(); + }); + + btnFullscreen.classList.remove("disabled"); + btnFullscreen.addEventListener("click", function() { + Module.requestFullscreen(false); + }); + + // ensure the canvas is focused so that keyboard events work + Module.canvas.focus(); + Module.canvas.addEventListener("pointerdown", function() { + Module.canvas.focus(); + }, false); + menuBar.addEventListener("pointerdown", function() { + setTimeout(function() { + Module.canvas.focus(); + }, 0); + }, false); + + Module.callMain(Module.arguments); } -function selectFiles(files) { - $('#btnAdd').addClass('disabled'); - $('#icnAdd').removeClass('fa-plus'); - $('#icnAdd').addClass('fa-spinner spinning'); - var count = files.length; - - for (var i = 0; i < count; i++) { - filereader = new FileReader(); - filereader.file_name = files[i].name; - filereader.readAsArrayBuffer(files[i]); - filereader.onload = function() { - uploadData(this.result, this.file_name) - }; - filereader.onloadend = function(evt) { - console.log("WEBPLAYER: file: " + this.file_name + " upload complete"); - if (evt.target.readyState == FileReader.DONE) { - $('#btnAdd').removeClass('disabled'); - $('#icnAdd').removeClass('fa-spinner spinning'); - $('#icnAdd').addClass('fa-plus'); - } - } - } +// called when the emscripten module has loaded +async function appInitialized() { + console.log("WASM runtime initialized"); + await fsLoadPromise; + console.log("FS initialized"); + setProgress("main"); + setProgressText("main"); + icnRun.classList.remove("fa-spinner", "fa-spin"); + icnRun.classList.add("fa-play"); + // Make the Preview image clickable to start RetroArch. + webplayerPreview.classList.add("loaded"); + webplayerPreview.addEventListener("click", function() { + startRetroArch(); + }); + btnRun.classList.remove("disabled"); + btnRun.addEventListener("click", function() { + startRetroArch(); + }); } -function uploadData(data, name) { - setupWorker.postMessage({command:"upload_file", name:name, data:data}, {transfer:[data]}); -} - -function switchCore(corename) { - localStorage.setItem("core", corename); -} - -function switchStorage(backend) { - if (backend != localStorage.getItem("backend")) { - localStorage.setItem("backend", backend); - location.reload(); - } +function loadCore(core) { + // Make the core the selected core in the UI. + const coreTitle = document.querySelector('#core-selector a[data-core="' + core + '"]')?.textContent; + if (coreTitle) coreSelectorCurrent.textContent = coreTitle; + const fileExt = (core == "retroarch") ? ".js" : "_libretro.js"; + import("./" + core + fileExt).then(script => { + script.default(Module).then(mod => { + Module = mod; + }).catch(err => { console.error("Couldn't instantiate module", err); throw err; }); + }).catch(err => { console.error("Couldn't load script", err); throw err; }); } // When the browser has loaded everything. -$(function() { - // Enable data clear - $('#btnClean').click(function() { - cleanupStorage(); - }); +document.addEventListener("DOMContentLoaded", async function() { + // watch the menu toggle checkbox + menuHider.addEventListener("change", adjustMenuHeight); + if (appIsSmallScreen()) menuHider.checked = true; + adjustMenuHeight(); - // Enable all available ToolTips. - $('.tooltip-enable').tooltip({ - placement: 'right' - }); + // make it easier to exit the core selector drop-down menu + document.addEventListener("click", function(e) { + if (!coreSelector.parentElement.contains(e.target)) dropdownBox.checked = false; + }); - // Allow hiding the top menu. - $('.showMenu').hide(); - $('#btnHideMenu, .showMenu').click(function() { - $('nav').slideToggle('slow'); - $('.showMenu').toggle('slow'); - }); + // disable default right click action + canvas.addEventListener("contextmenu", function(e) { + e.preventDefault(); + }, false); - // Attempt to disable some default browser keys. - var keys = { - 9: "tab", - 13: "enter", - 16: "shift", - 18: "alt", - 27: "esc", - 33: "rePag", - 34: "avPag", - 35: "end", - 36: "home", - 37: "left", - 38: "up", - 39: "right", - 40: "down", - 112: "F1", - 113: "F2", - 114: "F3", - 115: "F4", - 116: "F5", - 117: "F6", - 118: "F7", - 119: "F8", - 120: "F9", - 121: "F10", - 122: "F11", - 123: "F12" - }; - window.addEventListener('keydown', function(e) { - if (keys[e.which]) { - e.preventDefault(); - } - }); + // init the OPFS + await FS.init(); + fsLoadPromise = helper.loadFS(); - // Switch the core when selecting one. - $('#core-selector a').click(function() { - var coreChoice = $(this).data('core'); - switchCore(coreChoice); - }); - // Find which core to load. - var core = localStorage.getItem("core", core); - if (!core) { - core = 'gambatte'; - } - loadCore(core); + btnFiles.addEventListener("click", function() { + openModal("files"); + }); + + btnHelp.addEventListener("click", function() { + openModal("help"); + }); + + btnAdd.classList.remove("disabled"); + btnAdd.addEventListener("click", async function() { + btnAdd.classList.add("disabled"); + icnAdd.classList.remove("fa-plus"); + icnAdd.classList.add("fa-spinner", "fa-spin"); + await uploadFilesToDir("/retroarch/content"); + btnAdd.classList.remove("disabled"); + icnAdd.classList.remove("fa-spinner", "fa-spin"); + icnAdd.classList.add("fa-plus"); + }); + + fileManagerPanel.addEventListener("click", function(e) { + fileManagerEvent(e.target); + }); + + // Switch the core when selecting one. + coreSelector.addEventListener("click", function(e) { + const coreChoice = e.target.dataset?.core; + if (coreChoice) localStorage.setItem("core", coreChoice); + }); + + // Find which core to load. + const core = localStorage.getItem("core") || "gambatte"; + loadCore(core); }); - -function loadCore(core) { - // Make the core the selected core in the UI. - var coreTitle = $('#core-selector a[data-core="' + core + '"]').addClass('active').text(); - $('#dropdownMenu1').text(coreTitle); - import("./"+core+"_libretro.js").then(script => { - script.default(Module).then(mod => { - Module = mod; - }).catch(err => { console.error("Couldn't instantiate module",err); throw err; }); - }).catch(err => { console.error("Couldn't import module"); throw err; }); -} - -const setupWorker = new Worker("libretro.worker.js"); -setupWorker.onmessage = (msg) => { - if(msg.data.command == "loaded_bundle") { - filesystem_ready = true; - localStorage.setItem("asset_time", msg.data.time); - appInitialized(); - } else if(msg.data.command == "uploaded_file") { - // console.log("finished upload of",msg.data.name); - } -} -setupWorker.postMessage({command:"load_bundle",time:localStorage.getItem("asset_time") ?? ""}); diff --git a/pkg/emscripten/libretro-thread/libretro.worker.js b/pkg/emscripten/libretro-thread/libretro.worker.js index f7d5954a43..9ba3088b4f 100644 --- a/pkg/emscripten/libretro-thread/libretro.worker.js +++ b/pkg/emscripten/libretro-thread/libretro.worker.js @@ -1,66 +1,400 @@ -importScripts("zip-no-worker.min.js"); +let root, BFS, BFSDB; +let bundleCounter = 0; +let loadedScripts = []; +const FS = {}; +const helper = {}; -async function writeFile(path, data) { - const root = await navigator.storage.getDirectory(); - const dir_end = path.lastIndexOf("/"); - const parent = path.substr(0, dir_end); - const child = path.substr(dir_end+1); - const parent_dir = await mkdirTree(parent); - const file = await parent_dir.getFileHandle(child,{create:true}); - const stream = await file.createSyncAccessHandle(); - const written = stream.write(data); - stream.close(); +// this is huge and takes between 2 and 3 minutes to unzip. (10 minutes for firefox?) +// luckily it only needs to be done once. +const bundlePath = ["assets/frontend/bundle.zip.aa", + "assets/frontend/bundle.zip.ab", + "assets/frontend/bundle.zip.ac", + "assets/frontend/bundle.zip.ad", + "assets/frontend/bundle.zip.ae"]; +// ["assets/frontend/bundle-minimal.zip"] +const removeLeadingZipDirs = 1; + +// list of directories to migrate. previously these were mounted in the "userdata" directory. retroarch.cfg is ignored intentionally. +const dirsToMigrate = ["cheats", "config", "content", "logs", "playlists", "saves", "screenshots", "states", "system", "thumbnails"]; + +/* no return functions that run on the browser thread */ + +const noReturnProxyFunctions = ["debugLog", "setProgress", "setProgressColor", "setProgressText"] + +function handleNoReturnProxyFunction(func, args) { + postMessage({type: "noReturn", func: func, args: args}); } -async function mkdirTree(path) { - const root = await navigator.storage.getDirectory(); - const parts = path.split("/"); - let here = root; - for (const part of parts) { - if (part == "") { continue; } - here = await here.getDirectoryHandle(part, {create:true}); - } - return here; +// add global functions +for (const func of noReturnProxyFunctions) { + self[func] = function() { + handleNoReturnProxyFunction(func, Array.from(arguments)); + } +} + +/* misc */ + +function sleep(ms) { + return new Promise(function(resolve) { + setTimeout(resolve, ms); + }); +} + +// for lazy-loading of scripts, doesn't load if it's already loaded +function loadScripts() { + for (const path of arguments) { + if (loadedScripts.includes(path)) continue; + importScripts(path); + loadedScripts.push(path); + } +} + +/* OPFS misc */ + +async function getDirHandle(path, create) { + const parts = path.split("/"); + let here = root; + for (const part of parts) { + if (part == "") continue; + try { + here = await here.getDirectoryHandle(part, {create: !!create}); + } catch (e) { + return; + } + } + return here; +} + +/* OPFS impl */ + +FS.init = async function() { + root = await navigator.storage.getDirectory(); +} + +FS.writeFile = async function(path, data) { + const dir_end = path.lastIndexOf("/"); + const parent = path.substr(0, dir_end); + const child = path.substr(dir_end + 1); + const parent_dir = await getDirHandle(parent, true); + const file = await parent_dir.getFileHandle(child, {create: true}); + const handle = await file.createSyncAccessHandle({mode: "readwrite"}); + handle.write(data); + // todo: should we call handle.flush() here? + handle.close(); +} + +FS.readFile = async function(path) { + const dir_end = path.lastIndexOf("/"); + const parent = path.substr(0, dir_end); + const child = path.substr(dir_end + 1); + const parent_dir = await getDirHandle(parent); + if (!parent_dir) throw "directory doesn't exist"; + const file = await parent_dir.getFileHandle(child); + const handle = await file.createSyncAccessHandle({mode: "read-only"}); + let data = new Uint8Array(new ArrayBuffer(handle.getSize())); + handle.read(data); + handle.close(); + return data; +} + +// unlimited arguments +FS.mkdirTree = async function() { + for (const path of arguments) { + await getDirHandle(path, true); + } +} + +FS.readdir = async function(path) { + let items = []; + const dir = await getDirHandle(path); + if (!dir) return; + for await (const entry of dir.keys()) { + items.push(entry); + } + items.reverse(); + return items; +} + +FS.readdirTree = async function(path, maxDepth) { + let items = []; + if (isNaN(maxDepth)) maxDepth = 10; + const dir = await getDirHandle(path); + if (!dir) return; + if (!path.endsWith("/")) path += "/"; + for await (const handle of dir.values()) { + if (handle.kind == "file") { + items.push(path + handle.name); + } else if (handle.kind == "directory" && maxDepth > 0) { + items.push.apply(items, await FS.readdirTree(path + handle.name, maxDepth - 1)); + } + } + items.reverse(); + return items; +} + +// unlimited arguments +FS.rm = async function() { + for (const path of arguments) { + const dir_end = path.lastIndexOf("/"); + const parent = path.substr(0, dir_end); + const child = path.substr(dir_end + 1); + const parent_dir = await getDirHandle(parent); + if (!parent_dir) continue; + await parent_dir.removeEntry(child, {recursive: true}); + } +} + +FS.stat = async function(path) { + const dir_end = path.lastIndexOf("/"); + const parent = path.substr(0, dir_end); + if (!parent) return "directory"; + const child = path.substr(dir_end + 1); + const parent_dir = await getDirHandle(parent); + if (!parent_dir) return; + for await (const handle of parent_dir.values()) { + if (handle.name == child) return handle.kind; + } +} + +/* data migration */ + +function idbExists(name) { + return new Promise((resolve, reject) => { + let request = indexedDB.open(name); + request.onupgradeneeded = function(e) { + e.target.transaction.abort(); + resolve(false); + } + request.onsuccess = function(e) { + e.target.result.close(); + resolve(true); + } + request.onerror = function(e) { + reject(e); + } + }); +} + +function deleteIdb(name) { + return new Promise((resolve, reject) => { + let request = indexedDB.deleteDatabase(name); + request.onsuccess = function() { + resolve(); + } + request.onerror = function(e) { + reject("Error deleting IndexedDB!"); + } + request.onblocked = function(e) { + reject("Request to delete IndexedDB was blocked!"); + } + }); +} + +function initBfsIdbfs(name) { + return new Promise((resolve, reject) => { + loadScripts("jsdeps/browserfs.min.js"); + BrowserFS.getFileSystem({fs: "IndexedDB", options: {storeName: name}}, function(err, rv) { + if (err) { + reject(err); + } else { + BrowserFS.initialize(rv); + BFSDB = rv.store.db; + BFS = BrowserFS.BFSRequire("fs"); + resolve(); + } + }); + }); +} + +// calls BFS. with arguments..., returns a promise +function bfsAsyncCall(method) { + return new Promise((resolve, reject) => { + BFS[method].apply(null, Array.from(arguments).slice(1).concat(function(err, rv) { + if (err) { + reject(err); + } else { + resolve(rv); + } + })); + }); +} + +async function migrateFiles(files) { + for (let i = 0; i < files.length; i++) { + const path = files[i]; + debugLog(" Migrating " + path); + setProgressText("main", "Migrating file: " + path.substr(1)); + setProgress("main", (i + 1) / files.length); + const data = await bfsAsyncCall("readFile", path); + await FS.writeFile("/retroarch" + path, data); + } + setProgress("main", 0); + setProgressText("main"); +} + +// this is really finicky (thanks browserfs), probably don't touch this +async function indexMigrateTree(dir, maxDepth) { + let toMigrate = []; + if (isNaN(maxDepth)) maxDepth = 10; + const children = await bfsAsyncCall("readdir", dir); + if (!dir.endsWith("/")) dir += "/"; + for (const child of children) { + const info = await bfsAsyncCall("lstat", dir + child); + if (info.isSymbolicLink()) continue; + if (info.isFile() && dir != "/") { + toMigrate.push(dir + child); + } else if (info.isDirectory() && maxDepth > 0 && (dir != "/" || dirsToMigrate.includes(child))) { + toMigrate.push.apply(toMigrate, await indexMigrateTree(dir + child, maxDepth - 1)); + } + } + return toMigrate; +} + +// look for and migrate any data to the OPFS from the old BrowserFS in IndexedDB +async function tryMigrateFromIdbfs() { + if (await FS.stat("/retroarch/.migration-finished") == "file" || !(await idbExists("RetroArch"))) return; + debugLog("Migrating data from BrowserFS IndexedDB"); + await initBfsIdbfs("RetroArch"); + const files = await indexMigrateTree("/", 5); + await migrateFiles(files); + await FS.writeFile("/retroarch/.migration-finished", new Uint8Array()); + BFSDB.close(); + await sleep(100); // above method might need extra time, and indexedDB.deleteDatabase only gives us one shot + try { + await deleteIdb("RetroArch"); + } catch (e) { + debugLog("Warning: failed to delete old IndexedDB, probably doesn't matter.", e); + } + debugLog("Finished data migration! " + files.length + " files migrated successfully."); +} + +/* bundle loading */ + +function incBundleCounter() { + setProgress("main", ++bundleCounter / bundlePath.length); } async function setupZipFS(zipBuf) { - const root = await navigator.storage.getDirectory(); - const zipReader = new zip.ZipReader(new zip.Uint8ArrayReader(zipBuf), {useWebWorkers:false}); - const entries = await zipReader.getEntries(); - for(const file of entries) { - if (file.getData && !file.directory) { - const writer = new zip.Uint8ArrayWriter(); - const data = await file.getData(writer); - await writeFile(file.filename, data); - } else if (file.directory) { - await mkdirTree(file.filename); - } - } - await zipReader.close(); + loadScripts("jsdeps/zip-full.min.js"); + const mount = "/retroarch/"; + const zipReader = new zip.ZipReader(new zip.Uint8ArrayReader(zipBuf), {useWebWorkers: false}); + const entries = await zipReader.getEntries(); + setProgressText("main", "Extracting bundle... This only happens on the first visit or when the bundle is updated"); + for (let i = 0; i < entries.length; i++) { + const file = entries[i]; + if (file.getData && !file.directory) { + setProgress("main", (i + 1) / entries.length); + const path = mount + file.filename.split("/").slice(removeLeadingZipDirs).join("/"); + const data = await file.getData(new zip.Uint8ArrayWriter()); + await FS.writeFile(path, data); + } + } + await zipReader.close(); + setProgress("main", 0); + setProgressText("main"); } -onmessage = async (msg) => { - if(msg.data.command == "load_bundle") { - let old_timestamp = msg.data.time; - try { - const root = await navigator.storage.getDirectory(); - const _bundle = await root.getDirectoryHandle("bundle"); - } catch (_e) { - old_timestamp = ""; - } - let resp = await fetch("assets/frontend/bundle-minimal.zip", { - headers: { - "If-Modified-Since": old_timestamp - } - }); - if (resp.status == 200) { - await setupZipFS(new Uint8Array(await resp.arrayBuffer())); - } else { - await resp.text(); - } - postMessage({command:"loaded_bundle", time:resp.headers.get("last-modified")}); - } else if(msg.data.command == "upload_file") { - await writeFile("userdata/content/"+msg.data.name, new Uint8Array(msg.data.data)); - postMessage({command:"uploaded_file",name:msg.data.name}); - } +async function tryLoadBundle() { + let outBuf; + const timestampFile = "/retroarch/.bundle-timestamp"; + let timestamp = ""; + if (await FS.stat(timestampFile) == "file") + timestamp = new TextDecoder().decode(await FS.readFile(timestampFile)); + + // debuggers beware: the network tab's "Disable cache" option disables If-Modified-Since too + let resp = await fetch(bundlePath[0], {headers: {"If-Modified-Since": timestamp}}); + if (resp.status == 200) { + debugLog("Got new bundle"); + timestamp = resp.headers.get("last-modified"); + if (bundlePath.length > 1) { + // split bundle + let firstBuffer = await resp.arrayBuffer(); + setProgressColor("main", "#0275d8"); + setProgressText("main", "Fetching bundle... This only happens on the first visit or when the bundle is updated"); + incBundleCounter(); + // 256 MB max bundle size + let buffer = new ArrayBuffer(256 * 1024 * 1024); + let bufferView = new Uint8Array(buffer); + bufferView.set(new Uint8Array(firstBuffer), 0); + let idx = firstBuffer.byteLength; + let buffers = await Promise.all(bundlePath.slice(1).map(i => fetch(i).then(r => { incBundleCounter(); return r.arrayBuffer(); }))); + for (let buf of buffers) { + if (idx + buf.byteLength > buffer.maxByteLength) { + throw "error: bundle zip is too large"; + } + bufferView.set(new Uint8Array(buf), idx); + idx += buf.byteLength; + } + setProgress("main", 0); + setProgressColor("main"); + setProgressText("main"); + outBuf = new Uint8Array(buffer, 0, idx); + } else { + // single-file bundle + outBuf = new Uint8Array(await resp.arrayBuffer()); + } + debugLog("Unzipping..."); + let oldTime = performance.now(); + await setupZipFS(outBuf); + await FS.writeFile(timestampFile, new TextEncoder().encode(timestamp)); + debugLog("Finished bundle load in " + Math.round((performance.now() - oldTime) / 1000) + " seconds"); + } else { + debugLog("No new bundle exists"); + } +} + +/* helper functions */ + +helper.loadFS = async function() { + await tryMigrateFromIdbfs(); + await tryLoadBundle(); +} + +// zip directories... and return Uint8Array with zip file data +helper.zipDirs = async function() { + let toZip = []; + for (const path of arguments) { + const files = await FS.readdirTree(path); + if (files) toZip.push.apply(toZip, files); + } + if (toZip.length == 0) return; + + loadScripts("jsdeps/zip-full.min.js"); + const u8aWriter = new zip.Uint8ArrayWriter("application/zip"); + // using workers is faster for deflating, hmm... + const writer = new zip.ZipWriter(u8aWriter, {useWebWorkers: true}); + for (let i = 0; i < toZip.length; i++) { + const path = toZip[i]; + setProgress("modal", (i + 1) / toZip.length); + setProgressText("modal", "Deflating: " + path.substr(1)); + try { + const data = await FS.readFile(path); + await writer.add(path.substr(1), new zip.Uint8ArrayReader(data), {level: 1}); + } catch (e) { + debugLog("error while preparing zip", e); + } + } + await writer.close(); + const zipped = await u8aWriter.getData(); + setProgress("modal", 0); + setProgressText("modal"); + return zipped; +} + +/* handle messages from main thread */ + +const handlers = {FS: FS, helper: helper}; + +onmessage = async function(msg) { + if (msg.data?.handler in handlers && msg.data?.method in handlers[msg.data.handler]) { + let ret; + let err = false; + try { + ret = await handlers[msg.data.handler][msg.data.method].apply(null, msg.data?.args); + } catch (e) { + ret = e; + err = true; + } + postMessage({type: "ret", id: msg.data?.id, ret: ret, err: err}); + } } diff --git a/pkg/emscripten/libretro-thread/zip-no-worker.min.js b/pkg/emscripten/libretro-thread/zip-no-worker.min.js deleted file mode 100644 index cb5596a46f..0000000000 --- a/pkg/emscripten/libretro-thread/zip-no-worker.min.js +++ /dev/null @@ -1,2 +0,0 @@ -((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zip={})})(this,(function(e){"use strict";const{Array:t,Object:n,String:i,Number:r,BigInt:a,Math:s,Date:o,Map:l,Set:c,Response:d,URL:u,Error:f,Uint8Array:_,Uint16Array:w,Uint32Array:p,DataView:h,Blob:b,Promise:g,TextEncoder:m,TextDecoder:x,document:y,crypto:k,btoa:S,TransformStream:z,ReadableStream:v,WritableStream:E,CompressionStream:D,DecompressionStream:F,navigator:R,Worker:T}="undefined"!=typeof globalThis?globalThis:this||self,A=-2;function C(e){return N(e.map((([e,n])=>new t(e).fill(n,0,e))))}function N(e){return e.reduce(((e,n)=>e.concat(t.isArray(n)?N(n):n)),[])}const U=[0,1,2,3].concat(...C([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function W(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.build_tree=n=>{const i=e.dyn_tree,r=e.stat_desc.static_tree,a=e.stat_desc.elems;let o,l,c,d=-1;for(n.heap_len=0,n.heap_max=573,o=0;a>o;o++)0!==i[2*o]?(n.heap[++n.heap_len]=d=o,n.depth[o]=0):i[2*o+1]=0;for(;2>n.heap_len;)c=n.heap[++n.heap_len]=2>d?++d:0,i[2*c]=1,n.depth[c]=0,n.opt_len--,r&&(n.static_len-=r[2*c+1]);for(e.max_code=d,o=s.floor(n.heap_len/2);o>=1;o--)n.pqdownheap(i,o);c=a;do{o=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),l=n.heap[1],n.heap[--n.heap_max]=o,n.heap[--n.heap_max]=l,i[2*c]=i[2*o]+i[2*l],n.depth[c]=s.max(n.depth[o],n.depth[l])+1,i[2*o+1]=i[2*l+1]=c,n.heap[1]=c++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],(t=>{const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,s=e.stat_desc.max_length;let o,l,c,d,u,f,_=0;for(d=0;15>=d;d++)t.bl_count[d]=0;for(n[2*t.heap[t.heap_max]+1]=0,o=t.heap_max+1;573>o;o++)l=t.heap[o],d=n[2*n[2*l+1]+1]+1,d>s&&(d=s,_++),n[2*l+1]=d,l>e.max_code||(t.bl_count[d]++,u=0,a>l||(u=r[l-a]),f=n[2*l],t.opt_len+=f*(d+u),i&&(t.static_len+=f*(i[2*l+1]+u)));if(0!==_){do{for(d=s-1;0===t.bl_count[d];)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[s]--,_-=2}while(_>0);for(d=s;0!==d;d--)for(l=t.bl_count[d];0!==l;)c=t.heap[--o],c>e.max_code||(n[2*c+1]!=d&&(t.opt_len+=(d-n[2*c+1])*n[2*c],n[2*c+1]=d),l--)}})(n),((e,n,i)=>{const r=[];let a,s,o,l=0;for(a=1;15>=a;a++)r[a]=l=l+i[a-1]<<1;for(s=0;n>=s;s++)o=e[2*s+1],0!==o&&(e[2*s]=t(r[o]++,o))})(i,e.max_code,n.bl_count)}}function I(e,t,n,i,r){const a=this;a.static_tree=e,a.extra_bits=t,a.extra_base=n,a.elems=i,a.max_length=r}W._length_code=[0,1,2,3,4,5,6,7].concat(...C([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),W.base_length=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],W.base_dist=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],W.d_code=e=>256>e?U[e]:U[256+(e>>>7)],W.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],W.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],W.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],W.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const L=C([[144,8],[112,9],[24,7],[8,8]]);I.static_ltree=N([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,L[t]])));const O=C([[30,5]]);function M(e,t,n,i,r){const a=this;a.good_length=e,a.max_lazy=t,a.nice_length=n,a.max_chain=i,a.func=r}I.static_dtree=N([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,O[t]]))),I.static_l_desc=new I(I.static_ltree,W.extra_lbits,257,286,15),I.static_d_desc=new I(I.static_dtree,W.extra_dbits,0,30,15),I.static_bl_desc=new I(null,W.extra_blbits,0,19,7);const P=[new M(0,0,0,0,0),new M(4,4,8,4,1),new M(4,5,16,8,1),new M(4,6,32,32,1),new M(4,4,16,16,2),new M(8,16,32,32,2),new M(8,16,128,128,2),new M(8,32,128,256,2),new M(32,128,258,1024,2),new M(32,258,258,4096,2)],H=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],B=113,q=666,V=262;function Z(e,t,n,i){const r=e[2*t],a=e[2*n];return a>r||r==a&&i[t]<=i[n]}function K(){const e=this;let t,n,i,r,a,o,l,c,d,u,f,p,h,b,g,m,x,y,k,S,z,v,E,D,F,R,T,C,N,U,L,O,M;const K=new W,Y=new W,G=new W;let X,j,J,Q,$,ee;function te(){let t;for(t=0;286>t;t++)L[2*t]=0;for(t=0;30>t;t++)O[2*t]=0;for(t=0;19>t;t++)M[2*t]=0;L[512]=1,e.opt_len=e.static_len=0,j=J=0}function ne(e,t){let n,i=-1,r=e[1],a=0,s=7,o=4;0===r&&(s=138,o=3),e[2*(t+1)+1]=65535;for(let l=0;t>=l;l++)n=r,r=e[2*(l+1)+1],++aa?M[2*n]+=a:0!==n?(n!=i&&M[2*n]++,M[32]++):a>10?M[36]++:M[34]++,a=0,i=n,0===r?(s=138,o=3):n==r?(s=6,o=3):(s=7,o=4))}function ie(t){e.pending_buf[e.pending++]=t}function re(e){ie(255&e),ie(e>>>8&255)}function ae(e,t){let n;const i=t;ee>16-i?(n=e,$|=n<>>16-ee,ee+=i-16):($|=e<=n;n++)if(i=a,a=e[2*(n+1)+1],++s>=o||i!=a){if(l>s)do{se(i,M)}while(0!=--s);else 0!==i?(i!=r&&(se(i,M),s--),se(16,M),ae(s-3,2)):s>10?(se(18,M),ae(s-11,7)):(se(17,M),ae(s-3,3));s=0,r=i,0===a?(o=138,l=3):i==a?(o=6,l=3):(o=7,l=4)}}function le(){16==ee?(re($),$=0,ee=0):8>ee||(ie(255&$),$>>>=8,ee-=8)}function ce(t,n){let i,r,a;if(e.dist_buf[j]=t,e.lc_buf[j]=255&n,j++,0===t?L[2*n]++:(J++,t--,L[2*(W._length_code[n]+256+1)]++,O[2*W.d_code(t)]++),!(8191&j)&&T>2){for(i=8*j,r=z-x,a=0;30>a;a++)i+=O[2*a]*(5+W.extra_dbits[a]);if(i>>>=3,Jo);se(256,t),Q=t[513]}function ue(){ee>8?re($):ee>0&&ie(255&$),$=0,ee=0}function fe(t,n,i){ae(0+(i?1:0),3),((t,n)=>{ue(),Q=8,re(n),re(~n),e.pending_buf.set(c.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function _e(n){((t,n,i)=>{let r,a,s=0;T>0?(K.build_tree(e),Y.build_tree(e),s=(()=>{let t;for(ne(L,K.max_code),ne(O,Y.max_code),G.build_tree(e),t=18;t>=3&&0===M[2*W.bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(),r=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a>r||(r=a)):r=a=n+5,n+4>r||-1==t?a==r?(ae(2+(i?1:0),3),de(I.static_ltree,I.static_dtree)):(ae(4+(i?1:0),3),((e,t,n)=>{let i;for(ae(e-257,5),ae(t-1,5),ae(n-4,4),i=0;n>i;i++)ae(M[2*W.bl_order[i]+1],3);oe(L,e-1),oe(O,t-1)})(K.max_code+1,Y.max_code+1,s+1),de(L,O)):fe(t,n,i),te(),i&&ue()})(0>x?-1:x,z-x,n),x=z,t.flush_pending()}function we(){let e,n,i,r;do{if(r=d-E-z,0===r&&0===z&&0===E)r=a;else if(-1==r)r--;else if(z>=a+a-V){c.set(c.subarray(a,a+a),0),v-=a,z-=a,x-=a,e=h,i=e;do{n=65535&f[--i],f[i]=a>n?0:n-a}while(0!=--e);e=a,i=e;do{n=65535&u[--i],u[i]=a>n?0:n-a}while(0!=--e);r+=a}if(0===t.avail_in)return;e=t.read_buf(c,z+E,r),E+=e,3>E||(p=255&c[z],p=(p<E&&0!==t.avail_in)}function pe(e){let t,n,i=F,r=z,s=D;const o=z>a-V?z-(a-V):0;let d=U;const f=l,_=z+258;let w=c[r+s-1],p=c[r+s];N>D||(i>>=2),d>E&&(d=E);do{if(t=e,c[t+s]==p&&c[t+s-1]==w&&c[t]==c[r]&&c[++t]==c[r+1]){r+=2,t++;do{}while(c[++r]==c[++t]&&c[++r]==c[++t]&&c[++r]==c[++t]&&c[++r]==c[++t]&&c[++r]==c[++t]&&c[++r]==c[++t]&&c[++r]==c[++t]&&c[++r]==c[++t]&&_>r);if(n=258-(_-r),r=_-258,n>s){if(v=e,s=n,n>=d)break;w=c[r+s-1],p=c[r+s]}}}while((e=65535&u[e&f])>o&&0!=--i);return s>E?E:s}e.depth=[],e.bl_count=[],e.heap=[],L=[],O=[],M=[],e.pqdownheap=(t,n)=>{const i=e.heap,r=i[n];let a=n<<1;for(;a<=e.heap_len&&(a(W||(W=8),H||(H=8),q||(q=0),t.msg=null,-1==k&&(k=6),1>H||H>9||8!=W||9>v||v>15||0>k||k>9||0>q||q>2?A:(t.dstate=e,o=v,a=1<(t.total_in=t.total_out=0,t.msg=null,e.pending=0,e.pending_out=0,n=B,r=0,K.dyn_tree=L,K.stat_desc=I.static_l_desc,Y.dyn_tree=O,Y.stat_desc=I.static_d_desc,G.dyn_tree=M,G.stat_desc=I.static_bl_desc,$=0,ee=0,Q=8,te(),(()=>{d=2*a,f[h-1]=0;for(let e=0;h-1>e;e++)f[e]=0;R=P[T].max_lazy,N=P[T].good_length,U=P[T].nice_length,F=P[T].max_chain,z=0,x=0,E=0,y=D=2,S=0,p=0})(),0))(t))),e.deflateEnd=()=>42!=n&&n!=B&&n!=q?A:(e.lc_buf=null,e.dist_buf=null,e.pending_buf=null,f=null,u=null,c=null,e.dstate=null,n==B?-3:0),e.deflateParams=(e,t,n)=>{let i=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?A:(P[T].func!=P[t].func&&0!==e.total_in&&(i=e.deflate(1)),T!=t&&(T=t,R=P[T].max_lazy,N=P[T].good_length,U=P[T].nice_length,F=P[T].max_chain),C=n,i)},e.deflateSetDictionary=(e,t,i)=>{let r,s=i,o=0;if(!t||42!=n)return A;if(3>s)return 0;for(s>a-V&&(s=a-V,o=i-s),c.set(t.subarray(o,o+s),0),z=s,x=s,p=255&c[0],p=(p<=r;r++)p=(p<{let _,w,b,F,N;if(d>4||0>d)return A;if(!s.next_out||!s.next_in&&0!==s.avail_in||n==q&&4!=d)return s.msg=H[4],A;if(0===s.avail_out)return s.msg=H[7],-5;var U;if(t=s,F=r,r=d,42==n&&(w=8+(o-8<<4)<<8,b=(T-1&255)>>1,b>3&&(b=3),w|=b<<6,0!==z&&(w|=32),w+=31-w%31,n=B,ie((U=w)>>8&255),ie(255&U)),0!==e.pending){if(t.flush_pending(),0===t.avail_out)return r=-1,0}else if(0===t.avail_in&&F>=d&&4!=d)return t.msg=H[7],-5;if(n==q&&0!==t.avail_in)return s.msg=H[7],-5;if(0!==t.avail_in||0!==E||0!=d&&n!=q){switch(N=-1,P[T].func){case 0:N=(e=>{let n,r=65535;for(r>i-5&&(r=i-5);;){if(1>=E){if(we(),0===E&&0==e)return 0;if(0===E)break}if(z+=E,E=0,n=x+r,(0===z||z>=n)&&(E=z-n,z=n,_e(!1),0===t.avail_out))return 0;if(z-x>=a-V&&(_e(!1),0===t.avail_out))return 0}return _e(4==e),0===t.avail_out?4==e?2:0:4==e?3:1})(d);break;case 1:N=(e=>{let n,i=0;for(;;){if(V>E){if(we(),V>E&&0==e)return 0;if(0===E)break}if(3>E||(p=(p<a-V||2!=C&&(y=pe(i)),3>y)n=ce(0,255&c[z]),E--,z++;else if(n=ce(z-v,y-3),E-=y,y>R||3>E)z+=y,y=0,p=255&c[z],p=(p<{let n,i,r=0;for(;;){if(V>E){if(we(),V>E&&0==e)return 0;if(0===E)break}if(3>E||(p=(p<D&&a-V>=(z-r&65535)&&(2!=C&&(y=pe(r)),5>=y&&(1==C||3==y&&z-v>4096)&&(y=2)),3>D||y>D)if(0!==S){if(n=ce(0,255&c[z-1]),n&&_e(!1),z++,E--,0===t.avail_out)return 0}else S=1,z++,E--;else{i=z+E-3,n=ce(z-1-k,D-3),E-=D-1,D-=2;do{++z>i||(p=(p<1+Q+10-ee&&(ae(2,3),se(256,I.static_ltree),le()),Q=7;else if(fe(0,0,!1),3==d)for(_=0;h>_;_++)f[_]=0;if(t.flush_pending(),0===t.avail_out)return r=-1,0}}return 4!=d?0:1}}function Y(){const e=this;e.next_in_index=0,e.next_out_index=0,e.avail_in=0,e.total_in=0,e.avail_out=0,e.total_out=0}Y.prototype={deflateInit(e,t){const n=this;return n.dstate=new K,t||(t=15),n.dstate.deflateInit(n,e,t)},deflate(e){const t=this;return t.dstate?t.dstate.deflate(t,e):A},deflateEnd(){const e=this;if(!e.dstate)return A;const t=e.dstate.deflateEnd();return e.dstate=null,t},deflateParams(e,t){const n=this;return n.dstate?n.dstate.deflateParams(n,e,t):A},deflateSetDictionary(e,t){const n=this;return n.dstate?n.dstate.deflateSetDictionary(n,e,t):A},read_buf(e,t,n){const i=this;let r=i.avail_in;return r>n&&(r=n),0===r?0:(i.avail_in-=r,e.set(i.next_in.subarray(i.next_in_index,i.next_in_index+r),t),i.next_in_index+=r,i.total_in+=r,r)},flush_pending(){const e=this;let t=e.dstate.pending;t>e.avail_out&&(t=e.avail_out),0!==t&&(e.next_out.set(e.dstate.pending_buf.subarray(e.dstate.pending_out,e.dstate.pending_out+t),e.next_out_index),e.next_out_index+=t,e.dstate.pending_out+=t,e.total_out+=t,e.avail_out-=t,e.dstate.pending-=t,0===e.dstate.pending&&(e.dstate.pending_out=0))}};const G=-2,X=-3,j=-5,J=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Q=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],$=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],ee=[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],te=[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,112,112],ne=[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],ie=[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];function re(){let e,t,n,i,r,a;function s(e,t,s,o,l,c,d,u,f,_,w){let p,h,b,g,m,x,y,k,S,z,v,E,D,F,R;z=0,m=s;do{n[e[t+z]]++,z++,m--}while(0!==m);if(n[0]==s)return d[0]=-1,u[0]=0,0;for(k=u[0],x=1;15>=x&&0===n[x];x++);for(y=x,x>k&&(k=x),m=15;0!==m&&0===n[m];m--);for(b=m,k>m&&(k=m),u[0]=k,F=1<x;x++,F<<=1)if(0>(F-=n[x]))return X;if(0>(F-=n[m]))return X;for(n[m]+=F,a[1]=x=0,z=1,D=2;0!=--m;)a[D]=x+=n[z],D++,z++;m=0,z=0;do{0!==(x=e[t+z])&&(w[a[x]++]=m),z++}while(++m=y;y++)for(p=n[y];0!=p--;){for(;y>E+k;){if(g++,E+=k,R=b-E,R=R>k?k:R,(h=1<<(x=y-E))>p+1&&(h-=p+1,D=y,R>x))for(;++xn[++D];)h-=n[D];if(R=1<1440)return X;r[g]=v=_[0],_[0]+=R,0!==g?(a[g]=m,i[0]=x,i[1]=k,x=m>>>E-k,i[2]=v-r[g-1]-x,f.set(i,3*(r[g-1]+x))):d[0]=v}for(i[1]=y-E,s>z?w[z]w[z]?0:96,i[2]=w[z++]):(i[0]=c[w[z]-o]+16+64,i[2]=l[w[z++]-o]):i[0]=192,h=1<>>E;R>x;x+=h)f.set(i,3*(v+x));for(x=1<>>=1)m^=x;for(m^=x,S=(1<o;o++)t[o]=0;for(o=0;16>o;o++)n[o]=0;for(o=0;3>o;o++)i[o]=0;r.set(n.subarray(0,15),0),a.set(n.subarray(0,16),0)}this.inflate_trees_bits=(n,i,r,a,l)=>{let c;return o(19),e[0]=0,c=s(n,0,19,19,null,null,r,i,a,e,t),c==X?l.msg="oversubscribed dynamic bit lengths tree":c!=j&&0!==i[0]||(l.msg="incomplete dynamic bit lengths tree",c=X),c},this.inflate_trees_dynamic=(n,i,r,a,l,c,d,u,f)=>{let _;return o(288),e[0]=0,_=s(r,0,n,257,ee,te,c,a,u,e,t),0!=_||0===a[0]?(_==X?f.msg="oversubscribed literal/length tree":-4!=_&&(f.msg="incomplete literal/length tree",_=X),_):(o(288),_=s(r,n,i,0,ne,ie,d,l,u,e,t),0!=_||0===l[0]&&n>257?(_==X?f.msg="oversubscribed distance tree":_==j?(f.msg="incomplete distance tree",_=X):-4!=_&&(f.msg="empty distance tree with lengths",_=X),_):0)}}function ae(){const e=this;let t,n,i,r,a=0,s=0,o=0,l=0,c=0,d=0,u=0,f=0,_=0,w=0;function p(e,t,n,i,r,a,s,o){let l,c,d,u,f,_,w,p,h,b,g,m,x,y,k,S;w=o.next_in_index,p=o.avail_in,f=s.bitb,_=s.bitk,h=s.write,b=h_;)p--,f|=(255&o.read_byte(w++))<<_,_+=8;if(l=f&g,c=n,d=i,S=3*(d+l),0!==(u=c[S]))for(;;){if(f>>=c[S+1],_-=c[S+1],16&u){for(u&=15,x=c[S+2]+(f&J[u]),f>>=u,_-=u;15>_;)p--,f|=(255&o.read_byte(w++))<<_,_+=8;for(l=f&m,c=r,d=a,S=3*(d+l),u=c[S];;){if(f>>=c[S+1],_-=c[S+1],16&u){for(u&=15;u>_;)p--,f|=(255&o.read_byte(w++))<<_,_+=8;if(y=c[S+2]+(f&J[u]),f>>=u,_-=u,b-=x,y>h){k=h-y;do{k+=s.end}while(0>k);if(u=s.end-k,x>u){if(x-=u,h-k>0&&u>h-k)do{s.win[h++]=s.win[k++]}while(0!=--u);else s.win.set(s.win.subarray(k,k+u),h),h+=u,k+=u,u=0;k=0}}else k=h-y,h-k>0&&2>h-k?(s.win[h++]=s.win[k++],s.win[h++]=s.win[k++],x-=2):(s.win.set(s.win.subarray(k,k+2),h),h+=2,k+=2,x-=2);if(h-k>0&&x>h-k)do{s.win[h++]=s.win[k++]}while(0!=--x);else s.win.set(s.win.subarray(k,k+x),h),h+=x,k+=x,x=0;break}if(64&u)return o.msg="invalid distance code",x=o.avail_in-p,x=x>_>>3?_>>3:x,p+=x,w-=x,_-=x<<3,s.bitb=f,s.bitk=_,o.avail_in=p,o.total_in+=w-o.next_in_index,o.next_in_index=w,s.write=h,X;l+=c[S+2],l+=f&J[u],S=3*(d+l),u=c[S]}break}if(64&u)return 32&u?(x=o.avail_in-p,x=x>_>>3?_>>3:x,p+=x,w-=x,_-=x<<3,s.bitb=f,s.bitk=_,o.avail_in=p,o.total_in+=w-o.next_in_index,o.next_in_index=w,s.write=h,1):(o.msg="invalid literal/length code",x=o.avail_in-p,x=x>_>>3?_>>3:x,p+=x,w-=x,_-=x<<3,s.bitb=f,s.bitk=_,o.avail_in=p,o.total_in+=w-o.next_in_index,o.next_in_index=w,s.write=h,X);if(l+=c[S+2],l+=f&J[u],S=3*(d+l),0===(u=c[S])){f>>=c[S+1],_-=c[S+1],s.win[h++]=c[S+2],b--;break}}else f>>=c[S+1],_-=c[S+1],s.win[h++]=c[S+2],b--}while(b>=258&&p>=10);return x=o.avail_in-p,x=x>_>>3?_>>3:x,p+=x,w-=x,_-=x<<3,s.bitb=f,s.bitk=_,o.avail_in=p,o.total_in+=w-o.next_in_index,o.next_in_index=w,s.write=h,0}e.init=(e,a,s,o,l,c)=>{t=0,u=e,f=a,i=s,_=o,r=l,w=c,n=null},e.proc=(e,h,b)=>{let g,m,x,y,k,S,z,v=0,E=0,D=0;for(D=h.next_in_index,y=h.avail_in,v=e.bitb,E=e.bitk,k=e.write,S=k=258&&y>=10&&(e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,b=p(u,f,i,_,r,w,e,h),D=h.next_in_index,y=h.avail_in,v=e.bitb,E=e.bitk,k=e.write,S=kE;){if(0===y)return e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,e.inflate_flush(h,b);b=0,y--,v|=(255&h.read_byte(D++))<>>=n[m+1],E-=n[m+1],x=n[m],0===x){l=n[m+2],t=6;break}if(16&x){c=15&x,a=n[m+2],t=2;break}if(!(64&x)){o=x,s=m/3+n[m+2];break}if(32&x){t=7;break}return t=9,h.msg="invalid literal/length code",b=X,e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,e.inflate_flush(h,b);case 2:for(g=c;g>E;){if(0===y)return e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,e.inflate_flush(h,b);b=0,y--,v|=(255&h.read_byte(D++))<>=g,E-=g,o=f,n=r,s=w,t=3;case 3:for(g=o;g>E;){if(0===y)return e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,e.inflate_flush(h,b);b=0,y--,v|=(255&h.read_byte(D++))<>=n[m+1],E-=n[m+1],x=n[m],16&x){c=15&x,d=n[m+2],t=4;break}if(!(64&x)){o=x,s=m/3+n[m+2];break}return t=9,h.msg="invalid distance code",b=X,e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,e.inflate_flush(h,b);case 4:for(g=c;g>E;){if(0===y)return e.bitb=v,e.bitk=E,h.avail_in=y,h.total_in+=D-h.next_in_index,h.next_in_index=D,e.write=k,e.inflate_flush(h,b);b=0,y--,v|=(255&h.read_byte(D++))<>=g,E-=g,t=5;case 5:for(z=k-d;0>z;)z+=e.end;for(;0!==a;){if(0===S&&(k==e.end&&0!==e.read&&(k=0,S=k7&&(E-=8,y++,D--),e.write=k,b=e.inflate_flush(h,b),k=e.write,S=k{}}re.inflate_trees_fixed=(e,t,n,i)=>(e[0]=9,t[0]=5,n[0]=Q,i[0]=$,0);const se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function oe(e,t){const n=this;let i,r=0,a=0,s=0,o=0;const l=[0],c=[0],d=new ae;let u=0,f=new Int32Array(4320);const w=new re;n.bitk=0,n.bitb=0,n.win=new _(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==r&&d.free(e),r=0,n.bitk=0,n.bitb=0,n.read=n.write=0},n.reset(e,null),n.inflate_flush=(e,t)=>{let i,r,a;return r=e.next_out_index,a=n.read,i=(a>n.write?n.end:n.write)-a,i>e.avail_out&&(i=e.avail_out),0!==i&&t==j&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.win.subarray(a,a+i),r),r+=i,a+=i,a==n.end&&(a=0,n.write==n.end&&(n.write=0),i=n.write-a,i>e.avail_out&&(i=e.avail_out),0!==i&&t==j&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.win.subarray(a,a+i),r),r+=i,a+=i),e.next_out_index=r,n.read=a,t},n.proc=(e,t)=>{let _,p,h,b,g,m,x,y;for(b=e.next_in_index,g=e.avail_in,p=n.bitb,h=n.bitk,m=n.write,x=mh;){if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);t=0,g--,p|=(255&e.read_byte(b++))<>>1){case 0:p>>>=3,h-=3,_=7&h,p>>>=_,h-=_,r=1;break;case 1:k=[],S=[],z=[[]],v=[[]],re.inflate_trees_fixed(k,S,z,v),d.init(k[0],S[0],z[0],0,v[0],0),p>>>=3,h-=3,r=6;break;case 2:p>>>=3,h-=3,r=3;break;case 3:return p>>>=3,h-=3,r=9,e.msg="invalid block type",t=X,n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t)}break;case 1:for(;32>h;){if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);t=0,g--,p|=(255&e.read_byte(b++))<>>16&65535)!=(65535&p))return r=9,e.msg="invalid stored block lengths",t=X,n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);a=65535&p,p=h=0,r=0!==a?2:0!==u?7:0;break;case 2:if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);if(0===x&&(m==n.end&&0!==n.read&&(m=0,x=mg&&(_=g),_>x&&(_=x),n.win.set(e.read_buf(b,_),m),b+=_,g-=_,m+=_,x-=_,0!=(a-=_))break;r=0!==u?7:0;break;case 3:for(;14>h;){if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);t=0,g--,p|=(255&e.read_byte(b++))<29||(_>>5&31)>29)return r=9,e.msg="too many length or distance symbols",t=X,n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);if(_=258+(31&_)+(_>>5&31),!i||i.length<_)i=[];else for(y=0;_>y;y++)i[y]=0;p>>>=14,h-=14,o=0,r=4;case 4:for(;4+(s>>>10)>o;){for(;3>h;){if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);t=0,g--,p|=(255&e.read_byte(b++))<>>=3,h-=3}for(;19>o;)i[se[o++]]=0;if(l[0]=7,_=w.inflate_trees_bits(i,l,c,f,e),0!=_)return(t=_)==X&&(i=null,r=9),n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);o=0,r=5;case 5:for(;_=s,258+(31&_)+(_>>5&31)>o;){let a,d;for(_=l[0];_>h;){if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);t=0,g--,p|=(255&e.read_byte(b++))<d)p>>>=_,h-=_,i[o++]=d;else{for(y=18==d?7:d-14,a=18==d?11:3;_+y>h;){if(0===g)return n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);t=0,g--,p|=(255&e.read_byte(b++))<>>=_,h-=_,a+=p&J[y],p>>>=y,h-=y,y=o,_=s,y+a>258+(31&_)+(_>>5&31)||16==d&&1>y)return i=null,r=9,e.msg="invalid bit length repeat",t=X,n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);d=16==d?i[y-1]:0;do{i[y++]=d}while(0!=--a);o=y}}if(c[0]=-1,E=[],D=[],F=[],R=[],E[0]=9,D[0]=6,_=s,_=w.inflate_trees_dynamic(257+(31&_),1+(_>>5&31),i,E,D,F,R,f,e),0!=_)return _==X&&(i=null,r=9),t=_,n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,n.inflate_flush(e,t);d.init(E[0],D[0],f,F[0],f,R[0]),r=6;case 6:if(n.bitb=p,n.bitk=h,e.avail_in=g,e.total_in+=b-e.next_in_index,e.next_in_index=b,n.write=m,1!=(t=d.proc(n,e,t)))return n.inflate_flush(e,t);if(t=0,d.free(e),b=e.next_in_index,g=e.avail_in,p=n.bitb,h=n.bitk,m=n.write,x=m{n.reset(e,null),n.win=null,f=null},n.set_dictionary=(e,t,i)=>{n.win.set(e.subarray(t,t+i),0),n.read=n.write=i},n.sync_point=()=>1==r?1:0}const le=13,ce=[0,0,255,255];function de(){const e=this;function t(e){return e&&e.istate?(e.total_in=e.total_out=0,e.msg=null,e.istate.mode=7,e.istate.blocks.reset(e,null),0):G}e.mode=0,e.method=0,e.was=[0],e.need=0,e.marker=0,e.wbits=0,e.inflateEnd=t=>(e.blocks&&e.blocks.free(t),e.blocks=null,0),e.inflateInit=(n,i)=>(n.msg=null,e.blocks=null,8>i||i>15?(e.inflateEnd(n),G):(e.wbits=i,n.istate.blocks=new oe(n,1<{let n,i;if(!e||!e.istate||!e.next_in)return G;const r=e.istate;for(t=4==t?j:0,n=j;;)switch(r.mode){case 0:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,8!=(15&(r.method=e.read_byte(e.next_in_index++)))){r.mode=le,e.msg="unknown compression method",r.marker=5;break}if(8+(r.method>>4)>r.wbits){r.mode=le,e.msg="invalid win size",r.marker=5;break}r.mode=1;case 1:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,i=255&e.read_byte(e.next_in_index++),((r.method<<8)+i)%31!=0){r.mode=le,e.msg="incorrect header check",r.marker=5;break}if(!(32&i)){r.mode=7;break}r.mode=2;case 2:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,r.need=(255&e.read_byte(e.next_in_index++))<<24&4278190080,r.mode=3;case 3:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,r.need+=(255&e.read_byte(e.next_in_index++))<<16&16711680,r.mode=4;case 4:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,r.need+=(255&e.read_byte(e.next_in_index++))<<8&65280,r.mode=5;case 5:return 0===e.avail_in?n:(n=t,e.avail_in--,e.total_in++,r.need+=255&e.read_byte(e.next_in_index++),r.mode=6,2);case 6:return r.mode=le,e.msg="need dictionary",r.marker=0,G;case 7:if(n=r.blocks.proc(e,n),n==X){r.mode=le,r.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,r.blocks.reset(e,r.was),r.mode=12;case 12:return e.avail_in=0,1;case le:return X;default:return G}},e.inflateSetDictionary=(e,t,n)=>{let i=0,r=n;if(!e||!e.istate||6!=e.istate.mode)return G;const a=e.istate;return r<1<{let n,i,r,a,s;if(!e||!e.istate)return G;const o=e.istate;if(o.mode!=le&&(o.mode=le,o.marker=0),0===(n=e.avail_in))return j;for(i=e.next_in_index,r=o.marker;0!==n&&4>r;)e.read_byte(i)==ce[r]?r++:r=0!==e.read_byte(i)?0:4-r,i++,n--;return e.total_in+=i-e.next_in_index,e.next_in_index=i,e.avail_in=n,o.marker=r,4!=r?X:(a=e.total_in,s=e.total_out,t(e),e.total_in=a,e.total_out=s,o.mode=7,0)},e.inflateSyncPoint=e=>e&&e.istate&&e.istate.blocks?e.istate.blocks.sync_point():G}function ue(){}ue.prototype={inflateInit(e){const t=this;return t.istate=new de,e||(e=15),t.istate.inflateInit(t,e)},inflate(e){const t=this;return t.istate?t.istate.inflate(t,e):G},inflateEnd(){const e=this;if(!e.istate)return G;const t=e.istate.inflateEnd(e);return e.istate=null,t},inflateSync(){const e=this;return e.istate?e.istate.inflateSync(e):G},inflateSetDictionary(e,t){const n=this;return n.istate?n.istate.inflateSetDictionary(n,e,t):G},read_byte(e){return this.next_in[e]},read_buf(e,t){return this.next_in.subarray(e,e+t)}};const fe=4294967295,_e=65535,we=67324752,pe=134695760,he=pe,be=33639248,ge=101010256,me=101075792,xe=117853008,ye=22,ke=21589,Se=2048,ze="/",ve=new o(2107,11,31),Ee=new o(1980,0,1),De=void 0,Fe="undefined",Re="function";class Te{constructor(e){return class extends z{constructor(t,n){const i=new e(n);super({transform(e,t){t.enqueue(i.append(e))},flush(e){const t=i.flush();t&&e.enqueue(t)}})}}}}let Ae=2;try{typeof R!=Fe&&R.hardwareConcurrency&&(Ae=R.hardwareConcurrency)}catch(e){}const Ce={chunkSize:524288,maxWorkers:Ae,terminateWorkerTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,workerScripts:De,CompressionStreamNative:typeof D!=Fe&&D,DecompressionStreamNative:typeof F!=Fe&&F},Ne=n.assign({},Ce);function Ue(){return Ne}function We(e){return s.max(e.chunkSize,64)}function Ie(e){const{baseURL:n,chunkSize:i,maxWorkers:r,terminateWorkerTimeout:a,useCompressionStream:s,useWebWorkers:o,Deflate:l,Inflate:c,CompressionStream:d,DecompressionStream:u,workerScripts:_}=e;if(Le("baseURL",n),Le("chunkSize",i),Le("maxWorkers",r),Le("terminateWorkerTimeout",a),Le("useCompressionStream",s),Le("useWebWorkers",o),l&&(Ne.CompressionStream=new Te(l)),c&&(Ne.DecompressionStream=new Te(c)),Le("CompressionStream",d),Le("DecompressionStream",u),_!==De){const{deflate:e,inflate:n}=_;if((e||n)&&(Ne.workerScripts||(Ne.workerScripts={})),e){if(!t.isArray(e))throw new f("workerScripts.deflate must be an array");Ne.workerScripts.deflate=e}if(n){if(!t.isArray(n))throw new f("workerScripts.inflate must be an array");Ne.workerScripts.inflate=n}}}function Le(e,t){t!==De&&(Ne[e]=t)}const Oe=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;Oe[e]=t}class Me{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,i=0|e.length;i>n;n++)t=t>>>8^Oe[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class Pe extends z{constructor(){let e;const t=new Me;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new _(4);new h(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}function He(e){if(typeof m==Fe){const t=new _((e=unescape(encodeURIComponent(e))).length);for(let n=0;n0&&t&&(e[n-1]=Be.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,i){for(void 0===i&&(i=[]);t>=32;t-=32)i.push(n),n=0;if(0===t)return i.concat(e);for(let r=0;r>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,a=Be.getPartial(r);return i.push(Be.partial(t+a&31,t+a>32?n:i.pop(),1)),i}},qe={bytes:{fromBits(e){const t=Be.bitLength(e)/8,n=new _(t);let i;for(let r=0;t>r;r++)3&r||(i=e[r/4]),n[r]=i>>>24,i<<=8;return n},toBits(e){const t=[];let n,i=0;for(n=0;n9007199254740991)throw new f("Cannot hash more than 2^53 - 1 bits");const a=new p(n);let s=0;for(let e=t.blockSize+i-(t.blockSize+i&t.blockSize-1);r>=e;e+=t.blockSize)t._block(a.subarray(16*s,16*(s+1))),s+=1;return n.splice(0,16*s),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=Be.concat(t,[Be.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,i){return e>19?e>39?e>59?e>79?void 0:t^n^i:t&n|t&i|n&i:t^n^i:t&n|~t&i}_S(e,t){return t<>>32-e}_block(e){const n=this,i=n._h,r=t(80);for(let t=0;16>t;t++)r[t]=e[t];let a=i[0],o=i[1],l=i[2],c=i[3],d=i[4];for(let e=0;79>=e;e++){16>e||(r[e]=n._S(1,r[e-3]^r[e-8]^r[e-14]^r[e-16]));const t=n._S(5,a)+n._f(e,o,l,c)+d+r[e]+n._key[s.floor(e/20)]|0;d=c,c=l,l=n._S(30,o),o=a,a=t}i[0]=i[0]+a|0,i[1]=i[1]+o|0,i[2]=i[2]+l|0,i[3]=i[3]+c|0,i[4]=i[4]+d|0}},Ze={getRandomValues(e){const t=new p(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let i,r=0;rnew Ke.hmacSha1(qe.bytes.toBits(e)),pbkdf2(e,t,n,i){if(n=n||1e4,0>i||0>n)throw new f("invalid params to pbkdf2");const r=1+(i>>5)<<2;let a,s,o,l,c;const d=new ArrayBuffer(r),u=new h(d);let _=0;const w=Be;for(t=qe.bytes.toBits(t),c=1;(r||1)>_;c++){for(a=s=e.encrypt(w.concat(t,[c])),o=1;n>o;o++)for(s=e.encrypt(s),l=0;l_&&or&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)i[0][t]=909522486^e[t],i[1][t]=1549556828^e[t];t._baseHash[0].update(i[0]),t._baseHash[1].update(i[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new f("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},Ye=typeof k!=Fe&&typeof k.getRandomValues==Re,Ge="Invalid password",Xe="Invalid signature",je="zipjs-abort-check-password";function Je(e){return Ye?k.getRandomValues(e):Ze.getRandomValues(e)}const Qe=16,$e={name:"PBKDF2"},et=n.assign({hash:{name:"HMAC"}},$e),tt=n.assign({iterations:1e3,hash:{name:"SHA-1"}},$e),nt=["deriveBits"],it=[8,12,16],rt=[16,24,32],at=10,st=[0,0,0,0],ot=typeof k!=Fe,lt=ot&&k.subtle,ct=ot&&typeof lt!=Fe,dt=qe.bytes,ut=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],i=t._tables[1],r=e.length;let a,s,o,l=1;if(4!==r&&6!==r&&8!==r)throw new f("invalid aes key size");for(t._key=[s=e.slice(0),o=[]],a=r;4*r+28>a;a++){let e=s[a-1];(a%r==0||8===r&&a%r==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],a%r==0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),s[a]=s[a-r]^e}for(let e=0;a;e++,a--){const t=s[3&e?a:a-4];o[e]=4>=a||4>e?t:i[0][n[t>>>24]]^i[1][n[t>>16&255]]^i[2][n[t>>8&255]]^i[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],i=t[4],r=[],a=[];let s,o,l,c;for(let e=0;256>e;e++)a[(r[e]=e<<1^283*(e>>7))^e]=e;for(let d=s=0;!n[d];d^=o||1,s=a[s]||1){let a=s^s<<1^s<<2^s<<3^s<<4;a=a>>8^255&a^99,n[d]=a,i[a]=d,c=r[l=r[o=r[d]]];let u=16843009*c^65537*l^257*o^16843008*d,f=257*r[a]^16843008*a;for(let n=0;4>n;n++)e[n][d]=f=f<<24^f>>>8,t[n][a]=u=u<<24^u>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new f("invalid aes block size");const n=this._key[t],i=n.length/4-2,r=[0,0,0,0],a=this._tables[t],s=a[0],o=a[1],l=a[2],c=a[3],d=a[4];let u,_,w,p=e[0]^n[0],h=e[t?3:1]^n[1],b=e[2]^n[2],g=e[t?1:3]^n[3],m=4;for(let e=0;i>e;e++)u=s[p>>>24]^o[h>>16&255]^l[b>>8&255]^c[255&g]^n[m],_=s[h>>>24]^o[b>>16&255]^l[g>>8&255]^c[255&p]^n[m+1],w=s[b>>>24]^o[g>>16&255]^l[p>>8&255]^c[255&h]^n[m+2],g=s[g>>>24]^o[p>>16&255]^l[h>>8&255]^c[255&b]^n[m+3],m+=4,p=u,h=_,b=w;for(let e=0;4>e;e++)r[t?3&-e:e]=d[p>>>24]<<24^d[h>>16&255]<<16^d[b>>8&255]<<8^d[255&g]^n[m++],u=p,p=h,h=b,b=g,g=u;return r}},ft=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,i=255&e;255===t?(t=0,255===n?(n=0,255===i?i=0:++i):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=i}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let i;if(!(i=t.length))return[];const r=Be.bitLength(t);for(let r=0;i>r;r+=4){this.incCounter(n);const i=e.encrypt(n);t[r]^=i[0],t[r+1]^=i[1],t[r+2]^=i[2],t[r+3]^=i[3]}return Be.clamp(t,r)}},_t=Ke.hmacSha1;let wt=ot&&ct&&typeof lt.importKey==Re,pt=ot&&ct&&typeof lt.deriveBits==Re;class ht extends z{constructor({password:e,rawPassword:t,signed:i,encryptionStrength:r,checkPasswordOnly:a}){super({start(){n.assign(this,{ready:new g((e=>this.resolveReady=e)),password:xt(e,t),signed:i,strength:r-1,pending:new _})},async transform(e,t){const n=this,{password:i,strength:r,resolveReady:s,ready:o}=n;i?(await(async(e,t,n,i)=>{const r=await mt(e,t,n,kt(i,0,it[t])),a=kt(i,it[t]);if(r[0]!=a[0]||r[1]!=a[1])throw new f(Ge)})(n,r,i,kt(e,0,it[r]+2)),e=kt(e,it[r]+2),a?t.error(new f(je)):s()):await o;const l=new _(e.length-at-(e.length-at)%Qe);t.enqueue(gt(n,e,l,0,at,!0))},async flush(e){const{signed:t,ctr:n,hmac:i,pending:r,ready:a}=this;if(i&&n){await a;const s=kt(r,0,r.length-at),o=kt(r,r.length-at);let l=new _;if(s.length){const e=zt(dt,s);i.update(e);const t=n.update(e);l=St(dt,t)}if(t){const e=kt(St(dt,i.digest()),0,at);for(let t=0;at>t;t++)if(e[t]!=o[t])throw new f(Xe)}e.enqueue(l)}}})}}class bt extends z{constructor({password:e,rawPassword:t,encryptionStrength:i}){let r;super({start(){n.assign(this,{ready:new g((e=>this.resolveReady=e)),password:xt(e,t),strength:i-1,pending:new _})},async transform(e,t){const n=this,{password:i,strength:r,resolveReady:a,ready:s}=n;let o=new _;i?(o=await(async(e,t,n)=>{const i=Je(new _(it[t]));return yt(i,await mt(e,t,n,i))})(n,r,i),a()):await s;const l=new _(o.length+e.length-e.length%Qe);l.set(o,0),t.enqueue(gt(n,e,l,o.length,0))},async flush(e){const{ctr:t,hmac:n,pending:i,ready:a}=this;if(n&&t){await a;let s=new _;if(i.length){const e=t.update(zt(dt,i));n.update(e),s=St(dt,e)}r.signature=St(dt,n.digest()).slice(0,at),e.enqueue(yt(s,r.signature))}}}),r=this}}function gt(e,t,n,i,r,a){const{ctr:s,hmac:o,pending:l}=e,c=t.length-r;let d;for(l.length&&(t=yt(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new _(t)).set(n,0)}return e})(n,c-c%Qe)),d=0;c-Qe>=d;d+=Qe){const e=zt(dt,kt(t,d,d+Qe));a&&o.update(e);const r=s.update(e);a||o.update(r),n.set(St(dt,r),d+i)}return e.pending=kt(t,d),n}async function mt(e,i,r,a){e.password=null;const s=await(async(e,t,n,i,r)=>{if(!wt)return Ke.importKey(t);try{return await lt.importKey("raw",t,n,!1,r)}catch(e){return wt=!1,Ke.importKey(t)}})(0,r,et,0,nt),o=await(async(e,t,n)=>{if(!pt)return Ke.pbkdf2(t,e.salt,tt.iterations,n);try{return await lt.deriveBits(e,t,n)}catch(i){return pt=!1,Ke.pbkdf2(t,e.salt,tt.iterations,n)}})(n.assign({salt:a},tt),s,8*(2*rt[i]+2)),l=new _(o),c=zt(dt,kt(l,0,rt[i])),d=zt(dt,kt(l,rt[i],2*rt[i])),u=kt(l,2*rt[i]);return n.assign(e,{keys:{key:c,authentication:d,passwordVerification:u},ctr:new ft(new ut(c),t.from(st)),hmac:new _t(d)}),u}function xt(e,t){return t===De?He(e):t}function yt(e,t){let n=e;return e.length+t.length&&(n=new _(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function kt(e,t,n){return e.subarray(t,n)}function St(e,t){return e.fromBits(t)}function zt(e,t){return e.toBits(t)}class vt extends z{constructor({password:e,passwordVerification:t,checkPasswordOnly:i}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Rt(this,e)},transform(e,t){const n=this;if(n.password){const t=Dt(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new f(Ge);e=e.subarray(12)}i?t.error(new f(je)):t.enqueue(Dt(n,e))}})}}class Et extends z{constructor({password:e,passwordVerification:t}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Rt(this,e)},transform(e,t){const n=this;let i,r;if(n.password){n.password=null;const t=Je(new _(12));t[11]=n.passwordVerification,i=new _(e.length+t.length),i.set(Ft(n,t),0),r=12}else i=new _(e.length),r=0;i.set(Ft(n,e),r),t.enqueue(i)}})}}function Dt(e,t){const n=new _(t.length);for(let i=0;i>>24]),r=~e.crcKey2.get(),e.keys=[n,i,r]}function At(e){const t=2|e.keys[2];return Ct(s.imul(t,1^t)>>>8)}function Ct(e){return 255&e}function Nt(e){return 4294967295&e}const Ut="deflate-raw";class Wt extends z{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:i}){super({});const{compressed:r,encrypted:a,useCompressionStream:s,zipCrypto:o,signed:l,level:c}=e,d=this;let u,f,_=Lt(super.readable);a&&!o||!l||(u=new Pe,_=Pt(_,u)),r&&(_=Mt(_,s,{level:c,chunkSize:t},i,n)),a&&(o?_=Pt(_,new Et(e)):(f=new bt(e),_=Pt(_,f))),Ot(d,_,(()=>{let e;a&&!o&&(e=f.signature),a&&!o||!l||(e=new h(u.value.buffer).getUint32(0)),d.signature=e}))}}class It extends z{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:i}){super({});const{zipCrypto:r,encrypted:a,signed:s,signature:o,compressed:l,useCompressionStream:c}=e;let d,u,_=Lt(super.readable);a&&(r?_=Pt(_,new vt(e)):(u=new ht(e),_=Pt(_,u))),l&&(_=Mt(_,c,{chunkSize:t},i,n)),a&&!r||!s||(d=new Pe,_=Pt(_,d)),Ot(this,_,(()=>{if((!a||r)&&s){const e=new h(d.value.buffer);if(o!=e.getUint32(0,!1))throw new f(Xe)}}))}}function Lt(e){return Pt(e,new z({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function Ot(e,t,i){t=Pt(t,new z({flush:i})),n.defineProperty(e,"readable",{get:()=>t})}function Mt(e,t,n,i,r){try{e=Pt(e,new(t&&i?i:r)(Ut,n))}catch(i){if(!t)return e;try{e=Pt(e,new r(Ut,n))}catch(t){return e}}return e}function Pt(e,t){return e.pipeThrough(t)}const Ht="data",Bt="close",qt="deflate",Vt="inflate";class Zt extends z{constructor(e,t){super({});const i=this,{codecType:r}=e;let a;r.startsWith(qt)?a=Wt:r.startsWith(Vt)&&(a=It);let s=0,o=0;const l=new a(e,t),c=super.readable,d=new z({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){n.assign(i,{inputSize:o})}}),u=new z({transform(e,t){e&&e.length&&(s+=e.length,t.enqueue(e))},flush(){const{signature:e}=l;n.assign(i,{signature:e,outputSize:s,inputSize:o})}});n.defineProperty(i,"readable",{get:()=>c.pipeThrough(d).pipeThrough(l).pipeThrough(u)})}}class Kt extends z{constructor(e){let t;super({transform:function n(i,r){if(t){const e=new _(t.length+i.length);e.set(t),e.set(i,t.length),i=e,t=null}i.length>e?(r.enqueue(i.slice(0,e)),n(i.slice(e),r)):t=i},flush(e){t&&t.length&&e.enqueue(t)}})}}let Yt=typeof T!=Fe;class Gt{constructor(e,{readable:t,writable:i},{options:r,config:a,streamOptions:s,useWebWorkers:o,transferStreams:l,scripts:c},d){const{signal:u}=s;return n.assign(e,{busy:!0,readable:t.pipeThrough(new Kt(a.chunkSize)).pipeThrough(new Xt(t,s),{signal:u}),writable:i,options:n.assign({},r),scripts:c,transferStreams:l,terminate:()=>new g((t=>{const{worker:n,busy:i}=e;n?(i?e.resolveTerminated=t:(n.terminate(),t()),e.interface=null):t()})),onTaskFinished(){const{resolveTerminated:t}=e;t&&(e.resolveTerminated=null,e.terminated=!0,e.worker.terminate(),t()),e.busy=!1,d(e)}}),(o&&Yt?Qt:Jt)(e,a)}}class Xt extends z{constructor(e,{onstart:t,onprogress:n,size:i,onend:r}){let a=0;super({async start(){t&&await jt(t,i)},async transform(e,t){a+=e.length,n&&await jt(n,a,i),t.enqueue(e)},async flush(){e.size=a,r&&await jt(r,a)}})}}async function jt(e,...t){try{await e(...t)}catch(e){}}function Jt(e,t){return{run:()=>(async({options:e,readable:t,writable:n,onTaskFinished:i},r)=>{try{const i=new Zt(e,r);await t.pipeThrough(i).pipeTo(n,{preventClose:!0,preventAbort:!0});const{signature:a,inputSize:s,outputSize:o}=i;return{signature:a,inputSize:s,outputSize:o}}finally{i()}})(e,t)}}function Qt(e,t){const{baseURL:i,chunkSize:r}=t;if(!e.interface){let a;try{a=((e,t,i)=>{const r={type:"module"};let a,s;typeof e==Re&&(e=e());try{a=new u(e,t)}catch(t){a=e}if($t)try{s=new T(a)}catch(e){$t=!1,s=new T(a,r)}else s=new T(a,r);return s.addEventListener("message",(e=>(async({data:e},t)=>{const{type:i,value:r,messageId:a,result:s,error:o}=e,{reader:l,writer:c,resolveResult:d,rejectResult:u,onTaskFinished:w}=t;try{if(o){const{message:e,stack:t,code:i,name:r}=o,a=new f(e);n.assign(a,{stack:t,code:i,name:r}),p(a)}else{if("pull"==i){const{value:e,done:n}=await l.read();tn({type:Ht,value:e,done:n,messageId:a},t)}i==Ht&&(await c.ready,await c.write(new _(r)),tn({type:"ack",messageId:a},t)),i==Bt&&p(null,s)}}catch(o){tn({type:Bt,messageId:a},t),p(o)}function p(e,t){e?u(e):d(t),c&&c.releaseLock(),w()}})(e,i))),s})(e.scripts[0],i,e)}catch(n){return Yt=!1,Jt(e,t)}n.assign(e,{worker:a,interface:{run:()=>(async(e,t)=>{let i,r;const a=new g(((e,t)=>{i=e,r=t}));n.assign(e,{reader:null,writer:null,resolveResult:i,rejectResult:r,result:a});const{readable:s,options:o,scripts:l}=e,{writable:c,closed:d}=(e=>{let t;const n=new g((e=>t=e));return{writable:new E({async write(t){const n=e.getWriter();await n.ready,await n.write(t),n.releaseLock()},close(){t()},abort:t=>e.getWriter().abort(t)}),closed:n}})(e.writable),u=tn({type:"start",scripts:l.slice(1),options:o,config:t,readable:s,writable:c},e);u||n.assign(e,{reader:s.getReader(),writer:c.getWriter()});const f=await a;return u||await c.getWriter().close(),await d,f})(e,{chunkSize:r})}})}return e.interface}let $t=!0,en=!0;function tn(e,{worker:t,writer:n,onTaskFinished:i,transferStreams:r}){try{const{value:n,readable:i,writable:a}=e,s=[];if(n&&(n.byteLength{const n=nn.find((e=>!e.busy));if(n)return on(n),new Gt(n,e,t,p);if(nn.length<_){const n={indexWorker:an};return an++,nn.push(n),new Gt(n,e,t,p)}return new g((n=>rn.push({resolve:n,stream:e,workerOptions:t})))})()).run();function p(e){if(rn.length){const[{resolve:t,stream:n,workerOptions:i}]=rn.splice(0,1);t(new Gt(e,n,i,p))}else e.worker?(on(e),((e,t)=>{const{config:n}=t,{terminateWorkerTimeout:i}=n;r.isFinite(i)&&i>=0&&(e.terminated?e.terminated=!1:e.terminateTimeout=setTimeout((async()=>{nn=nn.filter((t=>t!=e));try{await e.terminate()}catch(e){}}),i))})(e,t)):nn=nn.filter((t=>t!=e))}}function on(e){const{terminateTimeout:t}=e;t&&(clearTimeout(t),e.terminateTimeout=null)}const ln="HTTP error ",cn="HTTP Range not supported",dn="Writer iterator completed too soon",un="Range",fn="GET",_n="bytes",wn=65536,pn="writable";class hn{constructor(){this.size=0}init(){this.initialized=!0}}class bn extends hn{get readable(){const e=this,{chunkSize:t=wn}=e,n=new v({start(){this.chunkOffset=0},async pull(i){const{offset:r=0,size:a,diskNumberStart:o}=n,{chunkOffset:l}=this;i.enqueue(await Pn(e,r+l,s.min(t,a-l),o)),l+t>a?i.close():this.chunkOffset+=t}});return n}}class gn extends hn{constructor(){super();const e=this,t=new E({write:t=>e.writeUint8Array(t)});n.defineProperty(e,pn,{get:()=>t})}writeUint8Array(){}}class mn extends bn{constructor(e){super(),n.assign(this,{blob:e,size:e.size})}async readUint8Array(e,t){const n=this,i=e+t,r=e||it&&(a=a.slice(e,i)),new _(a)}}class xn extends hn{constructor(e){super();const t=new z,i=[];e&&i.push(["Content-Type",e]),n.defineProperty(this,pn,{get:()=>t.writable}),this.blob=new d(t.readable,{headers:i}).blob()}getData(){return this.blob}}class yn extends bn{constructor(e,t){super(),Sn(this,e,t)}async init(){await zn(this,Cn,Fn),super.init()}readUint8Array(e,t){return vn(this,e,t,Cn,Fn)}}class kn extends bn{constructor(e,t){super(),Sn(this,e,t)}async init(){await zn(this,Nn,Rn),super.init()}readUint8Array(e,t){return vn(this,e,t,Nn,Rn)}}function Sn(e,t,i){const{preventHeadRequest:r,useRangeHeader:a,forceRangeRequests:s,combineSizeEocd:o}=i;delete(i=n.assign({},i)).preventHeadRequest,delete i.useRangeHeader,delete i.forceRangeRequests,delete i.combineSizeEocd,delete i.useXHR,n.assign(e,{url:t,options:i,preventHeadRequest:r,useRangeHeader:a,forceRangeRequests:s,combineSizeEocd:o})}async function zn(e,t,n){const{url:i,preventHeadRequest:a,useRangeHeader:s,forceRangeRequests:o,combineSizeEocd:l}=e;if((e=>{const{baseURL:t}=Ue(),{protocol:n}=new u(e,t);return"http:"==n||"https:"==n})(i)&&(s||o)&&(void 0===a||a)){const i=await t(fn,e,En(e,l?-22:void 0));if(!o&&i.headers.get("Accept-Ranges")!=_n)throw new f(cn);{let a;l&&(e.eocdCache=new _(await i.arrayBuffer()));const s=i.headers.get("Content-Range");if(s){const e=s.trim().split(/\s*\/\s*/);if(e.length){const t=e[1];t&&"*"!=t&&(a=r(t))}}a===De?await An(e,t,n):e.size=a}}else await An(e,t,n)}async function vn(e,t,n,i,r){const{useRangeHeader:a,forceRangeRequests:s,eocdCache:o,size:l,options:c}=e;if(a||s){if(o&&t==l-ye&&n==ye)return o;const r=await i(fn,e,En(e,t,n));if(206!=r.status)throw new f(cn);return new _(await r.arrayBuffer())}{const{data:i}=e;return i||await r(e,c),new _(e.data.subarray(t,t+n))}}function En(e,t=0,i=1){return n.assign({},Dn(e),{[un]:_n+"="+(0>t?t:t+"-"+(t+i-1))})}function Dn({options:e}){const{headers:t}=e;if(t)return Symbol.iterator in t?n.fromEntries(t):t}async function Fn(e){await Tn(e,Cn)}async function Rn(e){await Tn(e,Nn)}async function Tn(e,t){const n=await t(fn,e,Dn(e));e.data=new _(await n.arrayBuffer()),e.size||(e.size=e.data.length)}async function An(e,t,n){if(e.preventHeadRequest)await n(e,e.options);else{const i=(await t("HEAD",e,Dn(e))).headers.get("Content-Length");i?e.size=r(i):await n(e,e.options)}}async function Cn(e,{options:t,url:i},r){const a=await fetch(i,n.assign({},t,{method:e,headers:r}));if(400>a.status)return a;throw 416==a.status?new f(cn):new f(ln+(a.statusText||a.status))}function Nn(e,{url:t},i){return new g(((r,a)=>{const s=new XMLHttpRequest;if(s.addEventListener("load",(()=>{if(400>s.status){const e=[];s.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach((t=>{const n=t.trim().split(/\s*:\s*/);n[0]=n[0].trim().replace(/^[a-z]|-[a-z]/g,(e=>e.toUpperCase())),e.push(n)})),r({status:s.status,arrayBuffer:()=>s.response,headers:new l(e)})}else a(416==s.status?new f(cn):new f(ln+(s.statusText||s.status)))}),!1),s.addEventListener("error",(e=>a(e.detail?e.detail.error:new f("Network error"))),!1),s.open(e,t),i)for(const e of n.entries(i))s.setRequestHeader(e[0],e[1]);s.responseType="arraybuffer",s.send()}))}class Un extends bn{constructor(e,t={}){super(),n.assign(this,{url:e,reader:t.useXHR?new kn(e,t):new yn(e,t)})}set size(e){}get size(){return this.reader.size}async init(){await this.reader.init(),super.init()}readUint8Array(e,t){return this.reader.readUint8Array(e,t)}}class Wn extends bn{constructor(e){super(),this.readers=e}async init(){const e=this,{readers:t}=e;e.lastDiskNumber=0,e.lastDiskOffset=0,await g.all(t.map((async(n,i)=>{await n.init(),i!=t.length-1&&(e.lastDiskOffset+=n.size),e.size+=n.size}))),super.init()}async readUint8Array(e,t,n=0){const i=this,{readers:r}=this;let a,o=n;-1==o&&(o=r.length-1);let l=e;for(;l>=r[o].size;)l-=r[o].size,o++;const c=r[o],d=c.size;if(l+t>d){const r=d-l;a=new _(t),a.set(await Pn(c,l,r)),a.set(await i.readUint8Array(e+r,t-r,n),r)}else a=await Pn(c,l,t);return i.lastDiskNumber=s.max(o,i.lastDiskNumber),a}}class In extends hn{constructor(e,t=4294967295){super();const i=this;let r,a,s;n.assign(i,{diskNumber:0,diskOffset:0,size:0,maxSize:t,availableSize:t});const o=new E({async write(t){const{availableSize:n}=i;if(s)t.lengtho})}}async function Ln(e,t){if(!e.init||e.initialized)return g.resolve();await e.init(t)}function On(e){return t.isArray(e)&&(e=new Wn(e)),e instanceof v&&(e={readable:e}),e}function Mn(e){e.writable===De&&typeof e.next==Re&&(e=new In(e)),e instanceof E&&(e={writable:e});const{writable:t}=e;return t.size===De&&(t.size=0),e instanceof In||n.assign(e,{diskNumber:0,diskOffset:0,availableSize:1/0,maxSize:1/0}),e}function Pn(e,t,n,i){return e.readUint8Array(t,n,i)}const Hn=Wn,Bn=In,qn="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");function Vn(e,t){return t&&"cp437"==t.trim().toLowerCase()?(e=>{{let t="";for(let n=0;nthis[t]=e[t]))}}const bi="File format is not recognized",gi="End of central directory not found",mi="End of Zip64 central directory locator not found",xi="Central directory header not found",yi="Local file header not found",ki="Zip64 extra field not found",Si="File contains encrypted entry",zi="Encryption method not supported",vi="Compression method not supported",Ei="Split zip file",Di="utf-8",Fi="cp437",Ri=[[Xn,fe],[jn,fe],[Jn,fe],[Qn,_e]],Ti={[_e]:{getValue:Hi,bytes:4},[fe]:{getValue:Bi,bytes:8}};class Ai{constructor(e,t={}){n.assign(this,{reader:On(e),options:t,config:Ue()})}async*getEntriesGenerator(e={}){const t=this;let{reader:i}=t;const{config:r}=t;if(await Ln(i),i.size!==De&&i.readUint8Array||(i=new mn(await new d(i.readable).blob()),await Ln(i)),i.size{const i=new _(4);var r;return r=t,qi(i).setUint32(0,r,!0),await a(22)||await a(s.min(1048582,n));async function a(t){const r=n-t,a=await Pn(e,r,t);for(let e=a.length-22;e>=0;e--)if(a[e]==i[0]&&a[e+1]==i[1]&&a[e+2]==i[2]&&a[e+3]==i[3])return{offset:r+e,buffer:a.slice(e,e+22).buffer}}})(i,ge,i.size);if(!a)throw Hi(qi(await Pn(i,0,4)))==pe?new f(Ei):new f(gi);const o=qi(a);let l=Hi(o,12),c=Hi(o,16);const u=a.offset,w=Pi(o,20),p=u+ye+w;let h=Pi(o,4);const b=i.lastDiskNumber||0;let g=Pi(o,6),m=Pi(o,8),x=0,y=0;if(c==fe||l==fe||m==_e||g==_e){const e=qi(await Pn(i,a.offset-20,20));if(Hi(e,0)==xe){c=Bi(e,8);let t=await Pn(i,c,56,-1),n=qi(t);const r=a.offset-20-56;if(Hi(n,0)!=me&&c!=r){const e=c;c=r,x=c-e,t=await Pn(i,c,56,-1),n=qi(t)}if(Hi(n,0)!=me)throw new f(mi);h==_e&&(h=Hi(n,16)),g==_e&&(g=Hi(n,20)),m==_e&&(m=Bi(n,32)),l==fe&&(l=Bi(n,40)),c-=l}}if(cc)throw new f(bi);let k=0,S=await Pn(i,c,l,g),z=qi(S);if(l){const e=a.offset-l;if(Hi(z,k)!=be&&c!=e){const t=c;c=e,x+=c-t,S=await Pn(i,c,l,g),z=qi(S)}}const v=a.offset-c-(i.lastDiskOffset||0);if(l==v||0>v||(l=v,S=await Pn(i,c,l,g),z=qi(S)),0>c||c>=i.size)throw new f(bi);const E=Ii(t,e,"filenameEncoding"),D=Ii(t,e,"commentEncoding");for(let a=0;m>a;a++){const o=new Ci(i,r,t.options);if(Hi(z,k)!=be)throw new f(xi);Ni(o,z,k+6);const l=!!o.bitFlag.languageEncodingFlag,c=k+46,d=c+o.filenameLength,u=d+o.extraFieldLength,_=Pi(z,k+4),w=!(_>>8),p=_>>8==3,h=S.subarray(c,d),b=Pi(z,k+32),g=u+b,v=S.subarray(u,g),F=l,R=l,T=Hi(z,k+38),A=w&&!(16&~Mi(z,k+38))||p&&!(16384&~(T>>16))||h.length&&47==h[h.length-1],C=p&&!(73&~(T>>16)),N=Hi(z,k+42)+x;n.assign(o,{versionMadeBy:_,msDosCompatible:w,compressedSize:0,uncompressedSize:0,commentLength:b,directory:A,offset:N,diskNumberStart:Pi(z,k+34),internalFileAttributes:Pi(z,k+36),externalFileAttributes:T,rawFilename:h,filenameUTF8:F,commentUTF8:R,rawExtraField:S.subarray(d,u),executable:C}),o.internalFileAttribute=o.internalFileAttributes,o.externalFileAttribute=o.externalFileAttributes;const U=Ii(t,e,"decodeText")||Vn,W=F?Di:E||Fi,I=R?Di:D||Fi;let L=U(h,W);L===De&&(L=Vn(h,W));let O=U(v,I);O===De&&(O=Vn(v,I)),n.assign(o,{rawComment:v,filename:L,comment:O,directory:A||L.endsWith(ze)}),y=s.max(N,y),Ui(o,o,z,k+6),o.zipCrypto=o.encrypted&&!o.extraFieldAES;const M=new hi(o);M.getData=(e,t)=>o.getData(e,M,t),k=g;const{onprogress:P}=e;if(P)try{await P(a+1,m,new hi(o))}catch(e){}yield M}const F=Ii(t,e,"extractPrependedData"),R=Ii(t,e,"extractAppendedData");return F&&(t.prependedData=y>0?await Pn(i,0,y):new _),t.comment=w?await Pn(i,u+ye,w):new _,R&&(t.appendedData=p>>8&255:w>>>24&255),signature:w,compressed:0!=c&&!k,encrypted:r.encrypted&&!k,useWebWorkers:Ii(r,i,"useWebWorkers"),useCompressionStream:Ii(r,i,"useCompressionStream"),transferStreams:Ii(r,i,"transferStreams"),checkPasswordOnly:T},config:d,streamOptions:{signal:R,size:D,onstart:C,onprogress:N,onend:U}};let I=0;try{({outputSize:I}=await sn({readable:F,writable:A},W))}catch(e){if(!T||e.message!=je)throw e}finally{const e=Ii(r,i,"preventClose");A.size+=I,e||A.locked||await A.getWriter().close()}return T?De:e.getData?e.getData():A}}function Ni(e,t,i){const r=e.rawBitFlag=Pi(t,i+2),a=!(1&~r),s=Hi(t,i+6);n.assign(e,{encrypted:a,version:Pi(t,i),bitFlag:{level:(6&r)>>1,dataDescriptor:!(8&~r),languageEncodingFlag:(r&Se)==Se},rawLastModDate:s,lastModDate:Li(s),filenameLength:Pi(t,i+22),extraFieldLength:Pi(t,i+24)})}function Ui(e,t,i,r,a){const{rawExtraField:s}=t,c=t.extraField=new l,d=qi(new _(s));let u=0;try{for(;u{t.zip64=!0;const n=qi(e.data),i=Ri.filter((([e,n])=>t[e]==n));for(let r=0,a=0;r{const r=qi(e.data),a=Mi(r,4);n.assign(e,{vendorVersion:Mi(r,0),vendorId:Mi(r,2),strength:a,originalCompressionMethod:i,compressionMethod:Pi(r,5)}),t.compressionMethod=e.compressionMethod})(g,t,w),t.extraFieldAES=g):t.compressionMethod=w;const m=c.get(10);m&&(((e,t)=>{const i=qi(e.data);let r,a=4;try{for(;a{const i=qi(e.data),r=Mi(i,0),a=[],s=[];n?(1&~r||(a.push($n),s.push(ei)),2&~r||(a.push(ti),s.push("rawLastAccessDate")),4&~r||(a.push(ni),s.push("rawCreationDate"))):5>e.data.length||(a.push($n),s.push(ei));let l=1;a.forEach(((n,r)=>{if(e.data.length>=l+4){const a=Hi(i,l);t[n]=e[n]=new o(1e3*a);const c=s[r];e[c]=a}l+=4}))})(x,t,a),t.extraFieldExtendedTimestamp=x);const y=c.get(6534);y&&(t.extraFieldUSDZ=y)}function Wi(e,t,i,r,a){const s=qi(e.data),o=new Me;o.append(a[i]);const l=qi(new _(4));l.setUint32(0,o.get(),!0);const c=Hi(s,1);n.assign(e,{version:Mi(s,0),[t]:Vn(e.data.subarray(5)),valid:!a.bitFlag.languageEncodingFlag&&c==Hi(l,0)}),e.valid&&(r[t]=e[t],r[t+"UTF8"]=!0)}function Ii(e,t,n){return t[n]===De?e.options[n]:t[n]}function Li(e){const t=(4294901760&e)>>16,n=65535&e;try{return new o(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}function Oi(e){return new o(r(e/a(1e4)-a(116444736e5)))}function Mi(e,t){return e.getUint8(t)}function Pi(e,t){return e.getUint16(t,!0)}function Hi(e,t){return e.getUint32(t,!0)}function Bi(e,t){return r(e.getBigUint64(t,!0))}function qi(e){return new h(e.buffer)}const Vi="File already exists",Zi="Zip file comment exceeds 64KB",Ki="File entry comment exceeds 64KB",Yi="File entry name exceeds 64KB",Gi="Version exceeds 65535",Xi="The strength must equal 1, 2, or 3",ji="Extra field type exceeds 65535",Ji="Extra field data exceeds 64KB",Qi="Zip64 is not supported (make sure 'keepOrder' is set to 'true')",$i="Undefined uncompressed size",er=new _([7,0,2,0,65,69,3,0,0]);let tr=0;const nr=[];class ir{constructor(e,t={}){const i=(e=Mn(e)).availableSize!==De&&e.availableSize>0&&e.availableSize!==1/0&&e.maxSize!==De&&e.maxSize>0&&e.maxSize!==1/0;n.assign(this,{writer:e,addSplitZipSignature:i,options:t,config:Ue(),files:new l,filenames:new c,offset:t.offset===De?e.writable.size:t.offset,pendingEntriesSize:0,pendingAddFileCalls:new c,bufferedWrites:0})}async add(e="",i,r={}){const l=this,{pendingAddFileCalls:c,config:u}=l;let b;trnr.push(e)));try{if(e=e.trim(),l.filenames.has(e))throw new f(Vi);return l.filenames.add(e),b=(async(e,i,r,l)=>{i=i.trim();const c=sr(e,l,oi),u=sr(e,l,ui,c?20:768),b=sr(e,l,wi);if(u>_e)throw new f(Gi);let m=sr(e,l,si,0);0===m&&(m=sr(e,l,ai,0)),!l.directory&&i.endsWith(ze)&&(l.directory=!0),sr(e,l,_i)?(i.endsWith(ze)||(i+=ze),0===m&&(m=c?16:1073741824)):c||0!==m||(m=b?493<<16:27525120);const x=sr(e,l,"encodeText",He);let y=x(i);if(y===De&&(y=He(i)),wr(y)>_e)throw new f(Yi);const k=l.comment||"";let S=x(k);if(S===De&&(S=He(k)),wr(S)>_e)throw new f(Ki);const v=sr(e,l,di,20);if(v>_e)throw new f(Gi);const E=sr(e,l,$n,new o),D=sr(e,l,ti),F=sr(e,l,ni);let R=sr(e,l,ri,0);0===R&&(R=sr(e,l,ii,0));const T=sr(e,l,"passThrough");let A,C;T||(A=sr(e,l,"password"),C=sr(e,l,"rawPassword"));const N=sr(e,l,"encryptionStrength",3),U=sr(e,l,fi),W=sr(e,l,"extendedTimestamp",!0),I=sr(e,l,"keepOrder",!0),L=sr(e,l,"level"),O=sr(e,l,"useWebWorkers"),M=sr(e,l,"bufferedWrite"),P=sr(e,l,"dataDescriptorSignature",!1),H=sr(e,l,"signal"),B=sr(e,l,"useUnicodeFileNames",!0),q=sr(e,l,"useCompressionStream"),V=sr(e,l,"compressionMethod");let Z=sr(e,l,"dataDescriptor",!0),K=sr(e,l,li);if(!U&&(A!==De||C!==De)&&(1>N||N>3))throw new f(Xi);let Y=new _;const{extraField:G}=l;if(G){let e=0,t=0;G.forEach((t=>e+=4+wr(t))),Y=new _(e),G.forEach(((e,n)=>{if(n>_e)throw new f(ji);if(wr(e)>_e)throw new f(Ji);fr(Y,new w([n]),t),fr(Y,new w([wr(e)]),t+2),fr(Y,e,t+4),t+=4+wr(e)}))}let X=0,j=0,J=0;if(T&&(({uncompressedSize:J}=l),J===De))throw new f($i);const Q=!0===K;r&&(r=On(r),await Ln(r),T?X=or(J):r.size===De?(Z=!0,(K||K===De)&&(K=!0,J=X=4294967296)):(J=r.size,X=or(J)));const{diskOffset:$,diskNumber:ee,maxSize:te}=e.writer,ne=Q||J>fe,ie=Q||X>fe,re=Q||e.offset+e.pendingEntriesSize-$>fe,ae=sr(e,l,"supportZip64SplitFile",!0)&&Q||ee+s.ceil(e.pendingEntriesSize/te)>_e;if(re||ne||ie||ae){if(!1===K||!I)throw new f(Qi);K=!0}K=K||!1;const se=sr(e,l,ci),{signature:oe}=l,le=(e=>{const{rawFilename:t,lastModDate:n,lastAccessDate:i,creationDate:r,level:a,zip64:o,zipCrypto:l,useUnicodeFileNames:c,dataDescriptor:d,directory:u,rawExtraField:f,encryptionStrength:w,extendedTimestamp:h,encrypted:b}=e;let{version:g,compressionMethod:m}=e;const x=!u&&(a>0||a===De&&0!==m);let y,k,S,z;if(b&&!l){y=new _(wr(er)+2);const e=_r(y);cr(e,0,39169),fr(y,er,2),lr(e,8,w)}else y=new _;if(h){S=new _(9+(i?4:0)+(r?4:0));const e=_r(S);cr(e,0,ke),cr(e,2,wr(S)-4),z=1+(i?2:0)+(r?4:0),lr(e,4,z);let t=5;dr(e,t,s.floor(n.getTime()/1e3)),t+=4,i&&(dr(e,t,s.floor(i.getTime()/1e3)),t+=4),r&&dr(e,t,s.floor(r.getTime()/1e3));try{k=new _(36);const e=_r(k),t=ar(n);cr(e,0,10),cr(e,2,32),cr(e,8,1),cr(e,10,24),ur(e,12,t),ur(e,20,ar(i)||t),ur(e,28,ar(r)||t)}catch(e){k=new _}}else k=S=new _;let v=0;c&&(v|=Se),d&&(v|=8),m===De&&(m=x?8:0),8==m&&(a>=1&&3>a&&(v|=6),a>=3&&5>a&&(v|=1),9===a&&(v|=2)),o&&(g=g>45?g:45),b&&(v|=1,l||(g=g>51?g:51,y[9]=m,m=99));const E=new _(26),D=_r(E);cr(D,0,g),cr(D,2,v),cr(D,4,m);const F=new p(1),R=_r(F);let T;T=Ee>n?Ee:n>ve?ve:n,cr(R,0,(T.getHours()<<6|T.getMinutes())<<5|T.getSeconds()/2),cr(R,2,(T.getFullYear()-1980<<4|T.getMonth()+1)<<5|T.getDate());const A=F[0];dr(D,6,A),cr(D,22,wr(t));const C=wr(y,S,k,f);cr(D,24,C);const N=new _(30+wr(t)+C);return dr(_r(N),0,we),fr(N,E,4),fr(N,t,30),fr(N,y,30+wr(t)),fr(N,S,30+wr(t,y)),fr(N,k,30+wr(t,y,S)),fr(N,f,30+wr(t,y,S,k)),{localHeaderArray:N,headerArray:E,headerView:D,lastModDate:n,rawLastModDate:A,encrypted:b,compressed:x,version:g,compressionMethod:m,extraFieldExtendedTimestampFlag:z,rawExtraFieldExtendedTimestamp:S,rawExtraFieldNTFS:k,rawExtraFieldAES:y,extraFieldLength:C}})(l=n.assign({},l,{rawFilename:y,rawComment:S,version:v,versionMadeBy:u,lastModDate:E,lastAccessDate:D,creationDate:F,rawExtraField:Y,zip64:K,zip64UncompressedSize:ne,zip64CompressedSize:ie,zip64Offset:re,zip64DiskNumberStart:ae,password:A,rawPassword:C,level:q||e.config.CompressionStream!==De||e.config.CompressionStreamNative!==De?L:0,useWebWorkers:O,encryptionStrength:N,extendedTimestamp:W,zipCrypto:U,bufferedWrite:M,keepOrder:I,useUnicodeFileNames:B,dataDescriptor:Z,dataDescriptorSignature:P,signal:H,msDosCompatible:c,internalFileAttribute:R,internalFileAttributes:R,externalFileAttribute:m,externalFileAttributes:m,useCompressionStream:q,passThrough:T,encrypted:!!(A&&wr(A)||C&&wr(C))||T&&se,signature:oe,compressionMethod:V})),ce=(e=>{const{zip64:t,dataDescriptor:n,dataDescriptorSignature:i}=e;let r,a=new _,s=0;return n&&(a=new _(t?i?24:20:i?16:12),r=_r(a),i&&(s=4,dr(r,0,he))),{dataDescriptorArray:a,dataDescriptorView:r,dataDescriptorOffset:s}})(l),de=wr(le.localHeaderArray,ce.dataDescriptorArray);let ue;j=de+X,e.options.usdz&&(j+=j+64),e.pendingEntriesSize+=j;try{ue=await(async(e,i,r,s,o)=>{const{files:l,writer:c}=e,{keepOrder:u,dataDescriptor:w,signal:p}=o,{headerInfo:b}=s,{usdz:m}=e.options,x=t.from(l.values()).pop();let y,k,S,v,E,D,F,R={};l.set(i,R);try{let t;u&&(t=x&&x.lock,R.lock=new g((e=>S=e))),!(o.bufferedWrite||e.writerLocked||e.bufferedWrites&&u)&&w||m?(D=c,await T()):(D=new z,F=new d(D.readable).blob(),D.writable.size=0,y=!0,e.bufferedWrites++,await Ln(c)),await Ln(D);const{writable:b}=c;let{diskOffset:k}=c;if(e.addSplitZipSignature){delete e.addSplitZipSignature;const t=new _(4);dr(_r(t),0,pe),await rr(b,t),e.offset+=4}m&&((e,t)=>{const{headerInfo:n}=e;let{localHeaderArray:i,extraFieldLength:r}=n,a=_r(i),s=64-(t+wr(i))%64;4>s&&(s+=64);const o=new _(s),l=_r(o);cr(l,0,6534),cr(l,2,s-2);const c=i;n.localHeaderArray=i=new _(wr(c)+s),fr(i,c),fr(i,o,wr(c)),a=_r(i),cr(a,28,r+s),e.metadataSize+=s})(s,e.offset-k),y||(await t,await A(b));const{diskNumber:C}=c;if(E=!0,R.diskNumberStart=C,R=await(async(e,t,{diskNumberStart:i,lock:r},s,o,l)=>{const{headerInfo:c,dataDescriptorInfo:d,metadataSize:u}=s,{localHeaderArray:f,headerArray:w,lastModDate:p,rawLastModDate:h,encrypted:b,compressed:g,version:m,compressionMethod:x,rawExtraFieldExtendedTimestamp:y,extraFieldExtendedTimestampFlag:k,rawExtraFieldNTFS:S,rawExtraFieldAES:z}=c,{dataDescriptorArray:v}=d,{rawFilename:E,lastAccessDate:D,creationDate:F,password:R,rawPassword:T,level:A,zip64:C,zip64UncompressedSize:N,zip64CompressedSize:U,zip64Offset:W,zip64DiskNumberStart:I,zipCrypto:L,dataDescriptor:O,directory:M,executable:P,versionMadeBy:H,rawComment:B,rawExtraField:q,useWebWorkers:V,onstart:Z,onprogress:K,onend:Y,signal:G,encryptionStrength:X,extendedTimestamp:j,msDosCompatible:J,internalFileAttributes:Q,externalFileAttributes:$,useCompressionStream:ee,passThrough:te}=l,ne={lock:r,versionMadeBy:H,zip64:C,directory:!!M,executable:!!P,filenameUTF8:!0,rawFilename:E,commentUTF8:!0,rawComment:B,rawExtraFieldExtendedTimestamp:y,rawExtraFieldNTFS:S,rawExtraFieldAES:z,rawExtraField:q,extendedTimestamp:j,msDosCompatible:J,internalFileAttributes:Q,externalFileAttributes:$,diskNumberStart:i};let{signature:ie,uncompressedSize:re}=l,ae=0;te||(re=0);const{writable:se}=t;if(e){e.chunkSize=We(o),await rr(se,f);const t=e.readable,n=t.size=e.size,i={options:{codecType:qt,level:A,rawPassword:T,password:R,encryptionStrength:X,zipCrypto:b&&L,passwordVerification:b&&L&&h>>8&255,signed:!te,compressed:g&&!te,encrypted:b&&!te,useWebWorkers:V,useCompressionStream:ee,transferStreams:!1},config:o,streamOptions:{signal:G,size:n,onstart:Z,onprogress:K,onend:Y}},r=await sn({readable:t,writable:se},i);ae=r.outputSize,te||(re=r.inputSize,ie=r.signature),se.size+=re}else await rr(se,f);let oe;if(C){let e=4;N&&(e+=8),U&&(e+=8),W&&(e+=8),I&&(e+=4),oe=new _(e)}else oe=new _;return((e,t)=>{const{signature:n,rawExtraFieldZip64:i,compressedSize:r,uncompressedSize:s,headerInfo:o,dataDescriptorInfo:l}=e,{headerView:c,encrypted:d}=o,{dataDescriptorView:u,dataDescriptorOffset:f}=l,{zip64:_,zip64UncompressedSize:w,zip64CompressedSize:p,zipCrypto:h,dataDescriptor:b}=t;if(d&&!h||n===De||(dr(c,10,n),b&&dr(u,f,n)),_){const e=_r(i);cr(e,0,1),cr(e,2,wr(i)-4);let t=4;w&&(dr(c,18,fe),ur(e,t,a(s)),t+=8),p&&(dr(c,14,fe),ur(e,t,a(r))),b&&(ur(u,f+4,a(r)),ur(u,f+12,a(s)))}else dr(c,14,r),dr(c,18,s),b&&(dr(u,f+4,r),dr(u,f+8,s))})({signature:ie,rawExtraFieldZip64:oe,compressedSize:ae,uncompressedSize:re,headerInfo:c,dataDescriptorInfo:d},l),O&&await rr(se,v),n.assign(ne,{uncompressedSize:re,compressedSize:ae,lastModDate:p,rawLastModDate:h,creationDate:F,lastAccessDate:D,encrypted:b,zipCrypto:L,size:u+ae,compressionMethod:x,version:m,headerArray:w,signature:ie,rawExtraFieldZip64:oe,extraFieldExtendedTimestampFlag:k,zip64UncompressedSize:N,zip64CompressedSize:U,zip64Offset:W,zip64DiskNumberStart:I}),ne})(r,D,R,s,e.config,o),E=!1,l.set(i,R),R.filename=i,y){await D.writable.getWriter().close();let e=await F;await t,await T(),v=!0,w||(e=await(async(e,t,n,{zipCrypto:i})=>{let r;r=await t.slice(0,26).arrayBuffer(),26!=r.byteLength&&(r=r.slice(0,26));const a=new h(r);return e.encrypted&&!i||dr(a,14,e.signature),e.zip64?(dr(a,18,fe),dr(a,22,fe)):(dr(a,18,e.compressedSize),dr(a,22,e.uncompressedSize)),await rr(n,new _(r)),t.slice(r.byteLength)})(R,e,b,o)),await A(b),R.diskNumberStart=c.diskNumber,k=c.diskOffset,await e.stream().pipeTo(b,{preventClose:!0,preventAbort:!0,signal:p}),b.size+=e.size,v=!1}if(R.offset=e.offset-k,R.zip64)((e,t)=>{const{rawExtraFieldZip64:n,offset:i,diskNumberStart:r}=e,{zip64UncompressedSize:s,zip64CompressedSize:o,zip64Offset:l,zip64DiskNumberStart:c}=t,d=_r(n);let u=4;s&&(u+=8),o&&(u+=8),l&&(ur(d,u,a(i)),u+=8),c&&dr(d,u,r)})(R,o);else if(R.offset>fe)throw new f(Qi);return e.offset+=R.size,R}catch(t){if(y&&v||!y&&E){if(e.hasCorruptedEntries=!0,t)try{t.corruptedEntry=!0}catch(e){}y?e.offset+=D.writable.size:e.offset=D.writable.size}throw l.delete(i),t}finally{y&&e.bufferedWrites--,S&&S(),k&&k()}async function T(){e.writerLocked=!0;const{lockWriter:t}=e;e.lockWriter=new g((t=>k=()=>{e.writerLocked=!1,t()})),await t}async function A(e){wr(b.localHeaderArray)>c.availableSize&&(c.availableSize=0,await rr(e,new _))}})(e,i,r,{headerInfo:le,dataDescriptorInfo:ce,metadataSize:de},l)}finally{e.pendingEntriesSize-=j}return n.assign(ue,{name:i,comment:k,extraField:G}),new hi(ue)})(l,e,i,r),c.add(b),await b}catch(t){throw l.filenames.delete(e),t}finally{c.delete(b);const e=nr.shift();e?e():tr--}}async close(e=new _,n={}){const{pendingAddFileCalls:i,writer:r}=this,{writable:o}=r;for(;i.size;)await g.allSettled(t.from(i));return await(async(e,n,i)=>{const{files:r,writer:o}=e,{diskOffset:l,writable:c}=o;let{diskNumber:d}=o,u=0,w=0,p=e.offset-l,h=r.size;for(const[,e]of r){const{rawFilename:t,rawExtraFieldZip64:n,rawExtraFieldAES:i,rawComment:r,rawExtraFieldNTFS:a,rawExtraField:o,extendedTimestamp:l,extraFieldExtendedTimestampFlag:c,lastModDate:d}=e;let u;if(l){u=new _(9);const e=_r(u);cr(e,0,ke),cr(e,2,5),lr(e,4,c),dr(e,5,s.floor(d.getTime()/1e3))}else u=new _;e.rawExtraFieldCDExtendedTimestamp=u,w+=46+wr(t,r,n,i,a,u,o)}const b=new _(w),g=_r(b);await Ln(o);let m=0;for(const[e,n]of t.from(r.values()).entries()){const{offset:t,rawFilename:a,rawExtraFieldZip64:s,rawExtraFieldAES:l,rawExtraFieldCDExtendedTimestamp:d,rawExtraFieldNTFS:f,rawExtraField:_,rawComment:w,versionMadeBy:p,headerArray:h,zip64:x,zip64UncompressedSize:y,zip64CompressedSize:k,zip64DiskNumberStart:S,zip64Offset:z,internalFileAttributes:v,externalFileAttributes:E,diskNumberStart:D,uncompressedSize:F,compressedSize:R}=n,T=wr(s,l,d,f,_);dr(g,u,be),cr(g,u+4,p);const A=_r(h);y||dr(A,18,F),k||dr(A,14,R),fr(b,h,u+6),cr(g,u+30,T),cr(g,u+32,wr(w)),cr(g,u+34,x&&S?_e:D),cr(g,u+36,v),E&&dr(g,u+38,E),dr(g,u+42,x&&z?fe:t),fr(b,a,u+46),fr(b,s,u+46+wr(a)),fr(b,l,u+46+wr(a,s)),fr(b,d,u+46+wr(a,s,l)),fr(b,f,u+46+wr(a,s,l,d)),fr(b,_,u+46+wr(a,s,l,d,f)),fr(b,w,u+46+wr(a)+T);const C=46+wr(a,w)+T;if(u-m>o.availableSize&&(o.availableSize=0,await rr(c,b.slice(m,u)),m=u),u+=C,i.onprogress)try{await i.onprogress(e+1,r.size,new hi(n))}catch(e){}}await rr(c,m?b.slice(m):b);let x=o.diskNumber;const{availableSize:y}=o;ye>y&&x++;let k=sr(e,i,li);if(p>fe||w>fe||h>_e||x>_e){if(!1===k)throw new f(Qi);k=!0}const S=new _(k?98:ye),z=_r(S);u=0,k&&(dr(z,0,me),ur(z,4,a(44)),cr(z,12,45),cr(z,14,45),dr(z,16,x),dr(z,20,d),ur(z,24,a(h)),ur(z,32,a(h)),ur(z,40,a(w)),ur(z,48,a(p)),dr(z,56,xe),ur(z,64,a(p)+a(w)),dr(z,72,x+1),sr(e,i,"supportZip64SplitFile",!0)&&(x=_e,d=_e),h=_e,p=fe,w=fe,u+=76),dr(z,u,ge),cr(z,u+4,x),cr(z,u+6,d),cr(z,u+8,h),cr(z,u+10,h),dr(z,u+12,w),dr(z,u+16,p);const v=wr(n);if(v){if(v>_e)throw new f(Zi);cr(z,u+20,v)}await rr(c,S),v&&await rr(c,n)})(this,e,n),sr(this,n,"preventClose")||await o.getWriter().close(),r.getData?r.getData():o}}async function rr(e,t){const n=e.getWriter();try{await n.ready,e.size+=wr(t),await n.write(t)}finally{n.releaseLock()}}function ar(e){if(e)return(a(e.getTime())+a(116444736e5))*a(1e4)}function sr(e,t,n,i){const r=t[n]===De?e.options[n]:t[n];return r===De?i:r}function or(e){return e+5*(s.floor(e/16383)+1)}function lr(e,t,n){e.setUint8(t,n)}function cr(e,t,n){e.setUint16(t,n,!0)}function dr(e,t,n){e.setUint32(t,n,!0)}function ur(e,t,n){e.setBigUint64(t,n,!0)}function fr(e,t,n){e.set(t,n)}function _r(e){return new h(e.buffer)}function wr(...e){let t=0;return e.forEach((e=>e&&(t+=e.length))),t}Ie({Deflate:function(e){const t=new Y,n=(i=e&&e.chunkSize?e.chunkSize:65536)+5*(s.floor(i/16383)+1);var i;const r=new _(n);let a=e?e.level:-1;void 0===a&&(a=-1),t.deflateInit(a),t.next_out=r,this.append=(e,i)=>{let a,s,o=0,l=0,c=0;const d=[];if(e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,a=t.deflate(0),0!=a)throw new f("deflating: "+t.msg);t.next_out_index&&(t.next_out_index==n?d.push(new _(r)):d.push(r.subarray(0,t.next_out_index))),c+=t.next_out_index,i&&t.next_in_index>0&&t.next_in_index!=o&&(i(t.next_in_index),o=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return d.length>1?(s=new _(c),d.forEach((e=>{s.set(e,l),l+=e.length}))):s=d[0]?new _(d[0]):new _,s}},this.flush=()=>{let e,i,a=0,s=0;const o=[];do{if(t.next_out_index=0,t.avail_out=n,e=t.deflate(4),1!=e&&0!=e)throw new f("deflating: "+t.msg);n-t.avail_out>0&&o.push(r.slice(0,t.next_out_index)),s+=t.next_out_index}while(t.avail_in>0||0===t.avail_out);return t.deflateEnd(),i=new _(s),o.forEach((e=>{i.set(e,a),a+=e.length})),i}},Inflate:function(e){const t=new ue,n=e&&e.chunkSize?s.floor(2*e.chunkSize):131072,i=new _(n);let r=!1;t.inflateInit(),t.next_out=i,this.append=(e,a)=>{const s=[];let o,l,c=0,d=0,u=0;if(0!==e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,0!==t.avail_in||r||(t.next_in_index=0,r=!0),o=t.inflate(0),r&&o===j){if(0!==t.avail_in)throw new f("inflating: bad input")}else if(0!==o&&1!==o)throw new f("inflating: "+t.msg);if((r||1===o)&&t.avail_in===e.length)throw new f("inflating: bad input");t.next_out_index&&(t.next_out_index===n?s.push(new _(i)):s.push(i.subarray(0,t.next_out_index))),u+=t.next_out_index,a&&t.next_in_index>0&&t.next_in_index!=c&&(a(t.next_in_index),c=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return s.length>1?(l=new _(u),s.forEach((e=>{l.set(e,d),d+=e.length}))):l=s[0]?new _(s[0]):new _,l}},this.flush=()=>{t.inflateEnd()}}}),e.BlobReader=mn,e.BlobWriter=xn,e.Data64URIReader=class extends bn{constructor(e){super();let t=e.length;for(;"="==e.charAt(t-1);)t--;const i=e.indexOf(",")+1;n.assign(this,{dataURI:e,dataStart:i,size:s.floor(.75*(t-i))})}readUint8Array(e,t){const{dataStart:n,dataURI:i}=this,r=new _(t),a=4*s.floor(e/3),o=atob(i.substring(a+n,4*s.ceil((e+t)/3)+n)),l=e-3*s.floor(a/4);for(let e=l;l+t>e;e++)r[e-l]=o.charCodeAt(e);return r}},e.Data64URIWriter=class extends gn{constructor(e){super(),n.assign(this,{data:"data:"+(e||"")+";base64,",pending:[]})}writeUint8Array(e){const t=this;let n=0,r=t.pending;const a=t.pending.length;for(t.pending="",n=0;n<3*s.floor((a+e.length)/3)-a;n++)r+=i.fromCharCode(e[n]);for(;n2?t.data+=S(r):t.pending=r}getData(){return this.data+S(this.pending)}},e.ERR_BAD_FORMAT=bi,e.ERR_CENTRAL_DIRECTORY_NOT_FOUND=xi,e.ERR_DUPLICATED_NAME=Vi,e.ERR_ENCRYPTED=Si,e.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=mi,e.ERR_EOCDR_NOT_FOUND=gi,e.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=ki,e.ERR_HTTP_RANGE=cn,e.ERR_INVALID_COMMENT=Zi,e.ERR_INVALID_ENCRYPTION_STRENGTH=Xi,e.ERR_INVALID_ENTRY_COMMENT=Ki,e.ERR_INVALID_ENTRY_NAME=Yi,e.ERR_INVALID_EXTRAFIELD_DATA=Ji,e.ERR_INVALID_EXTRAFIELD_TYPE=ji,e.ERR_INVALID_PASSWORD=Ge,e.ERR_INVALID_SIGNATURE=Xe,e.ERR_INVALID_VERSION=Gi,e.ERR_ITERATOR_COMPLETED_TOO_SOON=dn,e.ERR_LOCAL_FILE_HEADER_NOT_FOUND=yi,e.ERR_SPLIT_ZIP_FILE=Ei,e.ERR_UNDEFINED_UNCOMPRESSED_SIZE=$i,e.ERR_UNSUPPORTED_COMPRESSION=vi,e.ERR_UNSUPPORTED_ENCRYPTION=zi,e.ERR_UNSUPPORTED_FORMAT=Qi,e.HttpRangeReader=class extends Un{constructor(e,t={}){t.useRangeHeader=!0,super(e,t)}},e.HttpReader=Un,e.Reader=bn,e.SplitDataReader=Wn,e.SplitDataWriter=In,e.SplitZipReader=Hn,e.SplitZipWriter=Bn,e.TextReader=class extends mn{constructor(e){super(new b([e],{type:"text/plain"}))}},e.TextWriter=class extends xn{constructor(e){super(e),n.assign(this,{encoding:e,utf8:!e||"utf-8"==e.toLowerCase()})}async getData(){const{encoding:e,utf8:t}=this,i=await super.getData();if(i.text&&t)return i.text();{const t=new FileReader;return new g(((r,a)=>{n.assign(t,{onload:({target:e})=>r(e.result),onerror:()=>a(t.error)}),t.readAsText(i,e)}))}}},e.Uint8ArrayReader=class extends bn{constructor(e){super(),n.assign(this,{array:e,size:e.length})}readUint8Array(e,t){return this.array.slice(e,e+t)}},e.Uint8ArrayWriter=class extends gn{init(e=0){n.assign(this,{offset:0,array:new _(e)}),super.init()}writeUint8Array(e){const t=this;if(t.offset+e.length>t.array.length){const n=t.array;t.array=new _(n.length+e.length),t.array.set(n)}t.array.set(e,t.offset),t.offset+=e.length}getData(){return this.array}},e.Writer=gn,e.ZipReader=Ai,e.ZipReaderStream=class{constructor(e={}){const{readable:t,writable:n}=new z,i=new Ai(t,e).getEntriesGenerator();this.readable=new v({async pull(e){const{done:t,value:n}=await i.next();if(t)return e.close();const r={...n,readable:(()=>{const{readable:e,writable:t}=new z;if(n.getData)return n.getData(t),e})()};delete r.getData,e.enqueue(r)}}),this.writable=n}},e.ZipWriter=ir,e.ZipWriterStream=class{constructor(e={}){const{readable:t,writable:n}=new z;this.readable=t,this.zipWriter=new ir(n,e)}transform(e){const{readable:t,writable:n}=new z({flush:()=>{this.zipWriter.close()}});return this.zipWriter.add(e,t),{readable:this.readable,writable:n}}writable(e){const{readable:t,writable:n}=new z;return this.zipWriter.add(e,t),n}close(e,t={}){return this.zipWriter.close(e,t)}},e.configure=Ie,e.getMimeType=()=>"application/octet-stream",e.initReader=On,e.initStream=Ln,e.initWriter=Mn,e.readUint8Array=Pn,e.terminateWorkers=async()=>{await g.allSettled(nn.map((e=>(on(e),e.terminate()))))}})); - diff --git a/pkg/emscripten/libretro/libretro.css b/pkg/emscripten/libretro/libretro.css index 4d08dc2eb4..ec3d514e3d 100644 --- a/pkg/emscripten/libretro/libretro.css +++ b/pkg/emscripten/libretro/libretro.css @@ -81,12 +81,22 @@ } } -/** - * Disable the border around the player. - */ canvas.webplayer { border: none; outline: none; + width: 800px; + height: 600px; +} + +/** + * Hack to make emscripten stop messing with the canvas size while in fullscreen. + * Foiled again! + */ +:fullscreen canvas.webplayer { + min-width: 100vw; + max-width: 100vw; + min-height: 100vh; + max-height: 100vh; } textarea { diff --git a/pkg/emscripten/libretro/libretro.js b/pkg/emscripten/libretro/libretro.js index bce92f64f1..d4dcb946fb 100644 --- a/pkg/emscripten/libretro/libretro.js +++ b/pkg/emscripten/libretro/libretro.js @@ -17,58 +17,11 @@ var Module = { message_accum: "", retroArchSend: function(msg) { - let bytes = this.encoder.encode(msg + "\n"); - this.message_queue.push([bytes, 0]); + this.EmscriptenSendCommand(msg); }, retroArchRecv: function() { - let out = this.message_out.shift(); - if (out == null && this.message_accum != "") { - out = this.message_accum; - this.message_accum = ""; - } - return out; + return this.EmscriptenReceiveCommandReply(); }, - preRun: [ - function(module) { - function stdin() { - // Return ASCII code of character, or null if no input - while (module.message_queue.length > 0) { - var msg = module.message_queue[0][0]; - var index = module.message_queue[0][1]; - if (index >= msg.length) { - module.message_queue.shift(); - } else { - module.message_queue[0][1] = index + 1; - // assumption: msg is a uint8array - return msg[index]; - } - } - return null; - } - - function stdout(c) { - if (c == null) { - // flush - if (module.message_accum != "") { - module.message_out.push(module.message_accum); - module.message_accum = ""; - } - } else { - let s = String.fromCharCode(c); - if (s == "\n") { - if (module.message_accum != "") { - module.message_out.push(module.message_accum); - module.message_accum = ""; - } - } else { - module.message_accum = module.message_accum + s; - } - } - } - module.FS.init(stdin, stdout); - } - ], - postRun: [], onRuntimeInitialized: function() { appInitialized(); }, @@ -197,13 +150,13 @@ function setupFileSystem(backend) { // create a mountable filesystem that will server as a root mountpoint for browserfs var mfs = new BrowserFS.FileSystem.MountableFileSystem(); - // create an XmlHttpRequest filesystem for the bundled data + // create a ZipFS filesystem for the bundled data var zipfs = new BrowserFS.FileSystem.ZipFS(zipTOC); // create an XmlHttpRequest filesystem for core assets var xfs = new BrowserFS.FileSystem.XmlHttpRequest(".index-xhr", "assets/cores/"); console.log("WEBPLAYER: initializing filesystem: " + backend); - mfs.mount('/home/web_user/retroarch/', zipfs); + mfs.mount('/home/web_user/retroarch', zipfs); mfs.mount('/home/web_user/retroarch/userdata', afs); mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs); BrowserFS.initialize(mfs); diff --git a/retroarch.c b/retroarch.c index 4d170dc853..ff225e2415 100644 --- a/retroarch.c +++ b/retroarch.c @@ -86,6 +86,7 @@ #ifdef EMSCRIPTEN #include +#include "gfx/common/gl_common.h" #endif #ifdef HAVE_LIBNX @@ -5959,8 +5960,10 @@ int rarch_main(int argc, char *argv[], void *data) } #if defined(EMSCRIPTEN) -#include "gfx/common/gl_common.h" +#ifdef PROXY_TO_PTHREAD +bool platform_emscripten_is_window_hidden(void); +#endif #ifdef HAVE_RWEBAUDIO void RWebAudioRecalibrateTime(void); #endif @@ -5979,6 +5982,13 @@ void emscripten_mainloop(void) bool runloop_is_slowmotion = (runloop_flags & RUNLOOP_FLAG_SLOWMOTION) ? true : false; bool runloop_is_paused = (runloop_flags & RUNLOOP_FLAG_PAUSED) ? true : false; +#ifdef PROXY_TO_PTHREAD + // ensure the same behavior when requestAnimationFrame is emulated (i.e. pause when window is hidden) + // todo: is this an emscripten bug? + if (!input_driver_nonblock_state && platform_emscripten_is_window_hidden()) + return; +#endif + #ifdef HAVE_RWEBAUDIO RWebAudioRecalibrateTime(); #endif From c672730259560afe49aa88243d8a3395355200c6 Mon Sep 17 00:00:00 2001 From: BinBashBanana <51469593+BinBashBanana@users.noreply.github.com> Date: Thu, 6 Mar 2025 15:38:40 -0800 Subject: [PATCH 2/2] address issues --- Makefile.emscripten | 15 ++- dist-scripts/dist-cores.sh | 12 +-- emscripten/library_platform_emscripten.js | 8 +- frontend/drivers/platform_emscripten.c | 121 ++++++++++++---------- gfx/drivers_context/emscriptenwebgl_ctx.c | 9 +- pkg/emscripten/README.md | 6 +- 6 files changed, 86 insertions(+), 85 deletions(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index c2e8280803..fde53d7a23 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -56,6 +56,7 @@ HAVE_BSV_MOVIE = 1 HAVE_AL = 1 HAVE_CHD ?= 0 HAVE_NETPLAYDISCOVERY ?= 0 +HAVE_THREADS ?= 0 # WARNING -- READ BEFORE ENABLING # The rwebaudio driver is known to have several audio bugs, such as @@ -79,7 +80,6 @@ PROXY_TO_PTHREAD ?= 0 ASYNC ?= 0 LTO ?= 0 -PTHREAD ?= 0 PTHREAD_POOL_SIZE ?= 4 STACK_SIZE ?= 4194304 @@ -121,7 +121,8 @@ endif ifeq ($(PROXY_TO_PTHREAD), 1) LIBS += -s OFFSCREENCANVAS_SUPPORT DEFINES += -DPROXY_TO_PTHREAD -DEMSCRIPTEN_STACK_SIZE=$(STACK_SIZE) - override PTHREAD = 1 + override HAVE_THREADS = 1 + # use the default stack size for the browser thread; the RetroArch thread will be created with the specified stack size override STACK_SIZE = 4194304 else ifeq ($(HAVE_AL), 1) override ASYNC = 1 @@ -169,19 +170,16 @@ ifeq ($(HAVE_AL), 1) DEFINES += -DHAVE_AL endif -ifeq ($(PTHREAD), 1) +ifeq ($(HAVE_THREADS), 1) LDFLAGS += -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD_POOL_SIZE) CFLAGS += -pthread -s SHARED_MEMORY - HAVE_THREADS = 1 -else - HAVE_THREADS = 0 endif ifeq ($(ASYNC), 1) DEFINES += -DEMSCRIPTEN_ASYNCIFY LDFLAGS += -s ASYNCIFY=1 -s ASYNCIFY_STACK_SIZE=8192 ifeq ($(DEBUG), 1) - # LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE + LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE endif endif @@ -205,7 +203,8 @@ endif ifeq ($(DEBUG), 1) LDFLAGS += -O0 -g -gsource-map -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2 -s ASSERTIONS=1 - CFLAGS += -O0 -g -gsource-map + # -O0 in cflags gives "too many locals" errors + CFLAGS += -O1 -g -gsource-map else LDFLAGS += -O3 # WARNING: some optimizations can break some cores (ex: LTO breaks tyrquake) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index 5c91e70860..cc4a13143c 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -214,7 +214,7 @@ for f in `ls -v *_${platform}.${EXT}`; do fi if [ $PLATFORM = "emscripten" ]; then async=${ASYNC:-0} - pthread=${PTHREAD:-0} + have_threads=${HAVE_THREADS:-0} proxy_to_pthread=${PROXY_TO_PTHREAD:-0} gles3=${HAVE_OPENGLES3:-0} stack_mem=4194304 @@ -249,7 +249,7 @@ for f in `ls -v *_${platform}.${EXT}`; do echo LTO: $lto if [ $PLATFORM = "emscripten" ]; then echo ASYNC: $async - echo PTHREAD: $pthread + echo HAVE_THREADS: $have_threads echo PROXY_TO_PTHREAD: $proxy_to_pthread echo GLES3: $gles3 echo STACK_MEMORY: $stack_mem @@ -261,7 +261,7 @@ for f in `ls -v *_${platform}.${EXT}`; do if [ $MAKEFILE_GRIFFIN = "yes" ]; then make -C ../ -f Makefile.griffin platform=${platform} clean || exit 1 elif [ $PLATFORM = "emscripten" ]; then - make -C ../ -f Makefile.emscripten PTHREAD=$pthread ASYNC=$async LTO=$lto HAVE_OPENGLES3=$gles3 -j7 clean || exit 1 + make -C ../ -f Makefile.emscripten HAVE_THREADS=$have_threads ASYNC=$async LTO=$lto HAVE_OPENGLES3=$gles3 -j7 clean || exit 1 elif [ $PLATFORM = "unix" ]; then make -C ../ -f Makefile LINK=g++ LTO=$lto -j7 clean || exit 1 else @@ -273,8 +273,8 @@ for f in `ls -v *_${platform}.${EXT}`; do if [ $MAKEFILE_GRIFFIN = "yes" ]; then make -C ../ -f Makefile.griffin $OPTS platform=${platform} $whole_archive $big_stack -j3 || exit 1 elif [ $PLATFORM = "emscripten" ]; then - echo "BUILD COMMAND: make -C ../ -f Makefile.emscripten $OPTS LTO=$lto ASYNC=$async PTHREAD=$pthread PROXY_TO_PTHREAD=$proxy_to_pthread HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js" - make -C ../ -f Makefile.emscripten $OPTS LTO=$lto ASYNC=$async PTHREAD=$pthread PROXY_TO_PTHREAD=$proxy_to_pthread HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js || exit 1 + echo "BUILD COMMAND: make -C ../ -f Makefile.emscripten $OPTS LTO=$lto ASYNC=$async HAVE_THREADS=$have_threads PROXY_TO_PTHREAD=$proxy_to_pthread HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js" + make -C ../ -f Makefile.emscripten $OPTS LTO=$lto ASYNC=$async HAVE_THREADS=$have_threads PROXY_TO_PTHREAD=$proxy_to_pthread HAVE_OPENGLES3=$gles3 STACK_SIZE=$stack_mem INITIAL_HEAP=$heap_mem -j7 LIBRETRO=${name} TARGET=${name}_libretro.js || exit 1 elif [ $PLATFORM = "unix" ]; then make -C ../ -f Makefile LINK=g++ $whole_archive $big_stack -j3 || exit 1 elif [ $PLATFORM = "ctr" ]; then @@ -393,7 +393,7 @@ for f in `ls -v *_${platform}.${EXT}`; do if [ $MAKEFILE_GRIFFIN = "yes" ]; then make -C ../ -f Makefile.griffin platform=${platform} clean || exit 1 elif [ $PLATFORM = "emscripten" ]; then - make -C ../ -f Makefile.emscripten PTHREAD=$pthread ASYNC=$async LTO=$lto -j7 clean || exit 1 + make -C ../ -f Makefile.emscripten HAVE_THREADS=$have_threads ASYNC=$async LTO=$lto -j7 clean || exit 1 elif [ $PLATFORM = "unix" ]; then make -C ../ -f Makefile LTO=$lto -j7 clean || exit 1 else diff --git a/emscripten/library_platform_emscripten.js b/emscripten/library_platform_emscripten.js index 305cd69f98..fb86595c3c 100644 --- a/emscripten/library_platform_emscripten.js +++ b/emscripten/library_platform_emscripten.js @@ -3,7 +3,7 @@ var LibraryPlatformEmscripten = { $RPE: { powerStateChange: function(e) { - Module._update_power_state(true, Number.isFinite(e.target.dischargingTime) ? e.target.dischargingTime : 0x7FFFFFFF, e.target.level, e.target.charging); + _update_power_state(true, Number.isFinite(e.target.dischargingTime) ? e.target.dischargingTime : 0x7FFFFFFF, e.target.level, e.target.charging); }, updateMemoryUsage: function() { @@ -11,7 +11,7 @@ var LibraryPlatformEmscripten = { var used = BigInt(performance.memory.usedJSHeapSize || 0); var limit = BigInt(performance.memory.jsHeapSizeLimit || 0); // emscripten currently only supports passing 32 bit ints, so pack it - Module._update_memory_usage(Number(used & 0xFFFFFFFFn), Number(used >> 32n), Number(limit & 0xFFFFFFFFn), Number(limit >> 32n)); + _update_memory_usage(Number(used & 0xFFFFFFFFn), Number(used >> 32n), Number(limit & 0xFFFFFFFFn), Number(limit >> 32n)); setTimeout(RPE.updateMemoryUsage, 5000); }, command_queue: [], @@ -37,7 +37,7 @@ var LibraryPlatformEmscripten = { } // doubles are too big to pass as an argument to exported functions {{{ makeSetValue("dpr", "0", "window.devicePixelRatio", "double") }}}; - Module._update_canvas_dimensions(width, height, dpr); + _update_canvas_dimensions(width, height, dpr); }); RPE.observer.observe(Module.canvas); window.addEventListener("resize", function() { @@ -48,7 +48,7 @@ var LibraryPlatformEmscripten = { PlatformEmscriptenWatchWindowVisibility: function() { document.addEventListener("visibilitychange", function() { - Module._update_window_hidden(document.visibilityState == "hidden"); + _update_window_hidden(document.visibilityState == "hidden"); }, false); }, diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index ac27c0f9a6..6e1eafb539 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -63,8 +63,10 @@ #include #include #define PLATFORM_SETVAL(type, addr, val) emscripten_atomic_store_##type(addr, val) +#define PLATFORM_GETVAL(type, addr) emscripten_atomic_load_##type(addr) #else #define PLATFORM_SETVAL(type, addr, val) *addr = val +#define PLATFORM_GETVAL(type, addr) *addr #endif void emscripten_mainloop(void); @@ -73,39 +75,6 @@ void PlatformEmscriptenWatchWindowVisibility(void); void PlatformEmscriptenPowerStateInit(void); void PlatformEmscriptenMemoryUsageInit(void); -static bool command_flag = false; - -void PlatformEmscriptenCommandReply(const char *msg, size_t len) -{ - MAIN_THREAD_EM_ASM({ - var message = UTF8ToString($0, $1); - RPE.command_reply_queue.push(message); - }, msg, len); -} - -size_t PlatformEmscriptenCommandRead(char **into, size_t max_len) -{ - if (!command_flag) { return 0; } - return MAIN_THREAD_EM_ASM_INT({ - var next_command = RPE.command_queue.shift(); - var length = lengthBytesUTF8(next_command); - if (length > $2) { - console.error("[CMD] Command too long, skipping", next_command); - return 0; - } - stringToUTF8(next_command, $1, $2); - if (RPE.command_queue.length == 0) { - setValue($0, 0, 'i8'); - } - return length; - }, &command_flag, into, max_len); -} - -void PlatformEmscriptenCommandRaiseFlag() -{ - command_flag = true; -} - typedef struct { uint64_t memory_used; @@ -118,6 +87,7 @@ typedef struct volatile bool power_state_charging; volatile bool power_state_supported; volatile bool window_hidden; + volatile bool command_flag; } emscripten_platform_data_t; static emscripten_platform_data_t *emscripten_platform_data = NULL; @@ -288,27 +258,62 @@ void update_memory_usage(uint32_t used1, uint32_t used2, uint32_t limit1, uint32 PLATFORM_SETVAL(u64, &emscripten_platform_data->memory_limit, limit1 | ((uint64_t)limit2 << 32)); } +void PlatformEmscriptenCommandRaiseFlag() +{ + if (!emscripten_platform_data) + return; + emscripten_platform_data->command_flag = true; +} + /* platform specific c helpers */ +void PlatformEmscriptenCommandReply(const char *msg, size_t len) +{ + MAIN_THREAD_EM_ASM({ + var message = UTF8ToString($0, $1); + RPE.command_reply_queue.push(message); + }, msg, len); +} + +size_t PlatformEmscriptenCommandRead(char **into, size_t max_len) +{ + if (!emscripten_platform_data || !emscripten_platform_data->command_flag) + return 0; + return MAIN_THREAD_EM_ASM_INT({ + var next_command = RPE.command_queue.shift(); + var length = lengthBytesUTF8(next_command); + if (length > $2) { + console.error("[CMD] Command too long, skipping", next_command); + return 0; + } + stringToUTF8(next_command, $1, $2); + if (RPE.command_queue.length == 0) { + setValue($0, 0, 'i8'); + } + return length; + }, &emscripten_platform_data->command_flag, into, max_len); +} + void platform_emscripten_get_canvas_size(int *width, int *height) { - if (!emscripten_platform_data || - (emscripten_platform_data->canvas_width == 0 && emscripten_platform_data->canvas_height == 0)) - { - *width = 800; - *height = 600; - RARCH_ERR("[EMSCRIPTEN]: Could not get screen dimensions!\n"); - } - else - { - *width = emscripten_platform_data->canvas_width; - *height = emscripten_platform_data->canvas_height; - } + if (!emscripten_platform_data) + goto error; + + *width = PLATFORM_GETVAL(u32, &emscripten_platform_data->canvas_width); + *height = PLATFORM_GETVAL(u32, &emscripten_platform_data->canvas_height); + + if (*width != 0 || *height != 0) + return; + +error: + *width = 800; + *height = 600; + RARCH_ERR("[EMSCRIPTEN]: Could not get screen dimensions!\n"); } double platform_emscripten_get_dpr(void) { - return emscripten_platform_data->device_pixel_ratio; + return PLATFORM_GETVAL(f64, &emscripten_platform_data->device_pixel_ratio); } bool platform_emscripten_is_window_hidden(void) @@ -440,19 +445,22 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], static enum frontend_powerstate frontend_emscripten_get_powerstate(int *seconds, int *percent) { enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; + int level; if (!emscripten_platform_data || !emscripten_platform_data->power_state_supported) return ret; + level = PLATFORM_GETVAL(f32, &emscripten_platform_data->power_state_level); + if (!emscripten_platform_data->power_state_charging) ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - else if (emscripten_platform_data->power_state_level == 1) + else if (level == 1) ret = FRONTEND_POWERSTATE_CHARGED; else ret = FRONTEND_POWERSTATE_CHARGING; - *seconds = emscripten_platform_data->power_state_discharge_time; - *percent = (int)(emscripten_platform_data->power_state_level * 100); + *seconds = PLATFORM_GETVAL(u32, &emscripten_platform_data->power_state_discharge_time); + *percent = (int)(level * 100); return ret; } @@ -461,7 +469,7 @@ static uint64_t frontend_emscripten_get_total_mem(void) { if (!emscripten_platform_data) return 0; - return emscripten_platform_data->memory_limit; + return PLATFORM_GETVAL(u64, &emscripten_platform_data->memory_limit); } static uint64_t frontend_emscripten_get_free_mem(void) @@ -469,11 +477,11 @@ static uint64_t frontend_emscripten_get_free_mem(void) if (!emscripten_platform_data) return 0; #ifndef PROXY_TO_PTHREAD - uint64_t used = emscripten_platform_data->memory_used; + uint64_t used = PLATFORM_GETVAL(u64, &emscripten_platform_data->memory_used); #else uint64_t used = mallinfo().uordblks; #endif - return (emscripten_platform_data->memory_limit - used); + return (PLATFORM_GETVAL(u64, &emscripten_platform_data->memory_limit) - used); } /* program entry and startup */ @@ -510,7 +518,7 @@ void platform_emscripten_mount_filesystems(void) abort(); } } -#if false + if (fetch_manifest) { /* fetch_manifest should be a path to a manifest file. @@ -575,7 +583,6 @@ void platform_emscripten_mount_filesystems(void) fclose(file); free(line); } -#endif } #endif /* HAVE_WASMFS */ @@ -608,6 +615,10 @@ static void *main_pthread(void* arg) int main(int argc, char *argv[]) { int ret = 0; +#ifdef PROXY_TO_PTHREAD + pthread_attr_t attr; + pthread_t thread; +#endif // this never gets freed emscripten_platform_data = (emscripten_platform_data_t *)calloc(1, sizeof(emscripten_platform_data_t)); @@ -619,8 +630,6 @@ int main(int argc, char *argv[]) #ifdef PROXY_TO_PTHREAD _main_argc = argc; _main_argv = argv; - pthread_attr_t attr; - pthread_t thread; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&attr, EMSCRIPTEN_STACK_SIZE); diff --git a/gfx/drivers_context/emscriptenwebgl_ctx.c b/gfx/drivers_context/emscriptenwebgl_ctx.c index 43cf6ba200..171abd804f 100644 --- a/gfx/drivers_context/emscriptenwebgl_ctx.c +++ b/gfx/drivers_context/emscriptenwebgl_ctx.c @@ -62,13 +62,10 @@ static void gfx_ctx_emscripten_webgl_check_window(void *data, bool *quit, *quit = false; } +/* https://github.com/emscripten-core/emscripten/issues/17816#issuecomment-1249719343 */ static void gfx_ctx_emscripten_webgl_swap_buffers(void *data) { -#ifdef PROXY_TO_PTHREAD - emscripten_webgl_commit_frame(); -#else (void)data; -#endif } static void gfx_ctx_emscripten_webgl_get_video_size(void *data, @@ -134,11 +131,7 @@ static void *gfx_ctx_emscripten_webgl_init(void *video_driver) #endif attrs.minorVersion = 0; attrs.enableExtensionsByDefault = true; -#ifdef PROXY_TO_PTHREAD - attrs.explicitSwapControl = true; -#else attrs.explicitSwapControl = false; -#endif attrs.renderViaOffscreenBackBuffer = false; attrs.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_DISALLOW; diff --git a/pkg/emscripten/README.md b/pkg/emscripten/README.md index b9a78a4c47..57c7b20e38 100644 --- a/pkg/emscripten/README.md +++ b/pkg/emscripten/README.md @@ -83,11 +83,11 @@ emmake make -f Makefile platform=emscripten cp melonds_libretro_emscripten.bc ~/retroarch/RetroArch/libretro_emscripten.bc ``` -Now build the frontend with the pthreads env variable: (2 is the number of workers; this can be any integer, but many browsers limit the number of workers) +Now build the frontend with the pthreads env variable: ``` cd ~/retroarch/RetroArch -emmake make -f Makefile.emscripten LIBRETRO=melonds PTHREAD=2 && cp melonds_libretro.* pkg/emscripten/libretro +emmake make -f Makefile.emscripten LIBRETRO=melonds HAVE_THREADS=1 && cp melonds_libretro.* pkg/emscripten/libretro ``` Your resulting output will be located in: @@ -153,7 +153,7 @@ git clone https://github.com/libretro/RetroArch.git ~/retroarch/RetroArch cp ~/retroarch/libretro-fceumm/fceumm_libretro_emscripten.bc ~/retroarch/RetroArch/libretro_emscripten.bc cd ~/retroarch -emmake make -f Makefile.emscripten LIBRETRO=fceumm PROXY_TO_PTHREAD=1 PTHREAD=4 HAVE_WASMFS=1 ASYNC=0 HAVE_EGL=0 -j all +emmake make -f Makefile.emscripten LIBRETRO=fceumm PROXY_TO_PTHREAD=1 HAVE_WASMFS=1 -j all cp fceumm_libretro.{js,wasm} pkg/emscripten/libretro-thread ```