From 441606a4083cb8db1084b2dfca471f02f3a8f6d6 Mon Sep 17 00:00:00 2001 From: dadajian Date: Wed, 11 Feb 2026 09:43:22 -0600 Subject: [PATCH 1/2] feat(action): support resizing images on upload --- action.yml | 6 + action/dist/main.js | 125021 +++++++++++++++++++++++++++++---- action/dist/main.js.map | 2 +- action/package.json | 3 +- action/src/s3-operations.ts | 36 +- bun.lock | 157 +- 6 files changed, 112943 insertions(+), 12282 deletions(-) diff --git a/action.yml b/action.yml index 89e358c9..53e1ddea 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,12 @@ inputs: description: 'The GitHub access token' required: false default: ${{ github.token }} + resize-width: + description: 'Optional maximum width to resize images before upload' + required: false + resize-height: + description: 'Optional maximum height to resize images before upload' + required: false runs: using: 'node20' main: 'action/dist/main.js' diff --git a/action/dist/main.js b/action/dist/main.js index 70d8e264..856cd306 100644 --- a/action/dist/main.js +++ b/action/dist/main.js @@ -15,13 +15,13 @@ var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; -var __copyProps = (to, from, except, desc) => { +var __copyProps = (to2, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + if (!__hasOwnProp.call(to2, key) && key !== except) + __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } - return to; + return to2; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM @@ -42,7 +42,7 @@ var require_tunnel = __commonJS({ var https = require("https"); var events2 = require("events"); var assert = require("assert"); - var util = require("util"); + var util17 = require("util"); exports2.httpOverHttp = httpOverHttp2; exports2.httpsOverHttp = httpsOverHttp2; exports2.httpOverHttps = httpOverHttps2; @@ -92,7 +92,7 @@ var require_tunnel = __commonJS({ self2.removeSocket(socket); }); } - util.inherits(TunnelingAgent, events2.EventEmitter); + util17.inherits(TunnelingAgent, events2.EventEmitter); TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { var self2 = this; var options = mergeOptions({ request: req }, self2.options, toOptions(host, port, localAddress)); @@ -948,7 +948,7 @@ var require_util = __commonJS({ var assert = require("assert"); var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols(); var { IncomingMessage } = require("http"); - var stream2 = require("stream"); + var stream3 = require("stream"); var net = require("net"); var { Blob: Blob2 } = require("buffer"); var nodeUtil = require("util"); @@ -1122,24 +1122,24 @@ var require_util = __commonJS({ return null; } function isDestroyed(body) { - return body && !!(body.destroyed || body[kDestroyed] || stream2.isDestroyed?.(body)); + return body && !!(body.destroyed || body[kDestroyed] || stream3.isDestroyed?.(body)); } - function destroy(stream3, err) { - if (stream3 == null || !isStream2(stream3) || isDestroyed(stream3)) { + function destroy(stream4, err) { + if (stream4 == null || !isStream2(stream4) || isDestroyed(stream4)) { return; } - if (typeof stream3.destroy === "function") { - if (Object.getPrototypeOf(stream3).constructor === IncomingMessage) { - stream3.socket = null; + if (typeof stream4.destroy === "function") { + if (Object.getPrototypeOf(stream4).constructor === IncomingMessage) { + stream4.socket = null; } - stream3.destroy(err); + stream4.destroy(err); } else if (err) { queueMicrotask(() => { - stream3.emit("error", err); + stream4.emit("error", err); }); } - if (stream3.destroyed !== true) { - stream3[kDestroyed] = true; + if (stream4.destroyed !== true) { + stream4[kDestroyed] = true; } } var KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/; @@ -1169,7 +1169,7 @@ var require_util = __commonJS({ if (typeof headersValue === "string") { obj2[key] = headersValue; } else { - obj2[key] = Array.isArray(headersValue) ? headersValue.map((x6) => x6.toString("utf8")) : headersValue.toString("utf8"); + obj2[key] = Array.isArray(headersValue) ? headersValue.map((x7) => x7.toString("utf8")) : headersValue.toString("utf8"); } } } @@ -1238,13 +1238,13 @@ var require_util = __commonJS({ } } function isDisturbed(body) { - return !!(body && (stream2.isDisturbed(body) || body[kBodyUsed])); + return !!(body && (stream3.isDisturbed(body) || body[kBodyUsed])); } function isErrored(body) { - return !!(body && stream2.isErrored(body)); + return !!(body && stream3.isErrored(body)); } function isReadable2(body) { - return !!(body && stream2.isReadable(body)); + return !!(body && stream3.isReadable(body)); } function getSocketInfo(socket) { return { @@ -1306,8 +1306,8 @@ var require_util = __commonJS({ function isUSVString(val) { return hasIsWellFormed ? `${val}`.isWellFormed() : toUSVString(val) === `${val}`; } - function isTokenCharCode(c6) { - switch (c6) { + function isTokenCharCode(c7) { + switch (c7) { case 34: case 40: case 41: @@ -1327,7 +1327,7 @@ var require_util = __commonJS({ case 125: return false; default: - return c6 >= 33 && c6 <= 126; + return c7 >= 33 && c7 <= 126; } } function isValidHTTPToken(characters) { @@ -1452,10 +1452,10 @@ var require_diagnostics = __commonJS({ "../node_modules/undici/lib/core/diagnostics.js"(exports2, module2) { "use strict"; var diagnosticsChannel = require("diagnostics_channel"); - var util = require("util"); - var undiciDebugLog = util.debuglog("undici"); - var fetchDebuglog = util.debuglog("fetch"); - var websocketDebuglog = util.debuglog("websocket"); + var util17 = require("util"); + var undiciDebugLog = util17.debuglog("undici"); + var fetchDebuglog = util17.debuglog("fetch"); + var websocketDebuglog = util17.debuglog("websocket"); var isClientSet = false; var channels = { // Client @@ -2055,9 +2055,9 @@ var require_dispatcher_base = __commonJS({ } close(callback) { if (callback === void 0) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { this.close((err, data) => { - return err ? reject(err) : resolve2(data); + return err ? reject2(err) : resolve3(data); }); }); } @@ -2095,12 +2095,12 @@ var require_dispatcher_base = __commonJS({ err = null; } if (callback === void 0) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { this.destroy(err, (err2, data) => { return err2 ? ( /* istanbul ignore next: should never error */ - reject(err2) - ) : resolve2(data); + reject2(err2) + ) : resolve3(data); }); }); } @@ -2409,7 +2409,7 @@ var require_connect = __commonJS({ "use strict"; var net = require("net"); var assert = require("assert"); - var util = require_util(); + var util17 = require_util(); var { InvalidArgumentError, ConnectTimeoutError } = require_errors(); var timers = require_timers(); function noop2() { @@ -2478,7 +2478,7 @@ var require_connect = __commonJS({ if (!tls) { tls = require("tls"); } - servername = servername || options.servername || util.getServerName(host) || null; + servername = servername || options.servername || util17.getServerName(host) || null; const sessionKey = servername || hostname; assert(sessionKey); const session = customSession || sessionCache.get(sessionKey) || null; @@ -2577,7 +2577,7 @@ var require_connect = __commonJS({ message += ` (attempted address: ${opts.hostname}:${opts.port},`; } message += ` timeout: ${opts.timeout}ms)`; - util.destroy(socket, new ConnectTimeoutError(message)); + util17.destroy(socket, new ConnectTimeoutError(message)); } module2.exports = buildConnector; } @@ -2899,7 +2899,7 @@ var require_constants2 = __commonJS({ exports2.HEADER_CHARS.push(i6); } } - exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS.filter((c6) => c6 !== 44); + exports2.CONNECTION_TOKEN_CHARS = exports2.HEADER_CHARS.filter((c7) => c7 !== 44); exports2.MAJOR = exports2.NUM_MAP; exports2.MINOR = exports2.MAJOR; var HEADER_STATE; @@ -3647,44 +3647,44 @@ var require_webidl = __commonJS({ lowerBound = Math.pow(-2, bitLength) - 1; upperBound = Math.pow(2, bitLength - 1) - 1; } - let x6 = Number(V2); - if (x6 === 0) { - x6 = 0; + let x7 = Number(V2); + if (x7 === 0) { + x7 = 0; } if (opts?.enforceRange === true) { - if (Number.isNaN(x6) || x6 === Number.POSITIVE_INFINITY || x6 === Number.NEGATIVE_INFINITY) { + if (Number.isNaN(x7) || x7 === Number.POSITIVE_INFINITY || x7 === Number.NEGATIVE_INFINITY) { throw webidl.errors.exception({ header: "Integer conversion", message: `Could not convert ${webidl.util.Stringify(V2)} to an integer.` }); } - x6 = webidl.util.IntegerPart(x6); - if (x6 < lowerBound || x6 > upperBound) { + x7 = webidl.util.IntegerPart(x7); + if (x7 < lowerBound || x7 > upperBound) { throw webidl.errors.exception({ header: "Integer conversion", - message: `Value must be between ${lowerBound}-${upperBound}, got ${x6}.` + message: `Value must be between ${lowerBound}-${upperBound}, got ${x7}.` }); } - return x6; + return x7; } - if (!Number.isNaN(x6) && opts?.clamp === true) { - x6 = Math.min(Math.max(x6, lowerBound), upperBound); - if (Math.floor(x6) % 2 === 0) { - x6 = Math.floor(x6); + if (!Number.isNaN(x7) && opts?.clamp === true) { + x7 = Math.min(Math.max(x7, lowerBound), upperBound); + if (Math.floor(x7) % 2 === 0) { + x7 = Math.floor(x7); } else { - x6 = Math.ceil(x6); + x7 = Math.ceil(x7); } - return x6; + return x7; } - if (Number.isNaN(x6) || x6 === 0 && Object.is(0, x6) || x6 === Number.POSITIVE_INFINITY || x6 === Number.NEGATIVE_INFINITY) { + if (Number.isNaN(x7) || x7 === 0 && Object.is(0, x7) || x7 === Number.POSITIVE_INFINITY || x7 === Number.NEGATIVE_INFINITY) { return 0; } - x6 = webidl.util.IntegerPart(x6); - x6 = x6 % Math.pow(2, bitLength); - if (signedness === "signed" && x6 >= Math.pow(2, bitLength) - 1) { - return x6 - Math.pow(2, bitLength); + x7 = webidl.util.IntegerPart(x7); + x7 = x7 % Math.pow(2, bitLength); + if (signedness === "signed" && x7 >= Math.pow(2, bitLength) - 1) { + return x7 - Math.pow(2, bitLength); } - return x6; + return x7; }; webidl.util.IntegerPart = function(n6) { const r6 = Math.floor(Math.abs(n6)); @@ -3836,39 +3836,39 @@ var require_webidl = __commonJS({ return String(V2); }; webidl.converters.ByteString = function(V2, prefix, argument) { - const x6 = webidl.converters.DOMString(V2, prefix, argument); - for (let index = 0; index < x6.length; index++) { - if (x6.charCodeAt(index) > 255) { + const x7 = webidl.converters.DOMString(V2, prefix, argument); + for (let index = 0; index < x7.length; index++) { + if (x7.charCodeAt(index) > 255) { throw new TypeError( - `Cannot convert argument to a ByteString because the character at index ${index} has a value of ${x6.charCodeAt(index)} which is greater than 255.` + `Cannot convert argument to a ByteString because the character at index ${index} has a value of ${x7.charCodeAt(index)} which is greater than 255.` ); } } - return x6; + return x7; }; webidl.converters.USVString = toUSVString; webidl.converters.boolean = function(V2) { - const x6 = Boolean(V2); - return x6; + const x7 = Boolean(V2); + return x7; }; webidl.converters.any = function(V2) { return V2; }; webidl.converters["long long"] = function(V2, prefix, argument) { - const x6 = webidl.util.ConvertToInt(V2, 64, "signed", void 0, prefix, argument); - return x6; + const x7 = webidl.util.ConvertToInt(V2, 64, "signed", void 0, prefix, argument); + return x7; }; webidl.converters["unsigned long long"] = function(V2, prefix, argument) { - const x6 = webidl.util.ConvertToInt(V2, 64, "unsigned", void 0, prefix, argument); - return x6; + const x7 = webidl.util.ConvertToInt(V2, 64, "unsigned", void 0, prefix, argument); + return x7; }; webidl.converters["unsigned long"] = function(V2, prefix, argument) { - const x6 = webidl.util.ConvertToInt(V2, 32, "unsigned", void 0, prefix, argument); - return x6; + const x7 = webidl.util.ConvertToInt(V2, 32, "unsigned", void 0, prefix, argument); + return x7; }; webidl.converters["unsigned short"] = function(V2, prefix, argument, opts) { - const x6 = webidl.util.ConvertToInt(V2, 16, "unsigned", opts, prefix, argument); - return x6; + const x7 = webidl.util.ConvertToInt(V2, 16, "unsigned", opts, prefix, argument); + return x7; }; webidl.converters.ArrayBuffer = function(V2, prefix, argument, opts) { if (webidl.util.Type(V2) !== "Object" || !types2.isAnyArrayBuffer(V2)) { @@ -4038,10 +4038,10 @@ var require_util2 = __commonJS({ } function isValidReasonPhrase(statusText) { for (let i6 = 0; i6 < statusText.length; ++i6) { - const c6 = statusText.charCodeAt(i6); - if (!(c6 === 9 || // HTAB - c6 >= 32 && c6 <= 126 || // SP / VCHAR - c6 >= 128 && c6 <= 255)) { + const c7 = statusText.charCodeAt(i6); + if (!(c7 === 9 || // HTAB + c7 >= 32 && c7 <= 126 || // SP / VCHAR + c7 >= 128 && c7 <= 255)) { return false; } } @@ -4367,13 +4367,13 @@ var require_util2 = __commonJS({ function createDeferredPromise() { let res; let rej; - const promise = new Promise((resolve2, reject) => { - res = resolve2; - rej = reject; + const promise = new Promise((resolve3, reject2) => { + res = resolve3; + rej = reject2; }); return { promise, resolve: res, reject: rej }; } - function isAborted(fetchParams) { + function isAborted17(fetchParams) { return fetchParams.controller.state === "aborted"; } function isCancelled(fetchParams) { @@ -4533,8 +4533,8 @@ var require_util2 = __commonJS({ errorSteps(e6); } } - function isReadableStreamLike(stream2) { - return stream2 instanceof ReadableStream || stream2[Symbol.toStringTag] === "ReadableStream" && typeof stream2.tee === "function"; + function isReadableStreamLike(stream3) { + return stream3 instanceof ReadableStream || stream3[Symbol.toStringTag] === "ReadableStream" && typeof stream3.tee === "function"; } function readableStreamClose(controller) { try { @@ -4782,7 +4782,7 @@ var require_util2 = __commonJS({ }; var environmentSettingsObject = new EnvironmentSettingsObject(); module2.exports = { - isAborted, + isAborted: isAborted17, isCancelled, isValidEncodedURL, createDeferredPromise, @@ -5316,7 +5316,7 @@ var require_formdata_parser = __commonJS({ var require_body = __commonJS({ "../node_modules/undici/lib/web/fetch/body.js"(exports2, module2) { "use strict"; - var util = require_util(); + var util17 = require_util(); var { ReadableStreamFrom, isBlobLike, @@ -5350,20 +5350,20 @@ var require_body = __commonJS({ var streamRegistry; if (hasFinalizationRegistry) { streamRegistry = new FinalizationRegistry((weakRef) => { - const stream2 = weakRef.deref(); - if (stream2 && !stream2.locked && !isDisturbed(stream2) && !isErrored(stream2)) { - stream2.cancel("Response object has been garbage collected").catch(noop2); + const stream3 = weakRef.deref(); + if (stream3 && !stream3.locked && !isDisturbed(stream3) && !isErrored(stream3)) { + stream3.cancel("Response object has been garbage collected").catch(noop2); } }); } function extractBody(object, keepalive = false) { - let stream2 = null; + let stream3 = null; if (object instanceof ReadableStream) { - stream2 = object; + stream3 = object; } else if (isBlobLike(object)) { - stream2 = object.stream(); + stream3 = object.stream(); } else { - stream2 = new ReadableStream({ + stream3 = new ReadableStream({ async pull(controller) { const buffer = typeof source === "string" ? textEncoder.encode(source) : source; if (buffer.byteLength) { @@ -5376,7 +5376,7 @@ var require_body = __commonJS({ type: "bytes" }); } - assert(isReadableStreamLike(stream2)); + assert(isReadableStreamLike(stream3)); let action = null; let source = null; let length = null; @@ -5391,7 +5391,7 @@ var require_body = __commonJS({ source = new Uint8Array(object.slice()); } else if (ArrayBuffer.isView(object)) { source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength)); - } else if (util.isFormDataLike(object)) { + } else if (util17.isFormDataLike(object)) { const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, "0")}`; const prefix = `--${boundary}\r Content-Disposition: form-data`; @@ -5450,19 +5450,19 @@ Content-Type: ${value.type || "application/octet-stream"}\r if (keepalive) { throw new TypeError("keepalive"); } - if (util.isDisturbed(object) || object.locked) { + if (util17.isDisturbed(object) || object.locked) { throw new TypeError( "Response body object should not be disturbed or locked" ); } - stream2 = object instanceof ReadableStream ? object : ReadableStreamFrom(object); + stream3 = object instanceof ReadableStream ? object : ReadableStreamFrom(object); } - if (typeof source === "string" || util.isBuffer(source)) { + if (typeof source === "string" || util17.isBuffer(source)) { length = Buffer.byteLength(source); } if (action != null) { let iterator2; - stream2 = new ReadableStream({ + stream3 = new ReadableStream({ async start() { iterator2 = action(object)[Symbol.asyncIterator](); }, @@ -5474,7 +5474,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r controller.byobRequest?.respond(0); }); } else { - if (!isErrored(stream2)) { + if (!isErrored(stream3)) { const buffer = new Uint8Array(value); if (buffer.byteLength) { controller.enqueue(buffer); @@ -5489,12 +5489,12 @@ Content-Type: ${value.type || "application/octet-stream"}\r type: "bytes" }); } - const body = { stream: stream2, source, length }; + const body = { stream: stream3, source, length }; return [body, type]; } function safelyExtractBody(object, keepalive = false) { if (object instanceof ReadableStream) { - assert(!util.isDisturbed(object), "The body has already been consumed."); + assert(!util17.isDisturbed(object), "The body has already been consumed."); assert(!object.locked, "The stream is locked."); } return extractBody(object, keepalive); @@ -5514,7 +5514,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r } } function bodyMixinMethods(instance) { - const methods = { + const methods19 = { blob() { return consumeBody(this, (bytes) => { let mimeType = bodyMimeType(this); @@ -5572,7 +5572,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r }, instance); } }; - return methods; + return methods19; } function mixinBody(prototype) { Object.assign(prototype.prototype, bodyMixinMethods(prototype)); @@ -5601,7 +5601,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r } function bodyUnusable(object) { const body = object[kState].body; - return body != null && (body.stream.locked || util.isDisturbed(body.stream)); + return body != null && (body.stream.locked || util17.isDisturbed(body.stream)); } function parseJSONFromBytes(bytes) { return JSON.parse(utf8DecodeBytes(bytes)); @@ -5631,7 +5631,7 @@ var require_client_h1 = __commonJS({ "../node_modules/undici/lib/dispatcher/client-h1.js"(exports2, module2) { "use strict"; var assert = require("assert"); - var util = require_util(); + var util17 = require_util(); var { channels } = require_diagnostics(); var timers = require_timers(); var { @@ -5679,11 +5679,11 @@ var require_client_h1 = __commonJS({ kResume, kHTTPContext } = require_symbols(); - var constants3 = require_constants2(); + var constants4 = require_constants2(); var EMPTY_BUF = Buffer.alloc(0); var FastBuffer = Buffer[Symbol.species]; - var addListener = util.addListener; - var removeAllListeners = util.removeAllListeners; + var addListener = util17.addListener; + var removeAllListeners = util17.removeAllListeners; var extractBody; async function lazyllhttp() { const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0; @@ -5751,7 +5751,7 @@ var require_client_h1 = __commonJS({ constructor(client, socket, { exports: exports3 }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0); this.llhttp = exports3; - this.ptr = this.llhttp.llhttp_alloc(constants3.TYPE.RESPONSE); + this.ptr = this.llhttp.llhttp_alloc(constants4.TYPE.RESPONSE); this.client = client; this.socket = socket; this.timeout = null; @@ -5846,22 +5846,22 @@ var require_client_h1 = __commonJS({ currentBufferRef = null; } const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr; - if (ret2 === constants3.ERROR.PAUSED_UPGRADE) { + if (ret2 === constants4.ERROR.PAUSED_UPGRADE) { this.onUpgrade(data.slice(offset)); - } else if (ret2 === constants3.ERROR.PAUSED) { + } else if (ret2 === constants4.ERROR.PAUSED) { this.paused = true; socket.unshift(data.slice(offset)); - } else if (ret2 !== constants3.ERROR.OK) { + } else if (ret2 !== constants4.ERROR.OK) { const ptr = llhttp.llhttp_get_error_reason(this.ptr); let message = ""; if (ptr) { const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0); message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")"; } - throw new HTTPParserError(message, constants3.ERROR[ret2], data.slice(offset)); + throw new HTTPParserError(message, constants4.ERROR[ret2], data.slice(offset)); } } catch (err) { - util.destroy(socket, err); + util17.destroy(socket, err); } } destroy() { @@ -5908,13 +5908,13 @@ var require_client_h1 = __commonJS({ } const key = this.headers[len - 2]; if (key.length === 10) { - const headerName = util.bufferToLowerCasedHeaderName(key); + const headerName = util17.bufferToLowerCasedHeaderName(key); if (headerName === "keep-alive") { this.keepAlive += buf.toString(); } else if (headerName === "connection") { this.connection += buf.toString(); } - } else if (key.length === 14 && util.bufferToLowerCasedHeaderName(key) === "content-length") { + } else if (key.length === 14 && util17.bufferToLowerCasedHeaderName(key) === "content-length") { this.contentLength += buf.toString(); } this.trackHeader(buf.length); @@ -5922,7 +5922,7 @@ var require_client_h1 = __commonJS({ trackHeader(len) { this.headersSize += len; if (this.headersSize >= this.headersMaxSize) { - util.destroy(this.socket, new HeadersOverflowError()); + util17.destroy(this.socket, new HeadersOverflowError()); } } onUpgrade(head) { @@ -5953,7 +5953,7 @@ var require_client_h1 = __commonJS({ try { request4.onUpgrade(statusCode, headers, socket); } catch (err) { - util.destroy(socket, err); + util17.destroy(socket, err); } client[kResume](); } @@ -5969,11 +5969,11 @@ var require_client_h1 = __commonJS({ assert(!this.upgrade); assert(this.statusCode < 200); if (statusCode === 100) { - util.destroy(socket, new SocketError("bad response", util.getSocketInfo(socket))); + util17.destroy(socket, new SocketError("bad response", util17.getSocketInfo(socket))); return -1; } if (upgrade && !request4.upgrade) { - util.destroy(socket, new SocketError("bad upgrade", util.getSocketInfo(socket))); + util17.destroy(socket, new SocketError("bad upgrade", util17.getSocketInfo(socket))); return -1; } assert(this.timeoutType === TIMEOUT_HEADERS); @@ -6002,7 +6002,7 @@ var require_client_h1 = __commonJS({ this.headers = []; this.headersSize = 0; if (this.shouldKeepAlive && client[kPipelining]) { - const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null; + const keepAliveTimeout = this.keepAlive ? util17.parseKeepAliveTimeout(this.keepAlive) : null; if (keepAliveTimeout != null) { const timeout = Math.min( keepAliveTimeout - client[kKeepAliveTimeoutThreshold], @@ -6033,7 +6033,7 @@ var require_client_h1 = __commonJS({ socket[kBlocking] = false; client[kResume](); } - return pause ? constants3.ERROR.PAUSED : 0; + return pause ? constants4.ERROR.PAUSED : 0; } onBody(buf) { const { client, socket, statusCode, maxResponseSize } = this; @@ -6050,12 +6050,12 @@ var require_client_h1 = __commonJS({ } assert(statusCode >= 200); if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) { - util.destroy(socket, new ResponseExceededMaxSizeError()); + util17.destroy(socket, new ResponseExceededMaxSizeError()); return -1; } this.bytesRead += buf.length; if (request4.onData(buf) === false) { - return constants3.ERROR.PAUSED; + return constants4.ERROR.PAUSED; } } onMessageComplete() { @@ -6082,21 +6082,21 @@ var require_client_h1 = __commonJS({ return; } if (request4.method !== "HEAD" && contentLength && bytesRead !== parseInt(contentLength, 10)) { - util.destroy(socket, new ResponseContentLengthMismatchError()); + util17.destroy(socket, new ResponseContentLengthMismatchError()); return -1; } request4.onComplete(headers); client[kQueue][client[kRunningIdx]++] = null; if (socket[kWriting]) { assert(client[kRunning] === 0); - util.destroy(socket, new InformationalError("reset")); - return constants3.ERROR.PAUSED; + util17.destroy(socket, new InformationalError("reset")); + return constants4.ERROR.PAUSED; } else if (!shouldKeepAlive) { - util.destroy(socket, new InformationalError("reset")); - return constants3.ERROR.PAUSED; + util17.destroy(socket, new InformationalError("reset")); + return constants4.ERROR.PAUSED; } else if (socket[kReset] && client[kRunning] === 0) { - util.destroy(socket, new InformationalError("reset")); - return constants3.ERROR.PAUSED; + util17.destroy(socket, new InformationalError("reset")); + return constants4.ERROR.PAUSED; } else if (client[kPipelining] == null || client[kPipelining] === 1) { setImmediate(() => client[kResume]()); } else { @@ -6109,15 +6109,15 @@ var require_client_h1 = __commonJS({ if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { assert(!paused, "cannot be paused while waiting for headers"); - util.destroy(socket, new HeadersTimeoutError()); + util17.destroy(socket, new HeadersTimeoutError()); } } else if (timeoutType === TIMEOUT_BODY) { if (!paused) { - util.destroy(socket, new BodyTimeoutError()); + util17.destroy(socket, new BodyTimeoutError()); } } else if (timeoutType === TIMEOUT_KEEP_ALIVE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]); - util.destroy(socket, new InformationalError("socket idle timeout")); + util17.destroy(socket, new InformationalError("socket idle timeout")); } } async function connectH1(client, socket) { @@ -6153,7 +6153,7 @@ var require_client_h1 = __commonJS({ parser2.onMessageComplete(); return; } - util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this))); + util17.destroy(this, new SocketError("other side closed", util17.getSocketInfo(this))); }); addListener(socket, "close", function() { const client2 = this[kClient]; @@ -6165,7 +6165,7 @@ var require_client_h1 = __commonJS({ this[kParser].destroy(); this[kParser] = null; } - const err = this[kError] || new SocketError("closed", util.getSocketInfo(this)); + const err = this[kError] || new SocketError("closed", util17.getSocketInfo(this)); client2[kSocket] = null; client2[kHTTPContext] = null; if (client2.destroyed) { @@ -6173,12 +6173,12 @@ var require_client_h1 = __commonJS({ const requests = client2[kQueue].splice(client2[kRunningIdx]); for (let i6 = 0; i6 < requests.length; i6++) { const request4 = requests[i6]; - util.errorRequest(client2, request4, err); + util17.errorRequest(client2, request4, err); } } else if (client2[kRunning] > 0 && err.code !== "UND_ERR_INFO") { const request4 = client2[kQueue][client2[kRunningIdx]]; client2[kQueue][client2[kRunningIdx]++] = null; - util.errorRequest(client2, request4, err); + util17.errorRequest(client2, request4, err); } client2[kPendingIdx] = client2[kRunningIdx]; assert(client2[kRunning] === 0); @@ -6219,7 +6219,7 @@ var require_client_h1 = __commonJS({ if (client[kRunning] > 0 && (request4.upgrade || request4.method === "CONNECT")) { return true; } - if (client[kRunning] > 0 && util.bodyLength(request4.body) !== 0 && (util.isStream(request4.body) || util.isAsyncIterable(request4.body) || util.isFormDataLike(request4.body))) { + if (client[kRunning] > 0 && util17.bodyLength(request4.body) !== 0 && (util17.isStream(request4.body) || util17.isAsyncIterable(request4.body) || util17.isFormDataLike(request4.body))) { return true; } } @@ -6259,7 +6259,7 @@ var require_client_h1 = __commonJS({ const { method, path: path7, host, upgrade, blocking, reset } = request4; let { body, headers, contentLength } = request4; const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH"; - if (util.isFormDataLike(body)) { + if (util17.isFormDataLike(body)) { if (!extractBody) { extractBody = require_body().extractBody; } @@ -6269,13 +6269,13 @@ var require_client_h1 = __commonJS({ } body = bodyStream.stream; contentLength = bodyStream.length; - } else if (util.isBlobLike(body) && request4.contentType == null && body.type) { + } else if (util17.isBlobLike(body) && request4.contentType == null && body.type) { headers.push("content-type", body.type); } if (body && typeof body.read === "function") { body.read(0); } - const bodyLength = util.bodyLength(body); + const bodyLength = util17.bodyLength(body); contentLength = bodyLength ?? contentLength; if (contentLength === null) { contentLength = request4.contentLength; @@ -6285,7 +6285,7 @@ var require_client_h1 = __commonJS({ } if (shouldSendContentLength(method) && contentLength > 0 && request4.contentLength !== null && request4.contentLength !== contentLength) { if (client[kStrictContentLength]) { - util.errorRequest(client, request4, new RequestContentLengthMismatchError()); + util17.errorRequest(client, request4, new RequestContentLengthMismatchError()); return false; } process.emitWarning(new RequestContentLengthMismatchError()); @@ -6295,14 +6295,14 @@ var require_client_h1 = __commonJS({ if (request4.aborted || request4.completed) { return; } - util.errorRequest(client, request4, err || new RequestAbortedError()); - util.destroy(body); - util.destroy(socket, new InformationalError("aborted")); + util17.errorRequest(client, request4, err || new RequestAbortedError()); + util17.destroy(body); + util17.destroy(socket, new InformationalError("aborted")); }; try { request4.onConnect(abort); } catch (err) { - util.errorRequest(client, request4, err); + util17.errorRequest(client, request4, err); } if (request4.aborted) { return false; @@ -6359,17 +6359,17 @@ upgrade: ${upgrade}\r } if (!body || bodyLength === 0) { writeBuffer(abort, null, client, request4, socket, contentLength, header, expectsPayload); - } else if (util.isBuffer(body)) { + } else if (util17.isBuffer(body)) { writeBuffer(abort, body, client, request4, socket, contentLength, header, expectsPayload); - } else if (util.isBlobLike(body)) { + } else if (util17.isBlobLike(body)) { if (typeof body.stream === "function") { writeIterable(abort, body.stream(), client, request4, socket, contentLength, header, expectsPayload); } else { writeBlob(abort, body, client, request4, socket, contentLength, header, expectsPayload); } - } else if (util.isStream(body)) { + } else if (util17.isStream(body)) { writeStream(abort, body, client, request4, socket, contentLength, header, expectsPayload); - } else if (util.isIterable(body)) { + } else if (util17.isIterable(body)) { writeIterable(abort, body, client, request4, socket, contentLength, header, expectsPayload); } else { assert(false); @@ -6389,7 +6389,7 @@ upgrade: ${upgrade}\r this.pause(); } } catch (err) { - util.destroy(this, err); + util17.destroy(this, err); } }; const onDrain = function() { @@ -6426,9 +6426,9 @@ upgrade: ${upgrade}\r } writer.destroy(err); if (err && (err.code !== "UND_ERR_INFO" || err.message !== "reset")) { - util.destroy(body, err); + util17.destroy(body, err); } else { - util.destroy(body); + util17.destroy(body); } }; body.on("data", onData).on("end", onFinished).on("error", onFinished).on("close", onClose); @@ -6457,7 +6457,7 @@ upgrade: ${upgrade}\r socket.write(`${header}\r `, "latin1"); } - } else if (util.isBuffer(body)) { + } else if (util17.isBuffer(body)) { assert(contentLength === body.byteLength, "buffer body must have content length"); socket.cork(); socket.write(`${header}content-length: ${contentLength}\r @@ -6509,12 +6509,12 @@ upgrade: ${upgrade}\r cb2(); } } - const waitForDrain = () => new Promise((resolve2, reject) => { + const waitForDrain = () => new Promise((resolve3, reject2) => { assert(callback === null); if (socket[kError]) { - reject(socket[kError]); + reject2(socket[kError]); } else { - callback = resolve2; + callback = resolve3; } }); socket.on("close", onDrain).on("drain", onDrain); @@ -6652,7 +6652,7 @@ var require_client_h2 = __commonJS({ "use strict"; var assert = require("assert"); var { pipeline } = require("stream"); - var util = require_util(); + var util17 = require_util(); var { RequestContentLengthMismatchError, RequestAbortedError, @@ -6726,37 +6726,37 @@ var require_client_h2 = __commonJS({ session[kOpenStreams] = 0; session[kClient] = client; session[kSocket] = socket; - util.addListener(session, "error", onHttp2SessionError); - util.addListener(session, "frameError", onHttp2FrameError); - util.addListener(session, "end", onHttp2SessionEnd); - util.addListener(session, "goaway", onHTTP2GoAway); - util.addListener(session, "close", function() { + util17.addListener(session, "error", onHttp2SessionError); + util17.addListener(session, "frameError", onHttp2FrameError); + util17.addListener(session, "end", onHttp2SessionEnd); + util17.addListener(session, "goaway", onHTTP2GoAway); + util17.addListener(session, "close", function() { const { [kClient]: client2 } = this; const { [kSocket]: socket2 } = client2; - const err = this[kSocket][kError] || this[kError] || new SocketError("closed", util.getSocketInfo(socket2)); + const err = this[kSocket][kError] || this[kError] || new SocketError("closed", util17.getSocketInfo(socket2)); client2[kHTTP2Session] = null; if (client2.destroyed) { assert(client2[kPending] === 0); const requests = client2[kQueue].splice(client2[kRunningIdx]); for (let i6 = 0; i6 < requests.length; i6++) { const request4 = requests[i6]; - util.errorRequest(client2, request4, err); + util17.errorRequest(client2, request4, err); } } }); session.unref(); client[kHTTP2Session] = session; socket[kHTTP2Session] = session; - util.addListener(socket, "error", function(err) { + util17.addListener(socket, "error", function(err) { assert(err.code !== "ERR_TLS_CERT_ALTNAME_INVALID"); this[kError] = err; this[kClient][kOnError](err); }); - util.addListener(socket, "end", function() { - util.destroy(this, new SocketError("other side closed", util.getSocketInfo(this))); + util17.addListener(socket, "end", function() { + util17.destroy(this, new SocketError("other side closed", util17.getSocketInfo(this))); }); - util.addListener(socket, "close", function() { - const err = this[kError] || new SocketError("closed", util.getSocketInfo(this)); + util17.addListener(socket, "close", function() { + const err = this[kError] || new SocketError("closed", util17.getSocketInfo(this)); client[kSocket] = null; if (this[kHTTP2Session] != null) { this[kHTTP2Session].destroy(err); @@ -6819,12 +6819,12 @@ var require_client_h2 = __commonJS({ } } function onHttp2SessionEnd() { - const err = new SocketError("other side closed", util.getSocketInfo(this[kSocket])); + const err = new SocketError("other side closed", util17.getSocketInfo(this[kSocket])); this.destroy(err); - util.destroy(this[kSocket], err); + util17.destroy(this[kSocket], err); } function onHTTP2GoAway(code) { - const err = this[kError] || new SocketError(`HTTP/2: "GOAWAY" frame received with code ${code}`, util.getSocketInfo(this)); + const err = this[kError] || new SocketError(`HTTP/2: "GOAWAY" frame received with code ${code}`, util17.getSocketInfo(this)); const client = this[kClient]; client[kSocket] = null; client[kHTTPContext] = null; @@ -6832,11 +6832,11 @@ var require_client_h2 = __commonJS({ this[kHTTP2Session].destroy(err); this[kHTTP2Session] = null; } - util.destroy(this[kSocket], err); + util17.destroy(this[kSocket], err); if (client[kRunningIdx] < client[kQueue].length) { const request4 = client[kQueue][client[kRunningIdx]]; client[kQueue][client[kRunningIdx]++] = null; - util.errorRequest(client, request4, err); + util17.errorRequest(client, request4, err); client[kPendingIdx] = client[kRunningIdx]; } assert(client[kRunning] === 0); @@ -6851,7 +6851,7 @@ var require_client_h2 = __commonJS({ const { method, path: path7, host, upgrade, expectContinue, signal, headers: reqHeaders } = request4; let { body } = request4; if (upgrade) { - util.errorRequest(client, request4, new Error("Upgrade not supported for H2")); + util17.errorRequest(client, request4, new Error("Upgrade not supported for H2")); return false; } const headers = {}; @@ -6870,7 +6870,7 @@ var require_client_h2 = __commonJS({ headers[key] = val; } } - let stream2; + let stream3; const { hostname, port } = client[kUrl]; headers[HTTP2_HEADER_AUTHORITY] = host || `${hostname}${port ? `:${port}` : ""}`; headers[HTTP2_HEADER_METHOD] = method; @@ -6879,37 +6879,37 @@ var require_client_h2 = __commonJS({ return; } err = err || new RequestAbortedError(); - util.errorRequest(client, request4, err); - if (stream2 != null) { - util.destroy(stream2, err); + util17.errorRequest(client, request4, err); + if (stream3 != null) { + util17.destroy(stream3, err); } - util.destroy(body, err); + util17.destroy(body, err); client[kQueue][client[kRunningIdx]++] = null; client[kResume](); }; try { request4.onConnect(abort); } catch (err) { - util.errorRequest(client, request4, err); + util17.errorRequest(client, request4, err); } if (request4.aborted) { return false; } if (method === "CONNECT") { session.ref(); - stream2 = session.request(headers, { endStream: false, signal }); - if (stream2.id && !stream2.pending) { - request4.onUpgrade(null, null, stream2); + stream3 = session.request(headers, { endStream: false, signal }); + if (stream3.id && !stream3.pending) { + request4.onUpgrade(null, null, stream3); ++session[kOpenStreams]; client[kQueue][client[kRunningIdx]++] = null; } else { - stream2.once("ready", () => { - request4.onUpgrade(null, null, stream2); + stream3.once("ready", () => { + request4.onUpgrade(null, null, stream3); ++session[kOpenStreams]; client[kQueue][client[kRunningIdx]++] = null; }); } - stream2.once("close", () => { + stream3.once("close", () => { session[kOpenStreams] -= 1; if (session[kOpenStreams] === 0) session.unref(); }); @@ -6921,8 +6921,8 @@ var require_client_h2 = __commonJS({ if (body && typeof body.read === "function") { body.read(0); } - let contentLength = util.bodyLength(body); - if (util.isFormDataLike(body)) { + let contentLength = util17.bodyLength(body); + if (util17.isFormDataLike(body)) { extractBody ??= require_body().extractBody; const [bodyStream, contentType] = extractBody(body); headers["content-type"] = contentType; @@ -6937,7 +6937,7 @@ var require_client_h2 = __commonJS({ } if (shouldSendContentLength(method) && contentLength > 0 && request4.contentLength != null && request4.contentLength !== contentLength) { if (client[kStrictContentLength]) { - util.errorRequest(client, request4, new RequestContentLengthMismatchError()); + util17.errorRequest(client, request4, new RequestContentLengthMismatchError()); return false; } process.emitWarning(new RequestContentLengthMismatchError()); @@ -6950,36 +6950,36 @@ var require_client_h2 = __commonJS({ const shouldEndStream = method === "GET" || method === "HEAD" || body === null; if (expectContinue) { headers[HTTP2_HEADER_EXPECT] = "100-continue"; - stream2 = session.request(headers, { endStream: shouldEndStream, signal }); - stream2.once("continue", writeBodyH2); + stream3 = session.request(headers, { endStream: shouldEndStream, signal }); + stream3.once("continue", writeBodyH2); } else { - stream2 = session.request(headers, { + stream3 = session.request(headers, { endStream: shouldEndStream, signal }); writeBodyH2(); } ++session[kOpenStreams]; - stream2.once("response", (headers2) => { + stream3.once("response", (headers2) => { const { [HTTP2_HEADER_STATUS]: statusCode, ...realHeaders } = headers2; request4.onResponseStarted(); if (request4.aborted) { const err = new RequestAbortedError(); - util.errorRequest(client, request4, err); - util.destroy(stream2, err); + util17.errorRequest(client, request4, err); + util17.destroy(stream3, err); return; } - if (request4.onHeaders(Number(statusCode), parseH2Headers(realHeaders), stream2.resume.bind(stream2), "") === false) { - stream2.pause(); + if (request4.onHeaders(Number(statusCode), parseH2Headers(realHeaders), stream3.resume.bind(stream3), "") === false) { + stream3.pause(); } - stream2.on("data", (chunk) => { + stream3.on("data", (chunk) => { if (request4.onData(chunk) === false) { - stream2.pause(); + stream3.pause(); } }); }); - stream2.once("end", () => { - if (stream2.state?.state == null || stream2.state.state < 6) { + stream3.once("end", () => { + if (stream3.state?.state == null || stream3.state.state < 6) { request4.onComplete([]); } if (session[kOpenStreams] === 0) { @@ -6990,16 +6990,16 @@ var require_client_h2 = __commonJS({ client[kPendingIdx] = client[kRunningIdx]; client[kResume](); }); - stream2.once("close", () => { + stream3.once("close", () => { session[kOpenStreams] -= 1; if (session[kOpenStreams] === 0) { session.unref(); } }); - stream2.once("error", function(err) { + stream3.once("error", function(err) { abort(err); }); - stream2.once("frameError", (type, code) => { + stream3.once("frameError", (type, code) => { abort(new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`)); }); return true; @@ -7007,7 +7007,7 @@ var require_client_h2 = __commonJS({ if (!body || contentLength === 0) { writeBuffer( abort, - stream2, + stream3, null, client, request4, @@ -7015,10 +7015,10 @@ var require_client_h2 = __commonJS({ contentLength, expectsPayload ); - } else if (util.isBuffer(body)) { + } else if (util17.isBuffer(body)) { writeBuffer( abort, - stream2, + stream3, body, client, request4, @@ -7026,11 +7026,11 @@ var require_client_h2 = __commonJS({ contentLength, expectsPayload ); - } else if (util.isBlobLike(body)) { + } else if (util17.isBlobLike(body)) { if (typeof body.stream === "function") { writeIterable( abort, - stream2, + stream3, body.stream(), client, request4, @@ -7041,7 +7041,7 @@ var require_client_h2 = __commonJS({ } else { writeBlob( abort, - stream2, + stream3, body, client, request4, @@ -7050,21 +7050,21 @@ var require_client_h2 = __commonJS({ expectsPayload ); } - } else if (util.isStream(body)) { + } else if (util17.isStream(body)) { writeStream( abort, client[kSocket], expectsPayload, - stream2, + stream3, body, client, request4, contentLength ); - } else if (util.isIterable(body)) { + } else if (util17.isIterable(body)) { writeIterable( abort, - stream2, + stream3, body, client, request4, @@ -7079,7 +7079,7 @@ var require_client_h2 = __commonJS({ } function writeBuffer(abort, h2stream, body, client, request4, socket, contentLength, expectsPayload) { try { - if (body != null && util.isBuffer(body)) { + if (body != null && util17.isBuffer(body)) { assert(contentLength === body.byteLength, "buffer body must have content length"); h2stream.cork(); h2stream.write(body); @@ -7103,10 +7103,10 @@ var require_client_h2 = __commonJS({ h2stream, (err) => { if (err) { - util.destroy(pipe, err); + util17.destroy(pipe, err); abort(err); } else { - util.removeAllListeners(pipe); + util17.removeAllListeners(pipe); request4.onRequestSent(); if (!expectsPayload) { socket[kReset] = true; @@ -7115,7 +7115,7 @@ var require_client_h2 = __commonJS({ } } ); - util.addListener(pipe, "data", onPipeData); + util17.addListener(pipe, "data", onPipeData); function onPipeData(chunk) { request4.onBodySent(chunk); } @@ -7151,12 +7151,12 @@ var require_client_h2 = __commonJS({ cb2(); } } - const waitForDrain = () => new Promise((resolve2, reject) => { + const waitForDrain = () => new Promise((resolve3, reject2) => { assert(callback === null); if (socket[kError]) { - reject(socket[kError]); + reject2(socket[kError]); } else { - callback = resolve2; + callback = resolve3; } }); h2stream.on("close", onDrain).on("drain", onDrain); @@ -7191,7 +7191,7 @@ var require_client_h2 = __commonJS({ var require_redirect_handler = __commonJS({ "../node_modules/undici/lib/handler/redirect-handler.js"(exports2, module2) { "use strict"; - var util = require_util(); + var util17 = require_util(); var { kBodyUsed } = require_symbols(); var assert = require("assert"); var { InvalidArgumentError } = require_errors(); @@ -7214,7 +7214,7 @@ var require_redirect_handler = __commonJS({ if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) { throw new InvalidArgumentError("maxRedirections must be a positive number"); } - util.validateHandler(handler2, opts.method, opts.upgrade); + util17.validateHandler(handler2, opts.method, opts.upgrade); this.dispatch = dispatch; this.location = null; this.abort = null; @@ -7223,8 +7223,8 @@ var require_redirect_handler = __commonJS({ this.handler = handler2; this.history = []; this.redirectionLimitReached = false; - if (util.isStream(this.opts.body)) { - if (util.bodyLength(this.opts.body) === 0) { + if (util17.isStream(this.opts.body)) { + if (util17.bodyLength(this.opts.body) === 0) { this.opts.body.on("data", function() { assert(false); }); @@ -7237,7 +7237,7 @@ var require_redirect_handler = __commonJS({ } } else if (this.opts.body && typeof this.opts.body.pipeTo === "function") { this.opts.body = new BodyAsyncIterable(this.opts.body); - } else if (this.opts.body && typeof this.opts.body !== "string" && !ArrayBuffer.isView(this.opts.body) && util.isIterable(this.opts.body)) { + } else if (this.opts.body && typeof this.opts.body !== "string" && !ArrayBuffer.isView(this.opts.body) && util17.isIterable(this.opts.body)) { this.opts.body = new BodyAsyncIterable(this.opts.body); } } @@ -7252,7 +7252,7 @@ var require_redirect_handler = __commonJS({ this.handler.onError(error2); } onHeaders(statusCode, headers, resume, statusText) { - this.location = this.history.length >= this.maxRedirections || util.isDisturbed(this.opts.body) ? null : parseLocation(statusCode, headers); + this.location = this.history.length >= this.maxRedirections || util17.isDisturbed(this.opts.body) ? null : parseLocation(statusCode, headers); if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) { if (this.request) { this.request.abort(new Error("max redirects")); @@ -7267,7 +7267,7 @@ var require_redirect_handler = __commonJS({ if (!this.location) { return this.handler.onHeaders(statusCode, headers, resume, statusText); } - const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin))); + const { origin, pathname, search } = util17.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin))); const path7 = search ? `${pathname}${search}` : pathname; this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin); this.opts.path = path7; @@ -7305,20 +7305,20 @@ var require_redirect_handler = __commonJS({ return null; } for (let i6 = 0; i6 < headers.length; i6 += 2) { - if (headers[i6].length === 8 && util.headerNameToString(headers[i6]) === "location") { + if (headers[i6].length === 8 && util17.headerNameToString(headers[i6]) === "location") { return headers[i6 + 1]; } } } function shouldRemoveHeader(header, removeContent, unknownOrigin) { if (header.length === 4) { - return util.headerNameToString(header) === "host"; + return util17.headerNameToString(header) === "host"; } - if (removeContent && util.headerNameToString(header).startsWith("content-")) { + if (removeContent && util17.headerNameToString(header).startsWith("content-")) { return true; } if (unknownOrigin && (header.length === 13 || header.length === 6 || header.length === 19)) { - const name = util.headerNameToString(header); + const name = util17.headerNameToString(header); return name === "authorization" || name === "cookie" || name === "proxy-authorization"; } return false; @@ -7375,7 +7375,7 @@ var require_client = __commonJS({ var assert = require("assert"); var net = require("net"); var http = require("http"); - var util = require_util(); + var util17 = require_util(); var { channels } = require_diagnostics(); var Request2 = require_request(); var DispatcherBase = require_dispatcher_base(); @@ -7558,7 +7558,7 @@ var require_client = __commonJS({ } else { this[kInterceptors] = [createRedirectInterceptor({ maxRedirections })]; } - this[kUrl] = util.parseOrigin(url); + this[kUrl] = util17.parseOrigin(url); this[kConnector] = connect2; this[kPipelining] = pipelining != null ? pipelining : 1; this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize; @@ -7621,7 +7621,7 @@ var require_client = __commonJS({ const request4 = new Request2(origin, opts, handler2); this[kQueue].push(request4); if (this[kResuming]) { - } else if (util.bodyLength(request4.body) == null && util.isIterable(request4.body)) { + } else if (util17.bodyLength(request4.body) == null && util17.isIterable(request4.body)) { this[kResuming] = 1; queueMicrotask(() => resume(this)); } else { @@ -7633,27 +7633,27 @@ var require_client = __commonJS({ return this[kNeedDrain] < 2; } async [kClose]() { - return new Promise((resolve2) => { + return new Promise((resolve3) => { if (this[kSize]) { - this[kClosedResolve] = resolve2; + this[kClosedResolve] = resolve3; } else { - resolve2(null); + resolve3(null); } }); } async [kDestroy](err) { - return new Promise((resolve2) => { + return new Promise((resolve3) => { const requests = this[kQueue].splice(this[kPendingIdx]); for (let i6 = 0; i6 < requests.length; i6++) { const request4 = requests[i6]; - util.errorRequest(this, request4, err); + util17.errorRequest(this, request4, err); } const callback = () => { if (this[kClosedResolve]) { this[kClosedResolve](); this[kClosedResolve] = null; } - resolve2(null); + resolve3(null); }; if (this[kHTTPContext]) { this[kHTTPContext].destroy(err, callback); @@ -7672,7 +7672,7 @@ var require_client = __commonJS({ const requests = client[kQueue].splice(client[kRunningIdx]); for (let i6 = 0; i6 < requests.length; i6++) { const request4 = requests[i6]; - util.errorRequest(client, request4, err); + util17.errorRequest(client, request4, err); } assert(client[kSize] === 0); } @@ -7704,7 +7704,7 @@ var require_client = __commonJS({ }); } try { - const socket = await new Promise((resolve2, reject) => { + const socket = await new Promise((resolve3, reject2) => { client[kConnector]({ host, hostname, @@ -7714,14 +7714,14 @@ var require_client = __commonJS({ localAddress: client[kLocalAddress] }, (err, socket2) => { if (err) { - reject(err); + reject2(err); } else { - resolve2(socket2); + resolve3(socket2); } }); }); if (client.destroyed) { - util.destroy(socket.on("error", noop2), new ClientDestroyedError()); + util17.destroy(socket.on("error", noop2), new ClientDestroyedError()); return; } assert(socket); @@ -7776,7 +7776,7 @@ var require_client = __commonJS({ assert(client[kRunning] === 0); while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) { const request4 = client[kQueue][client[kPendingIdx]++]; - util.errorRequest(client, request4, err); + util17.errorRequest(client, request4, err); } } else { onError(client, err); @@ -8002,7 +8002,7 @@ var require_pool_base = __commonJS({ pool.emit("drain", origin, [pool, ...targets]); } if (pool[kClosedResolve] && queue.isEmpty()) { - Promise.all(pool[kClients].map((c6) => c6.close())).then(pool[kClosedResolve]); + Promise.all(pool[kClients].map((c7) => c7.close())).then(pool[kClosedResolve]); } }; this[kOnConnect] = (origin, targets) => { @@ -8051,10 +8051,10 @@ var require_pool_base = __commonJS({ } async [kClose]() { if (this[kQueue].isEmpty()) { - await Promise.all(this[kClients].map((c6) => c6.close())); + await Promise.all(this[kClients].map((c7) => c7.close())); } else { - await new Promise((resolve2) => { - this[kClosedResolve] = resolve2; + await new Promise((resolve3) => { + this[kClosedResolve] = resolve3; }); } } @@ -8066,7 +8066,7 @@ var require_pool_base = __commonJS({ } item.handler.onError(err); } - await Promise.all(this[kClients].map((c6) => c6.destroy(err))); + await Promise.all(this[kClients].map((c7) => c7.destroy(err))); } [kDispatch](opts, handler2) { const dispatcher = this[kGetDispatcher](); @@ -8128,7 +8128,7 @@ var require_pool = __commonJS({ var { InvalidArgumentError } = require_errors(); - var util = require_util(); + var util17 = require_util(); var { kUrl, kInterceptors } = require_symbols(); var buildConnector = require_connect(); var kOptions = /* @__PURE__ */ Symbol("options"); @@ -8174,8 +8174,8 @@ var require_pool = __commonJS({ } this[kInterceptors] = options.interceptors?.Pool && Array.isArray(options.interceptors.Pool) ? options.interceptors.Pool : []; this[kConnections] = connections || null; - this[kUrl] = util.parseOrigin(origin); - this[kOptions] = { ...util.deepClone(options), connect, allowH2 }; + this[kUrl] = util17.parseOrigin(origin); + this[kOptions] = { ...util17.deepClone(options), connect, allowH2 }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kFactory] = factory; this.on("connectionError", (origin2, targets, error2) => { @@ -8357,7 +8357,7 @@ var require_agent = __commonJS({ var DispatcherBase = require_dispatcher_base(); var Pool = require_pool(); var Client2 = require_client(); - var util = require_util(); + var util17 = require_util(); var createRedirectInterceptor = require_redirect_interceptor(); var kOnConnect = /* @__PURE__ */ Symbol("onConnect"); var kOnDisconnect = /* @__PURE__ */ Symbol("onDisconnect"); @@ -8385,7 +8385,7 @@ var require_agent = __commonJS({ connect = { ...connect }; } this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })]; - this[kOptions] = { ...util.deepClone(options), connect }; + this[kOptions] = { ...util17.deepClone(options), connect }; this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0; this[kMaxRedirections] = maxRedirections; this[kFactory] = factory; @@ -8832,7 +8832,7 @@ var require_retry_handler = __commonJS({ minTimeout, timeoutFactor, // Response scoped - methods, + methods: methods19, errorCodes, retryAfter, statusCodes @@ -8852,7 +8852,7 @@ var require_retry_handler = __commonJS({ timeoutFactor: timeoutFactor ?? 2, maxRetries: maxRetries ?? 5, // What errors we should retry - methods: methods ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"], + methods: methods19 ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"], // Indicates which errors to retry statusCodes: statusCodes ?? [500, 502, 503, 504, 429], // List of errors to retry @@ -8913,14 +8913,14 @@ var require_retry_handler = __commonJS({ timeoutFactor, statusCodes, errorCodes, - methods + methods: methods19 } = retryOptions; const { counter } = state2; if (code && code !== "UND_ERR_REQ_RETRY" && !errorCodes.includes(code)) { cb2(err); return; } - if (Array.isArray(methods) && !methods.includes(method)) { + if (Array.isArray(methods19) && !methods19.includes(method)) { cb2(err); return; } @@ -9144,7 +9144,7 @@ var require_readable = __commonJS({ var assert = require("assert"); var { Readable: Readable8 } = require("stream"); var { RequestAbortedError, NotSupportedError, InvalidArgumentError, AbortError } = require_errors(); - var util = require_util(); + var util17 = require_util(); var { ReadableStreamFrom } = require_util(); var kConsume = /* @__PURE__ */ Symbol("kConsume"); var kReading = /* @__PURE__ */ Symbol("kReading"); @@ -9246,7 +9246,7 @@ var require_readable = __commonJS({ } // https://fetch.spec.whatwg.org/#dom-body-bodyused get bodyUsed() { - return util.isDisturbed(this); + return util17.isDisturbed(this); } // https://fetch.spec.whatwg.org/#dom-body-body get body() { @@ -9269,7 +9269,7 @@ var require_readable = __commonJS({ if (this._readableState.closeEmitted) { return null; } - return await new Promise((resolve2, reject) => { + return await new Promise((resolve3, reject2) => { if (this[kContentLength] > limit) { this.destroy(new AbortError()); } @@ -9280,9 +9280,9 @@ var require_readable = __commonJS({ this.on("close", function() { signal?.removeEventListener("abort", onAbort); if (signal?.aborted) { - reject(signal.reason ?? new AbortError()); + reject2(signal.reason ?? new AbortError()); } else { - resolve2(null); + resolve3(null); } }).on("error", noop2).on("data", function(chunk) { limit -= chunk.length; @@ -9297,40 +9297,40 @@ var require_readable = __commonJS({ return self2[kBody] && self2[kBody].locked === true || self2[kConsume]; } function isUnusable(self2) { - return util.isDisturbed(self2) || isLocked(self2); + return util17.isDisturbed(self2) || isLocked(self2); } - async function consume(stream2, type) { - assert(!stream2[kConsume]); - return new Promise((resolve2, reject) => { - if (isUnusable(stream2)) { - const rState = stream2._readableState; + async function consume(stream3, type) { + assert(!stream3[kConsume]); + return new Promise((resolve3, reject2) => { + if (isUnusable(stream3)) { + const rState = stream3._readableState; if (rState.destroyed && rState.closeEmitted === false) { - stream2.on("error", (err) => { - reject(err); + stream3.on("error", (err) => { + reject2(err); }).on("close", () => { - reject(new TypeError("unusable")); + reject2(new TypeError("unusable")); }); } else { - reject(rState.errored ?? new TypeError("unusable")); + reject2(rState.errored ?? new TypeError("unusable")); } } else { queueMicrotask(() => { - stream2[kConsume] = { + stream3[kConsume] = { type, - stream: stream2, - resolve: resolve2, - reject, + stream: stream3, + resolve: resolve3, + reject: reject2, length: 0, body: [] }; - stream2.on("error", function(err) { + stream3.on("error", function(err) { consumeFinish(this[kConsume], err); }).on("close", function() { if (this[kConsume].body !== null) { consumeFinish(this[kConsume], new RequestAbortedError()); } }); - consumeStart(stream2[kConsume]); + consumeStart(stream3[kConsume]); }); } }); @@ -9388,22 +9388,22 @@ var require_readable = __commonJS({ return buffer; } function consumeEnd(consume2) { - const { type, body, resolve: resolve2, stream: stream2, length } = consume2; + const { type, body, resolve: resolve3, stream: stream3, length } = consume2; try { if (type === "text") { - resolve2(chunksDecode(body, length)); + resolve3(chunksDecode(body, length)); } else if (type === "json") { - resolve2(JSON.parse(chunksDecode(body, length))); + resolve3(JSON.parse(chunksDecode(body, length))); } else if (type === "arrayBuffer") { - resolve2(chunksConcat(body, length).buffer); + resolve3(chunksConcat(body, length).buffer); } else if (type === "blob") { - resolve2(new Blob(body, { type: stream2[kContentType] })); + resolve3(new Blob(body, { type: stream3[kContentType] })); } else if (type === "bytes") { - resolve2(chunksConcat(body, length)); + resolve3(chunksConcat(body, length)); } consumeFinish(consume2); } catch (err) { - stream2.destroy(err); + stream3.destroy(err); } } function consumePush(consume2, chunk) { @@ -9499,7 +9499,7 @@ var require_api_request = __commonJS({ var assert = require("assert"); var { Readable: Readable8 } = require_readable(); var { InvalidArgumentError, RequestAbortedError } = require_errors(); - var util = require_util(); + var util17 = require_util(); var { getResolveErrorBodyCallback } = require_util3(); var { AsyncResource } = require("async_hooks"); var RequestHandler = class extends AsyncResource { @@ -9526,8 +9526,8 @@ var require_api_request = __commonJS({ } super("UNDICI_REQUEST"); } catch (err) { - if (util.isStream(body)) { - util.destroy(body.on("error", util.nop), err); + if (util17.isStream(body)) { + util17.destroy(body.on("error", util17.nop), err); } throw err; } @@ -9546,7 +9546,7 @@ var require_api_request = __commonJS({ this.signal = signal; this.reason = null; this.removeAbortListener = null; - if (util.isStream(body)) { + if (util17.isStream(body)) { body.on("error", (err) => { this.onError(err); }); @@ -9555,10 +9555,10 @@ var require_api_request = __commonJS({ if (this.signal.aborted) { this.reason = this.signal.reason ?? new RequestAbortedError(); } else { - this.removeAbortListener = util.addAbortListener(this.signal, () => { + this.removeAbortListener = util17.addAbortListener(this.signal, () => { this.reason = this.signal.reason ?? new RequestAbortedError(); if (this.res) { - util.destroy(this.res.on("error", util.nop), this.reason); + util17.destroy(this.res.on("error", util17.nop), this.reason); } else if (this.abort) { this.abort(this.reason); } @@ -9582,14 +9582,14 @@ var require_api_request = __commonJS({ } onHeaders(statusCode, rawHeaders, resume, statusMessage) { const { callback, opaque, abort, context: context3, responseHeaders, highWaterMark } = this; - const headers = responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); + const headers = responseHeaders === "raw" ? util17.parseRawHeaders(rawHeaders) : util17.parseHeaders(rawHeaders); if (statusCode < 200) { if (this.onInfo) { this.onInfo({ statusCode, headers }); } return; } - const parsedHeaders = responseHeaders === "raw" ? util.parseHeaders(rawHeaders) : headers; + const parsedHeaders = responseHeaders === "raw" ? util17.parseHeaders(rawHeaders) : headers; const contentType = parsedHeaders["content-type"]; const contentLength = parsedHeaders["content-length"]; const res = new Readable8({ @@ -9627,7 +9627,7 @@ var require_api_request = __commonJS({ return this.res.push(chunk); } onComplete(trailers) { - util.parseHeaders(trailers, this.trailers); + util17.parseHeaders(trailers, this.trailers); this.res.push(null); } onError(err) { @@ -9641,12 +9641,12 @@ var require_api_request = __commonJS({ if (res) { this.res = null; queueMicrotask(() => { - util.destroy(res, err); + util17.destroy(res, err); }); } if (body) { this.body = null; - util.destroy(body, err); + util17.destroy(body, err); } if (this.removeAbortListener) { res?.off("close", this.removeAbortListener); @@ -9657,9 +9657,9 @@ var require_api_request = __commonJS({ }; function request4(opts, callback) { if (callback === void 0) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { request4.call(this, opts, (err, data) => { - return err ? reject(err) : resolve2(data); + return err ? reject2(err) : resolve3(data); }); }); } @@ -9737,7 +9737,7 @@ var require_api_stream = __commonJS({ var assert = require("assert"); var { finished, PassThrough: PassThrough2 } = require("stream"); var { InvalidArgumentError, InvalidReturnValueError } = require_errors(); - var util = require_util(); + var util17 = require_util(); var { getResolveErrorBodyCallback } = require_util3(); var { AsyncResource } = require("async_hooks"); var { addSignal, removeSignal } = require_abort_signal(); @@ -9765,8 +9765,8 @@ var require_api_stream = __commonJS({ } super("UNDICI_STREAM"); } catch (err) { - if (util.isStream(body)) { - util.destroy(body.on("error", util.nop), err); + if (util17.isStream(body)) { + util17.destroy(body.on("error", util17.nop), err); } throw err; } @@ -9781,7 +9781,7 @@ var require_api_stream = __commonJS({ this.body = body; this.onInfo = onInfo || null; this.throwOnError = throwOnError || false; - if (util.isStream(body)) { + if (util17.isStream(body)) { body.on("error", (err) => { this.onError(err); }); @@ -9799,7 +9799,7 @@ var require_api_stream = __commonJS({ } onHeaders(statusCode, rawHeaders, resume, statusMessage) { const { factory, opaque, context: context3, callback, responseHeaders } = this; - const headers = responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); + const headers = responseHeaders === "raw" ? util17.parseRawHeaders(rawHeaders) : util17.parseHeaders(rawHeaders); if (statusCode < 200) { if (this.onInfo) { this.onInfo({ statusCode, headers }); @@ -9809,7 +9809,7 @@ var require_api_stream = __commonJS({ this.factory = null; let res; if (this.throwOnError && statusCode >= 400) { - const parsedHeaders = responseHeaders === "raw" ? util.parseHeaders(rawHeaders) : headers; + const parsedHeaders = responseHeaders === "raw" ? util17.parseHeaders(rawHeaders) : headers; const contentType = parsedHeaders["content-type"]; res = new PassThrough2(); this.callback = null; @@ -9835,7 +9835,7 @@ var require_api_stream = __commonJS({ const { callback: callback2, res: res2, opaque: opaque2, trailers, abort } = this; this.res = null; if (err || !res2.readable) { - util.destroy(res2, err); + util17.destroy(res2, err); } this.callback = null; this.runInAsyncScope(callback2, null, err || null, { opaque: opaque2, trailers }); @@ -9859,7 +9859,7 @@ var require_api_stream = __commonJS({ if (!res) { return; } - this.trailers = util.parseHeaders(trailers); + this.trailers = util17.parseHeaders(trailers); res.end(); } onError(err) { @@ -9868,7 +9868,7 @@ var require_api_stream = __commonJS({ this.factory = null; if (res) { this.res = null; - util.destroy(res, err); + util17.destroy(res, err); } else if (callback) { this.callback = null; queueMicrotask(() => { @@ -9877,15 +9877,15 @@ var require_api_stream = __commonJS({ } if (body) { this.body = null; - util.destroy(body, err); + util17.destroy(body, err); } } }; - function stream2(opts, factory, callback) { + function stream3(opts, factory, callback) { if (callback === void 0) { - return new Promise((resolve2, reject) => { - stream2.call(this, opts, factory, (err, data) => { - return err ? reject(err) : resolve2(data); + return new Promise((resolve3, reject2) => { + stream3.call(this, opts, factory, (err, data) => { + return err ? reject2(err) : resolve3(data); }); }); } @@ -9899,7 +9899,7 @@ var require_api_stream = __commonJS({ queueMicrotask(() => callback(err, { opaque })); } } - module2.exports = stream2; + module2.exports = stream3; } }); @@ -9917,7 +9917,7 @@ var require_api_pipeline = __commonJS({ InvalidReturnValueError, RequestAbortedError } = require_errors(); - var util = require_util(); + var util17 = require_util(); var { AsyncResource } = require("async_hooks"); var { addSignal, removeSignal } = require_abort_signal(); var assert = require("assert"); @@ -9979,7 +9979,7 @@ var require_api_pipeline = __commonJS({ this.abort = null; this.context = null; this.onInfo = onInfo || null; - this.req = new PipelineRequest().on("error", util.nop); + this.req = new PipelineRequest().on("error", util17.nop); this.ret = new Duplex2({ readableObjectMode: opts.objectMode, autoDestroy: true, @@ -10005,9 +10005,9 @@ var require_api_pipeline = __commonJS({ if (abort && err) { abort(); } - util.destroy(body, err); - util.destroy(req, err); - util.destroy(res, err); + util17.destroy(body, err); + util17.destroy(req, err); + util17.destroy(res, err); removeSignal(this); callback(err); } @@ -10033,7 +10033,7 @@ var require_api_pipeline = __commonJS({ const { opaque, handler: handler2, context: context3 } = this; if (statusCode < 200) { if (this.onInfo) { - const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); + const headers = this.responseHeaders === "raw" ? util17.parseRawHeaders(rawHeaders) : util17.parseHeaders(rawHeaders); this.onInfo({ statusCode, headers }); } return; @@ -10042,7 +10042,7 @@ var require_api_pipeline = __commonJS({ let body; try { this.handler = null; - const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); + const headers = this.responseHeaders === "raw" ? util17.parseRawHeaders(rawHeaders) : util17.parseHeaders(rawHeaders); body = this.runInAsyncScope(handler2, null, { statusCode, headers, @@ -10051,7 +10051,7 @@ var require_api_pipeline = __commonJS({ context: context3 }); } catch (err) { - this.res.on("error", util.nop); + this.res.on("error", util17.nop); throw err; } if (!body || typeof body.on !== "function") { @@ -10064,14 +10064,14 @@ var require_api_pipeline = __commonJS({ } }).on("error", (err) => { const { ret: ret2 } = this; - util.destroy(ret2, err); + util17.destroy(ret2, err); }).on("end", () => { const { ret: ret2 } = this; ret2.push(null); }).on("close", () => { const { ret: ret2 } = this; if (!ret2._readableState.ended) { - util.destroy(ret2, new RequestAbortedError()); + util17.destroy(ret2, new RequestAbortedError()); } }); this.body = body; @@ -10087,7 +10087,7 @@ var require_api_pipeline = __commonJS({ onError(err) { const { ret: ret2 } = this; this.handler = null; - util.destroy(ret2, err); + util17.destroy(ret2, err); } }; function pipeline(opts, handler2) { @@ -10109,7 +10109,7 @@ var require_api_upgrade = __commonJS({ "use strict"; var { InvalidArgumentError, SocketError } = require_errors(); var { AsyncResource } = require("async_hooks"); - var util = require_util(); + var util17 = require_util(); var { addSignal, removeSignal } = require_abort_signal(); var assert = require("assert"); var UpgradeHandler = class extends AsyncResource { @@ -10149,7 +10149,7 @@ var require_api_upgrade = __commonJS({ const { callback, opaque, context: context3 } = this; removeSignal(this); this.callback = null; - const headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); + const headers = this.responseHeaders === "raw" ? util17.parseRawHeaders(rawHeaders) : util17.parseHeaders(rawHeaders); this.runInAsyncScope(callback, null, null, { headers, socket, @@ -10170,9 +10170,9 @@ var require_api_upgrade = __commonJS({ }; function upgrade(opts, callback) { if (callback === void 0) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { upgrade.call(this, opts, (err, data) => { - return err ? reject(err) : resolve2(data); + return err ? reject2(err) : resolve3(data); }); }); } @@ -10202,7 +10202,7 @@ var require_api_connect = __commonJS({ var assert = require("assert"); var { AsyncResource } = require("async_hooks"); var { InvalidArgumentError, SocketError } = require_errors(); - var util = require_util(); + var util17 = require_util(); var { addSignal, removeSignal } = require_abort_signal(); var ConnectHandler = class extends AsyncResource { constructor(opts, callback) { @@ -10241,7 +10241,7 @@ var require_api_connect = __commonJS({ this.callback = null; let headers = rawHeaders; if (headers != null) { - headers = this.responseHeaders === "raw" ? util.parseRawHeaders(rawHeaders) : util.parseHeaders(rawHeaders); + headers = this.responseHeaders === "raw" ? util17.parseRawHeaders(rawHeaders) : util17.parseHeaders(rawHeaders); } this.runInAsyncScope(callback, null, null, { statusCode, @@ -10264,9 +10264,9 @@ var require_api_connect = __commonJS({ }; function connect(opts, callback) { if (callback === void 0) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { connect.call(this, opts, (err, data) => { - return err ? reject(err) : resolve2(data); + return err ? reject2(err) : resolve3(data); }); }); } @@ -10403,10 +10403,10 @@ var require_mock_utils = __commonJS({ } } function buildHeadersFromArray(headers) { - const clone = headers.slice(); + const clone3 = headers.slice(); const entries = []; - for (let index = 0; index < clone.length; index += 2) { - entries.push([clone[index], clone[index + 1]]); + for (let index = 0; index < clone3.length; index += 2) { + entries.push([clone3[index], clone3[index + 1]]); } return Object.fromEntries(entries); } @@ -11241,7 +11241,7 @@ var require_retry = __commonJS({ var require_dump = __commonJS({ "../node_modules/undici/lib/interceptor/dump.js"(exports2, module2) { "use strict"; - var util = require_util(); + var util17 = require_util(); var { InvalidArgumentError, RequestAbortedError } = require_errors(); var DecoratorHandler = require_decorator_handler(); var DumpHandler = class extends DecoratorHandler { @@ -11270,7 +11270,7 @@ var require_dump = __commonJS({ } // TODO: will require adjustment after new hooks are out onHeaders(statusCode, rawHeaders, resume, statusMessage) { - const headers = util.parseHeaders(rawHeaders); + const headers = util17.parseHeaders(rawHeaders); const contentLength = headers["content-length"]; if (contentLength != null && contentLength > this.#maxSize) { throw new RequestAbortedError( @@ -11637,7 +11637,7 @@ var require_headers = __commonJS({ } = require_util2(); var { webidl } = require_webidl(); var assert = require("assert"); - var util = require("util"); + var util17 = require("util"); var kHeadersMap = /* @__PURE__ */ Symbol("headers map"); var kHeadersSortedMap = /* @__PURE__ */ Symbol("headers map sorted"); function isHTTPWhiteSpaceCharCode(code) { @@ -11827,26 +11827,26 @@ var require_headers = __commonJS({ const firstValue = iterator2.next().value; array[0] = [firstValue[0], firstValue[1].value]; assert(firstValue[1].value !== null); - for (let i6 = 1, j6 = 0, right = 0, left = 0, pivot = 0, x6, value; i6 < size; ++i6) { + for (let i6 = 1, j6 = 0, right = 0, left = 0, pivot3 = 0, x7, value; i6 < size; ++i6) { value = iterator2.next().value; - x6 = array[i6] = [value[0], value[1].value]; - assert(x6[1] !== null); + x7 = array[i6] = [value[0], value[1].value]; + assert(x7[1] !== null); left = 0; right = i6; while (left < right) { - pivot = left + (right - left >> 1); - if (array[pivot][0] <= x6[0]) { - left = pivot + 1; + pivot3 = left + (right - left >> 1); + if (array[pivot3][0] <= x7[0]) { + left = pivot3 + 1; } else { - right = pivot; + right = pivot3; } } - if (i6 !== pivot) { + if (i6 !== pivot3) { j6 = i6; while (j6 > left) { array[j6] = array[--j6]; } - array[left] = x6; + array[left] = x7; } } if (!iterator2.next().done) { @@ -11979,13 +11979,13 @@ var require_headers = __commonJS({ return this.#headersList[kHeadersSortedMap]; } const headers = []; - const names = this.#headersList.toSortedArray(); + const names3 = this.#headersList.toSortedArray(); const cookies = this.#headersList.cookies; if (cookies === null || cookies.length === 1) { - return this.#headersList[kHeadersSortedMap] = names; + return this.#headersList[kHeadersSortedMap] = names3; } - for (let i6 = 0; i6 < names.length; ++i6) { - const { 0: name, 1: value } = names[i6]; + for (let i6 = 0; i6 < names3.length; ++i6) { + const { 0: name, 1: value } = names3[i6]; if (name === "set-cookie") { for (let j6 = 0; j6 < cookies.length; ++j6) { headers.push([name, cookies[j6]]); @@ -11996,9 +11996,9 @@ var require_headers = __commonJS({ } return this.#headersList[kHeadersSortedMap] = headers; } - [util.inspect.custom](depth, options) { + [util17.inspect.custom](depth, options) { options.depth ??= depth; - return `Headers ${util.formatWithOptions(options, this.#headersList.entries)}`; + return `Headers ${util17.formatWithOptions(options, this.#headersList.entries)}`; } static getHeadersGuard(o6) { return o6.#guard; @@ -12030,14 +12030,14 @@ var require_headers = __commonJS({ value: "Headers", configurable: true }, - [util.inspect.custom]: { + [util17.inspect.custom]: { enumerable: false } }); webidl.converters.HeadersInit = function(V2, prefix, argument) { if (webidl.util.Type(V2) === "Object") { const iterator2 = Reflect.get(V2, Symbol.iterator); - if (!util.types.isProxy(V2) && iterator2 === Headers3.prototype.entries) { + if (!util17.types.isProxy(V2) && iterator2 === Headers3.prototype.entries) { try { return getHeadersList(V2).entriesList; } catch { @@ -12074,13 +12074,13 @@ var require_response = __commonJS({ "use strict"; var { Headers: Headers3, HeadersList, fill, getHeadersGuard, setHeadersGuard, setHeadersList } = require_headers(); var { extractBody, cloneBody, mixinBody, hasFinalizationRegistry, streamRegistry, bodyUnusable } = require_body(); - var util = require_util(); + var util17 = require_util(); var nodeUtil = require("util"); - var { kEnumerableProperty } = util; + var { kEnumerableProperty } = util17; var { isValidReasonPhrase, isCancelled, - isAborted, + isAborted: isAborted17, isBlobLike, serializeJavascriptValueToJSONString, isErrorLike, @@ -12206,7 +12206,7 @@ var require_response = __commonJS({ } get bodyUsed() { webidl.brandCheck(this, _Response); - return !!this[kState].body && util.isDisturbed(this[kState].body.stream); + return !!this[kState].body && util17.isDisturbed(this[kState].body.stream); } // Returns a clone of response. clone() { @@ -12358,7 +12358,7 @@ var require_response = __commonJS({ } function makeAppropriateNetworkError(fetchParams, err = null) { assert(isCancelled(fetchParams)); - return isAborted(fetchParams) ? makeNetworkError(Object.assign(new DOMException("The operation was aborted.", "AbortError"), { cause: err })) : makeNetworkError(Object.assign(new DOMException("Request was cancelled."), { cause: err })); + return isAborted17(fetchParams) ? makeNetworkError(Object.assign(new DOMException("The operation was aborted.", "AbortError"), { cause: err })) : makeNetworkError(Object.assign(new DOMException("Request was cancelled."), { cause: err })); } function initializeResponse(response, init, body) { if (init.status !== null && (init.status < 200 || init.status > 599)) { @@ -12421,7 +12421,7 @@ var require_response = __commonJS({ if (ArrayBuffer.isView(V2) || types2.isArrayBuffer(V2)) { return webidl.converters.BufferSource(V2, prefix, name); } - if (util.isFormDataLike(V2)) { + if (util17.isFormDataLike(V2)) { return webidl.converters.FormData(V2, prefix, name, { strict: false }); } if (V2 instanceof URLSearchParams) { @@ -12516,7 +12516,7 @@ var require_request2 = __commonJS({ var { extractBody, mixinBody, cloneBody, bodyUnusable } = require_body(); var { Headers: Headers3, fill: fillHeaders, HeadersList, setHeadersGuard, getHeadersGuard, setHeadersList, getHeadersList } = require_headers(); var { FinalizationRegistry: FinalizationRegistry2 } = require_dispatcher_weakref()(); - var util = require_util(); + var util17 = require_util(); var nodeUtil = require("util"); var { isValidHTTPToken, @@ -12533,7 +12533,7 @@ var require_request2 = __commonJS({ requestCache, requestDuplex } = require_constants3(); - var { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util; + var { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util17; var { kHeaders, kSignal, kState, kDispatcher } = require_symbols2(); var { webidl } = require_webidl(); var { URLSerializer } = require_data_url(); @@ -12778,7 +12778,7 @@ var require_request2 = __commonJS({ } } catch { } - util.addAbortListener(signal, abort); + util17.addAbortListener(signal, abort); requestFinalizer.register(ac2, { signal, abort }, abort); } } @@ -12961,7 +12961,7 @@ var require_request2 = __commonJS({ } get bodyUsed() { webidl.brandCheck(this, _Request); - return !!this[kState].body && util.isDisturbed(this[kState].body.stream); + return !!this[kState].body && util17.isDisturbed(this[kState].body.stream); } get duplex() { webidl.brandCheck(this, _Request); @@ -12985,7 +12985,7 @@ var require_request2 = __commonJS({ } const acRef = new WeakRef(ac2); list.add(acRef); - util.addAbortListener( + util17.addAbortListener( ac2.signal, buildAbort(acRef) ); @@ -13239,7 +13239,7 @@ var require_fetch = __commonJS({ isBlobLike, sameOrigin, isCancelled, - isAborted, + isAborted: isAborted17, isErrorLike, fullyReadBody, readableStreamClose, @@ -14049,7 +14049,7 @@ var require_fetch = __commonJS({ fetchParams.controller.abort(reason); } }; - const stream2 = new ReadableStream( + const stream3 = new ReadableStream( { async start(controller) { fetchParams.controller.controller = controller; @@ -14063,7 +14063,7 @@ var require_fetch = __commonJS({ type: "bytes" } ); - response.body = { stream: stream2, source: null, length: null }; + response.body = { stream: stream3, source: null, length: null }; fetchParams.controller.onAborted = onAborted; fetchParams.controller.on("terminated", onAborted); fetchParams.controller.resume = async () => { @@ -14072,7 +14072,7 @@ var require_fetch = __commonJS({ let isFailure; try { const { done, value } = await fetchParams.controller.next(); - if (isAborted(fetchParams)) { + if (isAborted17(fetchParams)) { break; } bytes = done ? void 0 : value; @@ -14098,7 +14098,7 @@ var require_fetch = __commonJS({ if (buffer.byteLength) { fetchParams.controller.controller.enqueue(buffer); } - if (isErrored(stream2)) { + if (isErrored(stream3)) { fetchParams.controller.terminate(); return; } @@ -14108,15 +14108,15 @@ var require_fetch = __commonJS({ } }; function onAborted(reason) { - if (isAborted(fetchParams)) { + if (isAborted17(fetchParams)) { response.aborted = true; - if (isReadable2(stream2)) { + if (isReadable2(stream3)) { fetchParams.controller.controller.error( fetchParams.controller.serializedAbortReason ); } } else { - if (isReadable2(stream2)) { + if (isReadable2(stream3)) { fetchParams.controller.controller.error(new TypeError("terminated", { cause: isErrorLike(reason) ? reason : void 0 })); @@ -14128,7 +14128,7 @@ var require_fetch = __commonJS({ function dispatch({ body }) { const url = requestCurrentURL(request4); const agent = fetchParams.controller.dispatcher; - return new Promise((resolve2, reject) => agent.dispatch( + return new Promise((resolve3, reject2) => agent.dispatch( { path: url.pathname + url.search, origin: url.origin, @@ -14173,7 +14173,7 @@ var require_fetch = __commonJS({ const codings = contentEncoding ? contentEncoding.toLowerCase().split(",") : []; const maxContentEncodings = 5; if (codings.length > maxContentEncodings) { - reject(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`)); + reject2(new Error(`too many content-encodings in response: ${codings.length}, maximum allowed is ${maxContentEncodings}`)); return true; } for (let i6 = codings.length - 1; i6 >= 0; --i6) { @@ -14204,7 +14204,7 @@ var require_fetch = __commonJS({ } } const onError = this.onError.bind(this); - resolve2({ + resolve3({ status, statusText, headersList, @@ -14240,7 +14240,7 @@ var require_fetch = __commonJS({ } this.body?.destroy(error2); fetchParams.controller.terminate(error2); - reject(error2); + reject2(error2); }, onUpgrade(status, rawHeaders, socket) { if (status !== 101) { @@ -14250,7 +14250,7 @@ var require_fetch = __commonJS({ for (let i6 = 0; i6 < rawHeaders.length; i6 += 2) { headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i6]), rawHeaders[i6 + 1].toString("latin1"), true); } - resolve2({ + resolve3({ status, statusText: STATUS_CODES[status], headersList, @@ -14669,8 +14669,8 @@ var require_util4 = __commonJS({ fr[kState] = "loading"; fr[kResult] = null; fr[kError] = null; - const stream2 = blob.stream(); - const reader = stream2.getReader(); + const stream3 = blob.stream(); + const reader = stream3.getReader(); const bytes = []; let chunkPromise = reader.read(); let isFirstChunk = true; @@ -14767,7 +14767,7 @@ var require_util4 = __commonJS({ if (encoding === "failure") { encoding = "UTF-8"; } - return decode(bytes, encoding); + return decode3(bytes, encoding); } case "ArrayBuffer": { const sequence = combineByteSequences(bytes); @@ -14784,7 +14784,7 @@ var require_util4 = __commonJS({ } } } - function decode(ioQueue, encoding) { + function decode3(ioQueue, encoding) { const bytes = combineByteSequences(ioQueue); const BOMEncoding = BOMSniffing(bytes); let slice = 0; @@ -14796,8 +14796,8 @@ var require_util4 = __commonJS({ return new TextDecoder(encoding).decode(sliced); } function BOMSniffing(ioQueue) { - const [a6, b6, c6] = ioQueue; - if (a6 === 239 && b6 === 187 && c6 === 191) { + const [a6, b6, c7] = ioQueue; + if (a6 === 239 && b6 === 187 && c7 === 191) { return "UTF-8"; } else if (a6 === 254 && b6 === 255) { return "UTF-16BE"; @@ -15254,7 +15254,7 @@ var require_cache = __commonJS({ } const p6 = Promise.all(responsePromises); const responses = await p6; - const operations = []; + const operations2 = []; let index = 0; for (const response of responses) { const operation2 = { @@ -15265,13 +15265,13 @@ var require_cache = __commonJS({ response // 7.3.4 }; - operations.push(operation2); + operations2.push(operation2); index++; } const cacheJobPromise = createDeferredPromise(); let errorData = null; try { - this.#batchCacheOperations(operations); + this.#batchCacheOperations(operations2); } catch (e6) { errorData = e6; } @@ -15329,13 +15329,13 @@ var require_cache = __commonJS({ const clonedResponse = cloneResponse(innerResponse); const bodyReadPromise = createDeferredPromise(); if (innerResponse.body != null) { - const stream2 = innerResponse.body.stream; - const reader = stream2.getReader(); + const stream3 = innerResponse.body.stream; + const reader = stream3.getReader(); readAllBytes(reader).then(bodyReadPromise.resolve, bodyReadPromise.reject); } else { bodyReadPromise.resolve(void 0); } - const operations = []; + const operations2 = []; const operation2 = { type: "put", // 14. @@ -15344,7 +15344,7 @@ var require_cache = __commonJS({ response: clonedResponse // 16. }; - operations.push(operation2); + operations2.push(operation2); const bytes = await bodyReadPromise.promise; if (clonedResponse.body != null) { clonedResponse.body.source = bytes; @@ -15352,7 +15352,7 @@ var require_cache = __commonJS({ const cacheJobPromise = createDeferredPromise(); let errorData = null; try { - this.#batchCacheOperations(operations); + this.#batchCacheOperations(operations2); } catch (e6) { errorData = e6; } @@ -15381,18 +15381,18 @@ var require_cache = __commonJS({ assert(typeof request4 === "string"); r6 = new Request2(request4)[kState]; } - const operations = []; + const operations2 = []; const operation2 = { type: "delete", request: r6, options }; - operations.push(operation2); + operations2.push(operation2); const cacheJobPromise = createDeferredPromise(); let errorData = null; let requestResponses; try { - requestResponses = this.#batchCacheOperations(operations); + requestResponses = this.#batchCacheOperations(operations2); } catch (e6) { errorData = e6; } @@ -15458,13 +15458,13 @@ var require_cache = __commonJS({ * @param {CacheBatchOperation[]} operations * @returns {requestResponseList} */ - #batchCacheOperations(operations) { + #batchCacheOperations(operations2) { const cache6 = this.#relevantRequestResponseList; const backupCache = [...cache6]; const addedItems = []; const resultList = []; try { - for (const operation2 of operations) { + for (const operation2 of operations2) { if (operation2.type !== "delete" && operation2.type !== "put") { throw webidl.errors.exception({ header: "Cache.#batchCacheOperations", @@ -17843,8 +17843,8 @@ var require_util8 = __commonJS({ return true; } function delay(ms) { - return new Promise((resolve2) => { - setTimeout(resolve2, ms).unref(); + return new Promise((resolve3) => { + setTimeout(resolve3, ms).unref(); }); } module2.exports = { @@ -18395,7 +18395,7 @@ var require_undici = __commonJS({ var EnvHttpProxyAgent = require_env_http_proxy_agent(); var RetryAgent = require_retry_agent(); var errors = require_errors(); - var util = require_util(); + var util17 = require_util(); var { InvalidArgumentError } = errors; var api = require_api(); var buildConnector = require_connect(); @@ -18430,8 +18430,8 @@ var require_undici = __commonJS({ module2.exports.buildConnector = buildConnector; module2.exports.errors = errors; module2.exports.util = { - parseHeaders: util.parseHeaders, - headerNameToString: util.headerNameToString + parseHeaders: util17.parseHeaders, + headerNameToString: util17.headerNameToString }; function makeDispatcher(fn) { return (url, opts, handler2) => { @@ -18453,12 +18453,12 @@ var require_undici = __commonJS({ if (!opts.path.startsWith("/")) { path7 = `/${path7}`; } - url = new URL(util.parseOrigin(url).origin + path7); + url = new URL(util17.parseOrigin(url).origin + path7); } else { if (!opts) { opts = typeof url === "object" ? url : {}; } - url = util.parseURL(url); + url = util17.parseURL(url); } const { agent, dispatcher = getGlobalDispatcher() } = opts; if (agent) { @@ -20107,7 +20107,7 @@ var isReadableStream, isBlob; var init_stream_type_check = __esm({ "../node_modules/@smithy/util-stream/dist-es/stream-type-check.js"() { "use strict"; - isReadableStream = (stream2) => typeof ReadableStream === "function" && (stream2?.constructor?.name === ReadableStream.name || stream2 instanceof ReadableStream); + isReadableStream = (stream3) => typeof ReadableStream === "function" && (stream3?.constructor?.name === ReadableStream.name || stream3 instanceof ReadableStream); isBlob = (blob) => { return typeof Blob === "function" && (blob?.constructor?.name === Blob.name || blob instanceof Blob); }; @@ -20392,11 +20392,11 @@ var getAwsChunkedEncodingStream; var init_getAwsChunkedEncodingStream_browser = __esm({ "../node_modules/@smithy/util-stream/dist-es/getAwsChunkedEncodingStream.browser.js"() { "use strict"; - getAwsChunkedEncodingStream = (readableStream, options) => { + getAwsChunkedEncodingStream = (readableStream2, options) => { const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options; const checksumRequired = base64Encoder !== void 0 && bodyLengthChecker !== void 0 && checksumAlgorithmFn !== void 0 && checksumLocationName !== void 0 && streamHasher !== void 0; - const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : void 0; - const reader = readableStream.getReader(); + const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream2) : void 0; + const reader = readableStream2.getReader(); return new ReadableStream({ async pull(controller) { const { value, done } = await reader.read(); @@ -20423,11 +20423,11 @@ ${value}\r }); // ../node_modules/@smithy/util-stream/dist-es/getAwsChunkedEncodingStream.js -function getAwsChunkedEncodingStream2(stream2, options) { - const readable = stream2; - const readableStream = stream2; - if (isReadableStream(readableStream)) { - return getAwsChunkedEncodingStream(readableStream, options); +function getAwsChunkedEncodingStream2(stream3, options) { + const readable = stream3; + const readableStream2 = stream3; + if (isReadableStream(readableStream2)) { + return getAwsChunkedEncodingStream(readableStream2, options); } const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options; const checksumRequired = base64Encoder !== void 0 && checksumAlgorithmFn !== void 0 && checksumLocationName !== void 0 && streamHasher !== void 0; @@ -20471,10 +20471,10 @@ var init_getAwsChunkedEncodingStream = __esm({ }); // ../node_modules/@smithy/util-stream/dist-es/headStream.browser.js -async function headStream(stream2, bytes) { +async function headStream(stream3, bytes) { let byteLengthCounter = 0; const chunks = []; - const reader = stream2.getReader(); + const reader = stream3.getReader(); let isDone = false; while (!isDone) { const { done, value } = await reader.read(); @@ -20515,22 +20515,22 @@ var init_headStream = __esm({ import_stream2 = require("stream"); init_headStream_browser(); init_stream_type_check(); - headStream2 = (stream2, bytes) => { - if (isReadableStream(stream2)) { - return headStream(stream2, bytes); + headStream2 = (stream3, bytes) => { + if (isReadableStream(stream3)) { + return headStream(stream3, bytes); } - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { const collector = new Collector(); collector.limit = bytes; - stream2.pipe(collector); - stream2.on("error", (err) => { + stream3.pipe(collector); + stream3.on("error", (err) => { collector.end(); - reject(err); + reject2(err); }); - collector.on("error", reject); + collector.on("error", reject2); collector.on("finish", function() { const bytes2 = new Uint8Array(Buffer.concat(this.buffers)); - resolve2(bytes2); + resolve3(bytes2); }); }); }; @@ -20559,7 +20559,7 @@ var init_escape_uri = __esm({ "../node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js"() { "use strict"; escapeUri = (uri) => encodeURIComponent(uri).replace(/[!'()*]/g, hexEncode); - hexEncode = (c6) => `%${c6.charCodeAt(0).toString(16).toUpperCase()}`; + hexEncode = (c7) => `%${c7.charCodeAt(0).toString(16).toUpperCase()}`; } }); @@ -20650,14 +20650,14 @@ var init_set_connection_timeout = __esm({ "use strict"; init_timing(); DEFER_EVENT_LISTENER_TIME = 1e3; - setConnectionTimeout = (request4, reject, timeoutInMs = 0) => { + setConnectionTimeout = (request4, reject2, timeoutInMs = 0) => { if (!timeoutInMs) { return -1; } const registerTimeout = (offset) => { const timeoutId = timing.setTimeout(() => { request4.destroy(); - reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), { + reject2(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), { name: "TimeoutError" })); }, timeoutInMs - offset); @@ -20691,7 +20691,7 @@ var init_set_request_timeout = __esm({ "../node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js"() { "use strict"; init_timing(); - setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger2) => { + setRequestTimeout = (req, reject2, timeoutInMs = 0, throwOnRequestTimeout, logger2) => { if (timeoutInMs) { return timing.setTimeout(() => { let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`; @@ -20701,7 +20701,7 @@ var init_set_request_timeout = __esm({ code: "ETIMEDOUT" }); req.destroy(error2); - reject(error2); + reject2(error2); } else { msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`; logger2?.warn?.(msg); @@ -20749,12 +20749,12 @@ var init_set_socket_timeout = __esm({ "use strict"; init_timing(); DEFER_EVENT_LISTENER_TIME3 = 3e3; - setSocketTimeout = (request4, reject, timeoutInMs = 0) => { + setSocketTimeout = (request4, reject2, timeoutInMs = 0) => { const registerTimeout = (offset) => { const timeout = timeoutInMs - offset; const onTimeout = () => { request4.destroy(); - reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" })); + reject2(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" })); }; if (request4.socket) { request4.socket.setTimeout(timeout, onTimeout); @@ -20780,21 +20780,21 @@ async function writeRequestBody(httpRequest2, request4, maxContinueTimeoutMs = M let sendBody = true; if (!externalAgent && expect === "100-continue") { sendBody = await Promise.race([ - new Promise((resolve2) => { - timeoutId = Number(timing.setTimeout(() => resolve2(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs))); + new Promise((resolve3) => { + timeoutId = Number(timing.setTimeout(() => resolve3(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs))); }), - new Promise((resolve2) => { + new Promise((resolve3) => { httpRequest2.on("continue", () => { timing.clearTimeout(timeoutId); - resolve2(true); + resolve3(true); }); httpRequest2.on("response", () => { timing.clearTimeout(timeoutId); - resolve2(false); + resolve3(false); }); httpRequest2.on("error", () => { timing.clearTimeout(timeoutId); - resolve2(false); + resolve3(false); }); }) ]); @@ -20886,13 +20886,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf return socketWarningTimestamp; } constructor(options) { - this.configProvider = new Promise((resolve2, reject) => { + this.configProvider = new Promise((resolve3, reject2) => { if (typeof options === "function") { options().then((_options) => { - resolve2(this.resolveDefaultConfig(_options)); - }).catch(reject); + resolve3(this.resolveDefaultConfig(_options)); + }).catch(reject2); } else { - resolve2(this.resolveDefaultConfig(options)); + resolve3(this.resolveDefaultConfig(options)); } }); } @@ -20935,12 +20935,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf const config = this.config; let writeRequestBodyPromise = void 0; const timeouts = []; - const resolve2 = async (arg) => { + const resolve3 = async (arg) => { await writeRequestBodyPromise; timeouts.forEach(timing.clearTimeout); _resolve(arg); }; - const reject = async (arg) => { + const reject2 = async (arg) => { await writeRequestBodyPromise; timeouts.forEach(timing.clearTimeout); _reject(arg); @@ -20948,7 +20948,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf if (abortSignal?.aborted) { const abortError = new Error("Request aborted"); abortError.name = "AbortError"; - reject(abortError); + reject2(abortError); return; } const isSSL = request4.protocol === "https:"; @@ -21001,13 +21001,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf headers: getTransformedHeaders(res.headers), body: res }); - resolve2({ response: httpResponse }); + resolve3({ response: httpResponse }); }); req.on("error", (err) => { if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) { - reject(Object.assign(err, { name: "TimeoutError" })); + reject2(Object.assign(err, { name: "TimeoutError" })); } else { - reject(err); + reject2(err); } }); if (abortSignal) { @@ -21015,7 +21015,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf req.destroy(); const abortError = new Error("Request aborted"); abortError.name = "AbortError"; - reject(abortError); + reject2(abortError); }; if (typeof abortSignal.addEventListener === "function") { const signal = abortSignal; @@ -21026,9 +21026,9 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf } } const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout; - timeouts.push(setConnectionTimeout(req, reject, config.connectionTimeout)); - timeouts.push(setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, config.logger ?? console)); - timeouts.push(setSocketTimeout(req, reject, config.socketTimeout)); + timeouts.push(setConnectionTimeout(req, reject2, config.connectionTimeout)); + timeouts.push(setRequestTimeout(req, reject2, effectiveRequestTimeout, config.throwOnRequestTimeout, config.logger ?? console)); + timeouts.push(setSocketTimeout(req, reject2, config.socketTimeout)); const httpAgent = nodeHttpsOptions.agent; if (typeof httpAgent === "object" && "keepAlive" in httpAgent) { timeouts.push(setSocketKeepAlive(req, { @@ -21082,9 +21082,9 @@ var init_collector = __esm({ }); // ../node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js -async function collectReadableStream(stream2) { +async function collectReadableStream(stream3) { const chunks = []; - const reader = stream2.getReader(); + const reader = stream3.getReader(); let isDone = false; let length = 0; while (!isDone) { @@ -21108,25 +21108,25 @@ var init_stream_collector = __esm({ "../node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js"() { "use strict"; init_collector(); - streamCollector = (stream2) => { - if (isReadableStreamInstance(stream2)) { - return collectReadableStream(stream2); + streamCollector = (stream3) => { + if (isReadableStreamInstance(stream3)) { + return collectReadableStream(stream3); } - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { const collector = new Collector2(); - stream2.pipe(collector); - stream2.on("error", (err) => { + stream3.pipe(collector); + stream3.on("error", (err) => { collector.end(); - reject(err); + reject2(err); }); - collector.on("error", reject); + collector.on("error", reject2); collector.on("finish", function() { const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes)); - resolve2(bytes); + resolve3(bytes); }); }); }; - isReadableStreamInstance = (stream2) => typeof ReadableStream === "function" && stream2 instanceof ReadableStream; + isReadableStreamInstance = (stream3) => typeof ReadableStream === "function" && stream3 instanceof ReadableStream; } }); @@ -21153,9 +21153,9 @@ async function collectBlob(blob) { const arrayBuffer = fromBase64(base64); return new Uint8Array(arrayBuffer); } -async function collectStream(stream2) { +async function collectStream(stream3) { const chunks = []; - const reader = stream2.getReader(); + const reader = stream3.getReader(); let isDone = false; let length = 0; while (!isDone) { @@ -21175,19 +21175,19 @@ async function collectStream(stream2) { return collected; } function readToBase64(blob) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { const reader = new FileReader(); reader.onloadend = () => { if (reader.readyState !== 2) { - return reject(new Error("Reader aborted too early")); + return reject2(new Error("Reader aborted too early")); } const result = reader.result ?? ""; const commaIndex = result.indexOf(","); const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length; - resolve2(result.substring(dataOffset)); + resolve3(result.substring(dataOffset)); }; - reader.onabort = () => reject(new Error("Read aborted")); - reader.onerror = () => reject(reader.error); + reader.onabort = () => reject2(new Error("Read aborted")); + reader.onerror = () => reject2(reader.error); reader.readAsDataURL(blob); }); } @@ -21196,14 +21196,14 @@ var init_stream_collector2 = __esm({ "../node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js"() { "use strict"; init_dist_es8(); - streamCollector2 = async (stream2) => { - if (typeof Blob === "function" && stream2 instanceof Blob || stream2.constructor?.name === "Blob") { + streamCollector2 = async (stream3) => { + if (typeof Blob === "function" && stream3 instanceof Blob || stream3.constructor?.name === "Blob") { if (Blob.prototype.arrayBuffer !== void 0) { - return new Uint8Array(await stream2.arrayBuffer()); + return new Uint8Array(await stream3.arrayBuffer()); } - return collectBlob(stream2); + return collectBlob(stream3); } - return collectStream(stream2); + return collectStream(stream3); }; } }); @@ -21268,9 +21268,9 @@ var init_sdk_stream_mixin_browser = __esm({ init_dist_es7(); init_stream_type_check(); ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed."; - sdkStreamMixin = (stream2) => { - if (!isBlobInstance(stream2) && !isReadableStream(stream2)) { - const name = stream2?.__proto__?.constructor?.name || stream2; + sdkStreamMixin = (stream3) => { + if (!isBlobInstance(stream3) && !isReadableStream(stream3)) { + const name = stream3?.__proto__?.constructor?.name || stream3; throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${name}`); } let transformed = false; @@ -21279,7 +21279,7 @@ var init_sdk_stream_mixin_browser = __esm({ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED); } transformed = true; - return await streamCollector2(stream2); + return await streamCollector2(stream3); }; const blobToWebStream = (blob) => { if (typeof blob.stream !== "function") { @@ -21287,7 +21287,7 @@ var init_sdk_stream_mixin_browser = __esm({ } return blob.stream(); }; - return Object.assign(stream2, { + return Object.assign(stream3, { transformToByteArray, transformToString: async (encoding) => { const buf = await transformToByteArray(); @@ -21308,17 +21308,17 @@ var init_sdk_stream_mixin_browser = __esm({ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED); } transformed = true; - if (isBlobInstance(stream2)) { - return blobToWebStream(stream2); - } else if (isReadableStream(stream2)) { - return stream2; + if (isBlobInstance(stream3)) { + return blobToWebStream(stream3); + } else if (isReadableStream(stream3)) { + return stream3; } else { - throw new Error(`Cannot transform payload to web stream, got ${stream2}`); + throw new Error(`Cannot transform payload to web stream, got ${stream3}`); } } }); }; - isBlobInstance = (stream2) => typeof Blob === "function" && stream2 instanceof Blob; + isBlobInstance = (stream3) => typeof Blob === "function" && stream3 instanceof Blob; } }); @@ -21332,12 +21332,12 @@ var init_sdk_stream_mixin = __esm({ import_stream5 = require("stream"); init_sdk_stream_mixin_browser(); ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2 = "The stream has already been transformed."; - sdkStreamMixin2 = (stream2) => { - if (!(stream2 instanceof import_stream5.Readable)) { + sdkStreamMixin2 = (stream3) => { + if (!(stream3 instanceof import_stream5.Readable)) { try { - return sdkStreamMixin(stream2); + return sdkStreamMixin(stream3); } catch (e6) { - const name = stream2?.__proto__?.constructor?.name || stream2; + const name = stream3?.__proto__?.constructor?.name || stream3; throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${name}`); } } @@ -21347,9 +21347,9 @@ var init_sdk_stream_mixin = __esm({ throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2); } transformed = true; - return await streamCollector(stream2); + return await streamCollector(stream3); }; - return Object.assign(stream2, { + return Object.assign(stream3, { transformToByteArray, transformToString: async (encoding) => { const buf = await transformToByteArray(); @@ -21364,14 +21364,14 @@ var init_sdk_stream_mixin = __esm({ if (transformed) { throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2); } - if (stream2.readableFlowing !== null) { + if (stream3.readableFlowing !== null) { throw new Error("The stream has been consumed by other callbacks."); } if (typeof import_stream5.Readable.toWeb !== "function") { throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available."); } transformed = true; - return import_stream5.Readable.toWeb(stream2); + return import_stream5.Readable.toWeb(stream3); } }); }; @@ -21379,12 +21379,12 @@ var init_sdk_stream_mixin = __esm({ }); // ../node_modules/@smithy/util-stream/dist-es/splitStream.browser.js -async function splitStream(stream2) { - if (typeof stream2.stream === "function") { - stream2 = stream2.stream(); +async function splitStream(stream3) { + if (typeof stream3.stream === "function") { + stream3 = stream3.stream(); } - const readableStream = stream2; - return readableStream.tee(); + const readableStream2 = stream3; + return readableStream2.tee(); } var init_splitStream_browser = __esm({ "../node_modules/@smithy/util-stream/dist-es/splitStream.browser.js"() { @@ -21393,14 +21393,14 @@ var init_splitStream_browser = __esm({ }); // ../node_modules/@smithy/util-stream/dist-es/splitStream.js -async function splitStream2(stream2) { - if (isReadableStream(stream2) || isBlob(stream2)) { - return splitStream(stream2); +async function splitStream2(stream3) { + if (isReadableStream(stream3) || isBlob(stream3)) { + return splitStream(stream3); } const stream1 = new import_stream6.PassThrough(); const stream22 = new import_stream6.PassThrough(); - stream2.pipe(stream1); - stream2.pipe(stream22); + stream3.pipe(stream1); + stream3.pipe(stream22); return [stream1, stream22]; } var import_stream6; @@ -21449,8 +21449,8 @@ var init_collect_stream_body = __esm({ // ../node_modules/@smithy/core/dist-es/submodules/protocols/extended-encode-uri-component.js function extendedEncodeURIComponent(str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function(c6) { - return "%" + c6.charCodeAt(0).toString(16).toUpperCase(); + return encodeURIComponent(str).replace(/[!'()*]/g, function(c7) { + return "%" + c7.charCodeAt(0).toString(16).toUpperCase(); }); } var init_extended_encode_uri_component = __esm({ @@ -23557,9 +23557,9 @@ var init_HttpInterceptingShapeDeserializer = __esm({ read(schema, data) { const ns = NormalizedSchema.of(schema); const traits = ns.getMergedTraits(); - const toString = this.serdeContext?.utf8Encoder ?? toUtf8; + const toString2 = this.serdeContext?.utf8Encoder ?? toUtf8; if (traits.httpHeader || traits.httpResponseCode) { - return this.stringDeserializer.read(ns, toString(data)); + return this.stringDeserializer.read(ns, toString2(data)); } if (traits.httpPayload) { if (ns.isBlobSchema()) { @@ -23570,7 +23570,7 @@ var init_HttpInterceptingShapeDeserializer = __esm({ return data; } else if (ns.isStringSchema()) { if ("byteLength" in data) { - return toString(data); + return toString2(data); } return data; } @@ -25947,9 +25947,9 @@ var init_UnionSerde = __esm({ from; to; keys; - constructor(from, to) { + constructor(from, to2) { this.from = from; - this.to = to; + this.to = to2; this.keys = new Set(Object.keys(this.from).filter((k6) => k6 !== "__type")); } mark(key) { @@ -26662,9 +26662,9 @@ var init_XmlNode = __esm({ } return node; } - constructor(name, children = []) { + constructor(name, children2 = []) { this.name = name; - this.children = children; + this.children = children2; } withName(name) { this.name = name; @@ -26731,7 +26731,7 @@ var init_XmlNode = __esm({ xmlText += ` ${attributeName}="${escapeAttribute("" + attribute)}"`; } } - return xmlText += !hasChildren ? "/>" : `>${this.children.map((c6) => c6.toString()).join("")}`; + return xmlText += !hasChildren ? "/>" : `>${this.children.map((c7) => c7.toString()).join("")}`; } }; } @@ -26824,11 +26824,11 @@ function validate(xmlData, options) { if (attrStr[attrStr.length - 1] === "/") { const attrStrStart = i6 - attrStr.length; attrStr = attrStr.substring(0, attrStr.length - 1); - const isValid = validateAttributeString(attrStr, options); - if (isValid === true) { + const isValid18 = validateAttributeString(attrStr, options); + if (isValid18 === true) { tagFound = true; } else { - return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line)); + return getErrorObject(isValid18.err.code, isValid18.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid18.err.line)); } } else if (closingTag) { if (!result.tagClosed) { @@ -26852,9 +26852,9 @@ function validate(xmlData, options) { } } } else { - const isValid = validateAttributeString(attrStr, options); - if (isValid !== true) { - return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i6 - attrStr.length + isValid.err.line)); + const isValid18 = validateAttributeString(attrStr, options); + if (isValid18 !== true) { + return getErrorObject(isValid18.err.code, isValid18.err.msg, getLineNumberForPosition(xmlData, i6 - attrStr.length + isValid18.err.line)); } if (reachedRoot === true) { return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i6)); @@ -29861,7 +29861,7 @@ var uriEncode; var init_uriEncode = __esm({ "../node_modules/@smithy/util-endpoints/dist-es/lib/uriEncode.js"() { "use strict"; - uriEncode = (value) => encodeURIComponent(value).replace(/[!*'()]/g, (c6) => `%${c6.charCodeAt(0).toString(16).toUpperCase()}`); + uriEncode = (value) => encodeURIComponent(value).replace(/[!*'()]/g, (c7) => `%${c7.charCodeAt(0).toString(16).toUpperCase()}`); } }); @@ -31358,11 +31358,11 @@ var init_createConfigValueProvider = __esm({ // ../node_modules/@smithy/node-config-provider/dist-es/getSelectorName.js function getSelectorName(functionString) { try { - const constants3 = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? [])); - constants3.delete("CONFIG"); - constants3.delete("CONFIG_PREFIX_SEPARATOR"); - constants3.delete("ENV"); - return [...constants3].join(", "); + const constants4 = new Set(Array.from(functionString.match(/([A-Z_]){3,}/g) ?? [])); + constants4.delete("CONFIG"); + constants4.delete("CONFIG_PREFIX_SEPARATOR"); + constants4.delete("ENV"); + return [...constants4].join(", "); } catch (e6) { return functionString; } @@ -32144,8 +32144,8 @@ var init_dist_es37 = __esm({ "Load failed", "Network request failed" ]); - const isValid = error2 && error2 instanceof TypeError; - if (!isValid) { + const isValid18 = error2 && error2 instanceof TypeError; + if (!isValid18) { return false; } return errorMessages.has(error2.message); @@ -32214,7 +32214,7 @@ var init_DefaultRateLimiter = __esm({ this.refillTokenBucket(); if (amount > this.currentCapacity) { const delay = (amount - this.currentCapacity) / this.fillRate * 1e3; - await new Promise((resolve2) => _DefaultRateLimiter.setTimeoutFn(resolve2, delay)); + await new Promise((resolve3) => _DefaultRateLimiter.setTimeoutFn(resolve3, delay)); } this.currentCapacity = this.currentCapacity - amount; } @@ -32649,7 +32649,7 @@ var init_retryMiddleware = __esm({ attempts = retryToken.getRetryCount(); const delay = retryToken.getRetryDelay(); totalRetryDelay += delay; - await new Promise((resolve2) => setTimeout(resolve2, delay)); + await new Promise((resolve3) => setTimeout(resolve3, delay)); } } } else { @@ -32780,24 +32780,24 @@ var init_dist_es40 = __esm({ // ../node_modules/@smithy/credential-provider-imds/dist-es/remoteProvider/httpRequest.js function httpRequest(options) { - return new Promise((resolve2, reject) => { + return new Promise((resolve3, reject2) => { const req = (0, import_http2.request)({ method: "GET", ...options, hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1") }); req.on("error", (err) => { - reject(Object.assign(new ProviderError("Unable to connect to instance metadata service"), err)); + reject2(Object.assign(new ProviderError("Unable to connect to instance metadata service"), err)); req.destroy(); }); req.on("timeout", () => { - reject(new ProviderError("TimeoutError from instance metadata service")); + reject2(new ProviderError("TimeoutError from instance metadata service")); req.destroy(); }); req.on("response", (res) => { const { statusCode = 400 } = res; if (statusCode < 200 || 300 <= statusCode) { - reject(Object.assign(new ProviderError("Error response received from instance metadata service"), { statusCode })); + reject2(Object.assign(new ProviderError("Error response received from instance metadata service"), { statusCode })); req.destroy(); } const chunks = []; @@ -32805,7 +32805,7 @@ function httpRequest(options) { chunks.push(chunk); }); res.on("end", () => { - resolve2(import_buffer3.Buffer.concat(chunks)); + resolve3(import_buffer3.Buffer.concat(chunks)); req.destroy(); }); }); @@ -33329,8 +33329,8 @@ function createGetRequest(url) { }); } async function getCredentials(response, logger2) { - const stream2 = sdkStreamMixin2(response.body); - const str = await stream2.transformToString(); + const stream3 = sdkStreamMixin2(response.body); + const str = await stream3.transformToString(); if (response.statusCode === 200) { const parsed = JSON.parse(str); if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") { @@ -33377,7 +33377,7 @@ var init_retry_wrapper = __esm({ try { return await toRetry(); } catch (e6) { - await new Promise((resolve2) => setTimeout(resolve2, delayMs)); + await new Promise((resolve3) => setTimeout(resolve3, delayMs)); } } return await toRetry(); @@ -38115,16 +38115,16 @@ var init_LoginCredentialsFetcher = __esm({ break; } } - const x6 = publicDer.slice(pointStart + 1, pointStart + 33); - const y3 = publicDer.slice(pointStart + 33, pointStart + 65); + const x7 = publicDer.slice(pointStart + 1, pointStart + 33); + const y4 = publicDer.slice(pointStart + 33, pointStart + 65); const header = { alg: "ES256", typ: "dpop+jwt", jwk: { kty: "EC", crv: "P-256", - x: x6.toString("base64url"), - y: y3.toString("base64url") + x: x7.toString("base64url"), + y: y4.toString("base64url") } }; const payload = { @@ -38867,13 +38867,13 @@ var require_util9 = __commonJS({ function classString(obj2) { return {}.toString.call(obj2); } - function copyDescriptors(from, to, filter2) { + function copyDescriptors(from, to2, filter2) { var keys = es5.names(from); for (var i6 = 0; i6 < keys.length; ++i6) { var key = keys[i6]; if (filter2(key)) { try { - es5.defineProperty(to, key, es5.getDescriptor(from, key)); + es5.defineProperty(to2, key, es5.getDescriptor(from, key)); } catch (ignore) { } } @@ -39019,16 +39019,16 @@ var require_util9 = __commonJS({ var require_schedule = __commonJS({ "../node_modules/bluebird/js/release/schedule.js"(exports2, module2) { "use strict"; - var util = require_util9(); + var util17 = require_util9(); var schedule; var noAsyncScheduler = function() { throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n"); }; - var NativePromise = util.getNativePromise(); - if (util.isNode && typeof MutationObserver === "undefined") { + var NativePromise = util17.getNativePromise(); + if (util17.isNode && typeof MutationObserver === "undefined") { GlobalSetImmediate = global.setImmediate; ProcessNextTick = process.nextTick; - schedule = util.isRecentNode ? function(fn) { + schedule = util17.isRecentNode ? function(fn) { GlobalSetImmediate.call(global, fn); } : function(fn) { ProcessNextTick.call(process, fn); @@ -39268,9 +39268,9 @@ var require_errors2 = __commonJS({ "use strict"; var es52 = require_es5(); var Objectfreeze = es52.freeze; - var util = require_util9(); - var inherits2 = util.inherits; - var notEnumerableProp2 = util.notEnumerableProp; + var util17 = require_util9(); + var inherits2 = util17.inherits; + var notEnumerableProp2 = util17.notEnumerableProp; function subError(nameProperty, defaultMessage) { function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); @@ -39302,10 +39302,10 @@ var require_errors2 = __commonJS({ _TypeError = subError("TypeError", "type error"); _RangeError = subError("RangeError", "range error"); } - var methods = "join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "); - for (i6 = 0; i6 < methods.length; ++i6) { - if (typeof Array.prototype[methods[i6]] === "function") { - AggregateError.prototype[methods[i6]] = Array.prototype[methods[i6]]; + var methods19 = "join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "); + for (i6 = 0; i6 < methods19.length; ++i6) { + if (typeof Array.prototype[methods19[i6]] === "function") { + AggregateError.prototype[methods19[i6]] = Array.prototype[methods19[i6]]; } } var i6; @@ -39383,9 +39383,9 @@ var require_thenables = __commonJS({ "../node_modules/bluebird/js/release/thenables.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, INTERNAL) { - var util = require_util9(); - var errorObj2 = util.errorObj; - var isObject2 = util.isObject; + var util17 = require_util9(); + var errorObj2 = util17.errorObj; + var isObject2 = util17.isObject; function tryConvertToPromise(obj2, context3) { if (isObject2(obj2)) { if (obj2 instanceof Promise2) return obj2; @@ -39431,25 +39431,25 @@ var require_thenables = __commonJS({ return false; } } - function doThenable(x6, then, context3) { + function doThenable(x7, then, context3) { var promise = new Promise2(INTERNAL); var ret2 = promise; if (context3) context3._pushContext(); promise._captureStackTrace(); if (context3) context3._popContext(); var synchronous = true; - var result = util.tryCatch(then).call(x6, resolve2, reject); + var result = util17.tryCatch(then).call(x7, resolve3, reject2); synchronous = false; if (promise && result === errorObj2) { promise._rejectCallback(result.e, true, true); promise = null; } - function resolve2(value) { + function resolve3(value) { if (!promise) return; promise._resolveCallback(value); promise = null; } - function reject(reason) { + function reject2(reason) { if (!promise) return; promise._rejectCallback(reason, synchronous, true); promise = null; @@ -39466,8 +39466,8 @@ var require_promise_array = __commonJS({ "../node_modules/bluebird/js/release/promise_array.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, INTERNAL, tryConvertToPromise, apiRejection, Proxyable) { - var util = require_util9(); - var isArray = util.isArray; + var util17 = require_util9(); + var isArray = util17.isArray; function toResolutionValue(val) { switch (val) { case -2: @@ -39490,7 +39490,7 @@ var require_promise_array = __commonJS({ this._totalResolved = 0; this._init(void 0, -2); } - util.inherits(PromiseArray, Proxyable); + util17.inherits(PromiseArray, Proxyable); PromiseArray.prototype.length = function() { return this._length; }; @@ -39521,10 +39521,10 @@ var require_promise_array = __commonJS({ return this._cancel(); } } - values = util.asArray(values); + values = util17.asArray(values); if (values === null) { var err = apiRejection( - "expecting an array or an iterable object but got " + util.classString(values) + "expecting an array or an iterable object but got " + util17.classString(values) ).reason(); this._promise._rejectCallback(err, false); return; @@ -39717,9 +39717,9 @@ var require_debuggability = __commonJS({ module2.exports = function(Promise2, Context2, enableAsyncHooks, disableAsyncHooks) { var async = Promise2._async; var Warning = require_errors2().Warning; - var util = require_util9(); + var util17 = require_util9(); var es52 = require_es5(); - var canAttachTrace2 = util.canAttachTrace; + var canAttachTrace2 = util17.canAttachTrace; var unhandledRejectionHandled; var possiblyUnhandledRejection; var bluebirdFramePattern = /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/; @@ -39729,10 +39729,10 @@ var require_debuggability = __commonJS({ var formatStack = null; var indentStackFrames = false; var printWarning; - var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 && (util.env("BLUEBIRD_DEBUG") || util.env("NODE_ENV") === "development")); - var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 && (debugging || util.env("BLUEBIRD_WARNINGS"))); - var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 && (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES"))); - var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 && (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN")); + var debugging = !!(util17.env("BLUEBIRD_DEBUG") != 0 && (util17.env("BLUEBIRD_DEBUG") || util17.env("NODE_ENV") === "development")); + var warnings = !!(util17.env("BLUEBIRD_WARNINGS") != 0 && (debugging || util17.env("BLUEBIRD_WARNINGS"))); + var longStackTraces = !!(util17.env("BLUEBIRD_LONG_STACK_TRACES") != 0 && (debugging || util17.env("BLUEBIRD_LONG_STACK_TRACES"))); + var wForgottenReturn = util17.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 && (warnings || !!util17.env("BLUEBIRD_W_FORGOTTEN_RETURN")); var deferUnhandledRejectionCheck; (function() { var promises3 = []; @@ -39818,11 +39818,11 @@ var require_debuggability = __commonJS({ }; Promise2.onPossiblyUnhandledRejection = function(fn) { var context3 = Promise2._getContext(); - possiblyUnhandledRejection = util.contextBind(context3, fn); + possiblyUnhandledRejection = util17.contextBind(context3, fn); }; Promise2.onUnhandledRejectionHandled = function(fn) { var context3 = Promise2._getContext(); - unhandledRejectionHandled = util.contextBind(context3, fn); + unhandledRejectionHandled = util17.contextBind(context3, fn); }; var disableLongStackTraces = function() { }; @@ -39857,22 +39857,22 @@ var require_debuggability = __commonJS({ var legacyHandlers = { unhandledrejection: { before: function() { - var ret2 = util.global.onunhandledrejection; - util.global.onunhandledrejection = null; + var ret2 = util17.global.onunhandledrejection; + util17.global.onunhandledrejection = null; return ret2; }, after: function(fn) { - util.global.onunhandledrejection = fn; + util17.global.onunhandledrejection = fn; } }, rejectionhandled: { before: function() { - var ret2 = util.global.onrejectionhandled; - util.global.onrejectionhandled = null; + var ret2 = util17.global.onrejectionhandled; + util17.global.onrejectionhandled = null; return ret2; }, after: function(fn) { - util.global.onrejectionhandled = fn; + util17.global.onrejectionhandled = fn; } } }; @@ -39882,18 +39882,18 @@ var require_debuggability = __commonJS({ var fn; try { fn = legacy.before(); - return !util.global.dispatchEvent(e6); + return !util17.global.dispatchEvent(e6); } finally { legacy.after(fn); } } else { - return !util.global.dispatchEvent(e6); + return !util17.global.dispatchEvent(e6); } }; try { if (typeof CustomEvent === "function") { var event = new CustomEvent("CustomEvent"); - util.global.dispatchEvent(event); + util17.global.dispatchEvent(event); return function(name, event2) { name = name.toLowerCase(); var eventData = { @@ -39915,7 +39915,7 @@ var require_debuggability = __commonJS({ }; } else if (typeof Event === "function") { var event = new Event("CustomEvent"); - util.global.dispatchEvent(event); + util17.global.dispatchEvent(event); return function(name, event2) { name = name.toLowerCase(); var domEvent = new Event(name, { @@ -39929,7 +39929,7 @@ var require_debuggability = __commonJS({ } else { var event = document.createEvent("CustomEvent"); event.initCustomEvent("testingtheevent", false, true, {}); - util.global.dispatchEvent(event); + util17.global.dispatchEvent(event); return function(name, event2) { name = name.toLowerCase(); var domEvent = document.createEvent("CustomEvent"); @@ -39949,21 +39949,21 @@ var require_debuggability = __commonJS({ }; })(); var fireGlobalEvent = (function() { - if (util.isNode) { + if (util17.isNode) { return function() { return process.emit.apply(process, arguments); }; } else { - if (!util.global) { + if (!util17.global) { return function() { return false; }; } return function(name) { var methodName = "on" + name.toLowerCase(); - var method = util.global[methodName]; + var method = util17.global[methodName]; if (!method) return false; - method.apply(util.global, [].slice.call(arguments, 1)); + method.apply(util17.global, [].slice.call(arguments, 1)); return true; }; } @@ -40021,7 +40021,7 @@ var require_debuggability = __commonJS({ var warningsOption = opts.warnings; config.warnings = !!warningsOption; wForgottenReturn = config.warnings; - if (util.isObject(warningsOption)) { + if (util17.isObject(warningsOption)) { if ("wForgottenReturn" in warningsOption) { wForgottenReturn = !!warningsOption.wForgottenReturn; } @@ -40051,7 +40051,7 @@ var require_debuggability = __commonJS({ Promise2.prototype._fireEvent = defaultFireEvent; } } - if ("asyncHooks" in opts && util.nodeSupportsAsyncResource) { + if ("asyncHooks" in opts && util17.nodeSupportsAsyncResource) { var prev = config.asyncHooks; var cur = !!opts.asyncHooks; if (prev !== cur) { @@ -40069,9 +40069,9 @@ var require_debuggability = __commonJS({ return false; } Promise2.prototype._fireEvent = defaultFireEvent; - Promise2.prototype._execute = function(executor, resolve2, reject) { + Promise2.prototype._execute = function(executor, resolve3, reject2) { try { - executor(resolve2, reject); + executor(resolve3, reject2); } catch (e6) { return e6; } @@ -40096,12 +40096,12 @@ var require_debuggability = __commonJS({ ; ; }; - function cancellationExecute(executor, resolve2, reject) { + function cancellationExecute(executor, resolve3, reject2) { var promise = this; try { - executor(resolve2, reject, function(onCancel) { + executor(resolve3, reject2, function(onCancel) { if (typeof onCancel !== "function") { - throw new TypeError("onCancel must be a function, got: " + util.toString(onCancel)); + throw new TypeError("onCancel must be a function, got: " + util17.toString(onCancel)); } promise._attachCancellationCallback(onCancel); }); @@ -40113,7 +40113,7 @@ var require_debuggability = __commonJS({ if (!this._isCancellable()) return this; var previousOnCancel = this._onCancel(); if (previousOnCancel !== void 0) { - if (util.isArray(previousOnCancel)) { + if (util17.isArray(previousOnCancel)) { previousOnCancel.push(onCancel); } else { this._setOnCancel([previousOnCancel, onCancel]); @@ -40177,12 +40177,12 @@ var require_debuggability = __commonJS({ trace.attachExtraTrace(error2); } else if (!error2.__stackCleaned__) { var parsed = parseStackAndMessage(error2); - util.notEnumerableProp( + util17.notEnumerableProp( error2, "stack", parsed.message + "\n" + parsed.stack.join("\n") ); - util.notEnumerableProp(error2, "__stackCleaned__", true); + util17.notEnumerableProp(error2, "__stackCleaned__", true); } } } @@ -40329,7 +40329,7 @@ var require_debuggability = __commonJS({ function formatAndLogError(error2, title, isSoft) { if (typeof console !== "undefined") { var message; - if (util.isObject(error2)) { + if (util17.isObject(error2)) { var stack = error2.stack; message = title + formatStack(stack, error2); } else { @@ -40369,7 +40369,7 @@ var require_debuggability = __commonJS({ if (typeof obj2 === "function") { str = "[function " + (obj2.name || "anonymous") + "]"; } else { - str = obj2 && typeof obj2.toString === "function" ? obj2.toString() : util.toString(obj2); + str = obj2 && typeof obj2.toString === "function" ? obj2.toString() : util17.toString(obj2); var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/; if (ruselessToString.test(str)) { try { @@ -40452,7 +40452,7 @@ var require_debuggability = __commonJS({ captureStackTrace(this, CapturedTrace); if (length > 32) this.uncycle(); } - util.inherits(CapturedTrace, Error); + util17.inherits(CapturedTrace, Error); Context2.CapturedTrace = CapturedTrace; CapturedTrace.prototype.uncycle = function() { var length = this._length; @@ -40511,8 +40511,8 @@ var require_debuggability = __commonJS({ } removeCommonRoots(stacks); removeDuplicateOrEmptyJumps(stacks); - util.notEnumerableProp(error2, "stack", reconstructStack(message, stacks)); - util.notEnumerableProp(error2, "__stackCleaned__", true); + util17.notEnumerableProp(error2, "stack", reconstructStack(message, stacks)); + util17.notEnumerableProp(error2, "__stackCleaned__", true); }; var captureStackTrace = (function stackDetection() { var v8stackFramePattern = /^\s*at\s*/; @@ -40578,12 +40578,12 @@ var require_debuggability = __commonJS({ printWarning = function(message) { console.warn(message); }; - if (util.isNode && process.stderr.isTTY) { + if (util17.isNode && process.stderr.isTTY) { printWarning = function(message, isSoft) { var color = isSoft ? "\x1B[33m" : "\x1B[31m"; console.warn(color + message + "\x1B[0m\n"); }; - } else if (!util.isNode && typeof new Error().stack === "string") { + } else if (!util17.isNode && typeof new Error().stack === "string") { printWarning = function(message, isSoft) { console.warn( "%c" + message, @@ -40639,10 +40639,10 @@ var require_catch_filter = __commonJS({ "../node_modules/bluebird/js/release/catch_filter.js"(exports2, module2) { "use strict"; module2.exports = function(NEXT_FILTER) { - var util = require_util9(); + var util17 = require_util9(); var getKeys = require_es5().keys; - var tryCatch2 = util.tryCatch; - var errorObj2 = util.errorObj; + var tryCatch2 = util17.tryCatch; + var errorObj2 = util17.errorObj; function catchFilter(instances, cb2, promise) { return function(e6) { var boundTo = promise._boundValue(); @@ -40659,7 +40659,7 @@ var require_catch_filter = __commonJS({ } else if (matchesPredicate) { return tryCatch2(cb2).call(boundTo, e6); } - } else if (util.isObject(e6)) { + } else if (util17.isObject(e6)) { var keys = getKeys(item); for (var j6 = 0; j6 < keys.length; ++j6) { var key = keys[j6]; @@ -40683,9 +40683,9 @@ var require_finally = __commonJS({ "../node_modules/bluebird/js/release/finally.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, tryConvertToPromise, NEXT_FILTER) { - var util = require_util9(); + var util17 = require_util9(); var CancellationError = Promise2.CancellationError; - var errorObj2 = util.errorObj; + var errorObj2 = util17.errorObj; var catchFilter = require_catch_filter()(NEXT_FILTER); function PassThroughHandlerContext(promise, type, handler2) { this.promise = promise; @@ -40800,11 +40800,11 @@ var require_finally = __commonJS({ var catchInstances = new Array(len - 1), j6 = 0, i6; for (i6 = 0; i6 < len - 1; ++i6) { var item = arguments[i6]; - if (util.isObject(item)) { + if (util17.isObject(item)) { catchInstances[j6++] = item; } else { return Promise2.reject(new TypeError( - "tapCatch statement predicate: expecting an object but got " + util.classString(item) + "tapCatch statement predicate: expecting an object but got " + util17.classString(item) )); } } @@ -40827,8 +40827,8 @@ var require_finally = __commonJS({ var require_nodeback = __commonJS({ "../node_modules/bluebird/js/release/nodeback.js"(exports2, module2) { "use strict"; - var util = require_util9(); - var maybeWrapAsError2 = util.maybeWrapAsError; + var util17 = require_util9(); + var maybeWrapAsError2 = util17.maybeWrapAsError; var errors = require_errors2(); var OperationalError = errors.OperationalError; var es52 = require_es5(); @@ -40852,7 +40852,7 @@ var require_nodeback = __commonJS({ } return ret2; } - util.markAsOriginatingFromRejection(obj2); + util17.markAsOriginatingFromRejection(obj2); return obj2; } function nodebackForPromise(promise, multiArgs) { @@ -40885,11 +40885,11 @@ var require_method = __commonJS({ "../node_modules/bluebird/js/release/method.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, INTERNAL, tryConvertToPromise, apiRejection, debug2) { - var util = require_util9(); - var tryCatch2 = util.tryCatch; + var util17 = require_util9(); + var tryCatch2 = util17.tryCatch; Promise2.method = function(fn) { if (typeof fn !== "function") { - throw new Promise2.TypeError("expecting a function but got " + util.classString(fn)); + throw new Promise2.TypeError("expecting a function but got " + util17.classString(fn)); } return function() { var ret2 = new Promise2(INTERNAL); @@ -40909,7 +40909,7 @@ var require_method = __commonJS({ }; Promise2.attempt = Promise2["try"] = function(fn) { if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); + return apiRejection("expecting a function but got " + util17.classString(fn)); } var ret2 = new Promise2(INTERNAL); ret2._captureStackTrace(); @@ -40919,7 +40919,7 @@ var require_method = __commonJS({ debug2.deprecated("calling Promise.try with more than 1 argument"); var arg = arguments[1]; var ctx = arguments[2]; - value = util.isArray(arg) ? tryCatch2(fn).apply(ctx, arg) : tryCatch2(fn).call(ctx, arg); + value = util17.isArray(arg) ? tryCatch2(fn).apply(ctx, arg) : tryCatch2(fn).call(ctx, arg); } else { value = tryCatch2(fn)(); } @@ -40934,7 +40934,7 @@ var require_method = __commonJS({ return ret2; }; Promise2.prototype._resolveFromSyncValue = function(value) { - if (value === util.errorObj) { + if (value === util17.errorObj) { this._rejectCallback(value.e, false); } else { this._resolveCallback(value, true); @@ -41020,9 +41020,9 @@ var require_cancel = __commonJS({ "../node_modules/bluebird/js/release/cancel.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, PromiseArray, apiRejection, debug2) { - var util = require_util9(); - var tryCatch2 = util.tryCatch; - var errorObj2 = util.errorObj; + var util17 = require_util9(); + var tryCatch2 = util17.tryCatch; + var errorObj2 = util17.errorObj; var async = Promise2._async; Promise2.prototype["break"] = Promise2.prototype.cancel = function() { if (!debug2.cancellation()) return this._warn("cancellation is disabled"); @@ -41096,7 +41096,7 @@ var require_cancel = __commonJS({ return this.isPending() && !this.isCancelled(); }; Promise2.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) { - if (util.isArray(onCancelCallback)) { + if (util17.isArray(onCancelCallback)) { for (var i6 = 0; i6 < onCancelCallback.length; ++i6) { this._doInvokeOnCancel(onCancelCallback[i6], internalOnly); } @@ -41293,11 +41293,11 @@ var require_join = __commonJS({ "../node_modules/bluebird/js/release/join.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, PromiseArray, tryConvertToPromise, INTERNAL, async) { - var util = require_util9(); - var canEvaluate2 = util.canEvaluate; - var tryCatch2 = util.tryCatch; - var errorObj2 = util.errorObj; - var reject; + var util17 = require_util9(); + var canEvaluate2 = util17.canEvaluate; + var tryCatch2 = util17.tryCatch; + var errorObj2 = util17.errorObj; + var reject2; if (true) { if (canEvaluate2) { var thenCallback = function(i7) { @@ -41329,7 +41329,7 @@ var require_join = __commonJS({ thenCallbacks.push(thenCallback(i6 + 1)); promiseSetters.push(promiseSetter(i6 + 1)); } - reject = function(reason) { + reject2 = function(reason) { this._reject(reason); }; } @@ -41355,7 +41355,7 @@ var require_join = __commonJS({ if ((bitField & 50397184) === 0) { maybePromise._then( callbacks[i7], - reject, + reject2, void 0, ret2, holder @@ -41380,7 +41380,7 @@ var require_join = __commonJS({ if (!ret2._isFateSealed()) { if (holder.asyncNeeded) { var context3 = Promise2._getContext(); - holder.fn = util.contextBind(context3, holder.fn); + holder.fn = util17.contextBind(context3, holder.fn); } ret2._setAsyncGuaranteed(); ret2._setOnCancel(holder); @@ -41416,9 +41416,9 @@ var require_call_get = __commonJS({ var callerCache; var getterCache; module2.exports = function(Promise2) { - var util = require_util9(); - var canEvaluate2 = util.canEvaluate; - var isIdentifier2 = util.isIdentifier; + var util17 = require_util9(); + var canEvaluate2 = util17.canEvaluate; + var isIdentifier2 = util17.isIdentifier; var getMethodCaller; var getGetter; if (true) { @@ -41456,7 +41456,7 @@ var require_call_get = __commonJS({ var fn; if (obj2 != null) fn = obj2[methodName]; if (typeof fn !== "function") { - var message = "Object " + util.classString(obj2) + " has no method '" + util.toString(methodName) + "'"; + var message = "Object " + util17.classString(obj2) + " has no method '" + util17.toString(methodName) + "'"; throw new Promise2.TypeError(message); } return fn; @@ -41524,9 +41524,9 @@ var require_generators = __commonJS({ module2.exports = function(Promise2, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug2) { var errors = require_errors2(); var TypeError2 = errors.TypeError; - var util = require_util9(); - var errorObj2 = util.errorObj; - var tryCatch2 = util.tryCatch; + var util17 = require_util9(); + var errorObj2 = util17.errorObj; + var tryCatch2 = util17.tryCatch; var yieldHandlers = []; function promiseFromYieldHandler(value, yieldHandlers2, traceParent) { for (var i6 = 0; i6 < yieldHandlers2.length; ++i6) { @@ -41565,7 +41565,7 @@ var require_generators = __commonJS({ this._yieldedPromise = null; this._cancellationPhase = false; } - util.inherits(PromiseSpawn, Proxyable); + util17.inherits(PromiseSpawn, Proxyable); PromiseSpawn.prototype._isResolved = function() { return this._promise === null; }; @@ -41715,7 +41715,7 @@ var require_generators = __commonJS({ }; Promise2.coroutine.addYieldHandler = function(fn) { if (typeof fn !== "function") { - throw new TypeError2("expecting a function but got " + util.classString(fn)); + throw new TypeError2("expecting a function but got " + util17.classString(fn)); } yieldHandlers.push(fn); }; @@ -41738,21 +41738,21 @@ var require_map = __commonJS({ "../node_modules/bluebird/js/release/map.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug2) { - var util = require_util9(); - var tryCatch2 = util.tryCatch; - var errorObj2 = util.errorObj; + var util17 = require_util9(); + var tryCatch2 = util17.tryCatch; + var errorObj2 = util17.errorObj; var async = Promise2._async; function MappingPromiseArray(promises3, fn, limit, _filter) { this.constructor$(promises3); this._promise._captureStackTrace(); var context3 = Promise2._getContext(); - this._callback = util.contextBind(context3, fn); + this._callback = util17.contextBind(context3, fn); this._preservedValues = _filter === INTERNAL ? new Array(this.length()) : null; this._limit = limit; this._inFlight = 0; this._queue = []; async.invoke(this._asyncInit, this, void 0); - if (util.isArray(promises3)) { + if (util17.isArray(promises3)) { for (var i6 = 0; i6 < promises3.length; ++i6) { var maybePromise = promises3[i6]; if (maybePromise instanceof Promise2) { @@ -41761,7 +41761,7 @@ var require_map = __commonJS({ } } } - util.inherits(MappingPromiseArray, PromiseArray); + util17.inherits(MappingPromiseArray, PromiseArray); MappingPromiseArray.prototype._asyncInit = function() { this._init$(void 0, -2); }; @@ -41861,20 +41861,20 @@ var require_map = __commonJS({ }; function map2(promises3, fn, options, _filter) { if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); + return apiRejection("expecting a function but got " + util17.classString(fn)); } var limit = 0; if (options !== void 0) { if (typeof options === "object" && options !== null) { if (typeof options.concurrency !== "number") { return Promise2.reject( - new TypeError("'concurrency' must be a number but it is " + util.classString(options.concurrency)) + new TypeError("'concurrency' must be a number but it is " + util17.classString(options.concurrency)) ); } limit = options.concurrency; } else { return Promise2.reject(new TypeError( - "options argument must be an object but it is " + util.classString(options) + "options argument must be an object but it is " + util17.classString(options) )); } } @@ -41896,13 +41896,13 @@ var require_nodeify = __commonJS({ "../node_modules/bluebird/js/release/nodeify.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2) { - var util = require_util9(); + var util17 = require_util9(); var async = Promise2._async; - var tryCatch2 = util.tryCatch; - var errorObj2 = util.errorObj; + var tryCatch2 = util17.tryCatch; + var errorObj2 = util17.errorObj; function spreadAdapter(val, nodeback) { var promise = this; - if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback); + if (!util17.isArray(val)) return successAdapter.call(promise, val, nodeback); var ret2 = tryCatch2(nodeback).apply(promise._boundValue(), [null].concat(val)); if (ret2 === errorObj2) { async.throwLater(ret2.e); @@ -41954,11 +41954,11 @@ var require_promisify = __commonJS({ "use strict"; module2.exports = function(Promise2, INTERNAL) { var THIS = {}; - var util = require_util9(); + var util17 = require_util9(); var nodebackForPromise = require_nodeback(); - var withAppended2 = util.withAppended; - var maybeWrapAsError2 = util.maybeWrapAsError; - var canEvaluate2 = util.canEvaluate; + var withAppended2 = util17.withAppended; + var maybeWrapAsError2 = util17.maybeWrapAsError; + var canEvaluate2 = util17.canEvaluate; var TypeError2 = require_errors2().TypeError; var defaultSuffix = "Async"; var defaultPromisified = { __isPromisified__: true }; @@ -41974,7 +41974,7 @@ var require_promisify = __commonJS({ ]; var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$"); var defaultFilter = function(name) { - return util.isIdentifier(name) && name.charAt(0) !== "_" && name !== "constructor"; + return util17.isIdentifier(name) && name.charAt(0) !== "_" && name !== "constructor"; }; function propsFilter(key) { return !noCopyPropsPattern.test(key); @@ -41987,7 +41987,7 @@ var require_promisify = __commonJS({ } } function hasPromisified(obj2, key, suffix) { - var val = util.getDataPropertyOrDefault( + var val = util17.getDataPropertyOrDefault( obj2, key + suffix, defaultPromisified @@ -42008,7 +42008,7 @@ var require_promisify = __commonJS({ } } function promisifiableMethods(obj2, suffix, suffixRegexp, filter2) { - var keys = util.inheritedDataKeys(obj2); + var keys = util17.inheritedDataKeys(obj2); var ret2 = []; for (var i6 = 0; i6 < keys.length; ++i6) { var key = keys[i6]; @@ -42038,10 +42038,10 @@ var require_promisify = __commonJS({ return ret2; }; var argumentSequence = function(argumentCount) { - return util.filledRange(argumentCount, "_arg", ""); + return util17.filledRange(argumentCount, "_arg", ""); }; var parameterDeclaration = function(parameterCount2) { - return util.filledRange( + return util17.filledRange( Math.max(parameterCount2, 3), "_arg", "" @@ -42098,9 +42098,9 @@ var require_promisify = __commonJS({ withAppended2, maybeWrapAsError2, nodebackForPromise, - util.tryCatch, - util.errorObj, - util.notEnumerableProp, + util17.tryCatch, + util17.errorObj, + util17.notEnumerableProp, INTERNAL ); }; @@ -42128,16 +42128,16 @@ var require_promisify = __commonJS({ if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); return promise; } - util.notEnumerableProp(promisified, "__isPromisified__", true); + util17.notEnumerableProp(promisified, "__isPromisified__", true); return promisified; } var makeNodePromisified = canEvaluate2 ? makeNodePromisifiedEval : makeNodePromisifiedClosure; function promisifyAll(obj2, suffix, filter2, promisifier, multiArgs) { var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$"); - var methods = promisifiableMethods(obj2, suffix, suffixRegexp, filter2); - for (var i6 = 0, len = methods.length; i6 < len; i6 += 2) { - var key = methods[i6]; - var fn = methods[i6 + 1]; + var methods19 = promisifiableMethods(obj2, suffix, suffixRegexp, filter2); + for (var i6 = 0, len = methods19.length; i6 < len; i6 += 2) { + var key = methods19[i6]; + var fn = methods19[i6 + 1]; var promisifiedKey = key + suffix; if (promisifier === makeNodePromisified) { obj2[promisifiedKey] = makeNodePromisified(key, THIS, key, fn, suffix, multiArgs); @@ -42152,11 +42152,11 @@ var require_promisify = __commonJS({ multiArgs ); }); - util.notEnumerableProp(promisified, "__isPromisified__", true); + util17.notEnumerableProp(promisified, "__isPromisified__", true); obj2[promisifiedKey] = promisified; } } - util.toFastProperties(obj2); + util17.toFastProperties(obj2); return obj2; } function promisify2(callback, receiver2, multiArgs) { @@ -42171,7 +42171,7 @@ var require_promisify = __commonJS({ } Promise2.promisify = function(fn, options) { if (typeof fn !== "function") { - throw new TypeError2("expecting a function but got " + util.classString(fn)); + throw new TypeError2("expecting a function but got " + util17.classString(fn)); } if (isPromisified(fn)) { return fn; @@ -42180,7 +42180,7 @@ var require_promisify = __commonJS({ var receiver2 = options.context === void 0 ? THIS : options.context; var multiArgs = !!options.multiArgs; var ret2 = promisify2(fn, receiver2, multiArgs); - util.copyDescriptors(fn, ret2, propsFilter); + util17.copyDescriptors(fn, ret2, propsFilter); return ret2; }; Promise2.promisifyAll = function(target, options) { @@ -42195,13 +42195,13 @@ var require_promisify = __commonJS({ if (typeof filter2 !== "function") filter2 = defaultFilter; var promisifier = options.promisifier; if (typeof promisifier !== "function") promisifier = makeNodePromisified; - if (!util.isIdentifier(suffix)) { + if (!util17.isIdentifier(suffix)) { throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/MqrFmX\n"); } - var keys = util.inheritedDataKeys(target); + var keys = util17.inheritedDataKeys(target); for (var i6 = 0; i6 < keys.length; ++i6) { var value = target[keys[i6]]; - if (keys[i6] !== "constructor" && util.isClass(value)) { + if (keys[i6] !== "constructor" && util17.isClass(value)) { promisifyAll( value.prototype, suffix, @@ -42223,8 +42223,8 @@ var require_props = __commonJS({ "../node_modules/bluebird/js/release/props.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, PromiseArray, tryConvertToPromise, apiRejection) { - var util = require_util9(); - var isObject2 = util.isObject; + var util17 = require_util9(); + var isObject2 = util17.isObject; var es52 = require_es5(); var Es6Map; if (typeof Map === "function") Es6Map = Map; @@ -42274,7 +42274,7 @@ var require_props = __commonJS({ this._isMap = isMap; this._init$(void 0, isMap ? -6 : -3); } - util.inherits(PropertiesPromiseArray, PromiseArray); + util17.inherits(PropertiesPromiseArray, PromiseArray); PropertiesPromiseArray.prototype._init = function() { }; PropertiesPromiseArray.prototype._promiseFulfilled = function(value, index) { @@ -42338,7 +42338,7 @@ var require_race = __commonJS({ "../node_modules/bluebird/js/release/race.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, INTERNAL, tryConvertToPromise, apiRejection) { - var util = require_util9(); + var util17 = require_util9(); var raceLater = function(promise) { return promise.then(function(array) { return race(array, promise); @@ -42349,22 +42349,22 @@ var require_race = __commonJS({ if (maybePromise instanceof Promise2) { return raceLater(maybePromise); } else { - promises3 = util.asArray(promises3); + promises3 = util17.asArray(promises3); if (promises3 === null) - return apiRejection("expecting an array or an iterable object but got " + util.classString(promises3)); + return apiRejection("expecting an array or an iterable object but got " + util17.classString(promises3)); } var ret2 = new Promise2(INTERNAL); if (parent !== void 0) { ret2._propagateFrom(parent, 3); } var fulfill = ret2._fulfill; - var reject = ret2._reject; + var reject2 = ret2._reject; for (var i6 = 0, len = promises3.length; i6 < len; ++i6) { var val = promises3[i6]; if (val === void 0 && !(i6 in promises3)) { continue; } - Promise2.cast(val)._then(fulfill, reject, void 0, ret2, null); + Promise2.cast(val)._then(fulfill, reject2, void 0, ret2, null); } return ret2; } @@ -42383,12 +42383,12 @@ var require_reduce = __commonJS({ "../node_modules/bluebird/js/release/reduce.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug2) { - var util = require_util9(); - var tryCatch2 = util.tryCatch; + var util17 = require_util9(); + var tryCatch2 = util17.tryCatch; function ReductionPromiseArray(promises3, fn, initialValue, _each) { this.constructor$(promises3); var context3 = Promise2._getContext(); - this._fn = util.contextBind(context3, fn); + this._fn = util17.contextBind(context3, fn); if (initialValue !== void 0) { initialValue = Promise2.resolve(initialValue); initialValue._attachCancellationCallback(this); @@ -42405,7 +42405,7 @@ var require_reduce = __commonJS({ this._promise._captureStackTrace(); this._init$(void 0, -5); } - util.inherits(ReductionPromiseArray, PromiseArray); + util17.inherits(ReductionPromiseArray, PromiseArray); ReductionPromiseArray.prototype._gotAccum = function(accum) { if (this._eachValues !== void 0 && this._eachValues !== null && accum !== INTERNAL) { this._eachValues.push(accum); @@ -42494,7 +42494,7 @@ var require_reduce = __commonJS({ } function reduce(promises3, fn, initialValue, _each) { if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); + return apiRejection("expecting a function but got " + util17.classString(fn)); } var array = new ReductionPromiseArray(promises3, fn, initialValue, _each); return array.promise(); @@ -42549,11 +42549,11 @@ var require_settle = __commonJS({ "use strict"; module2.exports = function(Promise2, PromiseArray, debug2) { var PromiseInspection = Promise2.PromiseInspection; - var util = require_util9(); + var util17 = require_util9(); function SettledPromiseArray(values) { this.constructor$(values); } - util.inherits(SettledPromiseArray, PromiseArray); + util17.inherits(SettledPromiseArray, PromiseArray); SettledPromiseArray.prototype._promiseResolved = function(index, inspection) { this._values[index] = inspection; var totalResolved = ++this._totalResolved; @@ -42594,10 +42594,10 @@ var require_some = __commonJS({ "../node_modules/bluebird/js/release/some.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, PromiseArray, apiRejection) { - var util = require_util9(); + var util17 = require_util9(); var RangeError2 = require_errors2().RangeError; var AggregateError = require_errors2().AggregateError; - var isArray = util.isArray; + var isArray = util17.isArray; var CANCELLATION = {}; function SomePromiseArray(values) { this.constructor$(values); @@ -42605,7 +42605,7 @@ var require_some = __commonJS({ this._unwrap = false; this._initialized = false; } - util.inherits(SomePromiseArray, PromiseArray); + util17.inherits(SomePromiseArray, PromiseArray); SomePromiseArray.prototype._init = function() { if (!this._initialized) { return; @@ -42722,7 +42722,7 @@ var require_timers2 = __commonJS({ "../node_modules/bluebird/js/release/timers.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, INTERNAL, debug2) { - var util = require_util9(); + var util17 = require_util9(); var TimeoutError = Promise2.TimeoutError; function HandleWrapper(handle) { this.handle = handle; @@ -42768,7 +42768,7 @@ var require_timers2 = __commonJS({ } else { err = new TimeoutError(message); } - util.markAsOriginatingFromRejection(err); + util17.markAsOriginatingFromRejection(err); promise._attachExtraTrace(err); promise._reject(err); if (parent != null) { @@ -42821,11 +42821,11 @@ var require_using = __commonJS({ "../node_modules/bluebird/js/release/using.js"(exports2, module2) { "use strict"; module2.exports = function(Promise2, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug2) { - var util = require_util9(); + var util17 = require_util9(); var TypeError2 = require_errors2().TypeError; var inherits2 = require_util9().inherits; - var errorObj2 = util.errorObj; - var tryCatch2 = util.tryCatch; + var errorObj2 = util17.errorObj; + var tryCatch2 = util17.tryCatch; var NULL = {}; function thrower2(e6) { setTimeout(function() { @@ -42936,7 +42936,7 @@ var require_using = __commonJS({ ); var fn = arguments[len - 1]; if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); + return apiRejection("expecting a function but got " + util17.classString(fn)); } var input; var spreadArgs = true; @@ -43110,8 +43110,8 @@ var require_promise = __commonJS({ function Proxyable() { } var UNDEFINED_BINDING = {}; - var util = require_util9(); - util.setReflectHandler(reflectHandler2); + var util17 = require_util9(); + util17.setReflectHandler(reflectHandler2); var getDomain = function() { var domain = process.domain; if (domain === void 0) { @@ -43128,22 +43128,22 @@ var require_promise = __commonJS({ async: null }; }; - var AsyncResource = util.isNode && util.nodeSupportsAsyncResource ? require("async_hooks").AsyncResource : null; + var AsyncResource = util17.isNode && util17.nodeSupportsAsyncResource ? require("async_hooks").AsyncResource : null; var getContextAsyncHooks = function() { return { domain: getDomain(), async: new AsyncResource("Bluebird::Promise") }; }; - var getContext = util.isNode ? getContextDomain : getContextDefault; - util.notEnumerableProp(Promise2, "_getContext", getContext); + var getContext = util17.isNode ? getContextDomain : getContextDefault; + util17.notEnumerableProp(Promise2, "_getContext", getContext); var enableAsyncHooks = function() { getContext = getContextAsyncHooks; - util.notEnumerableProp(Promise2, "_getContext", getContextAsyncHooks); + util17.notEnumerableProp(Promise2, "_getContext", getContextAsyncHooks); }; var disableAsyncHooks = function() { getContext = getContextDomain; - util.notEnumerableProp(Promise2, "_getContext", getContextDomain); + util17.notEnumerableProp(Promise2, "_getContext", getContextDomain); }; var es52 = require_es5(); var Async = require_async(); @@ -43181,14 +43181,14 @@ var require_promise = __commonJS({ var PassThroughHandlerContext = require_finally()(Promise2, tryConvertToPromise, NEXT_FILTER); var catchFilter = require_catch_filter()(NEXT_FILTER); var nodebackForPromise = require_nodeback(); - var errorObj2 = util.errorObj; - var tryCatch2 = util.tryCatch; + var errorObj2 = util17.errorObj; + var tryCatch2 = util17.tryCatch; function check(self2, executor) { if (self2 == null || self2.constructor !== Promise2) { throw new TypeError2("the promise constructor cannot be invoked directly\n\n See http://goo.gl/MqrFmX\n"); } if (typeof executor !== "function") { - throw new TypeError2("expecting a function but got " + util.classString(executor)); + throw new TypeError2("expecting a function but got " + util17.classString(executor)); } } function Promise2(executor) { @@ -43213,16 +43213,16 @@ var require_promise = __commonJS({ var catchInstances = new Array(len - 1), j6 = 0, i6; for (i6 = 0; i6 < len - 1; ++i6) { var item = arguments[i6]; - if (util.isObject(item)) { + if (util17.isObject(item)) { catchInstances[j6++] = item; } else { - return apiRejection("Catch statement predicate: expecting an object but got " + util.classString(item)); + return apiRejection("Catch statement predicate: expecting an object but got " + util17.classString(item)); } } catchInstances.length = j6; fn = arguments[i6]; if (typeof fn !== "function") { - throw new TypeError2("The last argument to .catch() must be a function, got " + util.toString(fn)); + throw new TypeError2("The last argument to .catch() must be a function, got " + util17.toString(fn)); } return this.then(void 0, catchFilter(catchInstances, fn, this)); } @@ -43239,9 +43239,9 @@ var require_promise = __commonJS({ }; Promise2.prototype.then = function(didFulfill, didReject) { if (debug2.warnings() && arguments.length > 0 && typeof didFulfill !== "function" && typeof didReject !== "function") { - var msg = ".then() only accepts functions but was passed: " + util.classString(didFulfill); + var msg = ".then() only accepts functions but was passed: " + util17.classString(didFulfill); if (arguments.length > 1) { - msg += ", " + util.classString(didReject); + msg += ", " + util17.classString(didReject); } this._warn(msg); } @@ -43253,7 +43253,7 @@ var require_promise = __commonJS({ }; Promise2.prototype.spread = function(fn) { if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); + return apiRejection("expecting a function but got " + util17.classString(fn)); } return this.all()._then(fn, void 0, void 0, APPLY, void 0); }; @@ -43280,7 +43280,7 @@ var require_promise = __commonJS({ return new PromiseArray(this).promise(); }; Promise2.prototype.error = function(fn) { - return this.caught(util.originatesFromRejection, fn); + return this.caught(util17.originatesFromRejection, fn); }; Promise2.getNewLibraryCopy = module2.exports; Promise2.is = function(val) { @@ -43319,7 +43319,7 @@ var require_promise = __commonJS({ }; Promise2.setScheduler = function(fn) { if (typeof fn !== "function") { - throw new TypeError2("expecting a function but got " + util.classString(fn)); + throw new TypeError2("expecting a function but got " + util17.classString(fn)); } return async.setScheduler(fn); }; @@ -43357,7 +43357,7 @@ var require_promise = __commonJS({ handler2 = didReject; } async.invoke(settler, target, { - handler: util.contextBind(context3, handler2), + handler: util17.contextBind(context3, handler2), promise, receiver: receiver2, value @@ -43444,21 +43444,21 @@ var require_promise = __commonJS({ Promise2.prototype._migrateCallback0 = function(follower) { var bitField = follower._bitField; var fulfill = follower._fulfillmentHandler0; - var reject = follower._rejectionHandler0; + var reject2 = follower._rejectionHandler0; var promise = follower._promise0; var receiver2 = follower._receiverAt(0); if (receiver2 === void 0) receiver2 = UNDEFINED_BINDING; - this._addCallbacks(fulfill, reject, promise, receiver2, null); + this._addCallbacks(fulfill, reject2, promise, receiver2, null); }; Promise2.prototype._migrateCallbackAt = function(follower, index) { var fulfill = follower._fulfillmentHandlerAt(index); - var reject = follower._rejectionHandlerAt(index); + var reject2 = follower._rejectionHandlerAt(index); var promise = follower._promiseAt(index); var receiver2 = follower._receiverAt(index); if (receiver2 === void 0) receiver2 = UNDEFINED_BINDING; - this._addCallbacks(fulfill, reject, promise, receiver2, null); + this._addCallbacks(fulfill, reject2, promise, receiver2, null); }; - Promise2.prototype._addCallbacks = function(fulfill, reject, promise, receiver2, context3) { + Promise2.prototype._addCallbacks = function(fulfill, reject2, promise, receiver2, context3) { var index = this._length(); if (index >= 65535 - 4) { index = 0; @@ -43468,20 +43468,20 @@ var require_promise = __commonJS({ this._promise0 = promise; this._receiver0 = receiver2; if (typeof fulfill === "function") { - this._fulfillmentHandler0 = util.contextBind(context3, fulfill); + this._fulfillmentHandler0 = util17.contextBind(context3, fulfill); } - if (typeof reject === "function") { - this._rejectionHandler0 = util.contextBind(context3, reject); + if (typeof reject2 === "function") { + this._rejectionHandler0 = util17.contextBind(context3, reject2); } } else { var base = index * 4 - 4; this[base + 2] = promise; this[base + 3] = receiver2; if (typeof fulfill === "function") { - this[base + 0] = util.contextBind(context3, fulfill); + this[base + 0] = util17.contextBind(context3, fulfill); } - if (typeof reject === "function") { - this[base + 1] = util.contextBind(context3, reject); + if (typeof reject2 === "function") { + this[base + 1] = util17.contextBind(context3, reject2); } } this._setLength(index + 1); @@ -43523,10 +43523,10 @@ var require_promise = __commonJS({ } }; Promise2.prototype._rejectCallback = function(reason, synchronous, ignoreNonErrorWarnings) { - var trace = util.ensureErrorObject(reason); + var trace = util17.ensureErrorObject(reason); var hasStack = trace === reason; if (!hasStack && !ignoreNonErrorWarnings && debug2.warnings()) { - var message = "a promise was rejected with a non-error: " + util.classString(reason); + var message = "a promise was rejected with a non-error: " + util17.classString(reason); this._warn(message, true); } this._attachExtraTrace(trace, synchronous ? hasStack : false); @@ -43553,27 +43553,27 @@ var require_promise = __commonJS({ var bitField = promise._bitField; if ((bitField & 65536) !== 0) return; promise._pushContext(); - var x6; + var x7; if (receiver2 === APPLY) { if (!value || typeof value.length !== "number") { - x6 = errorObj2; - x6.e = new TypeError2("cannot .spread() a non-array: " + util.classString(value)); + x7 = errorObj2; + x7.e = new TypeError2("cannot .spread() a non-array: " + util17.classString(value)); } else { - x6 = tryCatch2(handler2).apply(this._boundValue(), value); + x7 = tryCatch2(handler2).apply(this._boundValue(), value); } } else { - x6 = tryCatch2(handler2).call(receiver2, value); + x7 = tryCatch2(handler2).call(receiver2, value); } var promiseCreated = promise._popContext(); bitField = promise._bitField; if ((bitField & 65536) !== 0) return; - if (x6 === NEXT_FILTER) { + if (x7 === NEXT_FILTER) { promise._reject(value); - } else if (x6 === errorObj2) { - promise._rejectCallback(x6.e, false); + } else if (x7 === errorObj2) { + promise._rejectCallback(x7.e, false); } else { - debug2.checkForgottenReturns(x6, promiseCreated, "", promise, this); - promise._resolveCallback(x6); + debug2.checkForgottenReturns(x7, promiseCreated, "", promise, this); + promise._resolveCallback(x7); } }; Promise2.prototype._target = function() { @@ -43685,7 +43685,7 @@ var require_promise = __commonJS({ this._setRejected(); this._fulfillmentHandler0 = reason; if (this._isFinal()) { - return async.fatalError(reason, util.isNode); + return async.fatalError(reason, util17.isNode); } if ((bitField & 65535) > 0) { async.settlePromises(this); @@ -43758,7 +43758,7 @@ var require_promise = __commonJS({ reject: deferReject }; }; - util.notEnumerableProp( + util17.notEnumerableProp( Promise2, "_makeSelfResolutionError", makeSelfResolutionError @@ -43798,8 +43798,8 @@ var require_promise = __commonJS({ require_any()(Promise2); require_each()(Promise2, INTERNAL); require_filter()(Promise2, INTERNAL); - util.toFastProperties(Promise2); - util.toFastProperties(Promise2.prototype); + util17.toFastProperties(Promise2); + util17.toFastProperties(Promise2.prototype); function fillTypes(value) { var p6 = new Promise2(INTERNAL); p6._fulfillmentHandler0 = value; @@ -43816,7 +43816,7 @@ var require_promise = __commonJS({ fillTypes(void 0); fillTypes(false); fillTypes(new Promise2(INTERNAL)); - debug2.setBounds(Async.firstLineError, util.lastLineError); + debug2.setBounds(Async.firstLineError, util17.lastLineError); return Promise2; }; } @@ -43841,4981 +43841,31842 @@ var require_bluebird = __commonJS({ } }); -// ../node_modules/@actions/github/node_modules/@actions/http-client/lib/proxy.js -var require_proxy = __commonJS({ - "../node_modules/@actions/github/node_modules/@actions/http-client/lib/proxy.js"(exports2) { +// ../node_modules/omggif/omggif.js +var require_omggif = __commonJS({ + "../node_modules/omggif/omggif.js"(exports2) { "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.getProxyUrl = getProxyUrl2; - exports2.checkBypass = checkBypass; - function getProxyUrl2(reqUrl) { - const usingSsl = reqUrl.protocol === "https:"; - if (checkBypass(reqUrl)) { - return void 0; - } - const proxyVar = (() => { - if (usingSsl) { - return process.env["https_proxy"] || process.env["HTTPS_PROXY"]; - } else { - return process.env["http_proxy"] || process.env["HTTP_PROXY"]; + function GifWriter(buf, width, height, gopts) { + var p6 = 0; + var gopts = gopts === void 0 ? {} : gopts; + var loop_count = gopts.loop === void 0 ? null : gopts.loop; + var global_palette = gopts.palette === void 0 ? null : gopts.palette; + if (width <= 0 || height <= 0 || width > 65535 || height > 65535) + throw new Error("Width/Height invalid."); + function check_palette_and_num_colors(palette2) { + var num_colors = palette2.length; + if (num_colors < 2 || num_colors > 256 || num_colors & num_colors - 1) { + throw new Error( + "Invalid code/color length, must be power of 2 and 2 .. 256." + ); } - })(); - if (proxyVar) { - try { - return new DecodedURL(proxyVar); - } catch (_a2) { - if (!proxyVar.startsWith("http://") && !proxyVar.startsWith("https://")) - return new DecodedURL(`http://${proxyVar}`); + return num_colors; + } + buf[p6++] = 71; + buf[p6++] = 73; + buf[p6++] = 70; + buf[p6++] = 56; + buf[p6++] = 57; + buf[p6++] = 97; + var gp_num_colors_pow2 = 0; + var background = 0; + if (global_palette !== null) { + var gp_num_colors = check_palette_and_num_colors(global_palette); + while (gp_num_colors >>= 1) ++gp_num_colors_pow2; + gp_num_colors = 1 << gp_num_colors_pow2; + --gp_num_colors_pow2; + if (gopts.background !== void 0) { + background = gopts.background; + if (background >= gp_num_colors) + throw new Error("Background index out of range."); + if (background === 0) + throw new Error("Background index explicitly passed as 0."); + } + } + buf[p6++] = width & 255; + buf[p6++] = width >> 8 & 255; + buf[p6++] = height & 255; + buf[p6++] = height >> 8 & 255; + buf[p6++] = (global_palette !== null ? 128 : 0) | // Global Color Table Flag. + gp_num_colors_pow2; + buf[p6++] = background; + buf[p6++] = 0; + if (global_palette !== null) { + for (var i6 = 0, il = global_palette.length; i6 < il; ++i6) { + var rgb = global_palette[i6]; + buf[p6++] = rgb >> 16 & 255; + buf[p6++] = rgb >> 8 & 255; + buf[p6++] = rgb & 255; + } + } + if (loop_count !== null) { + if (loop_count < 0 || loop_count > 65535) + throw new Error("Loop count invalid."); + buf[p6++] = 33; + buf[p6++] = 255; + buf[p6++] = 11; + buf[p6++] = 78; + buf[p6++] = 69; + buf[p6++] = 84; + buf[p6++] = 83; + buf[p6++] = 67; + buf[p6++] = 65; + buf[p6++] = 80; + buf[p6++] = 69; + buf[p6++] = 50; + buf[p6++] = 46; + buf[p6++] = 48; + buf[p6++] = 3; + buf[p6++] = 1; + buf[p6++] = loop_count & 255; + buf[p6++] = loop_count >> 8 & 255; + buf[p6++] = 0; + } + var ended = false; + this.addFrame = function(x7, y4, w6, h6, indexed_pixels, opts) { + if (ended === true) { + --p6; + ended = false; + } + opts = opts === void 0 ? {} : opts; + if (x7 < 0 || y4 < 0 || x7 > 65535 || y4 > 65535) + throw new Error("x/y invalid."); + if (w6 <= 0 || h6 <= 0 || w6 > 65535 || h6 > 65535) + throw new Error("Width/Height invalid."); + if (indexed_pixels.length < w6 * h6) + throw new Error("Not enough pixels for the frame size."); + var using_local_palette = true; + var palette2 = opts.palette; + if (palette2 === void 0 || palette2 === null) { + using_local_palette = false; + palette2 = global_palette; + } + if (palette2 === void 0 || palette2 === null) + throw new Error("Must supply either a local or global palette."); + var num_colors = check_palette_and_num_colors(palette2); + var min_code_size = 0; + while (num_colors >>= 1) ++min_code_size; + num_colors = 1 << min_code_size; + var delay = opts.delay === void 0 ? 0 : opts.delay; + var disposal = opts.disposal === void 0 ? 0 : opts.disposal; + if (disposal < 0 || disposal > 3) + throw new Error("Disposal out of range."); + var use_transparency = false; + var transparent_index = 0; + if (opts.transparent !== void 0 && opts.transparent !== null) { + use_transparency = true; + transparent_index = opts.transparent; + if (transparent_index < 0 || transparent_index >= num_colors) + throw new Error("Transparent color index."); + } + if (disposal !== 0 || use_transparency || delay !== 0) { + buf[p6++] = 33; + buf[p6++] = 249; + buf[p6++] = 4; + buf[p6++] = disposal << 2 | (use_transparency === true ? 1 : 0); + buf[p6++] = delay & 255; + buf[p6++] = delay >> 8 & 255; + buf[p6++] = transparent_index; + buf[p6++] = 0; + } + buf[p6++] = 44; + buf[p6++] = x7 & 255; + buf[p6++] = x7 >> 8 & 255; + buf[p6++] = y4 & 255; + buf[p6++] = y4 >> 8 & 255; + buf[p6++] = w6 & 255; + buf[p6++] = w6 >> 8 & 255; + buf[p6++] = h6 & 255; + buf[p6++] = h6 >> 8 & 255; + buf[p6++] = using_local_palette === true ? 128 | min_code_size - 1 : 0; + if (using_local_palette === true) { + for (var i7 = 0, il2 = palette2.length; i7 < il2; ++i7) { + var rgb2 = palette2[i7]; + buf[p6++] = rgb2 >> 16 & 255; + buf[p6++] = rgb2 >> 8 & 255; + buf[p6++] = rgb2 & 255; + } + } + p6 = GifWriterOutputLZWCodeStream( + buf, + p6, + min_code_size < 2 ? 2 : min_code_size, + indexed_pixels + ); + return p6; + }; + this.end = function() { + if (ended === false) { + buf[p6++] = 59; + ended = true; + } + return p6; + }; + this.getOutputBuffer = function() { + return buf; + }; + this.setOutputBuffer = function(v7) { + buf = v7; + }; + this.getOutputBufferPosition = function() { + return p6; + }; + this.setOutputBufferPosition = function(v7) { + p6 = v7; + }; + } + function GifWriterOutputLZWCodeStream(buf, p6, min_code_size, index_stream) { + buf[p6++] = min_code_size; + var cur_subblock = p6++; + var clear_code = 1 << min_code_size; + var code_mask = clear_code - 1; + var eoi_code = clear_code + 1; + var next_code = eoi_code + 1; + var cur_code_size = min_code_size + 1; + var cur_shift = 0; + var cur = 0; + function emit_bytes_to_buffer(bit_block_size) { + while (cur_shift >= bit_block_size) { + buf[p6++] = cur & 255; + cur >>= 8; + cur_shift -= 8; + if (p6 === cur_subblock + 256) { + buf[cur_subblock] = 255; + cur_subblock = p6++; + } + } + } + function emit_code(c7) { + cur |= c7 << cur_shift; + cur_shift += cur_code_size; + emit_bytes_to_buffer(8); + } + var ib_code = index_stream[0] & code_mask; + var code_table = {}; + emit_code(clear_code); + for (var i6 = 1, il = index_stream.length; i6 < il; ++i6) { + var k6 = index_stream[i6] & code_mask; + var cur_key = ib_code << 8 | k6; + var cur_code = code_table[cur_key]; + if (cur_code === void 0) { + cur |= ib_code << cur_shift; + cur_shift += cur_code_size; + while (cur_shift >= 8) { + buf[p6++] = cur & 255; + cur >>= 8; + cur_shift -= 8; + if (p6 === cur_subblock + 256) { + buf[cur_subblock] = 255; + cur_subblock = p6++; + } + } + if (next_code === 4096) { + emit_code(clear_code); + next_code = eoi_code + 1; + cur_code_size = min_code_size + 1; + code_table = {}; + } else { + if (next_code >= 1 << cur_code_size) ++cur_code_size; + code_table[cur_key] = next_code++; + } + ib_code = k6; + } else { + ib_code = cur_code; } + } + emit_code(ib_code); + emit_code(eoi_code); + emit_bytes_to_buffer(1); + if (cur_subblock + 1 === p6) { + buf[cur_subblock] = 0; } else { - return void 0; + buf[cur_subblock] = p6 - cur_subblock - 1; + buf[p6++] = 0; + } + return p6; + } + function GifReader(buf) { + var p6 = 0; + if (buf[p6++] !== 71 || buf[p6++] !== 73 || buf[p6++] !== 70 || buf[p6++] !== 56 || (buf[p6++] + 1 & 253) !== 56 || buf[p6++] !== 97) { + throw new Error("Invalid GIF 87a/89a header."); + } + var width = buf[p6++] | buf[p6++] << 8; + var height = buf[p6++] | buf[p6++] << 8; + var pf0 = buf[p6++]; + var global_palette_flag = pf0 >> 7; + var num_global_colors_pow2 = pf0 & 7; + var num_global_colors = 1 << num_global_colors_pow2 + 1; + var background = buf[p6++]; + buf[p6++]; + var global_palette_offset = null; + var global_palette_size = null; + if (global_palette_flag) { + global_palette_offset = p6; + global_palette_size = num_global_colors; + p6 += num_global_colors * 3; + } + var no_eof = true; + var frames = []; + var delay = 0; + var transparent_index = null; + var disposal = 0; + var loop_count = null; + this.width = width; + this.height = height; + while (no_eof && p6 < buf.length) { + switch (buf[p6++]) { + case 33: + switch (buf[p6++]) { + case 255: + if (buf[p6] !== 11 || // 21 FF already read, check block size. + // NETSCAPE2.0 + buf[p6 + 1] == 78 && buf[p6 + 2] == 69 && buf[p6 + 3] == 84 && buf[p6 + 4] == 83 && buf[p6 + 5] == 67 && buf[p6 + 6] == 65 && buf[p6 + 7] == 80 && buf[p6 + 8] == 69 && buf[p6 + 9] == 50 && buf[p6 + 10] == 46 && buf[p6 + 11] == 48 && // Sub-block + buf[p6 + 12] == 3 && buf[p6 + 13] == 1 && buf[p6 + 16] == 0) { + p6 += 14; + loop_count = buf[p6++] | buf[p6++] << 8; + p6++; + } else { + p6 += 12; + while (true) { + var block_size = buf[p6++]; + if (!(block_size >= 0)) throw Error("Invalid block size"); + if (block_size === 0) break; + p6 += block_size; + } + } + break; + case 249: + if (buf[p6++] !== 4 || buf[p6 + 4] !== 0) + throw new Error("Invalid graphics extension block."); + var pf1 = buf[p6++]; + delay = buf[p6++] | buf[p6++] << 8; + transparent_index = buf[p6++]; + if ((pf1 & 1) === 0) transparent_index = null; + disposal = pf1 >> 2 & 7; + p6++; + break; + case 254: + while (true) { + var block_size = buf[p6++]; + if (!(block_size >= 0)) throw Error("Invalid block size"); + if (block_size === 0) break; + p6 += block_size; + } + break; + default: + throw new Error( + "Unknown graphic control label: 0x" + buf[p6 - 1].toString(16) + ); + } + break; + case 44: + var x7 = buf[p6++] | buf[p6++] << 8; + var y4 = buf[p6++] | buf[p6++] << 8; + var w6 = buf[p6++] | buf[p6++] << 8; + var h6 = buf[p6++] | buf[p6++] << 8; + var pf2 = buf[p6++]; + var local_palette_flag = pf2 >> 7; + var interlace_flag = pf2 >> 6 & 1; + var num_local_colors_pow2 = pf2 & 7; + var num_local_colors = 1 << num_local_colors_pow2 + 1; + var palette_offset = global_palette_offset; + var palette_size = global_palette_size; + var has_local_palette = false; + if (local_palette_flag) { + var has_local_palette = true; + palette_offset = p6; + palette_size = num_local_colors; + p6 += num_local_colors * 3; + } + var data_offset = p6; + p6++; + while (true) { + var block_size = buf[p6++]; + if (!(block_size >= 0)) throw Error("Invalid block size"); + if (block_size === 0) break; + p6 += block_size; + } + frames.push({ + x: x7, + y: y4, + width: w6, + height: h6, + has_local_palette, + palette_offset, + palette_size, + data_offset, + data_length: p6 - data_offset, + transparent_index, + interlaced: !!interlace_flag, + delay, + disposal + }); + break; + case 59: + no_eof = false; + break; + default: + throw new Error("Unknown gif block: 0x" + buf[p6 - 1].toString(16)); + break; + } } + this.numFrames = function() { + return frames.length; + }; + this.loopCount = function() { + return loop_count; + }; + this.frameInfo = function(frame_num) { + if (frame_num < 0 || frame_num >= frames.length) + throw new Error("Frame index out of range."); + return frames[frame_num]; + }; + this.decodeAndBlitFrameBGRA = function(frame_num, pixels) { + var frame = this.frameInfo(frame_num); + var num_pixels = frame.width * frame.height; + var index_stream = new Uint8Array(num_pixels); + GifReaderLZWOutputIndexStream( + buf, + frame.data_offset, + index_stream, + num_pixels + ); + var palette_offset2 = frame.palette_offset; + var trans = frame.transparent_index; + if (trans === null) trans = 256; + var framewidth = frame.width; + var framestride = width - framewidth; + var xleft = framewidth; + var opbeg = (frame.y * width + frame.x) * 4; + var opend = ((frame.y + frame.height) * width + frame.x) * 4; + var op = opbeg; + var scanstride = framestride * 4; + if (frame.interlaced === true) { + scanstride += width * 4 * 7; + } + var interlaceskip = 8; + for (var i6 = 0, il = index_stream.length; i6 < il; ++i6) { + var index = index_stream[i6]; + if (xleft === 0) { + op += scanstride; + xleft = framewidth; + if (op >= opend) { + scanstride = framestride * 4 + width * 4 * (interlaceskip - 1); + op = opbeg + (framewidth + framestride) * (interlaceskip << 1); + interlaceskip >>= 1; + } + } + if (index === trans) { + op += 4; + } else { + var r6 = buf[palette_offset2 + index * 3]; + var g6 = buf[palette_offset2 + index * 3 + 1]; + var b6 = buf[palette_offset2 + index * 3 + 2]; + pixels[op++] = b6; + pixels[op++] = g6; + pixels[op++] = r6; + pixels[op++] = 255; + } + --xleft; + } + }; + this.decodeAndBlitFrameRGBA = function(frame_num, pixels) { + var frame = this.frameInfo(frame_num); + var num_pixels = frame.width * frame.height; + var index_stream = new Uint8Array(num_pixels); + GifReaderLZWOutputIndexStream( + buf, + frame.data_offset, + index_stream, + num_pixels + ); + var palette_offset2 = frame.palette_offset; + var trans = frame.transparent_index; + if (trans === null) trans = 256; + var framewidth = frame.width; + var framestride = width - framewidth; + var xleft = framewidth; + var opbeg = (frame.y * width + frame.x) * 4; + var opend = ((frame.y + frame.height) * width + frame.x) * 4; + var op = opbeg; + var scanstride = framestride * 4; + if (frame.interlaced === true) { + scanstride += width * 4 * 7; + } + var interlaceskip = 8; + for (var i6 = 0, il = index_stream.length; i6 < il; ++i6) { + var index = index_stream[i6]; + if (xleft === 0) { + op += scanstride; + xleft = framewidth; + if (op >= opend) { + scanstride = framestride * 4 + width * 4 * (interlaceskip - 1); + op = opbeg + (framewidth + framestride) * (interlaceskip << 1); + interlaceskip >>= 1; + } + } + if (index === trans) { + op += 4; + } else { + var r6 = buf[palette_offset2 + index * 3]; + var g6 = buf[palette_offset2 + index * 3 + 1]; + var b6 = buf[palette_offset2 + index * 3 + 2]; + pixels[op++] = r6; + pixels[op++] = g6; + pixels[op++] = b6; + pixels[op++] = 255; + } + --xleft; + } + }; } - function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; + function GifReaderLZWOutputIndexStream(code_stream, p6, output, output_length) { + var min_code_size = code_stream[p6++]; + var clear_code = 1 << min_code_size; + var eoi_code = clear_code + 1; + var next_code = eoi_code + 1; + var cur_code_size = min_code_size + 1; + var code_mask = (1 << cur_code_size) - 1; + var cur_shift = 0; + var cur = 0; + var op = 0; + var subblock_size = code_stream[p6++]; + var code_table = new Int32Array(4096); + var prev_code = null; + while (true) { + while (cur_shift < 16) { + if (subblock_size === 0) break; + cur |= code_stream[p6++] << cur_shift; + cur_shift += 8; + if (subblock_size === 1) { + subblock_size = code_stream[p6++]; + } else { + --subblock_size; + } + } + if (cur_shift < cur_code_size) + break; + var code = cur & code_mask; + cur >>= cur_code_size; + cur_shift -= cur_code_size; + if (code === clear_code) { + next_code = eoi_code + 1; + cur_code_size = min_code_size + 1; + code_mask = (1 << cur_code_size) - 1; + prev_code = null; + continue; + } else if (code === eoi_code) { + break; + } + var chase_code = code < next_code ? code : prev_code; + var chase_length = 0; + var chase = chase_code; + while (chase > clear_code) { + chase = code_table[chase] >> 8; + ++chase_length; + } + var k6 = chase; + var op_end = op + chase_length + (chase_code !== code ? 1 : 0); + if (op_end > output_length) { + console.log("Warning, gif stream longer than expected."); + return; + } + output[op++] = k6; + op += chase_length; + var b6 = op; + if (chase_code !== code) + output[op++] = k6; + chase = chase_code; + while (chase_length--) { + chase = code_table[chase]; + output[--b6] = chase & 255; + chase >>= 8; + } + if (prev_code !== null && next_code < 4096) { + code_table[next_code++] = prev_code << 8 | k6; + if (next_code >= code_mask + 1 && cur_code_size < 12) { + ++cur_code_size; + code_mask = code_mask << 1 | 1; + } + } + prev_code = code; } - const reqHost = reqUrl.hostname; - if (isLoopbackAddress(reqHost)) { - return true; + if (op !== output_length) { + console.log("Warning, gif stream shorter than expected."); } - const noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || ""; - if (!noProxy) { - return false; + return output; + } + try { + exports2.GifWriter = GifWriter; + exports2.GifReader = GifReader; + } catch (e6) { + } + } +}); + +// ../node_modules/gifwrap/src/bitmapimage.js +var require_bitmapimage = __commonJS({ + "../node_modules/gifwrap/src/bitmapimage.js"(exports2, module2) { + "use strict"; + var BitmapImage2 = class _BitmapImage { + /** + * BitmapImage is a class that hold an RGBA (red, green, blue, alpha) representation of an image. It's shape is borrowed from the Jimp package to make it easy to transfer GIF image frames into Jimp and Jimp images into GIF image frames. Each instance has a `bitmap` property having the following properties: + * + * Property | Description + * --- | --- + * bitmap.width | width of image in pixels + * bitmap.height | height of image in pixels + * bitmap.data | a Buffer whose every four bytes represents a pixel, each sequential byte of a pixel corresponding to the red, green, blue, and alpha values of the pixel + * + * Its constructor supports the following signatures: + * + * * new BitmapImage(bitmap: { width: number, height: number, data: Buffer }) + * * new BitmapImage(bitmapImage: BitmapImage) + * * new BitmapImage(width: number, height: number, buffer: Buffer) + * * new BitmapImage(width: number, height: number, backgroundRGBA?: number) + * + * When a `BitmapImage` is provided, the constructed `BitmapImage` is a deep clone of the provided one, so that each image's pixel data can subsequently be modified without affecting each other. + * + * `backgroundRGBA` is an optional parameter representing a pixel as a single number. In hex, the number is as follows: 0xRRGGBBAA, where RR is the red byte, GG the green byte, BB, the blue byte, and AA the alpha value. An AA of 0x00 is considered transparent, and all non-zero AA values are treated as opaque. + */ + constructor(...args) { + if (args.length === 0) { + throw new Error("constructor requires parameters"); + } + const firstArg = args[0]; + if (firstArg !== null && typeof firstArg === "object") { + if (firstArg instanceof _BitmapImage) { + const sourceBitmap = firstArg.bitmap; + this.bitmap = { + width: sourceBitmap.width, + height: sourceBitmap.height, + data: new Buffer(sourceBitmap.width * sourceBitmap.height * 4) + }; + sourceBitmap.data.copy(this.bitmap.data); + } else if (firstArg.width && firstArg.height && firstArg.data) { + this.bitmap = firstArg; + } else { + throw new Error("unrecognized constructor parameters"); + } + } else if (typeof firstArg === "number" && typeof args[1] === "number") { + const width = firstArg; + const height = args[1]; + const thirdArg = args[2]; + this.bitmap = { width, height }; + if (Buffer.isBuffer(thirdArg)) { + this.bitmap.data = thirdArg; + } else { + this.bitmap.data = new Buffer(width * height * 4); + if (typeof thirdArg === "number") { + this.fillRGBA(thirdArg); + } + } + } else { + throw new Error("unrecognized constructor parameters"); + } } - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); - } else if (reqUrl.protocol === "http:") { - reqPort = 80; - } else if (reqUrl.protocol === "https:") { - reqPort = 443; + /** + * Copy a square portion of this image into another image. + * + * @param {BitmapImage} toImage Image into which to copy the square + * @param {number} toX x-coord in toImage of upper-left corner of receiving square + * @param {number} toY y-coord in toImage of upper-left corner of receiving square + * @param {number} fromX x-coord in this image of upper-left corner of source square + * @param {number} fromY y-coord in this image of upper-left corner of source square + * @return {BitmapImage} The present image to allow for chaining. + */ + blit(toImage, toX, toY, fromX, fromY, fromWidth, fromHeight) { + if (fromX + fromWidth > this.bitmap.width) { + throw new Error("copy exceeds width of source bitmap"); + } + if (toX + fromWidth > toImage.bitmap.width) { + throw new Error("copy exceeds width of target bitmap"); + } + if (fromY + fromHeight > this.bitmap.height) { + throw new Error("copy exceeds height of source bitmap"); + } + if (toY + fromHeight > toImage.bitmap.height) { + throw new Erro("copy exceeds height of target bitmap"); + } + const sourceBuf = this.bitmap.data; + const targetBuf = toImage.bitmap.data; + const sourceByteWidth = this.bitmap.width * 4; + const targetByteWidth = toImage.bitmap.width * 4; + const copyByteWidth = fromWidth * 4; + let si = fromY * sourceByteWidth + fromX * 4; + let ti = toY * targetByteWidth + toX * 4; + while (--fromHeight >= 0) { + sourceBuf.copy(targetBuf, ti, si, si + copyByteWidth); + si += sourceByteWidth; + ti += targetByteWidth; + } + return this; } - const upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === "number") { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + /** + * Fills the image with a single color. + * + * @param {number} rgba Color with which to fill image, expressed as a singlenumber in the form 0xRRGGBBAA, where AA is 0x00 for transparent and any other value for opaque. + * @return {BitmapImage} The present image to allow for chaining. + */ + fillRGBA(rgba) { + const buf = this.bitmap.data; + const bufByteWidth = this.bitmap.height * 4; + let bi2 = 0; + while (bi2 < bufByteWidth) { + buf.writeUInt32BE(rgba, bi2); + bi2 += 4; + } + while (bi2 < buf.length) { + buf.copy(buf, bi2, 0, bufByteWidth); + bi2 += bufByteWidth; + } + return this; } - for (const upperNoProxyItem of noProxy.split(",").map((x6) => x6.trim().toUpperCase()).filter((x6) => x6)) { - if (upperNoProxyItem === "*" || upperReqHosts.some((x6) => x6 === upperNoProxyItem || x6.endsWith(`.${upperNoProxyItem}`) || upperNoProxyItem.startsWith(".") && x6.endsWith(`${upperNoProxyItem}`))) { - return true; + /** + * Gets the RGBA number of the pixel at the given coordinate in the form 0xRRGGBBAA, where AA is the alpha value, with alpha 0x00 encoding to transparency in GIFs. + * + * @param {number} x x-coord of pixel + * @param {number} y y-coord of pixel + * @return {number} RGBA of pixel in 0xRRGGBBAA form + */ + getRGBA(x7, y4) { + const bi2 = (y4 * this.bitmap.width + x7) * 4; + return this.bitmap.data.readUInt32BE(bi2); + } + /** + * Gets a set of all RGBA colors found within the image. + * + * @return {Set} Set of all RGBA colors that the image contains. + */ + getRGBASet() { + const rgbaSet = /* @__PURE__ */ new Set(); + const buf = this.bitmap.data; + for (let bi2 = 0; bi2 < buf.length; bi2 += 4) { + rgbaSet.add(buf.readUInt32BE(bi2, true)); } + return rgbaSet; } - return false; - } - function isLoopbackAddress(host) { - const hostLower = host.toLowerCase(); - return hostLower === "localhost" || hostLower.startsWith("127.") || hostLower.startsWith("[::1]") || hostLower.startsWith("[0:0:0:0:0:0:0:1]"); - } - var DecodedURL = class extends URL { - constructor(url, base) { - super(url, base); - this._decodedUsername = decodeURIComponent(super.username); - this._decodedPassword = decodeURIComponent(super.password); + /** + * Converts the image to greyscale using inferred Adobe metrics. + * + * @return {BitmapImage} The present image to allow for chaining. + */ + greyscale() { + const buf = this.bitmap.data; + this.scan(0, 0, this.bitmap.width, this.bitmap.height, (x7, y4, idx) => { + const grey = Math.round( + 0.299 * buf[idx] + 0.587 * buf[idx + 1] + 0.114 * buf[idx + 2] + ); + buf[idx] = grey; + buf[idx + 1] = grey; + buf[idx + 2] = grey; + }); + return this; } - get username() { - return this._decodedUsername; + /** + * Reframes the image as if placing a frame around the original image and replacing the original image with the newly framed image. When the new frame is strictly within the boundaries of the original image, this method crops the image. When any of the new boundaries exceed those of the original image, the `fillRGBA` must be provided to indicate the color with which to fill the extra space added to the image. + * + * @param {number} xOffset The x-coord offset of the upper-left pixel of the desired image relative to the present image. + * @param {number} yOffset The y-coord offset of the upper-left pixel of the desired image relative to the present image. + * @param {number} width The width of the new image after reframing + * @param {number} height The height of the new image after reframing + * @param {number} fillRGBA The color with which to fill space added to the image as a result of the reframing, in 0xRRGGBBAA format, where AA is 0x00 to indicate transparent and a non-zero value to indicate opaque. This parameter is only required when the reframing exceeds the original boundaries (i.e. does not simply perform a crop). + * @return {BitmapImage} The present image to allow for chaining. + */ + reframe(xOffset, yOffset, width, height, fillRGBA) { + const cropX = xOffset < 0 ? 0 : xOffset; + const cropY = yOffset < 0 ? 0 : yOffset; + const cropWidth = width + cropX > this.bitmap.width ? this.bitmap.width - cropX : width; + const cropHeight = height + cropY > this.bitmap.height ? this.bitmap.height - cropY : height; + const newX = xOffset < 0 ? -xOffset : 0; + const newY = yOffset < 0 ? -yOffset : 0; + let image2; + if (fillRGBA === void 0) { + if (cropX !== xOffset || cropY != yOffset || cropWidth !== width || cropHeight !== height) { + throw new GifError(`fillRGBA required for this reframing`); + } + image2 = new _BitmapImage(width, height); + } else { + image2 = new _BitmapImage(width, height, fillRGBA); + } + this.blit(image2, newX, newY, cropX, cropY, cropWidth, cropHeight); + this.bitmap = image2.bitmap; + return this; } - get password() { - return this._decodedPassword; + /** + * Scales the image size up by an integer factor. Each pixel of the original image becomes a square of the same color in the new image having a size of `factor` x `factor` pixels. + * + * @param {number} factor The factor by which to scale up the image. Must be an integer >= 1. + * @return {BitmapImage} The present image to allow for chaining. + */ + scale(factor) { + if (factor === 1) { + return; + } + if (!Number.isInteger(factor) || factor < 1) { + throw new Error("the scale must be an integer >= 1"); + } + const sourceWidth = this.bitmap.width; + const sourceHeight = this.bitmap.height; + const destByteWidth = sourceWidth * factor * 4; + const sourceBuf = this.bitmap.data; + const destBuf = new Buffer(sourceHeight * destByteWidth * factor); + let sourceIndex = 0; + let priorDestRowIndex; + let destIndex = 0; + for (let y4 = 0; y4 < sourceHeight; ++y4) { + priorDestRowIndex = destIndex; + for (let x7 = 0; x7 < sourceWidth; ++x7) { + const color = sourceBuf.readUInt32BE(sourceIndex, true); + for (let cx2 = 0; cx2 < factor; ++cx2) { + destBuf.writeUInt32BE(color, destIndex); + destIndex += 4; + } + sourceIndex += 4; + } + for (let cy2 = 1; cy2 < factor; ++cy2) { + destBuf.copy(destBuf, destIndex, priorDestRowIndex, destIndex); + destIndex += destByteWidth; + priorDestRowIndex += destByteWidth; + } + } + this.bitmap = { + width: sourceWidth * factor, + height: sourceHeight * factor, + data: destBuf + }; + return this; + } + /** + * Scans all coordinates of the image, handing each in turn to the provided handler function. + * + * @param {function} scanHandler A function(x: number, y: number, bi: number) to be called for each pixel of the image with that pixel's x-coord, y-coord, and index into the `data` buffer. The function accesses the pixel at this coordinate by accessing the `this.data` at index `bi`. + * @see scanAllIndexes + */ + scanAllCoords(scanHandler) { + const width = this.bitmap.width; + const bufferLength = this.bitmap.data.length; + let x7 = 0; + let y4 = 0; + for (let bi2 = 0; bi2 < bufferLength; bi2 += 4) { + scanHandler(x7, y4, bi2); + if (++x7 === width) { + x7 = 0; + ++y4; + } + } + } + /** + * Scans all pixels of the image, handing the index of each in turn to the provided handler function. Runs a bit faster than `scanAllCoords()`, should the handler not need pixel coordinates. + * + * @param {function} scanHandler A function(bi: number) to be called for each pixel of the image with that pixel's index into the `data` buffer. The pixels is found at index 'bi' within `this.data`. + * @see scanAllCoords + */ + scanAllIndexes(scanHandler) { + const bufferLength = this.bitmap.data.length; + for (let bi2 = 0; bi2 < bufferLength; bi2 += 4) { + scanHandler(bi2); + } } }; + module2.exports = BitmapImage2; } }); -// ../node_modules/@actions/github/node_modules/@actions/http-client/lib/index.js -var require_lib = __commonJS({ - "../node_modules/@actions/github/node_modules/@actions/http-client/lib/index.js"(exports2) { +// ../node_modules/gifwrap/src/gif.js +var require_gif = __commonJS({ + "../node_modules/gifwrap/src/gif.js"(exports2) { "use strict"; - var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o6, m6, k6, k22) { - if (k22 === void 0) k22 = k6; - var desc = Object.getOwnPropertyDescriptor(m6, k6); - if (!desc || ("get" in desc ? !m6.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m6[k6]; - } }; + var Gif = class { + // width - width of GIF in pixels + // height - height of GIF in pixels + // loops - 0 = unending; (n > 0) = iterate n times + // usesTransparency - whether any frames have transparent pixels + // colorScope - scope of color tables in GIF + // frames - array of frames + // buffer - GIF-formatted data + /** + * Gif is a class representing an encoded GIF. It is intended to be a read-only representation of a byte-encoded GIF. Only encoders and decoders should be creating instances of this class. + * + * Property | Description + * --- | --- + * width | width of the GIF at its widest + * height | height of the GIF at its highest + * loops | the number of times the GIF should loop before stopping; 0 => loop indefinitely + * usesTransparency | boolean indicating whether at least one frame contains at least one transparent pixel + * colorScope | the scope of the color tables as encoded within the GIF; either Gif.GlobalColorsOnly (== 1) or Gif.LocalColorsOnly (== 2). + * frames | a array of GifFrame instances, one for each frame of the GIF + * buffer | a Buffer holding the encoding's byte data + * + * Its constructor should only ever be called by the GIF encoder or decoder. + * + * @param {Buffer} buffer A Buffer containing the encoded bytes + * @param {GifFrame[]} frames Array of frames found in the encoding + * @param {object} spec Properties of the encoding as listed above + */ + constructor(buffer, frames, spec) { + this.width = spec.width; + this.height = spec.height; + this.loops = spec.loops; + this.usesTransparency = spec.usesTransparency; + this.colorScope = spec.colorScope; + this.frames = frames; + this.buffer = buffer; + } + }; + Gif.GlobalColorsPreferred = 0; + Gif.GlobalColorsOnly = 1; + Gif.LocalColorsOnly = 2; + var GifError2 = class extends Error { + /** + * GifError is a class representing a GIF-related error + * + * @param {string|Error} messageOrError + */ + constructor(messageOrError) { + super(messageOrError); + if (messageOrError instanceof Error) { + this.stack = "Gif" + messageOrError.stack; + } } - Object.defineProperty(o6, k22, desc); - }) : (function(o6, m6, k6, k22) { - if (k22 === void 0) k22 = k6; - o6[k22] = m6[k6]; - })); - var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o6, v7) { - Object.defineProperty(o6, "default", { enumerable: true, value: v7 }); - }) : function(o6, v7) { - o6["default"] = v7; + }; + exports2.Gif = Gif; + exports2.GifError = GifError2; + } +}); + +// ../node_modules/image-q/dist/cjs/image-q.cjs +var require_image_q = __commonJS({ + "../node_modules/image-q/dist/cjs/image-q.cjs"(exports2, module2) { + "use strict"; + var __defProp3 = Object.defineProperty; + var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; + var __getOwnPropNames2 = Object.getOwnPropertyNames; + var __hasOwnProp2 = Object.prototype.hasOwnProperty; + var __defNormalProp2 = (obj2, key, value) => key in obj2 ? __defProp3(obj2, key, { enumerable: true, configurable: true, writable: true, value }) : obj2[key] = value; + var __markAsModule = (target) => __defProp3(target, "__esModule", { value: true }); + var __export3 = (target, all) => { + for (var name in all) + __defProp3(target, name, { get: all[name], enumerable: true }); + }; + var __reExport = (target, module22, copyDefault, desc) => { + if (module22 && typeof module22 === "object" || typeof module22 === "function") { + for (let key of __getOwnPropNames2(module22)) + if (!__hasOwnProp2.call(target, key) && (copyDefault || key !== "default")) + __defProp3(target, key, { get: () => module22[key], enumerable: !(desc = __getOwnPropDesc2(module22, key)) || desc.enumerable }); + } + return target; + }; + var __toCommonJS = /* @__PURE__ */ ((cache6) => { + return (module22, temp) => { + return cache6 && cache6.get(module22) || (temp = __reExport(__markAsModule({}), module22, 1), cache6 && cache6.set(module22, temp), temp); + }; + })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0); + var __publicField2 = (obj2, key, value) => { + __defNormalProp2(obj2, typeof key !== "symbol" ? key + "" : key, value); + return value; + }; + var src_exports = {}; + __export3(src_exports, { + applyPalette: () => applyPalette, + applyPaletteSync: () => applyPaletteSync2, + buildPalette: () => buildPalette, + buildPaletteSync: () => buildPaletteSync2, + constants: () => constants_exports2, + conversion: () => conversion_exports2, + distance: () => distance_exports2, + image: () => image_exports2, + palette: () => palette_exports2, + quality: () => quality_exports2, + utils: () => utils_exports3 }); - var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() { - var ownKeys = function(o6) { - ownKeys = Object.getOwnPropertyNames || function(o7) { - var ar2 = []; - for (var k6 in o7) if (Object.prototype.hasOwnProperty.call(o7, k6)) ar2[ar2.length] = k6; - return ar2; - }; - return ownKeys(o6); + var constants_exports2 = {}; + __export3(constants_exports2, { + bt709: () => bt709_exports2 + }); + var bt709_exports2 = {}; + __export3(bt709_exports2, { + Y: () => Y3, + x: () => x7, + y: () => y4 + }); + var Y3 = /* @__PURE__ */ ((Y22) => { + Y22[Y22["RED"] = 0.2126] = "RED"; + Y22[Y22["GREEN"] = 0.7152] = "GREEN"; + Y22[Y22["BLUE"] = 0.0722] = "BLUE"; + Y22[Y22["WHITE"] = 1] = "WHITE"; + return Y22; + })(Y3 || {}); + var x7 = /* @__PURE__ */ ((x22) => { + x22[x22["RED"] = 0.64] = "RED"; + x22[x22["GREEN"] = 0.3] = "GREEN"; + x22[x22["BLUE"] = 0.15] = "BLUE"; + x22[x22["WHITE"] = 0.3127] = "WHITE"; + return x22; + })(x7 || {}); + var y4 = /* @__PURE__ */ ((y22) => { + y22[y22["RED"] = 0.33] = "RED"; + y22[y22["GREEN"] = 0.6] = "GREEN"; + y22[y22["BLUE"] = 0.06] = "BLUE"; + y22[y22["WHITE"] = 0.329] = "WHITE"; + return y22; + })(y4 || {}); + var conversion_exports2 = {}; + __export3(conversion_exports2, { + lab2rgb: () => lab2rgb2, + lab2xyz: () => lab2xyz2, + rgb2hsl: () => rgb2hsl2, + rgb2lab: () => rgb2lab2, + rgb2xyz: () => rgb2xyz2, + xyz2lab: () => xyz2lab2, + xyz2rgb: () => xyz2rgb2 + }); + function correctGamma3(n6) { + return n6 > 0.04045 ? ((n6 + 0.055) / 1.055) ** 2.4 : n6 / 12.92; + } + function rgb2xyz2(r6, g6, b6) { + r6 = correctGamma3(r6 / 255); + g6 = correctGamma3(g6 / 255); + b6 = correctGamma3(b6 / 255); + return { + x: r6 * 0.4124 + g6 * 0.3576 + b6 * 0.1805, + y: r6 * 0.2126 + g6 * 0.7152 + b6 * 0.0722, + z: r6 * 0.0193 + g6 * 0.1192 + b6 * 0.9505 }; - return function(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for (var k6 = ownKeys(mod), i6 = 0; i6 < k6.length; i6++) if (k6[i6] !== "default") __createBinding(result, mod, k6[i6]); + } + var arithmetic_exports2 = {}; + __export3(arithmetic_exports2, { + degrees2radians: () => degrees2radians2, + inRange0to255: () => inRange0to2552, + inRange0to255Rounded: () => inRange0to255Rounded2, + intInRange: () => intInRange2, + max3: () => max32, + min3: () => min32, + stableSort: () => stableSort2 + }); + function degrees2radians2(n6) { + return n6 * (Math.PI / 180); + } + function max32(a6, b6, c7) { + let m6 = a6; + if (m6 < b6) + m6 = b6; + if (m6 < c7) + m6 = c7; + return m6; + } + function min32(a6, b6, c7) { + let m6 = a6; + if (m6 > b6) + m6 = b6; + if (m6 > c7) + m6 = c7; + return m6; + } + function intInRange2(value, low, high) { + if (value > high) + value = high; + if (value < low) + value = low; + return value | 0; + } + function inRange0to255Rounded2(n6) { + n6 = Math.round(n6); + if (n6 > 255) + n6 = 255; + else if (n6 < 0) + n6 = 0; + return n6; + } + function inRange0to2552(n6) { + if (n6 > 255) + n6 = 255; + else if (n6 < 0) + n6 = 0; + return n6; + } + function stableSort2(arrayToSort, callback) { + const type = typeof arrayToSort[0]; + let sorted; + if (type === "number" || type === "string") { + const ord = /* @__PURE__ */ Object.create(null); + for (let i6 = 0, l6 = arrayToSort.length; i6 < l6; i6++) { + const val = arrayToSort[i6]; + if (ord[val] || ord[val] === 0) + continue; + ord[val] = i6; } - __setModuleDefault(result, mod); - return result; + sorted = arrayToSort.sort((a6, b6) => callback(a6, b6) || ord[a6] - ord[b6]); + } else { + const ord2 = arrayToSort.slice(0); + sorted = arrayToSort.sort((a6, b6) => callback(a6, b6) || ord2.indexOf(a6) - ord2.indexOf(b6)); + } + return sorted; + } + function rgb2hsl2(r6, g6, b6) { + const min = min32(r6, g6, b6); + const max = max32(r6, g6, b6); + const delta = max - min; + const l6 = (min + max) / 510; + let s6 = 0; + if (l6 > 0 && l6 < 1) + s6 = delta / (l6 < 0.5 ? max + min : 510 - max - min); + let h6 = 0; + if (delta > 0) { + if (max === r6) { + h6 = (g6 - b6) / delta; + } else if (max === g6) { + h6 = 2 + (b6 - r6) / delta; + } else { + h6 = 4 + (r6 - g6) / delta; + } + h6 *= 60; + if (h6 < 0) + h6 += 360; + } + return { h: h6, s: s6, l: l6 }; + } + var refX3 = 0.95047; + var refY3 = 1; + var refZ3 = 1.08883; + function pivot3(n6) { + return n6 > 8856e-6 ? n6 ** (1 / 3) : 7.787 * n6 + 16 / 116; + } + function xyz2lab2(x22, y22, z3) { + x22 = pivot3(x22 / refX3); + y22 = pivot3(y22 / refY3); + z3 = pivot3(z3 / refZ3); + if (116 * y22 - 16 < 0) + throw new Error("xxx"); + return { + L: Math.max(0, 116 * y22 - 16), + a: 500 * (x22 - y22), + b: 200 * (y22 - z3) }; - })(); - var __awaiter8 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e6) { - reject(e6); + } + function rgb2lab2(r6, g6, b6) { + const xyz = rgb2xyz2(r6, g6, b6); + return xyz2lab2(xyz.x, xyz.y, xyz.z); + } + var refX22 = 0.95047; + var refY22 = 1; + var refZ22 = 1.08883; + function pivot22(n6) { + return n6 > 0.206893034 ? n6 ** 3 : (n6 - 16 / 116) / 7.787; + } + function lab2xyz2(L2, a6, b6) { + const y22 = (L2 + 16) / 116; + const x22 = a6 / 500 + y22; + const z3 = y22 - b6 / 200; + return { + x: refX22 * pivot22(x22), + y: refY22 * pivot22(y22), + z: refZ22 * pivot22(z3) + }; + } + function correctGamma22(n6) { + return n6 > 31308e-7 ? 1.055 * n6 ** (1 / 2.4) - 0.055 : 12.92 * n6; + } + function xyz2rgb2(x22, y22, z3) { + const r6 = correctGamma22(x22 * 3.2406 + y22 * -1.5372 + z3 * -0.4986); + const g6 = correctGamma22(x22 * -0.9689 + y22 * 1.8758 + z3 * 0.0415); + const b6 = correctGamma22(x22 * 0.0557 + y22 * -0.204 + z3 * 1.057); + return { + r: inRange0to255Rounded2(r6 * 255), + g: inRange0to255Rounded2(g6 * 255), + b: inRange0to255Rounded2(b6 * 255) + }; + } + function lab2rgb2(L2, a6, b6) { + const xyz = lab2xyz2(L2, a6, b6); + return xyz2rgb2(xyz.x, xyz.y, xyz.z); + } + var distance_exports2 = {}; + __export3(distance_exports2, { + AbstractDistanceCalculator: () => AbstractDistanceCalculator2, + AbstractEuclidean: () => AbstractEuclidean2, + AbstractManhattan: () => AbstractManhattan2, + CIE94GraphicArts: () => CIE94GraphicArts2, + CIE94Textiles: () => CIE94Textiles2, + CIEDE2000: () => CIEDE20002, + CMetric: () => CMetric2, + Euclidean: () => Euclidean2, + EuclideanBT709: () => EuclideanBT7092, + EuclideanBT709NoAlpha: () => EuclideanBT709NoAlpha2, + Manhattan: () => Manhattan2, + ManhattanBT709: () => ManhattanBT7092, + ManhattanNommyde: () => ManhattanNommyde2, + PNGQuant: () => PNGQuant2 + }); + var AbstractDistanceCalculator2 = class { + constructor() { + __publicField2(this, "_maxDistance"); + __publicField2(this, "_whitePoint"); + this._setDefaults(); + this.setWhitePoint(255, 255, 255, 255); + } + setWhitePoint(r6, g6, b6, a6) { + this._whitePoint = { + r: r6 > 0 ? 255 / r6 : 0, + g: g6 > 0 ? 255 / g6 : 0, + b: b6 > 0 ? 255 / b6 : 0, + a: a6 > 0 ? 255 / a6 : 0 + }; + this._maxDistance = this.calculateRaw(r6, g6, b6, a6, 0, 0, 0, 0); + } + calculateNormalized(colorA, colorB) { + return this.calculateRaw(colorA.r, colorA.g, colorA.b, colorA.a, colorB.r, colorB.g, colorB.b, colorB.a) / this._maxDistance; + } + }; + var AbstractCIE942 = class extends AbstractDistanceCalculator2 { + calculateRaw(r1, g1, b1, a1, r22, g22, b22, a22) { + const lab1 = rgb2lab2(inRange0to2552(r1 * this._whitePoint.r), inRange0to2552(g1 * this._whitePoint.g), inRange0to2552(b1 * this._whitePoint.b)); + const lab2 = rgb2lab2(inRange0to2552(r22 * this._whitePoint.r), inRange0to2552(g22 * this._whitePoint.g), inRange0to2552(b22 * this._whitePoint.b)); + const dL = lab1.L - lab2.L; + const dA = lab1.a - lab2.a; + const dB = lab1.b - lab2.b; + const c1 = Math.sqrt(lab1.a * lab1.a + lab1.b * lab1.b); + const c22 = Math.sqrt(lab2.a * lab2.a + lab2.b * lab2.b); + const dC = c1 - c22; + let deltaH = dA * dA + dB * dB - dC * dC; + deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH); + const dAlpha = (a22 - a1) * this._whitePoint.a * this._kA; + return Math.sqrt((dL / this._Kl) ** 2 + (dC / (1 + this._K1 * c1)) ** 2 + (deltaH / (1 + this._K2 * c1)) ** 2 + dAlpha ** 2); + } + }; + var CIE94Textiles2 = class extends AbstractCIE942 { + _setDefaults() { + this._Kl = 2; + this._K1 = 0.048; + this._K2 = 0.014; + this._kA = 0.25 * 50 / 255; + } + }; + var CIE94GraphicArts2 = class extends AbstractCIE942 { + _setDefaults() { + this._Kl = 1; + this._K1 = 0.045; + this._K2 = 0.015; + this._kA = 0.25 * 100 / 255; + } + }; + var _CIEDE20002 = class extends AbstractDistanceCalculator2 { + _setDefaults() { + } + static _calculatehp(b6, ap2) { + const hp = Math.atan2(b6, ap2); + if (hp >= 0) + return hp; + return hp + _CIEDE20002._deg360InRad; + } + static _calculateRT(ahp, aCp) { + const aCp_to_7 = aCp ** 7; + const R_C = 2 * Math.sqrt(aCp_to_7 / (aCp_to_7 + _CIEDE20002._pow25to7)); + const delta_theta = _CIEDE20002._deg30InRad * Math.exp(-(((ahp - _CIEDE20002._deg275InRad) / _CIEDE20002._deg25InRad) ** 2)); + return -Math.sin(2 * delta_theta) * R_C; + } + static _calculateT(ahp) { + return 1 - 0.17 * Math.cos(ahp - _CIEDE20002._deg30InRad) + 0.24 * Math.cos(ahp * 2) + 0.32 * Math.cos(ahp * 3 + _CIEDE20002._deg6InRad) - 0.2 * Math.cos(ahp * 4 - _CIEDE20002._deg63InRad); + } + static _calculate_ahp(C1pC2p, h_bar, h1p, h2p) { + const hpSum = h1p + h2p; + if (C1pC2p === 0) + return hpSum; + if (h_bar <= _CIEDE20002._deg180InRad) + return hpSum / 2; + if (hpSum < _CIEDE20002._deg360InRad) { + return (hpSum + _CIEDE20002._deg360InRad) / 2; + } + return (hpSum - _CIEDE20002._deg360InRad) / 2; + } + static _calculate_dHp(C1pC2p, h_bar, h2p, h1p) { + let dhp; + if (C1pC2p === 0) { + dhp = 0; + } else if (h_bar <= _CIEDE20002._deg180InRad) { + dhp = h2p - h1p; + } else if (h2p <= h1p) { + dhp = h2p - h1p + _CIEDE20002._deg360InRad; + } else { + dhp = h2p - h1p - _CIEDE20002._deg360InRad; + } + return 2 * Math.sqrt(C1pC2p) * Math.sin(dhp / 2); + } + calculateRaw(r1, g1, b1, a1, r22, g22, b22, a22) { + const lab1 = rgb2lab2(inRange0to2552(r1 * this._whitePoint.r), inRange0to2552(g1 * this._whitePoint.g), inRange0to2552(b1 * this._whitePoint.b)); + const lab2 = rgb2lab2(inRange0to2552(r22 * this._whitePoint.r), inRange0to2552(g22 * this._whitePoint.g), inRange0to2552(b22 * this._whitePoint.b)); + const dA = (a22 - a1) * this._whitePoint.a * _CIEDE20002._kA; + const dE2 = this.calculateRawInLab(lab1, lab2); + return Math.sqrt(dE2 + dA * dA); + } + calculateRawInLab(Lab1, Lab2) { + const L1 = Lab1.L; + const a1 = Lab1.a; + const b1 = Lab1.b; + const L2 = Lab2.L; + const a22 = Lab2.a; + const b22 = Lab2.b; + const C1 = Math.sqrt(a1 * a1 + b1 * b1); + const C22 = Math.sqrt(a22 * a22 + b22 * b22); + const pow_a_C1_C2_to_7 = ((C1 + C22) / 2) ** 7; + const G3 = 0.5 * (1 - Math.sqrt(pow_a_C1_C2_to_7 / (pow_a_C1_C2_to_7 + _CIEDE20002._pow25to7))); + const a1p = (1 + G3) * a1; + const a2p = (1 + G3) * a22; + const C1p = Math.sqrt(a1p * a1p + b1 * b1); + const C2p = Math.sqrt(a2p * a2p + b22 * b22); + const C1pC2p = C1p * C2p; + const h1p = _CIEDE20002._calculatehp(b1, a1p); + const h2p = _CIEDE20002._calculatehp(b22, a2p); + const h_bar = Math.abs(h1p - h2p); + const dLp = L2 - L1; + const dCp = C2p - C1p; + const dHp = _CIEDE20002._calculate_dHp(C1pC2p, h_bar, h2p, h1p); + const ahp = _CIEDE20002._calculate_ahp(C1pC2p, h_bar, h1p, h2p); + const T2 = _CIEDE20002._calculateT(ahp); + const aCp = (C1p + C2p) / 2; + const aLp_minus_50_square = ((L1 + L2) / 2 - 50) ** 2; + const S_L = 1 + 0.015 * aLp_minus_50_square / Math.sqrt(20 + aLp_minus_50_square); + const S_C = 1 + 0.045 * aCp; + const S_H = 1 + 0.015 * T2 * aCp; + const R_T = _CIEDE20002._calculateRT(ahp, aCp); + const dLpSL = dLp / S_L; + const dCpSC = dCp / S_C; + const dHpSH = dHp / S_H; + return dLpSL ** 2 + dCpSC ** 2 + dHpSH ** 2 + R_T * dCpSC * dHpSH; + } + }; + var CIEDE20002 = _CIEDE20002; + __publicField2(CIEDE20002, "_kA", 0.25 * 100 / 255); + __publicField2(CIEDE20002, "_pow25to7", 25 ** 7); + __publicField2(CIEDE20002, "_deg360InRad", degrees2radians2(360)); + __publicField2(CIEDE20002, "_deg180InRad", degrees2radians2(180)); + __publicField2(CIEDE20002, "_deg30InRad", degrees2radians2(30)); + __publicField2(CIEDE20002, "_deg6InRad", degrees2radians2(6)); + __publicField2(CIEDE20002, "_deg63InRad", degrees2radians2(63)); + __publicField2(CIEDE20002, "_deg275InRad", degrees2radians2(275)); + __publicField2(CIEDE20002, "_deg25InRad", degrees2radians2(25)); + var CMetric2 = class extends AbstractDistanceCalculator2 { + calculateRaw(r1, g1, b1, a1, r22, g22, b22, a22) { + const rmean = (r1 + r22) / 2 * this._whitePoint.r; + const r6 = (r1 - r22) * this._whitePoint.r; + const g6 = (g1 - g22) * this._whitePoint.g; + const b6 = (b1 - b22) * this._whitePoint.b; + const dE = ((512 + rmean) * r6 * r6 >> 8) + 4 * g6 * g6 + ((767 - rmean) * b6 * b6 >> 8); + const dA = (a22 - a1) * this._whitePoint.a; + return Math.sqrt(dE + dA * dA); + } + _setDefaults() { + } + }; + var AbstractEuclidean2 = class extends AbstractDistanceCalculator2 { + calculateRaw(r1, g1, b1, a1, r22, g22, b22, a22) { + const dR = r22 - r1; + const dG = g22 - g1; + const dB = b22 - b1; + const dA = a22 - a1; + return Math.sqrt(this._kR * dR * dR + this._kG * dG * dG + this._kB * dB * dB + this._kA * dA * dA); + } + }; + var Euclidean2 = class extends AbstractEuclidean2 { + _setDefaults() { + this._kR = 1; + this._kG = 1; + this._kB = 1; + this._kA = 1; + } + }; + var EuclideanBT7092 = class extends AbstractEuclidean2 { + _setDefaults() { + this._kR = 0.2126; + this._kG = 0.7152; + this._kB = 0.0722; + this._kA = 1; + } + }; + var EuclideanBT709NoAlpha2 = class extends AbstractEuclidean2 { + _setDefaults() { + this._kR = 0.2126; + this._kG = 0.7152; + this._kB = 0.0722; + this._kA = 0; + } + }; + var AbstractManhattan2 = class extends AbstractDistanceCalculator2 { + calculateRaw(r1, g1, b1, a1, r22, g22, b22, a22) { + let dR = r22 - r1; + let dG = g22 - g1; + let dB = b22 - b1; + let dA = a22 - a1; + if (dR < 0) + dR = 0 - dR; + if (dG < 0) + dG = 0 - dG; + if (dB < 0) + dB = 0 - dB; + if (dA < 0) + dA = 0 - dA; + return this._kR * dR + this._kG * dG + this._kB * dB + this._kA * dA; + } + }; + var Manhattan2 = class extends AbstractManhattan2 { + _setDefaults() { + this._kR = 1; + this._kG = 1; + this._kB = 1; + this._kA = 1; + } + }; + var ManhattanNommyde2 = class extends AbstractManhattan2 { + _setDefaults() { + this._kR = 0.4984; + this._kG = 0.8625; + this._kB = 0.2979; + this._kA = 1; + } + }; + var ManhattanBT7092 = class extends AbstractManhattan2 { + _setDefaults() { + this._kR = 0.2126; + this._kG = 0.7152; + this._kB = 0.0722; + this._kA = 1; + } + }; + var PNGQuant2 = class extends AbstractDistanceCalculator2 { + calculateRaw(r1, g1, b1, a1, r22, g22, b22, a22) { + const alphas = (a22 - a1) * this._whitePoint.a; + return this._colordifferenceCh(r1 * this._whitePoint.r, r22 * this._whitePoint.r, alphas) + this._colordifferenceCh(g1 * this._whitePoint.g, g22 * this._whitePoint.g, alphas) + this._colordifferenceCh(b1 * this._whitePoint.b, b22 * this._whitePoint.b, alphas); + } + _colordifferenceCh(x22, y22, alphas) { + const black = x22 - y22; + const white = black + alphas; + return black * black + white * white; + } + _setDefaults() { + } + }; + var palette_exports2 = {}; + __export3(palette_exports2, { + AbstractPaletteQuantizer: () => AbstractPaletteQuantizer2, + ColorHistogram: () => ColorHistogram2, + NeuQuant: () => NeuQuant2, + NeuQuantFloat: () => NeuQuantFloat2, + RGBQuant: () => RGBQuant2, + WuColorCube: () => WuColorCube2, + WuQuant: () => WuQuant2 + }); + var AbstractPaletteQuantizer2 = class { + quantizeSync() { + for (const value of this.quantize()) { + if (value.palette) { + return value.palette; } } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); - } + throw new Error("unreachable"); + } + }; + var Point2 = class { + constructor() { + __publicField2(this, "r"); + __publicField2(this, "g"); + __publicField2(this, "b"); + __publicField2(this, "a"); + __publicField2(this, "uint32"); + __publicField2(this, "rgba"); + this.uint32 = -1 >>> 0; + this.r = this.g = this.b = this.a = 0; + this.rgba = new Array(4); + this.rgba[0] = 0; + this.rgba[1] = 0; + this.rgba[2] = 0; + this.rgba[3] = 0; + } + static createByQuadruplet(quadruplet) { + const point = new Point2(); + point.r = quadruplet[0] | 0; + point.g = quadruplet[1] | 0; + point.b = quadruplet[2] | 0; + point.a = quadruplet[3] | 0; + point._loadUINT32(); + point._loadQuadruplet(); + return point; + } + static createByRGBA(red, green, blue, alpha) { + const point = new Point2(); + point.r = red | 0; + point.g = green | 0; + point.b = blue | 0; + point.a = alpha | 0; + point._loadUINT32(); + point._loadQuadruplet(); + return point; + } + static createByUint32(uint32) { + const point = new Point2(); + point.uint32 = uint32 >>> 0; + point._loadRGBA(); + point._loadQuadruplet(); + return point; + } + from(point) { + this.r = point.r; + this.g = point.g; + this.b = point.b; + this.a = point.a; + this.uint32 = point.uint32; + this.rgba[0] = point.r; + this.rgba[1] = point.g; + this.rgba[2] = point.b; + this.rgba[3] = point.a; + } + getLuminosity(useAlphaChannel) { + let r6 = this.r; + let g6 = this.g; + let b6 = this.b; + if (useAlphaChannel) { + r6 = Math.min(255, 255 - this.a + this.a * r6 / 255); + g6 = Math.min(255, 255 - this.a + this.a * g6 / 255); + b6 = Math.min(255, 255 - this.a + this.a * b6 / 255); + } + return r6 * 0.2126 + g6 * 0.7152 + b6 * 0.0722; + } + _loadUINT32() { + this.uint32 = (this.a << 24 | this.b << 16 | this.g << 8 | this.r) >>> 0; + } + _loadRGBA() { + this.r = this.uint32 & 255; + this.g = this.uint32 >>> 8 & 255; + this.b = this.uint32 >>> 16 & 255; + this.a = this.uint32 >>> 24 & 255; + } + _loadQuadruplet() { + this.rgba[0] = this.r; + this.rgba[1] = this.g; + this.rgba[2] = this.b; + this.rgba[3] = this.a; + } + }; + var PointContainer2 = class { + constructor() { + __publicField2(this, "_pointArray"); + __publicField2(this, "_width"); + __publicField2(this, "_height"); + this._width = 0; + this._height = 0; + this._pointArray = []; + } + getWidth() { + return this._width; + } + getHeight() { + return this._height; + } + setWidth(width) { + this._width = width; + } + setHeight(height) { + this._height = height; + } + getPointArray() { + return this._pointArray; + } + clone() { + const clone3 = new PointContainer2(); + clone3._width = this._width; + clone3._height = this._height; + for (let i6 = 0, l6 = this._pointArray.length; i6 < l6; i6++) { + clone3._pointArray[i6] = Point2.createByUint32(this._pointArray[i6].uint32 | 0); + } + return clone3; + } + toUint32Array() { + const l6 = this._pointArray.length; + const uint32Array = new Uint32Array(l6); + for (let i6 = 0; i6 < l6; i6++) { + uint32Array[i6] = this._pointArray[i6].uint32; + } + return uint32Array; + } + toUint8Array() { + return new Uint8Array(this.toUint32Array().buffer); + } + static fromHTMLImageElement(img) { + const width = img.naturalWidth; + const height = img.naturalHeight; + const canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + const ctx = canvas.getContext("2d"); + ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height); + return PointContainer2.fromHTMLCanvasElement(canvas); + } + static fromHTMLCanvasElement(canvas) { + const width = canvas.width; + const height = canvas.height; + const ctx = canvas.getContext("2d"); + const imgData = ctx.getImageData(0, 0, width, height); + return PointContainer2.fromImageData(imgData); + } + static fromImageData(imageData) { + const width = imageData.width; + const height = imageData.height; + return PointContainer2.fromUint8Array(imageData.data, width, height); + } + static fromUint8Array(uint8Array, width, height) { + switch (Object.prototype.toString.call(uint8Array)) { + case "[object Uint8ClampedArray]": + case "[object Uint8Array]": + break; + default: + uint8Array = new Uint8Array(uint8Array); } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); + const uint32Array = new Uint32Array(uint8Array.buffer); + return PointContainer2.fromUint32Array(uint32Array, width, height); + } + static fromUint32Array(uint32Array, width, height) { + const container = new PointContainer2(); + container._width = width; + container._height = height; + for (let i6 = 0, l6 = uint32Array.length; i6 < l6; i6++) { + container._pointArray[i6] = Point2.createByUint32(uint32Array[i6] | 0); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); + return container; + } + static fromBuffer(buffer, width, height) { + const uint32Array = new Uint32Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / Uint32Array.BYTES_PER_ELEMENT); + return PointContainer2.fromUint32Array(uint32Array, width, height); + } }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.HttpClient = exports2.HttpClientResponse = exports2.HttpClientError = exports2.MediaTypes = exports2.Headers = exports2.HttpCodes = void 0; - exports2.getProxyUrl = getProxyUrl2; - exports2.isHttps = isHttps; - var http = __importStar(require("http")); - var https = __importStar(require("https")); - var pm = __importStar(require_proxy()); - var tunnel2 = __importStar(require_tunnel2()); - var undici_1 = require_undici(); - var HttpCodes2; - (function(HttpCodes3) { - HttpCodes3[HttpCodes3["OK"] = 200] = "OK"; - HttpCodes3[HttpCodes3["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes3[HttpCodes3["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes3[HttpCodes3["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes3[HttpCodes3["SeeOther"] = 303] = "SeeOther"; - HttpCodes3[HttpCodes3["NotModified"] = 304] = "NotModified"; - HttpCodes3[HttpCodes3["UseProxy"] = 305] = "UseProxy"; - HttpCodes3[HttpCodes3["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes3[HttpCodes3["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes3[HttpCodes3["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes3[HttpCodes3["BadRequest"] = 400] = "BadRequest"; - HttpCodes3[HttpCodes3["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes3[HttpCodes3["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes3[HttpCodes3["Forbidden"] = 403] = "Forbidden"; - HttpCodes3[HttpCodes3["NotFound"] = 404] = "NotFound"; - HttpCodes3[HttpCodes3["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes3[HttpCodes3["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes3[HttpCodes3["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes3[HttpCodes3["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes3[HttpCodes3["Conflict"] = 409] = "Conflict"; - HttpCodes3[HttpCodes3["Gone"] = 410] = "Gone"; - HttpCodes3[HttpCodes3["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes3[HttpCodes3["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes3[HttpCodes3["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes3[HttpCodes3["BadGateway"] = 502] = "BadGateway"; - HttpCodes3[HttpCodes3["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes3[HttpCodes3["GatewayTimeout"] = 504] = "GatewayTimeout"; - })(HttpCodes2 || (exports2.HttpCodes = HttpCodes2 = {})); - var Headers3; - (function(Headers4) { - Headers4["Accept"] = "accept"; - Headers4["ContentType"] = "content-type"; - })(Headers3 || (exports2.Headers = Headers3 = {})); - var MediaTypes2; - (function(MediaTypes3) { - MediaTypes3["ApplicationJson"] = "application/json"; - })(MediaTypes2 || (exports2.MediaTypes = MediaTypes2 = {})); - function getProxyUrl2(serverUrl) { - const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ""; + var hueGroups2 = 10; + function hueGroup2(hue, segmentsNumber) { + const maxHue = 360; + const seg = maxHue / segmentsNumber; + const half = seg / 2; + for (let i6 = 1, mid = seg - half; i6 < segmentsNumber; i6++, mid += seg) { + if (hue >= mid && hue < mid + seg) + return i6; + } + return 0; } - var HttpRedirectCodes2 = [ - HttpCodes2.MovedPermanently, - HttpCodes2.ResourceMoved, - HttpCodes2.SeeOther, - HttpCodes2.TemporaryRedirect, - HttpCodes2.PermanentRedirect - ]; - var HttpResponseRetryCodes2 = [ - HttpCodes2.BadGateway, - HttpCodes2.ServiceUnavailable, - HttpCodes2.GatewayTimeout - ]; - var RetryableHttpVerbs = ["OPTIONS", "GET", "DELETE", "HEAD"]; - var ExponentialBackoffCeiling = 10; - var ExponentialBackoffTimeSlice = 5; - var HttpClientError = class _HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = "HttpClientError"; - this.statusCode = statusCode; - Object.setPrototypeOf(this, _HttpClientError.prototype); + var Palette2 = class { + constructor() { + __publicField2(this, "_pointContainer"); + __publicField2(this, "_pointArray", []); + __publicField2(this, "_i32idx", {}); + this._pointContainer = new PointContainer2(); + this._pointContainer.setHeight(1); + this._pointArray = this._pointContainer.getPointArray(); + } + add(color) { + this._pointArray.push(color); + this._pointContainer.setWidth(this._pointArray.length); + } + has(color) { + for (let i6 = this._pointArray.length - 1; i6 >= 0; i6--) { + if (color.uint32 === this._pointArray[i6].uint32) + return true; + } + return false; + } + getNearestColor(colorDistanceCalculator, color) { + return this._pointArray[this._getNearestIndex(colorDistanceCalculator, color) | 0]; + } + getPointContainer() { + return this._pointContainer; + } + _nearestPointFromCache(key) { + return typeof this._i32idx[key] === "number" ? this._i32idx[key] : -1; + } + _getNearestIndex(colorDistanceCalculator, point) { + let idx = this._nearestPointFromCache("" + point.uint32); + if (idx >= 0) + return idx; + let minimalDistance = Number.MAX_VALUE; + idx = 0; + for (let i6 = 0, l6 = this._pointArray.length; i6 < l6; i6++) { + const p6 = this._pointArray[i6]; + const distance3 = colorDistanceCalculator.calculateRaw(point.r, point.g, point.b, point.a, p6.r, p6.g, p6.b, p6.a); + if (distance3 < minimalDistance) { + minimalDistance = distance3; + idx = i6; + } + } + this._i32idx[point.uint32] = idx; + return idx; + } + sort() { + this._i32idx = {}; + this._pointArray.sort((a6, b6) => { + const hslA = rgb2hsl2(a6.r, a6.g, a6.b); + const hslB = rgb2hsl2(b6.r, b6.g, b6.b); + const hueA = a6.r === a6.g && a6.g === a6.b ? 0 : 1 + hueGroup2(hslA.h, hueGroups2); + const hueB = b6.r === b6.g && b6.g === b6.b ? 0 : 1 + hueGroup2(hslB.h, hueGroups2); + const hueDiff = hueB - hueA; + if (hueDiff) + return -hueDiff; + const lA = a6.getLuminosity(true); + const lB = b6.getLuminosity(true); + if (lB - lA !== 0) + return lB - lA; + const satDiff = (hslB.s * 100 | 0) - (hslA.s * 100 | 0); + if (satDiff) + return -satDiff; + return 0; + }); } }; - exports2.HttpClientError = HttpClientError; - var HttpClientResponse = class { - constructor(message) { - this.message = message; + var utils_exports3 = {}; + __export3(utils_exports3, { + HueStatistics: () => HueStatistics2, + Palette: () => Palette2, + Point: () => Point2, + PointContainer: () => PointContainer2, + ProgressTracker: () => ProgressTracker2, + arithmetic: () => arithmetic_exports2 + }); + var HueGroup2 = class { + constructor() { + __publicField2(this, "num", 0); + __publicField2(this, "cols", []); + } + }; + var HueStatistics2 = class { + constructor(numGroups, minCols) { + __publicField2(this, "_numGroups"); + __publicField2(this, "_minCols"); + __publicField2(this, "_stats"); + __publicField2(this, "_groupsFull"); + this._numGroups = numGroups; + this._minCols = minCols; + this._stats = []; + for (let i6 = 0; i6 <= numGroups; i6++) { + this._stats[i6] = new HueGroup2(); + } + this._groupsFull = 0; + } + check(i32) { + if (this._groupsFull === this._numGroups + 1) { + this.check = () => { + }; + } + const r6 = i32 & 255; + const g6 = i32 >>> 8 & 255; + const b6 = i32 >>> 16 & 255; + const hg = r6 === g6 && g6 === b6 ? 0 : 1 + hueGroup2(rgb2hsl2(r6, g6, b6).h, this._numGroups); + const gr = this._stats[hg]; + const min = this._minCols; + gr.num++; + if (gr.num > min) { + return; + } + if (gr.num === min) { + this._groupsFull++; + } + if (gr.num <= min) { + this._stats[hg].cols.push(i32); + } } - readBody() { - return __awaiter8(this, void 0, void 0, function* () { - return new Promise((resolve2) => __awaiter8(this, void 0, void 0, function* () { - let output = Buffer.alloc(0); - this.message.on("data", (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on("end", () => { - resolve2(output.toString()); + injectIntoDictionary(histG) { + for (let i6 = 0; i6 <= this._numGroups; i6++) { + if (this._stats[i6].num <= this._minCols) { + this._stats[i6].cols.forEach((col) => { + if (!histG[col]) { + histG[col] = 1; + } else { + histG[col]++; + } }); - })); - }); + } + } } - readBodyBuffer() { - return __awaiter8(this, void 0, void 0, function* () { - return new Promise((resolve2) => __awaiter8(this, void 0, void 0, function* () { - const chunks = []; - this.message.on("data", (chunk) => { - chunks.push(chunk); - }); - this.message.on("end", () => { - resolve2(Buffer.concat(chunks)); + injectIntoArray(histG) { + for (let i6 = 0; i6 <= this._numGroups; i6++) { + if (this._stats[i6].num <= this._minCols) { + this._stats[i6].cols.forEach((col) => { + if (histG.indexOf(col) === -1) { + histG.push(col); + } }); - })); - }); + } + } } }; - exports2.HttpClientResponse = HttpClientResponse; - function isHttps(requestUrl) { - const parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === "https:"; - } - var HttpClient3 = class { - constructor(userAgent2, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = this._getUserAgentWithOrchestrationId(userAgent2); - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + var _ProgressTracker2 = class { + constructor(valueRange, progressRange) { + __publicField2(this, "progress"); + __publicField2(this, "_step"); + __publicField2(this, "_range"); + __publicField2(this, "_last"); + __publicField2(this, "_progressRange"); + this._range = valueRange; + this._progressRange = progressRange; + this._step = Math.max(1, this._range / (_ProgressTracker2.steps + 1) | 0); + this._last = -this._step; + this.progress = 0; + } + shouldNotify(current) { + if (current - this._last >= this._step) { + this._last = current; + this.progress = Math.min(this._progressRange * this._last / this._range, this._progressRange); + return true; + } + return false; + } + }; + var ProgressTracker2 = _ProgressTracker2; + __publicField2(ProgressTracker2, "steps", 100); + var networkBiasShift3 = 3; + var Neuron2 = class { + constructor(defaultValue) { + __publicField2(this, "r"); + __publicField2(this, "g"); + __publicField2(this, "b"); + __publicField2(this, "a"); + this.r = this.g = this.b = this.a = defaultValue; + } + toPoint() { + return Point2.createByRGBA(this.r >> networkBiasShift3, this.g >> networkBiasShift3, this.b >> networkBiasShift3, this.a >> networkBiasShift3); + } + subtract(r6, g6, b6, a6) { + this.r -= r6 | 0; + this.g -= g6 | 0; + this.b -= b6 | 0; + this.a -= a6 | 0; + } + }; + var _NeuQuant2 = class extends AbstractPaletteQuantizer2 { + constructor(colorDistanceCalculator, colors = 256) { + super(); + __publicField2(this, "_pointArray"); + __publicField2(this, "_networkSize"); + __publicField2(this, "_network"); + __publicField2(this, "_sampleFactor"); + __publicField2(this, "_radPower"); + __publicField2(this, "_freq"); + __publicField2(this, "_bias"); + __publicField2(this, "_distance"); + this._distance = colorDistanceCalculator; + this._pointArray = []; + this._sampleFactor = 1; + this._networkSize = colors; + this._distance.setWhitePoint(255 << networkBiasShift3, 255 << networkBiasShift3, 255 << networkBiasShift3, 255 << networkBiasShift3); + } + sample(pointContainer) { + this._pointArray = this._pointArray.concat(pointContainer.getPointArray()); + } + *quantize() { + this._init(); + yield* this._learn(); + yield { + palette: this._buildPalette(), + progress: 100 + }; + } + _init() { + this._freq = []; + this._bias = []; + this._radPower = []; + this._network = []; + for (let i6 = 0; i6 < this._networkSize; i6++) { + this._network[i6] = new Neuron2((i6 << networkBiasShift3 + 8) / this._networkSize | 0); + this._freq[i6] = _NeuQuant2._initialBias / this._networkSize | 0; + this._bias[i6] = 0; + } + } + *_learn() { + let sampleFactor = this._sampleFactor; + const pointsNumber = this._pointArray.length; + if (pointsNumber < _NeuQuant2._minpicturebytes) + sampleFactor = 1; + const alphadec = 30 + (sampleFactor - 1) / 3 | 0; + const pointsToSample = pointsNumber / sampleFactor | 0; + let delta = pointsToSample / _NeuQuant2._nCycles | 0; + let alpha = _NeuQuant2._initAlpha; + let radius = (this._networkSize >> 3) * _NeuQuant2._radiusBias; + let rad = radius >> _NeuQuant2._radiusBiasShift; + if (rad <= 1) + rad = 0; + for (let i6 = 0; i6 < rad; i6++) { + this._radPower[i6] = alpha * ((rad * rad - i6 * i6) * _NeuQuant2._radBias / (rad * rad)) >>> 0; + } + let step; + if (pointsNumber < _NeuQuant2._minpicturebytes) { + step = 1; + } else if (pointsNumber % _NeuQuant2._prime1 !== 0) { + step = _NeuQuant2._prime1; + } else if (pointsNumber % _NeuQuant2._prime2 !== 0) { + step = _NeuQuant2._prime2; + } else if (pointsNumber % _NeuQuant2._prime3 !== 0) { + step = _NeuQuant2._prime3; + } else { + step = _NeuQuant2._prime4; + } + const tracker = new ProgressTracker2(pointsToSample, 99); + for (let i6 = 0, pointIndex = 0; i6 < pointsToSample; ) { + if (tracker.shouldNotify(i6)) { + yield { + progress: tracker.progress + }; } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; + const point = this._pointArray[pointIndex]; + const b6 = point.b << networkBiasShift3; + const g6 = point.g << networkBiasShift3; + const r6 = point.r << networkBiasShift3; + const a6 = point.a << networkBiasShift3; + const neuronIndex = this._contest(b6, g6, r6, a6); + this._alterSingle(alpha, neuronIndex, b6, g6, r6, a6); + if (rad !== 0) + this._alterNeighbour(rad, neuronIndex, b6, g6, r6, a6); + pointIndex += step; + if (pointIndex >= pointsNumber) + pointIndex -= pointsNumber; + i6++; + if (delta === 0) + delta = 1; + if (i6 % delta === 0) { + alpha -= alpha / alphadec | 0; + radius -= radius / _NeuQuant2._radiusDecrease | 0; + rad = radius >> _NeuQuant2._radiusBiasShift; + if (rad <= 1) + rad = 0; + for (let j6 = 0; j6 < rad; j6++) { + this._radPower[j6] = alpha * ((rad * rad - j6 * j6) * _NeuQuant2._radBias / (rad * rad)) >>> 0; + } } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; + } + } + _buildPalette() { + const palette2 = new Palette2(); + this._network.forEach((neuron) => { + palette2.add(neuron.toPoint()); + }); + palette2.sort(); + return palette2; + } + _alterNeighbour(rad, i6, b6, g6, r6, al2) { + let lo = i6 - rad; + if (lo < -1) + lo = -1; + let hi = i6 + rad; + if (hi > this._networkSize) + hi = this._networkSize; + let j6 = i6 + 1; + let k6 = i6 - 1; + let m6 = 1; + while (j6 < hi || k6 > lo) { + const a6 = this._radPower[m6++] / _NeuQuant2._alphaRadBias; + if (j6 < hi) { + const p6 = this._network[j6++]; + p6.subtract(a6 * (p6.r - r6), a6 * (p6.g - g6), a6 * (p6.b - b6), a6 * (p6.a - al2)); + } + if (k6 > lo) { + const p6 = this._network[k6--]; + p6.subtract(a6 * (p6.r - r6), a6 * (p6.g - g6), a6 * (p6.b - b6), a6 * (p6.a - al2)); + } + } + } + _alterSingle(alpha, i6, b6, g6, r6, a6) { + alpha /= _NeuQuant2._initAlpha; + const n6 = this._network[i6]; + n6.subtract(alpha * (n6.r - r6), alpha * (n6.g - g6), alpha * (n6.b - b6), alpha * (n6.a - a6)); + } + _contest(b6, g6, r6, a6) { + const multiplier = 255 * 4 << networkBiasShift3; + let bestd = ~(1 << 31); + let bestbiasd = bestd; + let bestpos = -1; + let bestbiaspos = bestpos; + for (let i6 = 0; i6 < this._networkSize; i6++) { + const n6 = this._network[i6]; + const dist = this._distance.calculateNormalized(n6, { r: r6, g: g6, b: b6, a: a6 }) * multiplier | 0; + if (dist < bestd) { + bestd = dist; + bestpos = i6; + } + const biasdist = dist - (this._bias[i6] >> _NeuQuant2._initialBiasShift - networkBiasShift3); + if (biasdist < bestbiasd) { + bestbiasd = biasdist; + bestbiaspos = i6; + } + const betafreq = this._freq[i6] >> _NeuQuant2._betaShift; + this._freq[i6] -= betafreq; + this._bias[i6] += betafreq << _NeuQuant2._gammaShift; + } + this._freq[bestpos] += _NeuQuant2._beta; + this._bias[bestpos] -= _NeuQuant2._betaGamma; + return bestbiaspos; + } + }; + var NeuQuant2 = _NeuQuant2; + __publicField2(NeuQuant2, "_prime1", 499); + __publicField2(NeuQuant2, "_prime2", 491); + __publicField2(NeuQuant2, "_prime3", 487); + __publicField2(NeuQuant2, "_prime4", 503); + __publicField2(NeuQuant2, "_minpicturebytes", _NeuQuant2._prime4); + __publicField2(NeuQuant2, "_nCycles", 100); + __publicField2(NeuQuant2, "_initialBiasShift", 16); + __publicField2(NeuQuant2, "_initialBias", 1 << _NeuQuant2._initialBiasShift); + __publicField2(NeuQuant2, "_gammaShift", 10); + __publicField2(NeuQuant2, "_betaShift", 10); + __publicField2(NeuQuant2, "_beta", _NeuQuant2._initialBias >> _NeuQuant2._betaShift); + __publicField2(NeuQuant2, "_betaGamma", _NeuQuant2._initialBias << _NeuQuant2._gammaShift - _NeuQuant2._betaShift); + __publicField2(NeuQuant2, "_radiusBiasShift", 6); + __publicField2(NeuQuant2, "_radiusBias", 1 << _NeuQuant2._radiusBiasShift); + __publicField2(NeuQuant2, "_radiusDecrease", 30); + __publicField2(NeuQuant2, "_alphaBiasShift", 10); + __publicField2(NeuQuant2, "_initAlpha", 1 << _NeuQuant2._alphaBiasShift); + __publicField2(NeuQuant2, "_radBiasShift", 8); + __publicField2(NeuQuant2, "_radBias", 1 << _NeuQuant2._radBiasShift); + __publicField2(NeuQuant2, "_alphaRadBiasShift", _NeuQuant2._alphaBiasShift + _NeuQuant2._radBiasShift); + __publicField2(NeuQuant2, "_alphaRadBias", 1 << _NeuQuant2._alphaRadBiasShift); + var networkBiasShift22 = 3; + var NeuronFloat2 = class { + constructor(defaultValue) { + __publicField2(this, "r"); + __publicField2(this, "g"); + __publicField2(this, "b"); + __publicField2(this, "a"); + this.r = this.g = this.b = this.a = defaultValue; + } + toPoint() { + return Point2.createByRGBA(this.r >> networkBiasShift22, this.g >> networkBiasShift22, this.b >> networkBiasShift22, this.a >> networkBiasShift22); + } + subtract(r6, g6, b6, a6) { + this.r -= r6; + this.g -= g6; + this.b -= b6; + this.a -= a6; + } + }; + var _NeuQuantFloat2 = class extends AbstractPaletteQuantizer2 { + constructor(colorDistanceCalculator, colors = 256) { + super(); + __publicField2(this, "_pointArray"); + __publicField2(this, "_networkSize"); + __publicField2(this, "_network"); + __publicField2(this, "_sampleFactor"); + __publicField2(this, "_radPower"); + __publicField2(this, "_freq"); + __publicField2(this, "_bias"); + __publicField2(this, "_distance"); + this._distance = colorDistanceCalculator; + this._pointArray = []; + this._sampleFactor = 1; + this._networkSize = colors; + this._distance.setWhitePoint(255 << networkBiasShift22, 255 << networkBiasShift22, 255 << networkBiasShift22, 255 << networkBiasShift22); + } + sample(pointContainer) { + this._pointArray = this._pointArray.concat(pointContainer.getPointArray()); + } + *quantize() { + this._init(); + yield* this._learn(); + yield { + palette: this._buildPalette(), + progress: 100 + }; + } + _init() { + this._freq = []; + this._bias = []; + this._radPower = []; + this._network = []; + for (let i6 = 0; i6 < this._networkSize; i6++) { + this._network[i6] = new NeuronFloat2((i6 << networkBiasShift22 + 8) / this._networkSize); + this._freq[i6] = _NeuQuantFloat2._initialBias / this._networkSize; + this._bias[i6] = 0; + } + } + *_learn() { + let sampleFactor = this._sampleFactor; + const pointsNumber = this._pointArray.length; + if (pointsNumber < _NeuQuantFloat2._minpicturebytes) + sampleFactor = 1; + const alphadec = 30 + (sampleFactor - 1) / 3; + const pointsToSample = pointsNumber / sampleFactor; + let delta = pointsToSample / _NeuQuantFloat2._nCycles | 0; + let alpha = _NeuQuantFloat2._initAlpha; + let radius = (this._networkSize >> 3) * _NeuQuantFloat2._radiusBias; + let rad = radius >> _NeuQuantFloat2._radiusBiasShift; + if (rad <= 1) + rad = 0; + for (let i6 = 0; i6 < rad; i6++) { + this._radPower[i6] = alpha * ((rad * rad - i6 * i6) * _NeuQuantFloat2._radBias / (rad * rad)); + } + let step; + if (pointsNumber < _NeuQuantFloat2._minpicturebytes) { + step = 1; + } else if (pointsNumber % _NeuQuantFloat2._prime1 !== 0) { + step = _NeuQuantFloat2._prime1; + } else if (pointsNumber % _NeuQuantFloat2._prime2 !== 0) { + step = _NeuQuantFloat2._prime2; + } else if (pointsNumber % _NeuQuantFloat2._prime3 !== 0) { + step = _NeuQuantFloat2._prime3; + } else { + step = _NeuQuantFloat2._prime4; + } + const tracker = new ProgressTracker2(pointsToSample, 99); + for (let i6 = 0, pointIndex = 0; i6 < pointsToSample; ) { + if (tracker.shouldNotify(i6)) { + yield { + progress: tracker.progress + }; } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; + const point = this._pointArray[pointIndex]; + const b6 = point.b << networkBiasShift22; + const g6 = point.g << networkBiasShift22; + const r6 = point.r << networkBiasShift22; + const a6 = point.a << networkBiasShift22; + const neuronIndex = this._contest(b6, g6, r6, a6); + this._alterSingle(alpha, neuronIndex, b6, g6, r6, a6); + if (rad !== 0) + this._alterNeighbour(rad, neuronIndex, b6, g6, r6, a6); + pointIndex += step; + if (pointIndex >= pointsNumber) + pointIndex -= pointsNumber; + i6++; + if (delta === 0) + delta = 1; + if (i6 % delta === 0) { + alpha -= alpha / alphadec; + radius -= radius / _NeuQuantFloat2._radiusDecrease; + rad = radius >> _NeuQuantFloat2._radiusBiasShift; + if (rad <= 1) + rad = 0; + for (let j6 = 0; j6 < rad; j6++) { + this._radPower[j6] = alpha * ((rad * rad - j6 * j6) * _NeuQuantFloat2._radBias / (rad * rad)); + } } } } - options(requestUrl, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("OPTIONS", requestUrl, null, additionalHeaders || {}); + _buildPalette() { + const palette2 = new Palette2(); + this._network.forEach((neuron) => { + palette2.add(neuron.toPoint()); }); + palette2.sort(); + return palette2; + } + _alterNeighbour(rad, i6, b6, g6, r6, al2) { + let lo = i6 - rad; + if (lo < -1) + lo = -1; + let hi = i6 + rad; + if (hi > this._networkSize) + hi = this._networkSize; + let j6 = i6 + 1; + let k6 = i6 - 1; + let m6 = 1; + while (j6 < hi || k6 > lo) { + const a6 = this._radPower[m6++] / _NeuQuantFloat2._alphaRadBias; + if (j6 < hi) { + const p6 = this._network[j6++]; + p6.subtract(a6 * (p6.r - r6), a6 * (p6.g - g6), a6 * (p6.b - b6), a6 * (p6.a - al2)); + } + if (k6 > lo) { + const p6 = this._network[k6--]; + p6.subtract(a6 * (p6.r - r6), a6 * (p6.g - g6), a6 * (p6.b - b6), a6 * (p6.a - al2)); + } + } + } + _alterSingle(alpha, i6, b6, g6, r6, a6) { + alpha /= _NeuQuantFloat2._initAlpha; + const n6 = this._network[i6]; + n6.subtract(alpha * (n6.r - r6), alpha * (n6.g - g6), alpha * (n6.b - b6), alpha * (n6.a - a6)); + } + _contest(b6, g6, r6, al2) { + const multiplier = 255 * 4 << networkBiasShift22; + let bestd = ~(1 << 31); + let bestbiasd = bestd; + let bestpos = -1; + let bestbiaspos = bestpos; + for (let i6 = 0; i6 < this._networkSize; i6++) { + const n6 = this._network[i6]; + const dist = this._distance.calculateNormalized(n6, { r: r6, g: g6, b: b6, a: al2 }) * multiplier; + if (dist < bestd) { + bestd = dist; + bestpos = i6; + } + const biasdist = dist - (this._bias[i6] >> _NeuQuantFloat2._initialBiasShift - networkBiasShift22); + if (biasdist < bestbiasd) { + bestbiasd = biasdist; + bestbiaspos = i6; + } + const betafreq = this._freq[i6] >> _NeuQuantFloat2._betaShift; + this._freq[i6] -= betafreq; + this._bias[i6] += betafreq << _NeuQuantFloat2._gammaShift; + } + this._freq[bestpos] += _NeuQuantFloat2._beta; + this._bias[bestpos] -= _NeuQuantFloat2._betaGamma; + return bestbiaspos; + } + }; + var NeuQuantFloat2 = _NeuQuantFloat2; + __publicField2(NeuQuantFloat2, "_prime1", 499); + __publicField2(NeuQuantFloat2, "_prime2", 491); + __publicField2(NeuQuantFloat2, "_prime3", 487); + __publicField2(NeuQuantFloat2, "_prime4", 503); + __publicField2(NeuQuantFloat2, "_minpicturebytes", _NeuQuantFloat2._prime4); + __publicField2(NeuQuantFloat2, "_nCycles", 100); + __publicField2(NeuQuantFloat2, "_initialBiasShift", 16); + __publicField2(NeuQuantFloat2, "_initialBias", 1 << _NeuQuantFloat2._initialBiasShift); + __publicField2(NeuQuantFloat2, "_gammaShift", 10); + __publicField2(NeuQuantFloat2, "_betaShift", 10); + __publicField2(NeuQuantFloat2, "_beta", _NeuQuantFloat2._initialBias >> _NeuQuantFloat2._betaShift); + __publicField2(NeuQuantFloat2, "_betaGamma", _NeuQuantFloat2._initialBias << _NeuQuantFloat2._gammaShift - _NeuQuantFloat2._betaShift); + __publicField2(NeuQuantFloat2, "_radiusBiasShift", 6); + __publicField2(NeuQuantFloat2, "_radiusBias", 1 << _NeuQuantFloat2._radiusBiasShift); + __publicField2(NeuQuantFloat2, "_radiusDecrease", 30); + __publicField2(NeuQuantFloat2, "_alphaBiasShift", 10); + __publicField2(NeuQuantFloat2, "_initAlpha", 1 << _NeuQuantFloat2._alphaBiasShift); + __publicField2(NeuQuantFloat2, "_radBiasShift", 8); + __publicField2(NeuQuantFloat2, "_radBias", 1 << _NeuQuantFloat2._radBiasShift); + __publicField2(NeuQuantFloat2, "_alphaRadBiasShift", _NeuQuantFloat2._alphaBiasShift + _NeuQuantFloat2._radBiasShift); + __publicField2(NeuQuantFloat2, "_alphaRadBias", 1 << _NeuQuantFloat2._alphaRadBiasShift); + var _ColorHistogram2 = class { + constructor(method, colors) { + __publicField2(this, "_method"); + __publicField2(this, "_hueStats"); + __publicField2(this, "_histogram"); + __publicField2(this, "_initColors"); + __publicField2(this, "_minHueCols"); + this._method = method; + this._minHueCols = colors << 2; + this._initColors = colors << 2; + this._hueStats = new HueStatistics2(_ColorHistogram2._hueGroups, this._minHueCols); + this._histogram = /* @__PURE__ */ Object.create(null); + } + sample(pointContainer) { + switch (this._method) { + case 1: + this._colorStats1D(pointContainer); + break; + case 2: + this._colorStats2D(pointContainer); + break; + } } - get(requestUrl, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("GET", requestUrl, null, additionalHeaders || {}); - }); - } - del(requestUrl, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("DELETE", requestUrl, null, additionalHeaders || {}); - }); - } - post(requestUrl, data, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("POST", requestUrl, data, additionalHeaders || {}); - }); - } - patch(requestUrl, data, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("PATCH", requestUrl, data, additionalHeaders || {}); - }); - } - put(requestUrl, data, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("PUT", requestUrl, data, additionalHeaders || {}); - }); - } - head(requestUrl, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request("HEAD", requestUrl, null, additionalHeaders || {}); - }); - } - sendStream(verb, requestUrl, stream2, additionalHeaders) { - return __awaiter8(this, void 0, void 0, function* () { - return this.request(verb, requestUrl, stream2, additionalHeaders); - }); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - getJson(requestUrl_1) { - return __awaiter8(this, arguments, void 0, function* (requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers3.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers3.Accept, MediaTypes2.ApplicationJson); - const res = yield this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - }); - } - postJson(requestUrl_1, obj_1) { - return __awaiter8(this, arguments, void 0, function* (requestUrl, obj2, additionalHeaders = {}) { - const data = JSON.stringify(obj2, null, 2); - additionalHeaders[Headers3.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers3.Accept, MediaTypes2.ApplicationJson); - additionalHeaders[Headers3.ContentType] = this._getExistingOrDefaultContentTypeHeader(additionalHeaders, MediaTypes2.ApplicationJson); - const res = yield this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - }); - } - putJson(requestUrl_1, obj_1) { - return __awaiter8(this, arguments, void 0, function* (requestUrl, obj2, additionalHeaders = {}) { - const data = JSON.stringify(obj2, null, 2); - additionalHeaders[Headers3.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers3.Accept, MediaTypes2.ApplicationJson); - additionalHeaders[Headers3.ContentType] = this._getExistingOrDefaultContentTypeHeader(additionalHeaders, MediaTypes2.ApplicationJson); - const res = yield this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - }); - } - patchJson(requestUrl_1, obj_1) { - return __awaiter8(this, arguments, void 0, function* (requestUrl, obj2, additionalHeaders = {}) { - const data = JSON.stringify(obj2, null, 2); - additionalHeaders[Headers3.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers3.Accept, MediaTypes2.ApplicationJson); - additionalHeaders[Headers3.ContentType] = this._getExistingOrDefaultContentTypeHeader(additionalHeaders, MediaTypes2.ApplicationJson); - const res = yield this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - }); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - request(verb, requestUrl, data, headers) { - return __awaiter8(this, void 0, void 0, function* () { - if (this._disposed) { - throw new Error("Client has already been disposed."); - } - const parsedUrl = new URL(requestUrl); - let info2 = this._prepareRequest(verb, parsedUrl, headers); - const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1; - let numTries = 0; - let response; - do { - response = yield this.requestRaw(info2, data); - if (response && response.message && response.message.statusCode === HttpCodes2.Unauthorized) { - let authenticationHandler; - for (const handler2 of this.handlers) { - if (handler2.canHandleAuthentication(response)) { - authenticationHandler = handler2; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info2, data); - } else { - return response; - } + getImportanceSortedColorsIDXI32() { + const sorted = stableSort2(Object.keys(this._histogram), (a6, b6) => this._histogram[b6] - this._histogram[a6]); + if (sorted.length === 0) { + return []; + } + let idxi32; + switch (this._method) { + case 1: + const initialColorsLimit = Math.min(sorted.length, this._initColors); + const last = sorted[initialColorsLimit - 1]; + const freq = this._histogram[last]; + idxi32 = sorted.slice(0, initialColorsLimit); + let pos = initialColorsLimit; + const len = sorted.length; + while (pos < len && this._histogram[sorted[pos]] === freq) { + idxi32.push(sorted[pos++]); } - let redirectsRemaining = this._maxRedirects; - while (response.message.statusCode && HttpRedirectCodes2.includes(response.message.statusCode) && this._allowRedirects && redirectsRemaining > 0) { - const redirectUrl = response.message.headers["location"]; - if (!redirectUrl) { - break; - } - const parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol === "https:" && parsedUrl.protocol !== parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) { - throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true."); - } - yield response.readBody(); - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (const header in headers) { - if (header.toLowerCase() === "authorization") { - delete headers[header]; - } - } + this._hueStats.injectIntoArray(idxi32); + break; + case 2: + idxi32 = sorted; + break; + default: + throw new Error("Incorrect method"); + } + return idxi32.map((v7) => +v7); + } + _colorStats1D(pointContainer) { + const histG = this._histogram; + const pointArray = pointContainer.getPointArray(); + const len = pointArray.length; + for (let i6 = 0; i6 < len; i6++) { + const col = pointArray[i6].uint32; + this._hueStats.check(col); + if (col in histG) { + histG[col]++; + } else { + histG[col] = 1; + } + } + } + _colorStats2D(pointContainer) { + const width = pointContainer.getWidth(); + const height = pointContainer.getHeight(); + const pointArray = pointContainer.getPointArray(); + const boxW = _ColorHistogram2._boxSize[0]; + const boxH = _ColorHistogram2._boxSize[1]; + const area = boxW * boxH; + const boxes = this._makeBoxes(width, height, boxW, boxH); + const histG = this._histogram; + boxes.forEach((box) => { + let effc = Math.round(box.w * box.h / area) * _ColorHistogram2._boxPixels; + if (effc < 2) + effc = 2; + const histL = {}; + this._iterateBox(box, width, (i6) => { + const col = pointArray[i6].uint32; + this._hueStats.check(col); + if (col in histG) { + histG[col]++; + } else if (col in histL) { + if (++histL[col] >= effc) { + histG[col] = histL[col]; } - info2 = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = yield this.requestRaw(info2, data); - redirectsRemaining--; - } - if (!response.message.statusCode || !HttpResponseRetryCodes2.includes(response.message.statusCode)) { - return response; - } - numTries += 1; - if (numTries < maxTries) { - yield response.readBody(); - yield this._performExponentialBackoff(numTries); + } else { + histL[col] = 1; } - } while (numTries < maxTries); - return response; + }); }); - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); + this._hueStats.injectIntoDictionary(histG); + } + _iterateBox(bbox, wid, fn) { + const b6 = bbox; + const i0 = b6.y * wid + b6.x; + const i1 = (b6.y + b6.h - 1) * wid + (b6.x + b6.w - 1); + const incr = wid - b6.w + 1; + let cnt = 0; + let i6 = i0; + do { + fn.call(this, i6); + i6 += ++cnt % b6.w === 0 ? incr : 1; + } while (i6 <= i1); + } + _makeBoxes(width, height, stepX, stepY) { + const wrem = width % stepX; + const hrem = height % stepY; + const xend = width - wrem; + const yend = height - hrem; + const boxesArray = []; + for (let y22 = 0; y22 < height; y22 += stepY) { + for (let x22 = 0; x22 < width; x22 += stepX) { + boxesArray.push({ + x: x22, + y: y22, + w: x22 === xend ? wrem : stepX, + h: y22 === yend ? hrem : stepY + }); + } } - this._disposed = true; + return boxesArray; } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info2, data) { - return __awaiter8(this, void 0, void 0, function* () { - return new Promise((resolve2, reject) => { - function callbackForResult(err, res) { - if (err) { - reject(err); - } else if (!res) { - reject(new Error("Unknown error")); - } else { - resolve2(res); + }; + var ColorHistogram2 = _ColorHistogram2; + __publicField2(ColorHistogram2, "_boxSize", [64, 64]); + __publicField2(ColorHistogram2, "_boxPixels", 2); + __publicField2(ColorHistogram2, "_hueGroups", 10); + var RemovedColor2 = class { + constructor(index, color, distance3) { + __publicField2(this, "index"); + __publicField2(this, "color"); + __publicField2(this, "distance"); + this.index = index; + this.color = color; + this.distance = distance3; + } + }; + var RGBQuant2 = class extends AbstractPaletteQuantizer2 { + constructor(colorDistanceCalculator, colors = 256, method = 2) { + super(); + __publicField2(this, "_colors"); + __publicField2(this, "_initialDistance"); + __publicField2(this, "_distanceIncrement"); + __publicField2(this, "_histogram"); + __publicField2(this, "_distance"); + this._distance = colorDistanceCalculator; + this._colors = colors; + this._histogram = new ColorHistogram2(method, colors); + this._initialDistance = 0.01; + this._distanceIncrement = 5e-3; + } + sample(image2) { + this._histogram.sample(image2); + } + *quantize() { + const idxi32 = this._histogram.getImportanceSortedColorsIDXI32(); + if (idxi32.length === 0) { + throw new Error("No colors in image"); + } + yield* this._buildPalette(idxi32); + } + *_buildPalette(idxi32) { + const palette2 = new Palette2(); + const colorArray = palette2.getPointContainer().getPointArray(); + const usageArray = new Array(idxi32.length); + for (let i6 = 0; i6 < idxi32.length; i6++) { + colorArray.push(Point2.createByUint32(idxi32[i6])); + usageArray[i6] = 1; + } + const len = colorArray.length; + const memDist = []; + let palLen = len; + let thold = this._initialDistance; + const tracker = new ProgressTracker2(palLen - this._colors, 99); + while (palLen > this._colors) { + memDist.length = 0; + for (let i6 = 0; i6 < len; i6++) { + if (tracker.shouldNotify(len - palLen)) { + yield { + progress: tracker.progress + }; + } + if (usageArray[i6] === 0) + continue; + const pxi = colorArray[i6]; + for (let j6 = i6 + 1; j6 < len; j6++) { + if (usageArray[j6] === 0) + continue; + const pxj = colorArray[j6]; + const dist = this._distance.calculateNormalized(pxi, pxj); + if (dist < thold) { + memDist.push(new RemovedColor2(j6, pxj, dist)); + usageArray[j6] = 0; + palLen--; } } - this.requestRawWithCallback(info2, data, callbackForResult); - }); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info2, data, onResult) { - if (typeof data === "string") { - if (!info2.options.headers) { - info2.options.headers = {}; } - info2.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8"); + thold += palLen > this._colors * 3 ? this._initialDistance : this._distanceIncrement; } - let callbackCalled = false; - function handleResult(err, res) { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); + if (palLen < this._colors) { + stableSort2(memDist, (a6, b6) => b6.distance - a6.distance); + let k6 = 0; + while (palLen < this._colors && k6 < memDist.length) { + const removedColor = memDist[k6]; + usageArray[removedColor.index] = 1; + palLen++; + k6++; } } - const req = info2.httpModule.request(info2.options, (msg) => { - const res = new HttpClientResponse(msg); - handleResult(void 0, res); - }); - let socket; - req.on("socket", (sock) => { - socket = sock; - }); - req.setTimeout(this._socketTimeout || 3 * 6e4, () => { - if (socket) { - socket.end(); + let colors = colorArray.length; + for (let colorIndex = colors - 1; colorIndex >= 0; colorIndex--) { + if (usageArray[colorIndex] === 0) { + if (colorIndex !== colors - 1) { + colorArray[colorIndex] = colorArray[colors - 1]; + } + --colors; } - handleResult(new Error(`Request timeout: ${info2.options.path}`)); - }); - req.on("error", function(err) { - handleResult(err); - }); - if (data && typeof data === "string") { - req.write(data, "utf8"); - } - if (data && typeof data !== "string") { - data.on("close", function() { - req.end(); - }); - data.pipe(req); - } else { - req.end(); } + colorArray.length = colors; + palette2.sort(); + yield { + palette: palette2, + progress: 100 + }; } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - const parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - getAgentDispatcher(serverUrl) { - const parsedUrl = new URL(serverUrl); - const proxyUrl = pm.getProxyUrl(parsedUrl); - const useProxy = proxyUrl && proxyUrl.hostname; - if (!useProxy) { - return; - } - return this._getProxyAgentDispatcher(parsedUrl, proxyUrl); + }; + function createArray1D2(dimension1) { + const a6 = []; + for (let k6 = 0; k6 < dimension1; k6++) { + a6[k6] = 0; } - _prepareRequest(method, requestUrl, headers) { - const info2 = {}; - info2.parsedUrl = requestUrl; - const usingSsl = info2.parsedUrl.protocol === "https:"; - info2.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info2.options = {}; - info2.options.host = info2.parsedUrl.hostname; - info2.options.port = info2.parsedUrl.port ? parseInt(info2.parsedUrl.port) : defaultPort; - info2.options.path = (info2.parsedUrl.pathname || "") + (info2.parsedUrl.search || ""); - info2.options.method = method; - info2.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info2.options.headers["user-agent"] = this.userAgent; - } - info2.options.agent = this._getAgent(info2.parsedUrl); - if (this.handlers) { - for (const handler2 of this.handlers) { - handler2.prepareRequest(info2.options); + return a6; + } + function createArray4D2(dimension1, dimension2, dimension3, dimension4) { + const a6 = new Array(dimension1); + for (let i6 = 0; i6 < dimension1; i6++) { + a6[i6] = new Array(dimension2); + for (let j6 = 0; j6 < dimension2; j6++) { + a6[i6][j6] = new Array(dimension3); + for (let k6 = 0; k6 < dimension3; k6++) { + a6[i6][j6][k6] = new Array(dimension4); + for (let l6 = 0; l6 < dimension4; l6++) { + a6[i6][j6][k6][l6] = 0; + } } } - return info2; } - _mergeHeaders(headers) { - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys2(this.requestOptions.headers), lowercaseKeys2(headers || {})); + return a6; + } + function createArray3D2(dimension1, dimension2, dimension3) { + const a6 = new Array(dimension1); + for (let i6 = 0; i6 < dimension1; i6++) { + a6[i6] = new Array(dimension2); + for (let j6 = 0; j6 < dimension2; j6++) { + a6[i6][j6] = new Array(dimension3); + for (let k6 = 0; k6 < dimension3; k6++) { + a6[i6][j6][k6] = 0; + } } - return lowercaseKeys2(headers || {}); } - /** - * Gets an existing header value or returns a default. - * Handles converting number header values to strings since HTTP headers must be strings. - * Note: This returns string | string[] since some headers can have multiple values. - * For headers that must always be a single string (like Content-Type), use the - * specialized _getExistingOrDefaultContentTypeHeader method instead. - */ - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - const headerValue = lowercaseKeys2(this.requestOptions.headers)[header]; - if (headerValue) { - clientHeader = typeof headerValue === "number" ? headerValue.toString() : headerValue; + return a6; + } + function fillArray3D2(a6, dimension1, dimension2, dimension3, value) { + for (let i6 = 0; i6 < dimension1; i6++) { + a6[i6] = []; + for (let j6 = 0; j6 < dimension2; j6++) { + a6[i6][j6] = []; + for (let k6 = 0; k6 < dimension3; k6++) { + a6[i6][j6][k6] = value; } } - const additionalValue = additionalHeaders[header]; - if (additionalValue !== void 0) { - return typeof additionalValue === "number" ? additionalValue.toString() : additionalValue; - } - if (clientHeader !== void 0) { - return clientHeader; - } - return _default; } - /** - * Specialized version of _getExistingOrDefaultHeader for Content-Type header. - * Always returns a single string (not an array) since Content-Type should be a single value. - * Converts arrays to comma-separated strings and numbers to strings to ensure type safety. - * This was split from _getExistingOrDefaultHeader to provide stricter typing for callers - * that assign the result to places expecting a string (e.g., additionalHeaders[Headers.ContentType]). - */ - _getExistingOrDefaultContentTypeHeader(additionalHeaders, _default) { - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - const headerValue = lowercaseKeys2(this.requestOptions.headers)[Headers3.ContentType]; - if (headerValue) { - if (typeof headerValue === "number") { - clientHeader = String(headerValue); - } else if (Array.isArray(headerValue)) { - clientHeader = headerValue.join(", "); - } else { - clientHeader = headerValue; + } + function fillArray1D2(a6, dimension1, value) { + for (let i6 = 0; i6 < dimension1; i6++) { + a6[i6] = value; + } + } + var WuColorCube2 = class { + constructor() { + __publicField2(this, "redMinimum"); + __publicField2(this, "redMaximum"); + __publicField2(this, "greenMinimum"); + __publicField2(this, "greenMaximum"); + __publicField2(this, "blueMinimum"); + __publicField2(this, "blueMaximum"); + __publicField2(this, "volume"); + __publicField2(this, "alphaMinimum"); + __publicField2(this, "alphaMaximum"); + } + }; + var _WuQuant2 = class extends AbstractPaletteQuantizer2 { + constructor(colorDistanceCalculator, colors = 256, significantBitsPerChannel = 5) { + super(); + __publicField2(this, "_reds"); + __publicField2(this, "_greens"); + __publicField2(this, "_blues"); + __publicField2(this, "_alphas"); + __publicField2(this, "_sums"); + __publicField2(this, "_weights"); + __publicField2(this, "_momentsRed"); + __publicField2(this, "_momentsGreen"); + __publicField2(this, "_momentsBlue"); + __publicField2(this, "_momentsAlpha"); + __publicField2(this, "_moments"); + __publicField2(this, "_table"); + __publicField2(this, "_pixels"); + __publicField2(this, "_cubes"); + __publicField2(this, "_colors"); + __publicField2(this, "_significantBitsPerChannel"); + __publicField2(this, "_maxSideIndex"); + __publicField2(this, "_alphaMaxSideIndex"); + __publicField2(this, "_sideSize"); + __publicField2(this, "_alphaSideSize"); + __publicField2(this, "_distance"); + this._distance = colorDistanceCalculator; + this._setQuality(significantBitsPerChannel); + this._initialize(colors); + } + sample(image2) { + const pointArray = image2.getPointArray(); + for (let i6 = 0, l6 = pointArray.length; i6 < l6; i6++) { + this._addColor(pointArray[i6]); + } + this._pixels = this._pixels.concat(pointArray); + } + *quantize() { + yield* this._preparePalette(); + const palette2 = new Palette2(); + for (let paletteIndex = 0; paletteIndex < this._colors; paletteIndex++) { + if (this._sums[paletteIndex] > 0) { + const sum = this._sums[paletteIndex]; + const r6 = this._reds[paletteIndex] / sum; + const g6 = this._greens[paletteIndex] / sum; + const b6 = this._blues[paletteIndex] / sum; + const a6 = this._alphas[paletteIndex] / sum; + const color = Point2.createByRGBA(r6 | 0, g6 | 0, b6 | 0, a6 | 0); + palette2.add(color); + } + } + palette2.sort(); + yield { + palette: palette2, + progress: 100 + }; + } + *_preparePalette() { + yield* this._calculateMoments(); + let next = 0; + const volumeVariance = createArray1D2(this._colors); + for (let cubeIndex = 1; cubeIndex < this._colors; ++cubeIndex) { + if (this._cut(this._cubes[next], this._cubes[cubeIndex])) { + volumeVariance[next] = this._cubes[next].volume > 1 ? this._calculateVariance(this._cubes[next]) : 0; + volumeVariance[cubeIndex] = this._cubes[cubeIndex].volume > 1 ? this._calculateVariance(this._cubes[cubeIndex]) : 0; + } else { + volumeVariance[next] = 0; + cubeIndex--; + } + next = 0; + let temp = volumeVariance[0]; + for (let index = 1; index <= cubeIndex; ++index) { + if (volumeVariance[index] > temp) { + temp = volumeVariance[index]; + next = index; } } + if (temp <= 0) { + this._colors = cubeIndex + 1; + break; + } } - const additionalValue = additionalHeaders[Headers3.ContentType]; - if (additionalValue !== void 0) { - if (typeof additionalValue === "number") { - return String(additionalValue); - } else if (Array.isArray(additionalValue)) { - return additionalValue.join(", "); + const lookupRed = []; + const lookupGreen = []; + const lookupBlue = []; + const lookupAlpha = []; + for (let k6 = 0; k6 < this._colors; ++k6) { + const weight = _WuQuant2._volume(this._cubes[k6], this._weights); + if (weight > 0) { + lookupRed[k6] = _WuQuant2._volume(this._cubes[k6], this._momentsRed) / weight | 0; + lookupGreen[k6] = _WuQuant2._volume(this._cubes[k6], this._momentsGreen) / weight | 0; + lookupBlue[k6] = _WuQuant2._volume(this._cubes[k6], this._momentsBlue) / weight | 0; + lookupAlpha[k6] = _WuQuant2._volume(this._cubes[k6], this._momentsAlpha) / weight | 0; } else { - return additionalValue; + lookupRed[k6] = 0; + lookupGreen[k6] = 0; + lookupBlue[k6] = 0; + lookupAlpha[k6] = 0; + } + } + this._reds = createArray1D2(this._colors + 1); + this._greens = createArray1D2(this._colors + 1); + this._blues = createArray1D2(this._colors + 1); + this._alphas = createArray1D2(this._colors + 1); + this._sums = createArray1D2(this._colors + 1); + for (let index = 0, l6 = this._pixels.length; index < l6; index++) { + const color = this._pixels[index]; + const match2 = -1; + let bestMatch = match2; + let bestDistance = Number.MAX_VALUE; + for (let lookup = 0; lookup < this._colors; lookup++) { + const foundRed = lookupRed[lookup]; + const foundGreen = lookupGreen[lookup]; + const foundBlue = lookupBlue[lookup]; + const foundAlpha = lookupAlpha[lookup]; + const distance3 = this._distance.calculateRaw(foundRed, foundGreen, foundBlue, foundAlpha, color.r, color.g, color.b, color.a); + if (distance3 < bestDistance) { + bestDistance = distance3; + bestMatch = lookup; + } + } + this._reds[bestMatch] += color.r; + this._greens[bestMatch] += color.g; + this._blues[bestMatch] += color.b; + this._alphas[bestMatch] += color.a; + this._sums[bestMatch]++; + } + } + _addColor(color) { + const bitsToRemove = 8 - this._significantBitsPerChannel; + const indexRed = (color.r >> bitsToRemove) + 1; + const indexGreen = (color.g >> bitsToRemove) + 1; + const indexBlue = (color.b >> bitsToRemove) + 1; + const indexAlpha = (color.a >> bitsToRemove) + 1; + this._weights[indexAlpha][indexRed][indexGreen][indexBlue]++; + this._momentsRed[indexAlpha][indexRed][indexGreen][indexBlue] += color.r; + this._momentsGreen[indexAlpha][indexRed][indexGreen][indexBlue] += color.g; + this._momentsBlue[indexAlpha][indexRed][indexGreen][indexBlue] += color.b; + this._momentsAlpha[indexAlpha][indexRed][indexGreen][indexBlue] += color.a; + this._moments[indexAlpha][indexRed][indexGreen][indexBlue] += this._table[color.r] + this._table[color.g] + this._table[color.b] + this._table[color.a]; + } + *_calculateMoments() { + const area = []; + const areaRed = []; + const areaGreen = []; + const areaBlue = []; + const areaAlpha = []; + const area2 = []; + const xarea = createArray3D2(this._sideSize, this._sideSize, this._sideSize); + const xareaRed = createArray3D2(this._sideSize, this._sideSize, this._sideSize); + const xareaGreen = createArray3D2(this._sideSize, this._sideSize, this._sideSize); + const xareaBlue = createArray3D2(this._sideSize, this._sideSize, this._sideSize); + const xareaAlpha = createArray3D2(this._sideSize, this._sideSize, this._sideSize); + const xarea2 = createArray3D2(this._sideSize, this._sideSize, this._sideSize); + let trackerProgress = 0; + const tracker = new ProgressTracker2(this._alphaMaxSideIndex * this._maxSideIndex, 99); + for (let alphaIndex = 1; alphaIndex <= this._alphaMaxSideIndex; ++alphaIndex) { + fillArray3D2(xarea, this._sideSize, this._sideSize, this._sideSize, 0); + fillArray3D2(xareaRed, this._sideSize, this._sideSize, this._sideSize, 0); + fillArray3D2(xareaGreen, this._sideSize, this._sideSize, this._sideSize, 0); + fillArray3D2(xareaBlue, this._sideSize, this._sideSize, this._sideSize, 0); + fillArray3D2(xareaAlpha, this._sideSize, this._sideSize, this._sideSize, 0); + fillArray3D2(xarea2, this._sideSize, this._sideSize, this._sideSize, 0); + for (let redIndex = 1; redIndex <= this._maxSideIndex; ++redIndex, ++trackerProgress) { + if (tracker.shouldNotify(trackerProgress)) { + yield { + progress: tracker.progress + }; + } + fillArray1D2(area, this._sideSize, 0); + fillArray1D2(areaRed, this._sideSize, 0); + fillArray1D2(areaGreen, this._sideSize, 0); + fillArray1D2(areaBlue, this._sideSize, 0); + fillArray1D2(areaAlpha, this._sideSize, 0); + fillArray1D2(area2, this._sideSize, 0); + for (let greenIndex = 1; greenIndex <= this._maxSideIndex; ++greenIndex) { + let line = 0; + let lineRed = 0; + let lineGreen = 0; + let lineBlue = 0; + let lineAlpha = 0; + let line2 = 0; + for (let blueIndex = 1; blueIndex <= this._maxSideIndex; ++blueIndex) { + line += this._weights[alphaIndex][redIndex][greenIndex][blueIndex]; + lineRed += this._momentsRed[alphaIndex][redIndex][greenIndex][blueIndex]; + lineGreen += this._momentsGreen[alphaIndex][redIndex][greenIndex][blueIndex]; + lineBlue += this._momentsBlue[alphaIndex][redIndex][greenIndex][blueIndex]; + lineAlpha += this._momentsAlpha[alphaIndex][redIndex][greenIndex][blueIndex]; + line2 += this._moments[alphaIndex][redIndex][greenIndex][blueIndex]; + area[blueIndex] += line; + areaRed[blueIndex] += lineRed; + areaGreen[blueIndex] += lineGreen; + areaBlue[blueIndex] += lineBlue; + areaAlpha[blueIndex] += lineAlpha; + area2[blueIndex] += line2; + xarea[redIndex][greenIndex][blueIndex] = xarea[redIndex - 1][greenIndex][blueIndex] + area[blueIndex]; + xareaRed[redIndex][greenIndex][blueIndex] = xareaRed[redIndex - 1][greenIndex][blueIndex] + areaRed[blueIndex]; + xareaGreen[redIndex][greenIndex][blueIndex] = xareaGreen[redIndex - 1][greenIndex][blueIndex] + areaGreen[blueIndex]; + xareaBlue[redIndex][greenIndex][blueIndex] = xareaBlue[redIndex - 1][greenIndex][blueIndex] + areaBlue[blueIndex]; + xareaAlpha[redIndex][greenIndex][blueIndex] = xareaAlpha[redIndex - 1][greenIndex][blueIndex] + areaAlpha[blueIndex]; + xarea2[redIndex][greenIndex][blueIndex] = xarea2[redIndex - 1][greenIndex][blueIndex] + area2[blueIndex]; + this._weights[alphaIndex][redIndex][greenIndex][blueIndex] = this._weights[alphaIndex - 1][redIndex][greenIndex][blueIndex] + xarea[redIndex][greenIndex][blueIndex]; + this._momentsRed[alphaIndex][redIndex][greenIndex][blueIndex] = this._momentsRed[alphaIndex - 1][redIndex][greenIndex][blueIndex] + xareaRed[redIndex][greenIndex][blueIndex]; + this._momentsGreen[alphaIndex][redIndex][greenIndex][blueIndex] = this._momentsGreen[alphaIndex - 1][redIndex][greenIndex][blueIndex] + xareaGreen[redIndex][greenIndex][blueIndex]; + this._momentsBlue[alphaIndex][redIndex][greenIndex][blueIndex] = this._momentsBlue[alphaIndex - 1][redIndex][greenIndex][blueIndex] + xareaBlue[redIndex][greenIndex][blueIndex]; + this._momentsAlpha[alphaIndex][redIndex][greenIndex][blueIndex] = this._momentsAlpha[alphaIndex - 1][redIndex][greenIndex][blueIndex] + xareaAlpha[redIndex][greenIndex][blueIndex]; + this._moments[alphaIndex][redIndex][greenIndex][blueIndex] = this._moments[alphaIndex - 1][redIndex][greenIndex][blueIndex] + xarea2[redIndex][greenIndex][blueIndex]; + } + } } } - if (clientHeader !== void 0) { - return clientHeader; - } - return _default; } - _getAgent(parsedUrl) { - let agent; - const proxyUrl = pm.getProxyUrl(parsedUrl); - const useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (!useProxy) { - agent = this._agent; - } - if (agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === "https:"; - let maxSockets = 100; - if (this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + static _volumeFloat(cube, moment) { + return moment[cube.alphaMaximum][cube.redMaximum][cube.greenMaximum][cube.blueMaximum] - moment[cube.alphaMaximum][cube.redMaximum][cube.greenMinimum][cube.blueMaximum] - moment[cube.alphaMaximum][cube.redMinimum][cube.greenMaximum][cube.blueMaximum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] - moment[cube.alphaMinimum][cube.redMaximum][cube.greenMaximum][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMaximum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] - (moment[cube.alphaMaximum][cube.redMaximum][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMaximum][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMaximum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] - moment[cube.alphaMaximum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum]); + } + static _volume(cube, moment) { + return _WuQuant2._volumeFloat(cube, moment) | 0; + } + static _top(cube, direction, position, moment) { + let result; + switch (direction) { + case _WuQuant2._alpha: + result = moment[position][cube.redMaximum][cube.greenMaximum][cube.blueMaximum] - moment[position][cube.redMaximum][cube.greenMinimum][cube.blueMaximum] - moment[position][cube.redMinimum][cube.greenMaximum][cube.blueMaximum] + moment[position][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] - (moment[position][cube.redMaximum][cube.greenMaximum][cube.blueMinimum] - moment[position][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] - moment[position][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] + moment[position][cube.redMinimum][cube.greenMinimum][cube.blueMinimum]); + break; + case _WuQuant2._red: + result = moment[cube.alphaMaximum][position][cube.greenMaximum][cube.blueMaximum] - moment[cube.alphaMaximum][position][cube.greenMinimum][cube.blueMaximum] - moment[cube.alphaMinimum][position][cube.greenMaximum][cube.blueMaximum] + moment[cube.alphaMinimum][position][cube.greenMinimum][cube.blueMaximum] - (moment[cube.alphaMaximum][position][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMaximum][position][cube.greenMinimum][cube.blueMinimum] - moment[cube.alphaMinimum][position][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMinimum][position][cube.greenMinimum][cube.blueMinimum]); + break; + case _WuQuant2._green: + result = moment[cube.alphaMaximum][cube.redMaximum][position][cube.blueMaximum] - moment[cube.alphaMaximum][cube.redMinimum][position][cube.blueMaximum] - moment[cube.alphaMinimum][cube.redMaximum][position][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMinimum][position][cube.blueMaximum] - (moment[cube.alphaMaximum][cube.redMaximum][position][cube.blueMinimum] - moment[cube.alphaMaximum][cube.redMinimum][position][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMaximum][position][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMinimum][position][cube.blueMinimum]); + break; + case _WuQuant2._blue: + result = moment[cube.alphaMaximum][cube.redMaximum][cube.greenMaximum][position] - moment[cube.alphaMaximum][cube.redMaximum][cube.greenMinimum][position] - moment[cube.alphaMaximum][cube.redMinimum][cube.greenMaximum][position] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][position] - (moment[cube.alphaMinimum][cube.redMaximum][cube.greenMaximum][position] - moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][position] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][position] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][position]); + break; + default: + throw new Error("impossible"); + } + return result | 0; + } + static _bottom(cube, direction, moment) { + switch (direction) { + case _WuQuant2._alpha: + return -moment[cube.alphaMinimum][cube.redMaximum][cube.greenMaximum][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMaximum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] - (-moment[cube.alphaMinimum][cube.redMaximum][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum]); + case _WuQuant2._red: + return -moment[cube.alphaMaximum][cube.redMinimum][cube.greenMaximum][cube.blueMaximum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMaximum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] - (-moment[cube.alphaMaximum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum]); + case _WuQuant2._green: + return -moment[cube.alphaMaximum][cube.redMaximum][cube.greenMinimum][cube.blueMaximum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMaximum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMaximum] - (-moment[cube.alphaMaximum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum]); + case _WuQuant2._blue: + return -moment[cube.alphaMaximum][cube.redMaximum][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMaximum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMaximum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMaximum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum] - (-moment[cube.alphaMinimum][cube.redMaximum][cube.greenMaximum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMaximum][cube.greenMinimum][cube.blueMinimum] + moment[cube.alphaMinimum][cube.redMinimum][cube.greenMaximum][cube.blueMinimum] - moment[cube.alphaMinimum][cube.redMinimum][cube.greenMinimum][cube.blueMinimum]); + default: + return 0; } - if (proxyUrl && proxyUrl.hostname) { - const agentOptions = { - maxSockets, - keepAlive: this._keepAlive, - proxy: Object.assign(Object.assign({}, (proxyUrl.username || proxyUrl.password) && { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` - }), { host: proxyUrl.hostname, port: proxyUrl.port }) - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === "https:"; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel2.httpsOverHttps : tunnel2.httpsOverHttp; - } else { - tunnelAgent = overHttps ? tunnel2.httpOverHttps : tunnel2.httpOverHttp; + } + _calculateVariance(cube) { + const volumeRed = _WuQuant2._volume(cube, this._momentsRed); + const volumeGreen = _WuQuant2._volume(cube, this._momentsGreen); + const volumeBlue = _WuQuant2._volume(cube, this._momentsBlue); + const volumeAlpha = _WuQuant2._volume(cube, this._momentsAlpha); + const volumeMoment = _WuQuant2._volumeFloat(cube, this._moments); + const volumeWeight = _WuQuant2._volume(cube, this._weights); + const distance3 = volumeRed * volumeRed + volumeGreen * volumeGreen + volumeBlue * volumeBlue + volumeAlpha * volumeAlpha; + return volumeMoment - distance3 / volumeWeight; + } + _maximize(cube, direction, first, last, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight) { + const bottomRed = _WuQuant2._bottom(cube, direction, this._momentsRed) | 0; + const bottomGreen = _WuQuant2._bottom(cube, direction, this._momentsGreen) | 0; + const bottomBlue = _WuQuant2._bottom(cube, direction, this._momentsBlue) | 0; + const bottomAlpha = _WuQuant2._bottom(cube, direction, this._momentsAlpha) | 0; + const bottomWeight = _WuQuant2._bottom(cube, direction, this._weights) | 0; + let result = 0; + let cutPosition = -1; + for (let position = first; position < last; ++position) { + let halfRed = bottomRed + _WuQuant2._top(cube, direction, position, this._momentsRed); + let halfGreen = bottomGreen + _WuQuant2._top(cube, direction, position, this._momentsGreen); + let halfBlue = bottomBlue + _WuQuant2._top(cube, direction, position, this._momentsBlue); + let halfAlpha = bottomAlpha + _WuQuant2._top(cube, direction, position, this._momentsAlpha); + let halfWeight = bottomWeight + _WuQuant2._top(cube, direction, position, this._weights); + if (halfWeight !== 0) { + let halfDistance = halfRed * halfRed + halfGreen * halfGreen + halfBlue * halfBlue + halfAlpha * halfAlpha; + let temp = halfDistance / halfWeight; + halfRed = wholeRed - halfRed; + halfGreen = wholeGreen - halfGreen; + halfBlue = wholeBlue - halfBlue; + halfAlpha = wholeAlpha - halfAlpha; + halfWeight = wholeWeight - halfWeight; + if (halfWeight !== 0) { + halfDistance = halfRed * halfRed + halfGreen * halfGreen + halfBlue * halfBlue + halfAlpha * halfAlpha; + temp += halfDistance / halfWeight; + if (temp > result) { + result = temp; + cutPosition = position; + } + } } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - if (!agent) { - const options = { keepAlive: this._keepAlive, maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; } - if (usingSsl && this._ignoreSslError) { - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); + return { max: result, position: cutPosition }; + } + _cut(first, second) { + let direction; + const wholeRed = _WuQuant2._volume(first, this._momentsRed); + const wholeGreen = _WuQuant2._volume(first, this._momentsGreen); + const wholeBlue = _WuQuant2._volume(first, this._momentsBlue); + const wholeAlpha = _WuQuant2._volume(first, this._momentsAlpha); + const wholeWeight = _WuQuant2._volume(first, this._weights); + const red = this._maximize(first, _WuQuant2._red, first.redMinimum + 1, first.redMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight); + const green = this._maximize(first, _WuQuant2._green, first.greenMinimum + 1, first.greenMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight); + const blue = this._maximize(first, _WuQuant2._blue, first.blueMinimum + 1, first.blueMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight); + const alpha = this._maximize(first, _WuQuant2._alpha, first.alphaMinimum + 1, first.alphaMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight); + if (alpha.max >= red.max && alpha.max >= green.max && alpha.max >= blue.max) { + direction = _WuQuant2._alpha; + if (alpha.position < 0) + return false; + } else if (red.max >= alpha.max && red.max >= green.max && red.max >= blue.max) { + direction = _WuQuant2._red; + } else if (green.max >= alpha.max && green.max >= red.max && green.max >= blue.max) { + direction = _WuQuant2._green; + } else { + direction = _WuQuant2._blue; + } + second.redMaximum = first.redMaximum; + second.greenMaximum = first.greenMaximum; + second.blueMaximum = first.blueMaximum; + second.alphaMaximum = first.alphaMaximum; + switch (direction) { + case _WuQuant2._red: + second.redMinimum = first.redMaximum = red.position; + second.greenMinimum = first.greenMinimum; + second.blueMinimum = first.blueMinimum; + second.alphaMinimum = first.alphaMinimum; + break; + case _WuQuant2._green: + second.greenMinimum = first.greenMaximum = green.position; + second.redMinimum = first.redMinimum; + second.blueMinimum = first.blueMinimum; + second.alphaMinimum = first.alphaMinimum; + break; + case _WuQuant2._blue: + second.blueMinimum = first.blueMaximum = blue.position; + second.redMinimum = first.redMinimum; + second.greenMinimum = first.greenMinimum; + second.alphaMinimum = first.alphaMinimum; + break; + case _WuQuant2._alpha: + second.alphaMinimum = first.alphaMaximum = alpha.position; + second.blueMinimum = first.blueMinimum; + second.redMinimum = first.redMinimum; + second.greenMinimum = first.greenMinimum; + break; } - return agent; + first.volume = (first.redMaximum - first.redMinimum) * (first.greenMaximum - first.greenMinimum) * (first.blueMaximum - first.blueMinimum) * (first.alphaMaximum - first.alphaMinimum); + second.volume = (second.redMaximum - second.redMinimum) * (second.greenMaximum - second.greenMinimum) * (second.blueMaximum - second.blueMinimum) * (second.alphaMaximum - second.alphaMinimum); + return true; } - _getProxyAgentDispatcher(parsedUrl, proxyUrl) { - let proxyAgent; - if (this._keepAlive) { - proxyAgent = this._proxyAgentDispatcher; - } - if (proxyAgent) { - return proxyAgent; - } - const usingSsl = parsedUrl.protocol === "https:"; - proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, (proxyUrl.username || proxyUrl.password) && { - token: `Basic ${Buffer.from(`${proxyUrl.username}:${proxyUrl.password}`).toString("base64")}` - })); - this._proxyAgentDispatcher = proxyAgent; - if (usingSsl && this._ignoreSslError) { - proxyAgent.options = Object.assign(proxyAgent.options.requestTls || {}, { - rejectUnauthorized: false - }); + _initialize(colors) { + this._colors = colors; + this._cubes = []; + for (let cubeIndex = 0; cubeIndex < colors; cubeIndex++) { + this._cubes[cubeIndex] = new WuColorCube2(); + } + this._cubes[0].redMinimum = 0; + this._cubes[0].greenMinimum = 0; + this._cubes[0].blueMinimum = 0; + this._cubes[0].alphaMinimum = 0; + this._cubes[0].redMaximum = this._maxSideIndex; + this._cubes[0].greenMaximum = this._maxSideIndex; + this._cubes[0].blueMaximum = this._maxSideIndex; + this._cubes[0].alphaMaximum = this._alphaMaxSideIndex; + this._weights = createArray4D2(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize); + this._momentsRed = createArray4D2(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize); + this._momentsGreen = createArray4D2(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize); + this._momentsBlue = createArray4D2(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize); + this._momentsAlpha = createArray4D2(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize); + this._moments = createArray4D2(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize); + this._table = []; + for (let tableIndex = 0; tableIndex < 256; ++tableIndex) { + this._table[tableIndex] = tableIndex * tableIndex; + } + this._pixels = []; + } + _setQuality(significantBitsPerChannel = 5) { + this._significantBitsPerChannel = significantBitsPerChannel; + this._maxSideIndex = 1 << this._significantBitsPerChannel; + this._alphaMaxSideIndex = this._maxSideIndex; + this._sideSize = this._maxSideIndex + 1; + this._alphaSideSize = this._alphaMaxSideIndex + 1; + } + }; + var WuQuant2 = _WuQuant2; + __publicField2(WuQuant2, "_alpha", 3); + __publicField2(WuQuant2, "_red", 2); + __publicField2(WuQuant2, "_green", 1); + __publicField2(WuQuant2, "_blue", 0); + var image_exports2 = {}; + __export3(image_exports2, { + AbstractImageQuantizer: () => AbstractImageQuantizer2, + ErrorDiffusionArray: () => ErrorDiffusionArray2, + ErrorDiffusionArrayKernel: () => ErrorDiffusionArrayKernel2, + ErrorDiffusionRiemersma: () => ErrorDiffusionRiemersma2, + NearestColor: () => NearestColor2 + }); + var AbstractImageQuantizer2 = class { + quantizeSync(pointContainer, palette2) { + for (const value of this.quantize(pointContainer, palette2)) { + if (value.pointContainer) { + return value.pointContainer; + } } - return proxyAgent; + throw new Error("unreachable"); } - _getUserAgentWithOrchestrationId(userAgent2) { - const baseUserAgent = userAgent2 || "actions/http-client"; - const orchId = process.env["ACTIONS_ORCHESTRATION_ID"]; - if (orchId) { - const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, "_"); - return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`; + }; + var NearestColor2 = class extends AbstractImageQuantizer2 { + constructor(colorDistanceCalculator) { + super(); + __publicField2(this, "_distance"); + this._distance = colorDistanceCalculator; + } + *quantize(pointContainer, palette2) { + const pointArray = pointContainer.getPointArray(); + const width = pointContainer.getWidth(); + const height = pointContainer.getHeight(); + const tracker = new ProgressTracker2(height, 99); + for (let y22 = 0; y22 < height; y22++) { + if (tracker.shouldNotify(y22)) { + yield { + progress: tracker.progress + }; + } + for (let x22 = 0, idx = y22 * width; x22 < width; x22++, idx++) { + const point = pointArray[idx]; + point.from(palette2.getNearestColor(this._distance, point)); + } } - return baseUserAgent; - } - _performExponentialBackoff(retryNumber) { - return __awaiter8(this, void 0, void 0, function* () { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise((resolve2) => setTimeout(() => resolve2(), ms)); - }); + yield { + pointContainer, + progress: 100 + }; } - _processResponse(res, options) { - return __awaiter8(this, void 0, void 0, function* () { - return new Promise((resolve2, reject) => __awaiter8(this, void 0, void 0, function* () { - const statusCode = res.message.statusCode || 0; - const response = { - statusCode, - result: null, - headers: {} + }; + var ErrorDiffusionArrayKernel2 = /* @__PURE__ */ ((ErrorDiffusionArrayKernel22) => { + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["FloydSteinberg"] = 0] = "FloydSteinberg"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["FalseFloydSteinberg"] = 1] = "FalseFloydSteinberg"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["Stucki"] = 2] = "Stucki"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["Atkinson"] = 3] = "Atkinson"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["Jarvis"] = 4] = "Jarvis"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["Burkes"] = 5] = "Burkes"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["Sierra"] = 6] = "Sierra"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["TwoSierra"] = 7] = "TwoSierra"; + ErrorDiffusionArrayKernel22[ErrorDiffusionArrayKernel22["SierraLite"] = 8] = "SierraLite"; + return ErrorDiffusionArrayKernel22; + })(ErrorDiffusionArrayKernel2 || {}); + var ErrorDiffusionArray2 = class extends AbstractImageQuantizer2 { + constructor(colorDistanceCalculator, kernel, serpentine = true, minimumColorDistanceToDither = 0, calculateErrorLikeGIMP = false) { + super(); + __publicField2(this, "_minColorDistance"); + __publicField2(this, "_serpentine"); + __publicField2(this, "_kernel"); + __publicField2(this, "_calculateErrorLikeGIMP"); + __publicField2(this, "_distance"); + this._setKernel(kernel); + this._distance = colorDistanceCalculator; + this._minColorDistance = minimumColorDistanceToDither; + this._serpentine = serpentine; + this._calculateErrorLikeGIMP = calculateErrorLikeGIMP; + } + *quantize(pointContainer, palette2) { + const pointArray = pointContainer.getPointArray(); + const originalPoint = new Point2(); + const width = pointContainer.getWidth(); + const height = pointContainer.getHeight(); + const errorLines = []; + let dir = 1; + let maxErrorLines = 1; + for (const kernel of this._kernel) { + const kernelErrorLines = kernel[2] + 1; + if (maxErrorLines < kernelErrorLines) + maxErrorLines = kernelErrorLines; + } + for (let i6 = 0; i6 < maxErrorLines; i6++) { + this._fillErrorLine(errorLines[i6] = [], width); + } + const tracker = new ProgressTracker2(height, 99); + for (let y22 = 0; y22 < height; y22++) { + if (tracker.shouldNotify(y22)) { + yield { + progress: tracker.progress }; - if (statusCode === HttpCodes2.NotFound) { - resolve2(response); - } - function dateTimeDeserializer(key, value) { - if (typeof value === "string") { - const a6 = new Date(value); - if (!isNaN(a6.valueOf())) { - return a6; - } - } - return value; + } + if (this._serpentine) + dir *= -1; + const lni = y22 * width; + const xStart = dir === 1 ? 0 : width - 1; + const xEnd = dir === 1 ? width : -1; + this._fillErrorLine(errorLines[0], width); + errorLines.push(errorLines.shift()); + const errorLine = errorLines[0]; + for (let x22 = xStart, idx = lni + xStart; x22 !== xEnd; x22 += dir, idx += dir) { + const point = pointArray[idx]; + const error2 = errorLine[x22]; + originalPoint.from(point); + const correctedPoint = Point2.createByRGBA(inRange0to255Rounded2(point.r + error2[0]), inRange0to255Rounded2(point.g + error2[1]), inRange0to255Rounded2(point.b + error2[2]), inRange0to255Rounded2(point.a + error2[3])); + const palettePoint = palette2.getNearestColor(this._distance, correctedPoint); + point.from(palettePoint); + if (this._minColorDistance) { + const dist = this._distance.calculateNormalized(originalPoint, palettePoint); + if (dist < this._minColorDistance) + continue; } - let obj2; - let contents; - try { - contents = yield res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj2 = JSON.parse(contents, dateTimeDeserializer); - } else { - obj2 = JSON.parse(contents); - } - response.result = obj2; - } - response.headers = res.message.headers; - } catch (err) { + let er; + let eg; + let eb; + let ea; + if (this._calculateErrorLikeGIMP) { + er = correctedPoint.r - palettePoint.r; + eg = correctedPoint.g - palettePoint.g; + eb = correctedPoint.b - palettePoint.b; + ea = correctedPoint.a - palettePoint.a; + } else { + er = originalPoint.r - palettePoint.r; + eg = originalPoint.g - palettePoint.g; + eb = originalPoint.b - palettePoint.b; + ea = originalPoint.a - palettePoint.a; } - if (statusCode > 299) { - let msg; - if (obj2 && obj2.message) { - msg = obj2.message; - } else if (contents && contents.length > 0) { - msg = contents; - } else { - msg = `Failed request: (${statusCode})`; + const dStart = dir === 1 ? 0 : this._kernel.length - 1; + const dEnd = dir === 1 ? this._kernel.length : -1; + for (let i6 = dStart; i6 !== dEnd; i6 += dir) { + const x1 = this._kernel[i6][1] * dir; + const y1 = this._kernel[i6][2]; + if (x1 + x22 >= 0 && x1 + x22 < width && y1 + y22 >= 0 && y1 + y22 < height) { + const d6 = this._kernel[i6][0]; + const e6 = errorLines[y1][x1 + x22]; + e6[0] += er * d6; + e6[1] += eg * d6; + e6[2] += eb * d6; + e6[3] += ea * d6; } - const err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } else { - resolve2(response); } - })); - }); + } + } + yield { + pointContainer, + progress: 100 + }; } - }; - exports2.HttpClient = HttpClient3; - var lowercaseKeys2 = (obj2) => Object.keys(obj2).reduce((c6, k6) => (c6[k6.toLowerCase()] = obj2[k6], c6), {}); - } -}); - -// ../node_modules/fast-content-type-parse/index.js -var require_fast_content_type_parse = __commonJS({ - "../node_modules/fast-content-type-parse/index.js"(exports2, module2) { - "use strict"; - var NullObject = function NullObject2() { - }; - NullObject.prototype = /* @__PURE__ */ Object.create(null); - var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu; - var quotedPairRE = /\\([\v\u0020-\u00ff])/gu; - var mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u; - var defaultContentType = { type: "", parameters: new NullObject() }; - Object.freeze(defaultContentType.parameters); - Object.freeze(defaultContentType); - function parse3(header) { - if (typeof header !== "string") { - throw new TypeError("argument header is required and must be a string"); + _fillErrorLine(errorLine, width) { + if (errorLine.length > width) { + errorLine.length = width; + } + const l6 = errorLine.length; + for (let i6 = 0; i6 < l6; i6++) { + const error2 = errorLine[i6]; + error2[0] = error2[1] = error2[2] = error2[3] = 0; + } + for (let i6 = l6; i6 < width; i6++) { + errorLine[i6] = [0, 0, 0, 0]; + } } - let index = header.indexOf(";"); - const type = index !== -1 ? header.slice(0, index).trim() : header.trim(); - if (mediaTypeRE.test(type) === false) { - throw new TypeError("invalid media type"); - } - const result = { - type: type.toLowerCase(), - parameters: new NullObject() + _setKernel(kernel) { + switch (kernel) { + case 0: + this._kernel = [ + [7 / 16, 1, 0], + [3 / 16, -1, 1], + [5 / 16, 0, 1], + [1 / 16, 1, 1] + ]; + break; + case 1: + this._kernel = [ + [3 / 8, 1, 0], + [3 / 8, 0, 1], + [2 / 8, 1, 1] + ]; + break; + case 2: + this._kernel = [ + [8 / 42, 1, 0], + [4 / 42, 2, 0], + [2 / 42, -2, 1], + [4 / 42, -1, 1], + [8 / 42, 0, 1], + [4 / 42, 1, 1], + [2 / 42, 2, 1], + [1 / 42, -2, 2], + [2 / 42, -1, 2], + [4 / 42, 0, 2], + [2 / 42, 1, 2], + [1 / 42, 2, 2] + ]; + break; + case 3: + this._kernel = [ + [1 / 8, 1, 0], + [1 / 8, 2, 0], + [1 / 8, -1, 1], + [1 / 8, 0, 1], + [1 / 8, 1, 1], + [1 / 8, 0, 2] + ]; + break; + case 4: + this._kernel = [ + [7 / 48, 1, 0], + [5 / 48, 2, 0], + [3 / 48, -2, 1], + [5 / 48, -1, 1], + [7 / 48, 0, 1], + [5 / 48, 1, 1], + [3 / 48, 2, 1], + [1 / 48, -2, 2], + [3 / 48, -1, 2], + [5 / 48, 0, 2], + [3 / 48, 1, 2], + [1 / 48, 2, 2] + ]; + break; + case 5: + this._kernel = [ + [8 / 32, 1, 0], + [4 / 32, 2, 0], + [2 / 32, -2, 1], + [4 / 32, -1, 1], + [8 / 32, 0, 1], + [4 / 32, 1, 1], + [2 / 32, 2, 1] + ]; + break; + case 6: + this._kernel = [ + [5 / 32, 1, 0], + [3 / 32, 2, 0], + [2 / 32, -2, 1], + [4 / 32, -1, 1], + [5 / 32, 0, 1], + [4 / 32, 1, 1], + [2 / 32, 2, 1], + [2 / 32, -1, 2], + [3 / 32, 0, 2], + [2 / 32, 1, 2] + ]; + break; + case 7: + this._kernel = [ + [4 / 16, 1, 0], + [3 / 16, 2, 0], + [1 / 16, -2, 1], + [2 / 16, -1, 1], + [3 / 16, 0, 1], + [2 / 16, 1, 1], + [1 / 16, 2, 1] + ]; + break; + case 8: + this._kernel = [ + [2 / 4, 1, 0], + [1 / 4, -1, 1], + [1 / 4, 0, 1] + ]; + break; + default: + throw new Error(`ErrorDiffusionArray: unknown kernel = ${kernel}`); + } + } + }; + function* hilbertCurve2(width, height, callback) { + const maxBound = Math.max(width, height); + const level = Math.floor(Math.log(maxBound) / Math.log(2) + 1); + const tracker = new ProgressTracker2(width * height, 99); + const data = { + width, + height, + level, + callback, + tracker, + index: 0, + x: 0, + y: 0 }; - if (index === -1) { - return result; - } - let key; - let match2; - let value; - paramRE.lastIndex = index; - while (match2 = paramRE.exec(header)) { - if (match2.index !== index) { - throw new TypeError("invalid parameter format"); - } - index += match2[0].length; - key = match2[1].toLowerCase(); - value = match2[2]; - if (value[0] === '"') { - value = value.slice(1, value.length - 1); - quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1")); - } - result.parameters[key] = value; + yield* walkHilbert2( + data, + 1 + /* UP */ + ); + visit2( + data, + 0 + /* NONE */ + ); + } + function* walkHilbert2(data, direction) { + if (data.level < 1) + return; + if (data.tracker.shouldNotify(data.index)) { + yield { progress: data.tracker.progress }; } - if (index !== header.length) { - throw new TypeError("invalid parameter format"); + data.level--; + switch (direction) { + case 2: + yield* walkHilbert2( + data, + 1 + /* UP */ + ); + visit2( + data, + 3 + /* RIGHT */ + ); + yield* walkHilbert2( + data, + 2 + /* LEFT */ + ); + visit2( + data, + 4 + /* DOWN */ + ); + yield* walkHilbert2( + data, + 2 + /* LEFT */ + ); + visit2( + data, + 2 + /* LEFT */ + ); + yield* walkHilbert2( + data, + 4 + /* DOWN */ + ); + break; + case 3: + yield* walkHilbert2( + data, + 4 + /* DOWN */ + ); + visit2( + data, + 2 + /* LEFT */ + ); + yield* walkHilbert2( + data, + 3 + /* RIGHT */ + ); + visit2( + data, + 1 + /* UP */ + ); + yield* walkHilbert2( + data, + 3 + /* RIGHT */ + ); + visit2( + data, + 3 + /* RIGHT */ + ); + yield* walkHilbert2( + data, + 1 + /* UP */ + ); + break; + case 1: + yield* walkHilbert2( + data, + 2 + /* LEFT */ + ); + visit2( + data, + 4 + /* DOWN */ + ); + yield* walkHilbert2( + data, + 1 + /* UP */ + ); + visit2( + data, + 3 + /* RIGHT */ + ); + yield* walkHilbert2( + data, + 1 + /* UP */ + ); + visit2( + data, + 1 + /* UP */ + ); + yield* walkHilbert2( + data, + 3 + /* RIGHT */ + ); + break; + case 4: + yield* walkHilbert2( + data, + 3 + /* RIGHT */ + ); + visit2( + data, + 1 + /* UP */ + ); + yield* walkHilbert2( + data, + 4 + /* DOWN */ + ); + visit2( + data, + 2 + /* LEFT */ + ); + yield* walkHilbert2( + data, + 4 + /* DOWN */ + ); + visit2( + data, + 4 + /* DOWN */ + ); + yield* walkHilbert2( + data, + 2 + /* LEFT */ + ); + break; + default: + break; } - return result; + data.level++; } - function safeParse3(header) { - if (typeof header !== "string") { - return defaultContentType; + function visit2(data, direction) { + if (data.x >= 0 && data.x < data.width && data.y >= 0 && data.y < data.height) { + data.callback(data.x, data.y); + data.index++; } - let index = header.indexOf(";"); - const type = index !== -1 ? header.slice(0, index).trim() : header.trim(); - if (mediaTypeRE.test(type) === false) { - return defaultContentType; + switch (direction) { + case 2: + data.x--; + break; + case 3: + data.x++; + break; + case 1: + data.y--; + break; + case 4: + data.y++; + break; } - const result = { - type: type.toLowerCase(), - parameters: new NullObject() - }; - if (index === -1) { - return result; + } + var ErrorDiffusionRiemersma2 = class extends AbstractImageQuantizer2 { + constructor(colorDistanceCalculator, errorQueueSize = 16, errorPropagation = 1) { + super(); + __publicField2(this, "_distance"); + __publicField2(this, "_weights"); + __publicField2(this, "_errorQueueSize"); + this._distance = colorDistanceCalculator; + this._errorQueueSize = errorQueueSize; + this._weights = ErrorDiffusionRiemersma2._createWeights(errorPropagation, errorQueueSize); + } + *quantize(pointContainer, palette2) { + const pointArray = pointContainer.getPointArray(); + const width = pointContainer.getWidth(); + const height = pointContainer.getHeight(); + const errorQueue = []; + let head = 0; + for (let i6 = 0; i6 < this._errorQueueSize; i6++) { + errorQueue[i6] = { r: 0, g: 0, b: 0, a: 0 }; + } + yield* hilbertCurve2(width, height, (x22, y22) => { + const p6 = pointArray[x22 + y22 * width]; + let { r: r6, g: g6, b: b6, a: a6 } = p6; + for (let i6 = 0; i6 < this._errorQueueSize; i6++) { + const weight = this._weights[i6]; + const e6 = errorQueue[(i6 + head) % this._errorQueueSize]; + r6 += e6.r * weight; + g6 += e6.g * weight; + b6 += e6.b * weight; + a6 += e6.a * weight; + } + const correctedPoint = Point2.createByRGBA(inRange0to255Rounded2(r6), inRange0to255Rounded2(g6), inRange0to255Rounded2(b6), inRange0to255Rounded2(a6)); + const quantizedPoint = palette2.getNearestColor(this._distance, correctedPoint); + head = (head + 1) % this._errorQueueSize; + const tail = (head + this._errorQueueSize - 1) % this._errorQueueSize; + errorQueue[tail].r = p6.r - quantizedPoint.r; + errorQueue[tail].g = p6.g - quantizedPoint.g; + errorQueue[tail].b = p6.b - quantizedPoint.b; + errorQueue[tail].a = p6.a - quantizedPoint.a; + p6.from(quantizedPoint); + }); + yield { + pointContainer, + progress: 100 + }; } - let key; - let match2; - let value; - paramRE.lastIndex = index; - while (match2 = paramRE.exec(header)) { - if (match2.index !== index) { - return defaultContentType; - } - index += match2[0].length; - key = match2[1].toLowerCase(); - value = match2[2]; - if (value[0] === '"') { - value = value.slice(1, value.length - 1); - quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1")); + static _createWeights(errorPropagation, errorQueueSize) { + const weights = []; + const multiplier = Math.exp(Math.log(errorQueueSize) / (errorQueueSize - 1)); + for (let i6 = 0, next = 1; i6 < errorQueueSize; i6++) { + weights[i6] = (next + 0.5 | 0) / errorQueueSize * errorPropagation; + next *= multiplier; } - result.parameters[key] = value; + return weights; } - if (index !== header.length) { - return defaultContentType; + }; + var quality_exports2 = {}; + __export3(quality_exports2, { + ssim: () => ssim2 + }); + var K12 = 0.01; + var K22 = 0.03; + function ssim2(image1, image2) { + if (image1.getHeight() !== image2.getHeight() || image1.getWidth() !== image2.getWidth()) { + throw new Error("Images have different sizes!"); + } + const bitsPerComponent = 8; + const L2 = (1 << bitsPerComponent) - 1; + const c1 = (K12 * L2) ** 2; + const c22 = (K22 * L2) ** 2; + let numWindows = 0; + let mssim = 0; + iterate3(image1, image2, (lumaValues1, lumaValues2, averageLumaValue1, averageLumaValue2) => { + let sigxy = 0; + let sigsqx = 0; + let sigsqy = 0; + for (let i6 = 0; i6 < lumaValues1.length; i6++) { + sigsqx += (lumaValues1[i6] - averageLumaValue1) ** 2; + sigsqy += (lumaValues2[i6] - averageLumaValue2) ** 2; + sigxy += (lumaValues1[i6] - averageLumaValue1) * (lumaValues2[i6] - averageLumaValue2); + } + const numPixelsInWin = lumaValues1.length - 1; + sigsqx /= numPixelsInWin; + sigsqy /= numPixelsInWin; + sigxy /= numPixelsInWin; + const numerator = (2 * averageLumaValue1 * averageLumaValue2 + c1) * (2 * sigxy + c22); + const denominator = (averageLumaValue1 ** 2 + averageLumaValue2 ** 2 + c1) * (sigsqx + sigsqy + c22); + const ssim22 = numerator / denominator; + mssim += ssim22; + numWindows++; + }); + return mssim / numWindows; + } + function iterate3(image1, image2, callback) { + const windowSize = 8; + const width = image1.getWidth(); + const height = image1.getHeight(); + for (let y22 = 0; y22 < height; y22 += windowSize) { + for (let x22 = 0; x22 < width; x22 += windowSize) { + const windowWidth = Math.min(windowSize, width - x22); + const windowHeight = Math.min(windowSize, height - y22); + const lumaValues1 = calculateLumaValuesForWindow2(image1, x22, y22, windowWidth, windowHeight); + const lumaValues2 = calculateLumaValuesForWindow2(image2, x22, y22, windowWidth, windowHeight); + const averageLuma1 = calculateAverageLuma2(lumaValues1); + const averageLuma2 = calculateAverageLuma2(lumaValues2); + callback(lumaValues1, lumaValues2, averageLuma1, averageLuma2); + } + } + } + function calculateLumaValuesForWindow2(image2, x22, y22, width, height) { + const pointArray = image2.getPointArray(); + const lumaValues = []; + let counter = 0; + for (let j6 = y22; j6 < y22 + height; j6++) { + const offset = j6 * image2.getWidth(); + for (let i6 = x22; i6 < x22 + width; i6++) { + const point = pointArray[offset + i6]; + lumaValues[counter] = point.r * 0.2126 + point.g * 0.7152 + point.b * 0.0722; + counter++; + } + } + return lumaValues; + } + function calculateAverageLuma2(lumaValues) { + let sumLuma = 0; + for (const luma of lumaValues) { + sumLuma += luma; + } + return sumLuma / lumaValues.length; + } + var setImmediateImpl2 = typeof setImmediate === "function" ? setImmediate : typeof process !== "undefined" && typeof (process == null ? void 0 : process.nextTick) === "function" ? (callback) => process.nextTick(callback) : (callback) => setTimeout(callback, 0); + function buildPaletteSync2(images, { + colorDistanceFormula, + paletteQuantization, + colors + } = {}) { + const distanceCalculator = colorDistanceFormulaToColorDistance2(colorDistanceFormula); + const paletteQuantizer = paletteQuantizationToPaletteQuantizer2(distanceCalculator, paletteQuantization, colors); + images.forEach((image2) => paletteQuantizer.sample(image2)); + return paletteQuantizer.quantizeSync(); + } + async function buildPalette(images, { + colorDistanceFormula, + paletteQuantization, + colors, + onProgress + } = {}) { + return new Promise((resolve3, reject2) => { + const distanceCalculator = colorDistanceFormulaToColorDistance2(colorDistanceFormula); + const paletteQuantizer = paletteQuantizationToPaletteQuantizer2(distanceCalculator, paletteQuantization, colors); + images.forEach((image2) => paletteQuantizer.sample(image2)); + let palette2; + const iterator2 = paletteQuantizer.quantize(); + const next = () => { + try { + const result = iterator2.next(); + if (result.done) { + resolve3(palette2); + } else { + if (result.value.palette) + palette2 = result.value.palette; + if (onProgress) + onProgress(result.value.progress); + setImmediateImpl2(next); + } + } catch (error2) { + reject2(error2); + } + }; + setImmediateImpl2(next); + }); + } + function applyPaletteSync2(image2, palette2, { colorDistanceFormula, imageQuantization } = {}) { + const distanceCalculator = colorDistanceFormulaToColorDistance2(colorDistanceFormula); + const imageQuantizer = imageQuantizationToImageQuantizer2(distanceCalculator, imageQuantization); + return imageQuantizer.quantizeSync(image2, palette2); + } + async function applyPalette(image2, palette2, { + colorDistanceFormula, + imageQuantization, + onProgress + } = {}) { + return new Promise((resolve3, reject2) => { + const distanceCalculator = colorDistanceFormulaToColorDistance2(colorDistanceFormula); + const imageQuantizer = imageQuantizationToImageQuantizer2(distanceCalculator, imageQuantization); + let outPointContainer; + const iterator2 = imageQuantizer.quantize(image2, palette2); + const next = () => { + try { + const result = iterator2.next(); + if (result.done) { + resolve3(outPointContainer); + } else { + if (result.value.pointContainer) { + outPointContainer = result.value.pointContainer; + } + if (onProgress) + onProgress(result.value.progress); + setImmediateImpl2(next); + } + } catch (error2) { + reject2(error2); + } + }; + setImmediateImpl2(next); + }); + } + function colorDistanceFormulaToColorDistance2(colorDistanceFormula = "euclidean-bt709") { + switch (colorDistanceFormula) { + case "cie94-graphic-arts": + return new CIE94GraphicArts2(); + case "cie94-textiles": + return new CIE94Textiles2(); + case "ciede2000": + return new CIEDE20002(); + case "color-metric": + return new CMetric2(); + case "euclidean": + return new Euclidean2(); + case "euclidean-bt709": + return new EuclideanBT7092(); + case "euclidean-bt709-noalpha": + return new EuclideanBT709NoAlpha2(); + case "manhattan": + return new Manhattan2(); + case "manhattan-bt709": + return new ManhattanBT7092(); + case "manhattan-nommyde": + return new ManhattanNommyde2(); + case "pngquant": + return new PNGQuant2(); + default: + throw new Error(`Unknown colorDistanceFormula ${colorDistanceFormula}`); + } + } + function imageQuantizationToImageQuantizer2(distanceCalculator, imageQuantization = "floyd-steinberg") { + switch (imageQuantization) { + case "nearest": + return new NearestColor2(distanceCalculator); + case "riemersma": + return new ErrorDiffusionRiemersma2(distanceCalculator); + case "floyd-steinberg": + return new ErrorDiffusionArray2( + distanceCalculator, + 0 + /* FloydSteinberg */ + ); + case "false-floyd-steinberg": + return new ErrorDiffusionArray2( + distanceCalculator, + 1 + /* FalseFloydSteinberg */ + ); + case "stucki": + return new ErrorDiffusionArray2( + distanceCalculator, + 2 + /* Stucki */ + ); + case "atkinson": + return new ErrorDiffusionArray2( + distanceCalculator, + 3 + /* Atkinson */ + ); + case "jarvis": + return new ErrorDiffusionArray2( + distanceCalculator, + 4 + /* Jarvis */ + ); + case "burkes": + return new ErrorDiffusionArray2( + distanceCalculator, + 5 + /* Burkes */ + ); + case "sierra": + return new ErrorDiffusionArray2( + distanceCalculator, + 6 + /* Sierra */ + ); + case "two-sierra": + return new ErrorDiffusionArray2( + distanceCalculator, + 7 + /* TwoSierra */ + ); + case "sierra-lite": + return new ErrorDiffusionArray2( + distanceCalculator, + 8 + /* SierraLite */ + ); + default: + throw new Error(`Unknown imageQuantization ${imageQuantization}`); + } + } + function paletteQuantizationToPaletteQuantizer2(distanceCalculator, paletteQuantization = "wuquant", colors = 256) { + switch (paletteQuantization) { + case "neuquant": + return new NeuQuant2(distanceCalculator, colors); + case "rgbquant": + return new RGBQuant2(distanceCalculator, colors); + case "wuquant": + return new WuQuant2(distanceCalculator, colors); + case "neuquant-float": + return new NeuQuantFloat2(distanceCalculator, colors); + default: + throw new Error(`Unknown paletteQuantization ${paletteQuantization}`); } - return result; } - module2.exports.default = { parse: parse3, safeParse: safeParse3 }; - module2.exports.parse = parse3; - module2.exports.safeParse = safeParse3; - module2.exports.defaultContentType = defaultContentType; + module2.exports = __toCommonJS(src_exports); } }); -// ../node_modules/@actions/core/lib/command.js -var os = __toESM(require("os"), 1); - -// ../node_modules/@actions/core/lib/utils.js -function toCommandValue(input) { - if (input === null || input === void 0) { - return ""; - } else if (typeof input === "string" || input instanceof String) { - return input; - } - return JSON.stringify(input); -} -function toCommandProperties(annotationProperties) { - if (!Object.keys(annotationProperties).length) { - return {}; +// ../node_modules/gifwrap/src/gifframe.js +var require_gifframe = __commonJS({ + "../node_modules/gifwrap/src/gifframe.js"(exports2) { + "use strict"; + var BitmapImage2 = require_bitmapimage(); + var { GifError: GifError2 } = require_gif(); + var GifFrame2 = class _GifFrame extends BitmapImage2 { + // xOffset - x offset of bitmap on GIF (defaults to 0) + // yOffset - y offset of bitmap on GIF (defaults to 0) + // disposalMethod - pixel disposal method when handling partial images + // delayCentisecs - duration of frame in hundredths of a second + // interlaced - whether the image is interlaced (defaults to false) + /** + * GifFrame is a class representing an image frame of a GIF. GIFs contain one or more instances of GifFrame. + * + * Property | Description + * --- | --- + * xOffset | x-coord of position within GIF at which to render the image (defaults to 0) + * yOffset | y-coord of position within GIF at which to render the image (defaults to 0) + * disposalMethod | GIF disposal method; only relevant when the frames aren't all the same size (defaults to 2, disposing to background color) + * delayCentisecs | duration of the frame in hundreths of a second + * interlaced | boolean indicating whether the frame renders interlaced + * + * Its constructor supports the following signatures: + * + * * new GifFrame(bitmap: {width: number, height: number, data: Buffer}, options?) + * * new GifFrame(bitmapImage: BitmapImage, options?) + * * new GifFrame(width: number, height: number, buffer: Buffer, options?) + * * new GifFrame(width: number, height: number, backgroundRGBA?: number, options?) + * * new GifFrame(frame: GifFrame) + * + * See the base class BitmapImage for a discussion of all parameters but `options` and `frame`. `options` is an optional argument providing initial values for the above-listed GifFrame properties. Each property within option is itself optional. + * + * Provide a `frame` to the constructor to create a clone of the provided frame. The new frame includes a copy of the provided frame's pixel data so that each can subsequently be modified without affecting each other. + */ + constructor(...args) { + super(...args); + if (args[0] instanceof _GifFrame) { + const source = args[0]; + this.xOffset = source.xOffset; + this.yOffset = source.yOffset; + this.disposalMethod = source.disposalMethod; + this.delayCentisecs = source.delayCentisecs; + this.interlaced = source.interlaced; + } else { + const lastArg = args[args.length - 1]; + let options = {}; + if (typeof lastArg === "object" && !(lastArg instanceof BitmapImage2)) { + options = lastArg; + } + this.xOffset = options.xOffset || 0; + this.yOffset = options.yOffset || 0; + this.disposalMethod = options.disposalMethod !== void 0 ? options.disposalMethod : _GifFrame.DisposeToBackgroundColor; + this.delayCentisecs = options.delayCentisecs || 8; + this.interlaced = options.interlaced || false; + } + } + /** + * Get a summary of the colors found within the frame. The return value is an object of the following form: + * + * Property | Description + * --- | --- + * colors | An array of all the opaque colors found within the frame. Each color is given as an RGB number of the form 0xRRGGBB. The array is sorted by increasing number. Will be an empty array when the image is completely transparent. + * usesTransparency | boolean indicating whether there are any transparent pixels within the frame. A pixel is considered transparent if its alpha value is 0x00. + * indexCount | The number of color indexes required to represent this palette of colors. It is equal to the number of opaque colors plus one if the image includes transparency. + * + * @return {object} An object representing a color palette as described above. + */ + getPalette() { + const colorSet = /* @__PURE__ */ new Set(); + const buf = this.bitmap.data; + let i6 = 0; + let usesTransparency = false; + while (i6 < buf.length) { + if (buf[i6 + 3] === 0) { + usesTransparency = true; + } else { + const color = buf.readUInt32BE(i6, true) >> 8 & 16777215; + colorSet.add(color); + } + i6 += 4; + } + const colors = new Array(colorSet.size); + const iter = colorSet.values(); + for (i6 = 0; i6 < colors.length; ++i6) { + colors[i6] = iter.next().value; + } + colors.sort((a6, b6) => a6 - b6); + let indexCount = colors.length; + if (usesTransparency) { + ++indexCount; + } + return { colors, usesTransparency, indexCount }; + } + }; + GifFrame2.DisposeToAnything = 0; + GifFrame2.DisposeNothing = 1; + GifFrame2.DisposeToBackgroundColor = 2; + GifFrame2.DisposeToPrevious = 3; + exports2.GifFrame = GifFrame2; } - return { - title: annotationProperties.title, - file: annotationProperties.file, - line: annotationProperties.startLine, - endLine: annotationProperties.endLine, - col: annotationProperties.startColumn, - endColumn: annotationProperties.endColumn - }; -} +}); -// ../node_modules/@actions/core/lib/command.js -function issueCommand(command, properties, message) { - const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os.EOL); -} -var CMD_STRING = "::"; -var Command = class { - constructor(command, properties, message) { - if (!command) { - command = "missing.command"; +// ../node_modules/gifwrap/src/gifutil.js +var require_gifutil = __commonJS({ + "../node_modules/gifwrap/src/gifutil.js"(exports2) { + "use strict"; + var fs6 = require("fs"); + var ImageQ = require_image_q(); + var BitmapImage2 = require_bitmapimage(); + var { GifFrame: GifFrame2 } = require_gifframe(); + var { GifError: GifError2 } = require_gif(); + var { GifCodec: GifCodec2 } = require_gifcodec(); + var INVALID_SUFFIXES = [".jpg", ".jpeg", ".png", ".bmp"]; + var defaultCodec = new GifCodec2(); + exports2.cloneFrames = function(frames) { + let clones = []; + frames.forEach((frame) => { + clones.push(new GifFrame2(frame)); + }); + return clones; + }; + exports2.getColorInfo = function(frames, maxGlobalIndex) { + let usesTransparency = false; + const palettes = []; + for (let i6 = 0; i6 < frames.length; ++i6) { + let palette2 = frames[i6].getPalette(); + if (palette2.usesTransparency) { + usesTransparency = true; + } + if (palette2.indexCount > 256) { + throw new GifError2(`Frame ${i6} uses more than 256 color indexes`); + } + palettes.push(palette2); + } + if (maxGlobalIndex === 0) { + return { usesTransparency, palettes }; + } + const globalColorSet = /* @__PURE__ */ new Set(); + palettes.forEach((palette2) => { + palette2.colors.forEach((color) => { + globalColorSet.add(color); + }); + }); + let indexCount = globalColorSet.size; + if (usesTransparency) { + ++indexCount; + } + if (maxGlobalIndex && indexCount > maxGlobalIndex) { + return { usesTransparency, palettes }; + } + const colors = new Array(globalColorSet.size); + const iter = globalColorSet.values(); + for (let i6 = 0; i6 < colors.length; ++i6) { + colors[i6] = iter.next().value; + } + colors.sort((a6, b6) => a6 - b6); + return { colors, indexCount, usesTransparency, palettes }; + }; + exports2.copyAsJimp = function(jimp, bitmapImageToCopy) { + return exports2.shareAsJimp(jimp, new BitmapImage2(bitmapImageToCopy)); + }; + exports2.getMaxDimensions = function(frames) { + let maxWidth = 0, maxHeight = 0; + frames.forEach((frame) => { + const width = frame.xOffset + frame.bitmap.width; + if (width > maxWidth) { + maxWidth = width; + } + const height = frame.yOffset + frame.bitmap.height; + if (height > maxHeight) { + maxHeight = height; + } + }); + return { maxWidth, maxHeight }; + }; + exports2.quantizeDekker = function(imageOrImages, maxColorIndexes, dither) { + maxColorIndexes = maxColorIndexes || 256; + _quantize(imageOrImages, "NeuQuantFloat", maxColorIndexes, 0, dither); + }; + exports2.quantizeSorokin = function(imageOrImages, maxColorIndexes, histogram2, dither) { + maxColorIndexes = maxColorIndexes || 256; + histogram2 = histogram2 || "min-pop"; + let histogramID; + switch (histogram2) { + case "min-pop": + histogramID = 2; + break; + case "top-pop": + histogramID = 1; + break; + default: + throw new Error(`Invalid quantizeSorokin histogram '${histogram2}'`); + } + _quantize(imageOrImages, "RGBQuant", maxColorIndexes, histogramID, dither); + }; + exports2.quantizeWu = function(imageOrImages, maxColorIndexes, significantBits, dither) { + maxColorIndexes = maxColorIndexes || 256; + significantBits = significantBits || 5; + if (significantBits < 1 || significantBits > 8) { + throw new Error("Invalid quantization quality"); + } + _quantize(imageOrImages, "WuQuant", maxColorIndexes, significantBits, dither); + }; + exports2.read = function(source, decoder) { + decoder = decoder || defaultCodec; + if (Buffer.isBuffer(source)) { + return decoder.decodeGif(source); + } + return _readBinary(source).then((buffer) => { + return decoder.decodeGif(buffer); + }); + }; + exports2.shareAsJimp = function(jimp, bitmapImageToShare) { + const jimpImage = new jimp( + bitmapImageToShare.bitmap.width, + bitmapImageToShare.bitmap.height, + 0 + ); + jimpImage.bitmap.data = bitmapImageToShare.bitmap.data; + return jimpImage; + }; + exports2.write = function(path7, frames, spec, encoder) { + encoder = encoder || defaultCodec; + const matches = path7.match(/\.[a-zA-Z]+$/); + if (matches !== null && INVALID_SUFFIXES.includes(matches[0].toLowerCase())) { + throw new Error(`GIF '${path7}' has an unexpected suffix`); + } + return encoder.encodeGif(frames, spec).then((gif2) => { + return _writeBinary(path7, gif2.buffer).then(() => { + return gif2; + }); + }); + }; + function _quantize(imageOrImages, method, maxColorIndexes, modifier, dither) { + const images = Array.isArray(imageOrImages) ? imageOrImages : [imageOrImages]; + const ditherAlgs = [ + "FloydSteinberg", + "FalseFloydSteinberg", + "Stucki", + "Atkinson", + "Jarvis", + "Burkes", + "Sierra", + "TwoSierra", + "SierraLite" + ]; + if (dither) { + if (ditherAlgs.indexOf(dither.ditherAlgorithm) < 0) { + throw new Error(`Invalid ditherAlgorithm '${dither.ditherAlgorithm}'`); + } + if (dither.serpentine === void 0) { + dither.serpentine = true; + } + if (dither.minimumColorDistanceToDither === void 0) { + dither.minimumColorDistanceToDither = 0; + } + if (dither.calculateErrorLikeGIMP === void 0) { + dither.calculateErrorLikeGIMP = false; + } + } + const distCalculator = new ImageQ.distance.Euclidean(); + const quantizer = new ImageQ.palette[method](distCalculator, maxColorIndexes, modifier); + let imageMaker; + if (dither) { + imageMaker = new ImageQ.image.ErrorDiffusionArray( + distCalculator, + ImageQ.image.ErrorDiffusionArrayKernel[dither.ditherAlgorithm], + dither.serpentine, + dither.minimumColorDistanceToDither, + dither.calculateErrorLikeGIMP + ); + } else { + imageMaker = new ImageQ.image.NearestColor(distCalculator); + } + const inputContainers = []; + images.forEach((image2) => { + const imageBuf = image2.bitmap.data; + const inputBuf = new ArrayBuffer(imageBuf.length); + const inputArray = new Uint32Array(inputBuf); + for (let bi2 = 0, ai2 = 0; bi2 < imageBuf.length; bi2 += 4, ++ai2) { + inputArray[ai2] = imageBuf.readUInt32LE(bi2, true); + } + const inputContainer = ImageQ.utils.PointContainer.fromUint32Array( + inputArray, + image2.bitmap.width, + image2.bitmap.height + ); + quantizer.sample(inputContainer); + inputContainers.push(inputContainer); + }); + const limitedPalette = quantizer.quantizeSync(); + for (let i6 = 0; i6 < images.length; ++i6) { + const imageBuf = images[i6].bitmap.data; + const outputContainer = imageMaker.quantizeSync(inputContainers[i6], limitedPalette); + const outputArray = outputContainer.toUint32Array(); + for (let bi2 = 0, ai2 = 0; bi2 < imageBuf.length; bi2 += 4, ++ai2) { + imageBuf.writeUInt32LE(outputArray[ai2], bi2); + } + } + } + function _readBinary(path7) { + return new Promise((resolve3, reject2) => { + fs6.readFile(path7, (err, buffer) => { + if (err) { + return reject2(err); + } + return resolve3(buffer); + }); + }); + } + function _writeBinary(path7, buffer) { + return new Promise((resolve3, reject2) => { + fs6.writeFile(path7, buffer, (err) => { + if (err) { + return reject2(err); + } + return resolve3(); + }); + }); } - this.command = command; - this.properties = properties; - this.message = message; } - toString() { - let cmdStr = CMD_STRING + this.command; - if (this.properties && Object.keys(this.properties).length > 0) { - cmdStr += " "; - let first = true; - for (const key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - const val = this.properties[key]; - if (val) { - if (first) { - first = false; - } else { - cmdStr += ","; +}); + +// ../node_modules/gifwrap/src/gifcodec.js +var require_gifcodec = __commonJS({ + "../node_modules/gifwrap/src/gifcodec.js"(exports2) { + "use strict"; + var Omggif = require_omggif(); + var { Gif, GifError: GifError2 } = require_gif(); + function GifUtil2() { + const data = require_gifutil(); + GifUtil2 = function() { + return data; + }; + return data; + } + var { GifFrame: GifFrame2 } = require_gifframe(); + var PER_GIF_OVERHEAD = 200; + var PER_FRAME_OVERHEAD = 100; + var GifCodec2 = class { + // _transparentRGBA - RGB given to transparent pixels (alpha=0) on decode; defaults to null indicating 0x000000, which is fastest + /** + * GifCodec is a class that both encodes and decodes GIFs. It implements both the `encode()` method expected of an encoder and the `decode()` method expected of a decoder, and it wraps the `omggif` GIF encoder/decoder package. GifCodec serves as this library's default encoder and decoder, but it's possible to wrap other GIF encoders and decoders for use by `gifwrap` as well. GifCodec will not encode GIFs with interlacing. + * + * Instances of this class are stateless and can be shared across multiple encodings and decodings. + * + * Its constructor takes one option argument: + * + * @param {object} options Optionally takes an objection whose only possible property is `transparentRGB`. Images are internally represented in RGBA format, where A is the alpha value of a pixel. When `transparentRGB` is provided, this RGB value (excluding alpha) is assigned to transparent pixels, which are also given alpha value 0x00. (All opaque pixels are given alpha value 0xFF). The RGB color of transparent pixels shouldn't matter for most applications. Defaults to 0x000000. + */ + constructor(options = {}) { + this._transparentRGB = null; + if (typeof options.transparentRGB === "number" && options.transparentRGB !== 0) { + this._transparentRGBA = options.transparentRGB * 256; + } + this._testInitialBufferSize = 0; + } + /** + * Decodes a GIF from a Buffer to yield an instance of Gif. Transparent pixels of the GIF are given alpha values of 0x00, and opaque pixels are given alpha values of 0xFF. The RGB values of transparent pixels default to 0x000000 but can be overridden by the constructor's `transparentRGB` option. + * + * @param {Buffer} buffer Bytes of an encoded GIF to decode. + * @return {Promise} A Promise that resolves to an instance of the Gif class, representing the encoded GIF. + * @throws {GifError} Error upon encountered an encoding-related problem with a GIF, so that the caller can distinguish between software errors and problems with GIFs. + */ + decodeGif(buffer) { + try { + let reader; + try { + reader = new Omggif.GifReader(buffer); + } catch (err) { + throw new GifError2(err); + } + const frameCount = reader.numFrames(); + const frames = []; + const spec = { + width: reader.width, + height: reader.height, + loops: reader.loopCount() + }; + spec.usesTransparency = false; + for (let i6 = 0; i6 < frameCount; ++i6) { + const frameInfo = this._decodeFrame(reader, i6, spec.usesTransparency); + frames.push(frameInfo.frame); + if (frameInfo.usesTransparency) { + spec.usesTransparency = true; } - cmdStr += `${key}=${escapeProperty(val)}`; } + return Promise.resolve(new Gif(buffer, frames, spec)); + } catch (err) { + return Promise.reject(err); + } + } + /** + * Encodes a GIF from provided frames. Each pixel having an alpha value of 0x00 renders as transparent within the encoding, while all pixels of non-zero alpha value render as opaque. + * + * @param {GifFrame[]} frames Array of frames to encode + * @param {object} spec An optional object that may provide values for `loops` and `colorScope`, as defined for the Gif class. However, `colorSpace` may also take the value Gif.GlobalColorsPreferred (== 0) to indicate that the encoder should attempt to create only a global color table. `loop` defaults to 0, looping indefinitely. Set `loop` to null to disable looping, playing only once. `colorScope` defaults to Gif.GlobalColorsPreferred. + * @return {Promise} A Promise that resolves to an instance of the Gif class, representing the encoded GIF. + * @throws {GifError} Error upon encountered an encoding-related problem with a GIF, so that the caller can distinguish between software errors and problems with GIFs. + */ + encodeGif(frames, spec = {}) { + try { + if (frames === null || frames.length === 0) { + throw new GifError2("there are no frames"); + } + const dims = GifUtil2().getMaxDimensions(frames); + spec = Object.assign({}, spec); + spec.width = dims.maxWidth; + spec.height = dims.maxHeight; + if (spec.loops === void 0) { + spec.loops = 0; + } + spec.colorScope = spec.colorScope || Gif.GlobalColorsPreferred; + return Promise.resolve(this._encodeGif(frames, spec)); + } catch (err) { + return Promise.reject(err); + } + } + _decodeFrame(reader, frameIndex, alreadyUsedTransparency) { + let info2, buffer; + try { + info2 = reader.frameInfo(frameIndex); + buffer = new Buffer(reader.width * reader.height * 4); + reader.decodeAndBlitFrameRGBA(frameIndex, buffer); + if (info2.width !== reader.width || info2.height !== reader.height) { + if (info2.y) { + buffer = buffer.slice(info2.y * reader.width * 4); + } + if (reader.width > info2.width) { + for (let ii = 0; ii < info2.height; ++ii) { + buffer.copy( + buffer, + ii * info2.width * 4, + (info2.x + ii * reader.width) * 4, + (info2.x + ii * reader.width) * 4 + info2.width * 4 + ); + } + } + buffer = buffer.slice(0, info2.width * info2.height * 4); + } + } catch (err) { + throw new GifError2(err); + } + let usesTransparency = false; + if (this._transparentRGBA === null) { + if (!alreadyUsedTransparency) { + for (let i6 = 3; i6 < buffer.length; i6 += 4) { + if (buffer[i6] === 0) { + usesTransparency = true; + i6 = buffer.length; + } + } + } + } else { + for (let i6 = 3; i6 < buffer.length; i6 += 4) { + if (buffer[i6] === 0) { + buffer.writeUInt32BE(this._transparentRGBA, i6 - 3); + usesTransparency = true; + } + } + } + const frame = new GifFrame2(info2.width, info2.height, buffer, { + xOffset: info2.x, + yOffset: info2.y, + disposalMethod: info2.disposal, + interlaced: info2.interlaced, + delayCentisecs: info2.delay + }); + return { frame, usesTransparency }; + } + _encodeGif(frames, spec) { + let colorInfo; + if (spec.colorScope === Gif.LocalColorsOnly) { + colorInfo = GifUtil2().getColorInfo(frames, 0); + } else { + colorInfo = GifUtil2().getColorInfo(frames, 256); + if (!colorInfo.colors) { + if (spec.colorScope === Gif.GlobalColorsOnly) { + throw new GifError2( + "Too many color indexes for global color table" + ); + } + spec.colorScope = Gif.LocalColorsOnly; + } + } + spec.usesTransparency = colorInfo.usesTransparency; + const localPalettes = colorInfo.palettes; + if (spec.colorScope === Gif.LocalColorsOnly) { + const localSizeEst = 2e3; + return _encodeLocal(frames, spec, localSizeEst, localPalettes); } + const globalSizeEst = 2e3; + return _encodeGlobal(frames, spec, globalSizeEst, colorInfo); + } + _getSizeEstimateGlobal(globalPalette, frames) { + if (this._testInitialBufferSize > 0) { + return this._testInitialBufferSize; + } + let sizeEst = PER_GIF_OVERHEAD + 3 * 256; + const pixelBitWidth = _getPixelBitWidth(globalPalette); + frames.forEach((frame) => { + sizeEst += _getFrameSizeEst(frame, pixelBitWidth); + }); + return sizeEst; + } + _getSizeEstimateLocal(palettes, frames) { + if (this._testInitialBufferSize > 0) { + return this._testInitialBufferSize; + } + let sizeEst = PER_GIF_OVERHEAD; + for (let i6 = 0; i6 < frames.length; ++i6) { + const palette2 = palettes[i6]; + const pixelBitWidth = _getPixelBitWidth(palette2); + sizeEst += _getFrameSizeEst(frames[i6], pixelBitWidth); + } + return sizeEst; + } + }; + exports2.GifCodec = GifCodec2; + function _colorLookupLinear(colors, color) { + const index = colors.indexOf(color); + return index === -1 ? null : index; + } + function _colorLookupBinary(colors, color) { + var lo = 0, hi = colors.length - 1, mid; + while (lo <= hi) { + mid = Math.floor((lo + hi) / 2); + if (colors[mid] > color) + hi = mid - 1; + else if (colors[mid] < color) + lo = mid + 1; + else + return mid; } + return null; } - cmdStr += `${CMD_STRING}${escapeData(this.message)}`; - return cmdStr; - } -}; -function escapeData(s6) { - return toCommandValue(s6).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A"); -} -function escapeProperty(s6) { - return toCommandValue(s6).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C"); -} - -// ../node_modules/@actions/core/lib/core.js -var os4 = __toESM(require("os"), 1); - -// ../node_modules/@actions/http-client/lib/index.js -var tunnel = __toESM(require_tunnel2(), 1); -var import_undici = __toESM(require_undici(), 1); -var HttpCodes; -(function(HttpCodes2) { - HttpCodes2[HttpCodes2["OK"] = 200] = "OK"; - HttpCodes2[HttpCodes2["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes2[HttpCodes2["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes2[HttpCodes2["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes2[HttpCodes2["SeeOther"] = 303] = "SeeOther"; - HttpCodes2[HttpCodes2["NotModified"] = 304] = "NotModified"; - HttpCodes2[HttpCodes2["UseProxy"] = 305] = "UseProxy"; - HttpCodes2[HttpCodes2["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes2[HttpCodes2["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes2[HttpCodes2["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes2[HttpCodes2["BadRequest"] = 400] = "BadRequest"; - HttpCodes2[HttpCodes2["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes2[HttpCodes2["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes2[HttpCodes2["Forbidden"] = 403] = "Forbidden"; - HttpCodes2[HttpCodes2["NotFound"] = 404] = "NotFound"; - HttpCodes2[HttpCodes2["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes2[HttpCodes2["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes2[HttpCodes2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes2[HttpCodes2["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes2[HttpCodes2["Conflict"] = 409] = "Conflict"; - HttpCodes2[HttpCodes2["Gone"] = 410] = "Gone"; - HttpCodes2[HttpCodes2["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes2[HttpCodes2["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes2[HttpCodes2["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes2[HttpCodes2["BadGateway"] = 502] = "BadGateway"; - HttpCodes2[HttpCodes2["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes2[HttpCodes2["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes || (HttpCodes = {})); -var Headers2; -(function(Headers3) { - Headers3["Accept"] = "accept"; - Headers3["ContentType"] = "content-type"; -})(Headers2 || (Headers2 = {})); -var MediaTypes; -(function(MediaTypes2) { - MediaTypes2["ApplicationJson"] = "application/json"; -})(MediaTypes || (MediaTypes = {})); -var HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -var HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; - -// ../node_modules/@actions/core/lib/summary.js -var import_os = require("os"); -var import_fs = require("fs"); -var __awaiter = function(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { + function _encodeGlobal(frames, spec, bufferSizeEst, globalPalette) { + const extendedGlobalPalette = { + colors: globalPalette.colors.slice(), + usesTransparency: globalPalette.usesTransparency + }; + _extendPaletteToPowerOf2(extendedGlobalPalette); + const options = { + palette: extendedGlobalPalette.colors, + loop: spec.loops + }; + let buffer = new Buffer(bufferSizeEst); + let gifWriter; try { - step(generator.next(value)); - } catch (e6) { - reject(e6); + gifWriter = new Omggif.GifWriter( + buffer, + spec.width, + spec.height, + options + ); + } catch (err) { + throw new GifError2(err); + } + for (let i6 = 0; i6 < frames.length; ++i6) { + buffer = _writeFrame(gifWriter, i6, frames[i6], globalPalette, false); } + return new Gif(buffer.slice(0, gifWriter.end()), frames, spec); } - function rejected(value) { + function _encodeLocal(frames, spec, bufferSizeEst, localPalettes) { + const options = { + loop: spec.loops + }; + let buffer = new Buffer(bufferSizeEst); + let gifWriter; try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); + gifWriter = new Omggif.GifWriter( + buffer, + spec.width, + spec.height, + options + ); + } catch (err) { + throw new GifError2(err); + } + for (let i6 = 0; i6 < frames.length; ++i6) { + buffer = _writeFrame(gifWriter, i6, frames[i6], localPalettes[i6], true); + } + return new Gif(buffer.slice(0, gifWriter.end()), frames, spec); + } + function _extendPaletteToPowerOf2(palette2) { + const colors = palette2.colors; + if (palette2.usesTransparency) { + colors.push(0); + } + const colorCount = colors.length; + let powerOf2 = 2; + while (colorCount > powerOf2) { + powerOf2 <<= 1; + } + colors.length = powerOf2; + colors.fill(0, colorCount); + } + function _getFrameSizeEst(frame, pixelBitWidth) { + let byteLength = frame.bitmap.width * frame.bitmap.height; + byteLength = Math.ceil(byteLength * pixelBitWidth / 8); + byteLength += Math.ceil(byteLength / 255); + return PER_FRAME_OVERHEAD + byteLength + 3 * 256; + } + function _getIndexedImage(frameIndex, frame, palette2) { + const colors = palette2.colors; + const colorToIndexFunc = colors.length <= 8 ? ( + // guess at the break-even + _colorLookupLinear + ) : _colorLookupBinary; + const colorBuffer = frame.bitmap.data; + const indexBuffer = new Buffer(colorBuffer.length / 4); + let transparentIndex = colors.length; + let i6 = 0, j6 = 0; + while (i6 < colorBuffer.length) { + if (colorBuffer[i6 + 3] !== 0) { + const color = colorBuffer.readUInt32BE(i6, true) >> 8 & 16777215; + indexBuffer[j6] = colorToIndexFunc(colors, color); + } else { + indexBuffer[j6] = transparentIndex; + } + i6 += 4; + ++j6; + } + if (palette2.usesTransparency) { + if (transparentIndex === 256) { + throw new GifError2(`Frame ${frameIndex} already has 256 colorsand so can't use transparency`); + } + } else { + transparentIndex = null; } + return { buffer: indexBuffer, transparentIndex }; } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); + function _getPixelBitWidth(palette2) { + let indexCount = palette2.indexCount; + let pixelBitWidth = 0; + --indexCount; + while (indexCount) { + ++pixelBitWidth; + indexCount >>= 1; + } + return pixelBitWidth > 0 ? pixelBitWidth : 1; } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var { access, appendFile, writeFile } = import_fs.promises; -var SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY"; -var Summary = class { - constructor() { - this._buffer = ""; - } - /** - * Finds the summary file path from the environment, rejects if env var is not found or file does not exist - * Also checks r/w permissions. - * - * @returns step summary file path - */ - filePath() { - return __awaiter(this, void 0, void 0, function* () { - if (this._filePath) { - return this._filePath; + function _writeFrame(gifWriter, frameIndex, frame, palette2, isLocalPalette) { + if (frame.interlaced) { + throw new GifError2("writing interlaced GIFs is not supported"); } - const pathFromEnv = process.env[SUMMARY_ENV_VAR]; - if (!pathFromEnv) { - throw new Error(`Unable to find environment variable for $${SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + const frameInfo = _getIndexedImage(frameIndex, frame, palette2); + const options = { + delay: frame.delayCentisecs, + disposal: frame.disposalMethod, + transparent: frameInfo.transparentIndex + }; + if (isLocalPalette) { + _extendPaletteToPowerOf2(palette2); + options.palette = palette2.colors; } try { - yield access(pathFromEnv, import_fs.constants.R_OK | import_fs.constants.W_OK); - } catch (_a2) { - throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + let buffer = gifWriter.getOutputBuffer(); + let startOfFrame = gifWriter.getOutputBufferPosition(); + let endOfFrame; + let tryAgain = true; + while (tryAgain) { + endOfFrame = gifWriter.addFrame( + frame.xOffset, + frame.yOffset, + frame.bitmap.width, + frame.bitmap.height, + frameInfo.buffer, + options + ); + tryAgain = false; + if (endOfFrame >= buffer.length - 1) { + const biggerBuffer = new Buffer(buffer.length * 1.5); + buffer.copy(biggerBuffer); + gifWriter.setOutputBuffer(biggerBuffer); + gifWriter.setOutputBufferPosition(startOfFrame); + buffer = biggerBuffer; + tryAgain = true; + } + } + return buffer; + } catch (err) { + throw new GifError2(err); } - this._filePath = pathFromEnv; - return this._filePath; - }); - } - /** - * Wraps content in an HTML tag, adding any HTML attributes - * - * @param {string} tag HTML tag to wrap - * @param {string | null} content content within the tag - * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add - * - * @returns {string} content wrapped in HTML element - */ - wrap(tag, content, attrs = {}) { - const htmlAttrs = Object.entries(attrs).map(([key, value]) => ` ${key}="${value}"`).join(""); - if (!content) { - return `<${tag}${htmlAttrs}>`; } - return `<${tag}${htmlAttrs}>${content}`; } - /** - * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. - * - * @param {SummaryWriteOptions} [options] (optional) options for write operation - * - * @returns {Promise} summary instance - */ - write(options) { - return __awaiter(this, void 0, void 0, function* () { - const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); - const filePath = yield this.filePath(); - const writeFunc = overwrite ? writeFile : appendFile; - yield writeFunc(filePath, this._buffer, { encoding: "utf8" }); - return this.emptyBuffer(); - }); - } - /** - * Clears the summary buffer and wipes the summary file - * - * @returns {Summary} summary instance - */ - clear() { - return __awaiter(this, void 0, void 0, function* () { - return this.emptyBuffer().write({ overwrite: true }); - }); - } - /** - * Returns the current summary buffer as a string - * - * @returns {string} string of summary buffer - */ - stringify() { - return this._buffer; - } - /** - * If the summary buffer is empty - * - * @returns {boolen} true if the buffer is empty - */ - isEmptyBuffer() { - return this._buffer.length === 0; - } - /** - * Resets the summary buffer without writing to summary file - * - * @returns {Summary} summary instance - */ - emptyBuffer() { - this._buffer = ""; - return this; - } - /** - * Adds raw text to the summary buffer - * - * @param {string} text content to add - * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) - * - * @returns {Summary} summary instance - */ - addRaw(text, addEOL = false) { - this._buffer += text; - return addEOL ? this.addEOL() : this; - } - /** - * Adds the operating system-specific end-of-line marker to the buffer - * - * @returns {Summary} summary instance - */ - addEOL() { - return this.addRaw(import_os.EOL); - } - /** - * Adds an HTML codeblock to the summary buffer - * - * @param {string} code content to render within fenced code block - * @param {string} lang (optional) language to syntax highlight code - * - * @returns {Summary} summary instance - */ - addCodeBlock(code, lang) { - const attrs = Object.assign({}, lang && { lang }); - const element = this.wrap("pre", this.wrap("code", code), attrs); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML list to the summary buffer - * - * @param {string[]} items list of items to render - * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) - * - * @returns {Summary} summary instance - */ - addList(items, ordered = false) { - const tag = ordered ? "ol" : "ul"; - const listItems = items.map((item) => this.wrap("li", item)).join(""); - const element = this.wrap(tag, listItems); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML table to the summary buffer - * - * @param {SummaryTableCell[]} rows table rows - * - * @returns {Summary} summary instance - */ - addTable(rows) { - const tableBody = rows.map((row) => { - const cells = row.map((cell) => { - if (typeof cell === "string") { - return this.wrap("td", cell); - } - const { header, data, colspan, rowspan } = cell; - const tag = header ? "th" : "td"; - const attrs = Object.assign(Object.assign({}, colspan && { colspan }), rowspan && { rowspan }); - return this.wrap(tag, data, attrs); - }).join(""); - return this.wrap("tr", cells); - }).join(""); - const element = this.wrap("table", tableBody); - return this.addRaw(element).addEOL(); - } - /** - * Adds a collapsable HTML details element to the summary buffer - * - * @param {string} label text for the closed state - * @param {string} content collapsable content - * - * @returns {Summary} summary instance - */ - addDetails(label, content) { - const element = this.wrap("details", this.wrap("summary", label) + content); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML image tag to the summary buffer - * - * @param {string} src path to the image you to embed - * @param {string} alt text description of the image - * @param {SummaryImageOptions} options (optional) addition image attributes - * - * @returns {Summary} summary instance - */ - addImage(src, alt, options) { - const { width, height } = options || {}; - const attrs = Object.assign(Object.assign({}, width && { width }), height && { height }); - const element = this.wrap("img", null, Object.assign({ src, alt }, attrs)); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML section heading element - * - * @param {string} text heading text - * @param {number | string} [level=1] (optional) the heading level, default: 1 - * - * @returns {Summary} summary instance - */ - addHeading(text, level) { - const tag = `h${level}`; - const allowedTag = ["h1", "h2", "h3", "h4", "h5", "h6"].includes(tag) ? tag : "h1"; - const element = this.wrap(allowedTag, text); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML thematic break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ - addSeparator() { - const element = this.wrap("hr", null); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML line break (
) to the summary buffer - * - * @returns {Summary} summary instance - */ - addBreak() { - const element = this.wrap("br", null); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML blockquote to the summary buffer - * - * @param {string} text quote text - * @param {string} cite (optional) citation url - * - * @returns {Summary} summary instance - */ - addQuote(text, cite) { - const attrs = Object.assign({}, cite && { cite }); - const element = this.wrap("blockquote", text, attrs); - return this.addRaw(element).addEOL(); - } - /** - * Adds an HTML anchor tag to the summary buffer - * - * @param {string} text link text/content - * @param {string} href hyperlink - * - * @returns {Summary} summary instance - */ - addLink(text, href) { - const element = this.wrap("a", text, { href }); - return this.addRaw(element).addEOL(); - } -}; -var _summary = new Summary(); - -// ../node_modules/@actions/core/lib/platform.js -var import_os2 = __toESM(require("os"), 1); - -// ../node_modules/@actions/exec/lib/toolrunner.js -var os2 = __toESM(require("os"), 1); -var events = __toESM(require("events"), 1); -var child = __toESM(require("child_process"), 1); -var path3 = __toESM(require("path"), 1); - -// ../node_modules/@actions/io/lib/io.js -var path2 = __toESM(require("path"), 1); +}); -// ../node_modules/@actions/io/lib/io-util.js -var fs = __toESM(require("fs"), 1); -var path = __toESM(require("path"), 1); -var __awaiter2 = function(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); +// ../node_modules/gifwrap/src/index.js +var require_src = __commonJS({ + "../node_modules/gifwrap/src/index.js"(exports2, module2) { + "use strict"; + var BitmapImage2 = require_bitmapimage(); + var { Gif, GifError: GifError2 } = require_gif(); + var { GifCodec: GifCodec2 } = require_gifcodec(); + var { GifFrame: GifFrame2 } = require_gifframe(); + var GifUtil2 = require_gifutil(); + module2.exports = { + BitmapImage: BitmapImage2, + Gif, + GifCodec: GifCodec2, + GifFrame: GifFrame2, + GifUtil: GifUtil2, + GifError: GifError2 + }; } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e6) { - reject(e6); +}); + +// ../node_modules/jpeg-js/lib/encoder.js +var require_encoder = __commonJS({ + "../node_modules/jpeg-js/lib/encoder.js"(exports2, module2) { + "use strict"; + var btoa = btoa || function(buf) { + return Buffer.from(buf).toString("base64"); + }; + function JPEGEncoder(quality2) { + var self2 = this; + var fround = Math.round; + var ffloor = Math.floor; + var YTable = new Array(64); + var UVTable = new Array(64); + var fdtbl_Y = new Array(64); + var fdtbl_UV = new Array(64); + var YDC_HT; + var UVDC_HT; + var YAC_HT; + var UVAC_HT; + var bitcode = new Array(65535); + var category = new Array(65535); + var outputfDCTQuant = new Array(64); + var DU = new Array(64); + var byteout = []; + var bytenew = 0; + var bytepos = 7; + var YDU = new Array(64); + var UDU = new Array(64); + var VDU = new Array(64); + var clt = new Array(256); + var RGB_YUV_TABLE = new Array(2048); + var currentQuality; + var ZigZag = [ + 0, + 1, + 5, + 6, + 14, + 15, + 27, + 28, + 2, + 4, + 7, + 13, + 16, + 26, + 29, + 42, + 3, + 8, + 12, + 17, + 25, + 30, + 41, + 43, + 9, + 11, + 18, + 24, + 31, + 40, + 44, + 53, + 10, + 19, + 23, + 32, + 39, + 45, + 52, + 54, + 20, + 22, + 33, + 38, + 46, + 51, + 55, + 60, + 21, + 34, + 37, + 47, + 50, + 56, + 59, + 61, + 35, + 36, + 48, + 49, + 57, + 58, + 62, + 63 + ]; + var std_dc_luminance_nrcodes = [0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]; + var std_dc_luminance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + var std_ac_luminance_nrcodes = [0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125]; + var std_ac_luminance_values = [ + 1, + 2, + 3, + 0, + 4, + 17, + 5, + 18, + 33, + 49, + 65, + 6, + 19, + 81, + 97, + 7, + 34, + 113, + 20, + 50, + 129, + 145, + 161, + 8, + 35, + 66, + 177, + 193, + 21, + 82, + 209, + 240, + 36, + 51, + 98, + 114, + 130, + 9, + 10, + 22, + 23, + 24, + 25, + 26, + 37, + 38, + 39, + 40, + 41, + 42, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250 + ]; + var std_dc_chrominance_nrcodes = [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]; + var std_dc_chrominance_values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + var std_ac_chrominance_nrcodes = [0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119]; + var std_ac_chrominance_values = [ + 0, + 1, + 2, + 3, + 17, + 4, + 5, + 33, + 49, + 6, + 18, + 65, + 81, + 7, + 97, + 113, + 19, + 34, + 50, + 129, + 8, + 20, + 66, + 145, + 161, + 177, + 193, + 9, + 35, + 51, + 82, + 240, + 21, + 98, + 114, + 209, + 10, + 22, + 36, + 52, + 225, + 37, + 241, + 23, + 24, + 25, + 26, + 38, + 39, + 40, + 41, + 42, + 53, + 54, + 55, + 56, + 57, + 58, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250 + ]; + function initQuantTables(sf) { + var YQT = [ + 16, + 11, + 10, + 16, + 24, + 40, + 51, + 61, + 12, + 12, + 14, + 19, + 26, + 58, + 60, + 55, + 14, + 13, + 16, + 24, + 40, + 57, + 69, + 56, + 14, + 17, + 22, + 29, + 51, + 87, + 80, + 62, + 18, + 22, + 37, + 56, + 68, + 109, + 103, + 77, + 24, + 35, + 55, + 64, + 81, + 104, + 113, + 92, + 49, + 64, + 78, + 87, + 103, + 121, + 120, + 101, + 72, + 92, + 95, + 98, + 112, + 100, + 103, + 99 + ]; + for (var i6 = 0; i6 < 64; i6++) { + var t12 = ffloor((YQT[i6] * sf + 50) / 100); + if (t12 < 1) { + t12 = 1; + } else if (t12 > 255) { + t12 = 255; + } + YTable[ZigZag[i6]] = t12; + } + var UVQT = [ + 17, + 18, + 24, + 47, + 99, + 99, + 99, + 99, + 18, + 21, + 26, + 66, + 99, + 99, + 99, + 99, + 24, + 26, + 56, + 99, + 99, + 99, + 99, + 99, + 47, + 66, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99, + 99 + ]; + for (var j6 = 0; j6 < 64; j6++) { + var u6 = ffloor((UVQT[j6] * sf + 50) / 100); + if (u6 < 1) { + u6 = 1; + } else if (u6 > 255) { + u6 = 255; + } + UVTable[ZigZag[j6]] = u6; + } + var aasf = [ + 1, + 1.387039845, + 1.306562965, + 1.175875602, + 1, + 0.785694958, + 0.5411961, + 0.275899379 + ]; + var k6 = 0; + for (var row = 0; row < 8; row++) { + for (var col = 0; col < 8; col++) { + fdtbl_Y[k6] = 1 / (YTable[ZigZag[k6]] * aasf[row] * aasf[col] * 8); + fdtbl_UV[k6] = 1 / (UVTable[ZigZag[k6]] * aasf[row] * aasf[col] * 8); + k6++; + } + } + } + function computeHuffmanTbl(nrcodes, std_table) { + var codevalue = 0; + var pos_in_table = 0; + var HT = new Array(); + for (var k6 = 1; k6 <= 16; k6++) { + for (var j6 = 1; j6 <= nrcodes[k6]; j6++) { + HT[std_table[pos_in_table]] = []; + HT[std_table[pos_in_table]][0] = codevalue; + HT[std_table[pos_in_table]][1] = k6; + pos_in_table++; + codevalue++; + } + codevalue *= 2; + } + return HT; + } + function initHuffmanTbl() { + YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes, std_dc_luminance_values); + UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes, std_dc_chrominance_values); + YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes, std_ac_luminance_values); + UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes, std_ac_chrominance_values); + } + function initCategoryNumber() { + var nrlower = 1; + var nrupper = 2; + for (var cat = 1; cat <= 15; cat++) { + for (var nr = nrlower; nr < nrupper; nr++) { + category[32767 + nr] = cat; + bitcode[32767 + nr] = []; + bitcode[32767 + nr][1] = cat; + bitcode[32767 + nr][0] = nr; + } + for (var nrneg = -(nrupper - 1); nrneg <= -nrlower; nrneg++) { + category[32767 + nrneg] = cat; + bitcode[32767 + nrneg] = []; + bitcode[32767 + nrneg][1] = cat; + bitcode[32767 + nrneg][0] = nrupper - 1 + nrneg; + } + nrlower <<= 1; + nrupper <<= 1; + } + } + function initRGBYUVTable() { + for (var i6 = 0; i6 < 256; i6++) { + RGB_YUV_TABLE[i6] = 19595 * i6; + RGB_YUV_TABLE[i6 + 256 >> 0] = 38470 * i6; + RGB_YUV_TABLE[i6 + 512 >> 0] = 7471 * i6 + 32768; + RGB_YUV_TABLE[i6 + 768 >> 0] = -11059 * i6; + RGB_YUV_TABLE[i6 + 1024 >> 0] = -21709 * i6; + RGB_YUV_TABLE[i6 + 1280 >> 0] = 32768 * i6 + 8421375; + RGB_YUV_TABLE[i6 + 1536 >> 0] = -27439 * i6; + RGB_YUV_TABLE[i6 + 1792 >> 0] = -5329 * i6; + } + } + function writeBits(bs2) { + var value = bs2[0]; + var posval = bs2[1] - 1; + while (posval >= 0) { + if (value & 1 << posval) { + bytenew |= 1 << bytepos; + } + posval--; + bytepos--; + if (bytepos < 0) { + if (bytenew == 255) { + writeByte(255); + writeByte(0); + } else { + writeByte(bytenew); + } + bytepos = 7; + bytenew = 0; + } + } } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); + function writeByte(value) { + byteout.push(value); } - } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var { chmod, copyFile, lstat, mkdir, open, readdir, rename, rm, rmdir, stat, symlink, unlink } = fs.promises; -var IS_WINDOWS = process.platform === "win32"; -var READONLY = fs.constants.O_RDONLY; -function exists(fsPath) { - return __awaiter2(this, void 0, void 0, function* () { - try { - yield stat(fsPath); - } catch (err) { - if (err.code === "ENOENT") { - return false; + function writeWord(value) { + writeByte(value >> 8 & 255); + writeByte(value & 255); } - throw err; - } - return true; - }); -} -function isRooted(p6) { - p6 = normalizeSeparators(p6); - if (!p6) { - throw new Error('isRooted() parameter "p" cannot be empty'); - } - if (IS_WINDOWS) { - return p6.startsWith("\\") || /^[A-Z]:/i.test(p6); - } - return p6.startsWith("/"); -} -function tryGetExecutablePath(filePath, extensions) { - return __awaiter2(this, void 0, void 0, function* () { - let stats = void 0; - try { - stats = yield stat(filePath); - } catch (err) { - if (err.code !== "ENOENT") { - console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); + function fDCTQuant(data, fdtbl) { + var d0, d1, d22, d32, d42, d52, d6, d7; + var dataOff = 0; + var i6; + var I8 = 8; + var I64 = 64; + for (i6 = 0; i6 < I8; ++i6) { + d0 = data[dataOff]; + d1 = data[dataOff + 1]; + d22 = data[dataOff + 2]; + d32 = data[dataOff + 3]; + d42 = data[dataOff + 4]; + d52 = data[dataOff + 5]; + d6 = data[dataOff + 6]; + d7 = data[dataOff + 7]; + var tmp0 = d0 + d7; + var tmp7 = d0 - d7; + var tmp1 = d1 + d6; + var tmp6 = d1 - d6; + var tmp2 = d22 + d52; + var tmp5 = d22 - d52; + var tmp3 = d32 + d42; + var tmp4 = d32 - d42; + var tmp10 = tmp0 + tmp3; + var tmp13 = tmp0 - tmp3; + var tmp11 = tmp1 + tmp2; + var tmp12 = tmp1 - tmp2; + data[dataOff] = tmp10 + tmp11; + data[dataOff + 4] = tmp10 - tmp11; + var z1 = (tmp12 + tmp13) * 0.707106781; + data[dataOff + 2] = tmp13 + z1; + data[dataOff + 6] = tmp13 - z1; + tmp10 = tmp4 + tmp5; + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + var z5 = (tmp10 - tmp12) * 0.382683433; + var z22 = 0.5411961 * tmp10 + z5; + var z4 = 1.306562965 * tmp12 + z5; + var z3 = tmp11 * 0.707106781; + var z11 = tmp7 + z3; + var z13 = tmp7 - z3; + data[dataOff + 5] = z13 + z22; + data[dataOff + 3] = z13 - z22; + data[dataOff + 1] = z11 + z4; + data[dataOff + 7] = z11 - z4; + dataOff += 8; + } + dataOff = 0; + for (i6 = 0; i6 < I8; ++i6) { + d0 = data[dataOff]; + d1 = data[dataOff + 8]; + d22 = data[dataOff + 16]; + d32 = data[dataOff + 24]; + d42 = data[dataOff + 32]; + d52 = data[dataOff + 40]; + d6 = data[dataOff + 48]; + d7 = data[dataOff + 56]; + var tmp0p2 = d0 + d7; + var tmp7p2 = d0 - d7; + var tmp1p2 = d1 + d6; + var tmp6p2 = d1 - d6; + var tmp2p2 = d22 + d52; + var tmp5p2 = d22 - d52; + var tmp3p2 = d32 + d42; + var tmp4p2 = d32 - d42; + var tmp10p2 = tmp0p2 + tmp3p2; + var tmp13p2 = tmp0p2 - tmp3p2; + var tmp11p2 = tmp1p2 + tmp2p2; + var tmp12p2 = tmp1p2 - tmp2p2; + data[dataOff] = tmp10p2 + tmp11p2; + data[dataOff + 32] = tmp10p2 - tmp11p2; + var z1p2 = (tmp12p2 + tmp13p2) * 0.707106781; + data[dataOff + 16] = tmp13p2 + z1p2; + data[dataOff + 48] = tmp13p2 - z1p2; + tmp10p2 = tmp4p2 + tmp5p2; + tmp11p2 = tmp5p2 + tmp6p2; + tmp12p2 = tmp6p2 + tmp7p2; + var z5p2 = (tmp10p2 - tmp12p2) * 0.382683433; + var z2p2 = 0.5411961 * tmp10p2 + z5p2; + var z4p2 = 1.306562965 * tmp12p2 + z5p2; + var z3p2 = tmp11p2 * 0.707106781; + var z11p2 = tmp7p2 + z3p2; + var z13p2 = tmp7p2 - z3p2; + data[dataOff + 40] = z13p2 + z2p2; + data[dataOff + 24] = z13p2 - z2p2; + data[dataOff + 8] = z11p2 + z4p2; + data[dataOff + 56] = z11p2 - z4p2; + dataOff++; + } + var fDCTQuant2; + for (i6 = 0; i6 < I64; ++i6) { + fDCTQuant2 = data[i6] * fdtbl[i6]; + outputfDCTQuant[i6] = fDCTQuant2 > 0 ? fDCTQuant2 + 0.5 | 0 : fDCTQuant2 - 0.5 | 0; + } + return outputfDCTQuant; + } + function writeAPP0() { + writeWord(65504); + writeWord(16); + writeByte(74); + writeByte(70); + writeByte(73); + writeByte(70); + writeByte(0); + writeByte(1); + writeByte(1); + writeByte(0); + writeWord(1); + writeWord(1); + writeByte(0); + writeByte(0); + } + function writeAPP1(exifBuffer) { + if (!exifBuffer) return; + writeWord(65505); + if (exifBuffer[0] === 69 && exifBuffer[1] === 120 && exifBuffer[2] === 105 && exifBuffer[3] === 102) { + writeWord(exifBuffer.length + 2); + } else { + writeWord(exifBuffer.length + 5 + 2); + writeByte(69); + writeByte(120); + writeByte(105); + writeByte(102); + writeByte(0); + } + for (var i6 = 0; i6 < exifBuffer.length; i6++) { + writeByte(exifBuffer[i6]); + } + } + function writeSOF0(width, height) { + writeWord(65472); + writeWord(17); + writeByte(8); + writeWord(height); + writeWord(width); + writeByte(3); + writeByte(1); + writeByte(17); + writeByte(0); + writeByte(2); + writeByte(17); + writeByte(1); + writeByte(3); + writeByte(17); + writeByte(1); + } + function writeDQT() { + writeWord(65499); + writeWord(132); + writeByte(0); + for (var i6 = 0; i6 < 64; i6++) { + writeByte(YTable[i6]); + } + writeByte(1); + for (var j6 = 0; j6 < 64; j6++) { + writeByte(UVTable[j6]); + } + } + function writeDHT() { + writeWord(65476); + writeWord(418); + writeByte(0); + for (var i6 = 0; i6 < 16; i6++) { + writeByte(std_dc_luminance_nrcodes[i6 + 1]); + } + for (var j6 = 0; j6 <= 11; j6++) { + writeByte(std_dc_luminance_values[j6]); + } + writeByte(16); + for (var k6 = 0; k6 < 16; k6++) { + writeByte(std_ac_luminance_nrcodes[k6 + 1]); + } + for (var l6 = 0; l6 <= 161; l6++) { + writeByte(std_ac_luminance_values[l6]); + } + writeByte(1); + for (var m6 = 0; m6 < 16; m6++) { + writeByte(std_dc_chrominance_nrcodes[m6 + 1]); + } + for (var n6 = 0; n6 <= 11; n6++) { + writeByte(std_dc_chrominance_values[n6]); + } + writeByte(17); + for (var o6 = 0; o6 < 16; o6++) { + writeByte(std_ac_chrominance_nrcodes[o6 + 1]); + } + for (var p6 = 0; p6 <= 161; p6++) { + writeByte(std_ac_chrominance_values[p6]); + } + } + function writeCOM(comments) { + if (typeof comments === "undefined" || comments.constructor !== Array) return; + comments.forEach((e6) => { + if (typeof e6 !== "string") return; + writeWord(65534); + var l6 = e6.length; + writeWord(l6 + 2); + var i6; + for (i6 = 0; i6 < l6; i6++) + writeByte(e6.charCodeAt(i6)); + }); } - } - if (stats && stats.isFile()) { - if (IS_WINDOWS) { - const upperExt = path.extname(filePath).toUpperCase(); - if (extensions.some((validExt) => validExt.toUpperCase() === upperExt)) { - return filePath; + function writeSOS() { + writeWord(65498); + writeWord(12); + writeByte(3); + writeByte(1); + writeByte(0); + writeByte(2); + writeByte(17); + writeByte(3); + writeByte(17); + writeByte(0); + writeByte(63); + writeByte(0); + } + function processDU(CDU, fdtbl, DC, HTDC, HTAC) { + var EOB = HTAC[0]; + var M16zeroes = HTAC[240]; + var pos; + var I16 = 16; + var I63 = 63; + var I64 = 64; + var DU_DCT = fDCTQuant(CDU, fdtbl); + for (var j6 = 0; j6 < I64; ++j6) { + DU[ZigZag[j6]] = DU_DCT[j6]; + } + var Diff = DU[0] - DC; + DC = DU[0]; + if (Diff == 0) { + writeBits(HTDC[0]); + } else { + pos = 32767 + Diff; + writeBits(HTDC[category[pos]]); + writeBits(bitcode[pos]); } - } else { - if (isUnixExecutable(stats)) { - return filePath; + var end0pos = 63; + for (; end0pos > 0 && DU[end0pos] == 0; end0pos--) { } - } + ; + if (end0pos == 0) { + writeBits(EOB); + return DC; + } + var i6 = 1; + var lng; + while (i6 <= end0pos) { + var startpos = i6; + for (; DU[i6] == 0 && i6 <= end0pos; ++i6) { + } + var nrzeroes = i6 - startpos; + if (nrzeroes >= I16) { + lng = nrzeroes >> 4; + for (var nrmarker = 1; nrmarker <= lng; ++nrmarker) + writeBits(M16zeroes); + nrzeroes = nrzeroes & 15; + } + pos = 32767 + DU[i6]; + writeBits(HTAC[(nrzeroes << 4) + category[pos]]); + writeBits(bitcode[pos]); + i6++; + } + if (end0pos != I63) { + writeBits(EOB); + } + return DC; + } + function initCharLookupTable() { + var sfcc = String.fromCharCode; + for (var i6 = 0; i6 < 256; i6++) { + clt[i6] = sfcc(i6); + } + } + this.encode = function(image2, quality3) { + var time_start = (/* @__PURE__ */ new Date()).getTime(); + if (quality3) setQuality(quality3); + byteout = new Array(); + bytenew = 0; + bytepos = 7; + writeWord(65496); + writeAPP0(); + writeCOM(image2.comments); + writeAPP1(image2.exifBuffer); + writeDQT(); + writeSOF0(image2.width, image2.height); + writeDHT(); + writeSOS(); + var DCY = 0; + var DCU = 0; + var DCV = 0; + bytenew = 0; + bytepos = 7; + this.encode.displayName = "_encode_"; + var imageData = image2.data; + var width = image2.width; + var height = image2.height; + var quadWidth = width * 4; + var tripleWidth = width * 3; + var x7, y4 = 0; + var r6, g6, b6; + var start, p6, col, row, pos; + while (y4 < height) { + x7 = 0; + while (x7 < quadWidth) { + start = quadWidth * y4 + x7; + p6 = start; + col = -1; + row = 0; + for (pos = 0; pos < 64; pos++) { + row = pos >> 3; + col = (pos & 7) * 4; + p6 = start + row * quadWidth + col; + if (y4 + row >= height) { + p6 -= quadWidth * (y4 + 1 + row - height); + } + if (x7 + col >= quadWidth) { + p6 -= x7 + col - quadWidth + 4; + } + r6 = imageData[p6++]; + g6 = imageData[p6++]; + b6 = imageData[p6++]; + YDU[pos] = (RGB_YUV_TABLE[r6] + RGB_YUV_TABLE[g6 + 256 >> 0] + RGB_YUV_TABLE[b6 + 512 >> 0] >> 16) - 128; + UDU[pos] = (RGB_YUV_TABLE[r6 + 768 >> 0] + RGB_YUV_TABLE[g6 + 1024 >> 0] + RGB_YUV_TABLE[b6 + 1280 >> 0] >> 16) - 128; + VDU[pos] = (RGB_YUV_TABLE[r6 + 1280 >> 0] + RGB_YUV_TABLE[g6 + 1536 >> 0] + RGB_YUV_TABLE[b6 + 1792 >> 0] >> 16) - 128; + } + DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + x7 += 32; + } + y4 += 8; + } + if (bytepos >= 0) { + var fillbits = []; + fillbits[1] = bytepos + 1; + fillbits[0] = (1 << bytepos + 1) - 1; + writeBits(fillbits); + } + writeWord(65497); + if (typeof module2 === "undefined") return new Uint8Array(byteout); + return Buffer.from(byteout); + var jpegDataUri = "data:image/jpeg;base64," + btoa(byteout.join("")); + byteout = []; + var duration = (/* @__PURE__ */ new Date()).getTime() - time_start; + return jpegDataUri; + }; + function setQuality(quality3) { + if (quality3 <= 0) { + quality3 = 1; + } + if (quality3 > 100) { + quality3 = 100; + } + if (currentQuality == quality3) return; + var sf = 0; + if (quality3 < 50) { + sf = Math.floor(5e3 / quality3); + } else { + sf = Math.floor(200 - quality3 * 2); + } + initQuantTables(sf); + currentQuality = quality3; + } + function init() { + var time_start = (/* @__PURE__ */ new Date()).getTime(); + if (!quality2) quality2 = 50; + initCharLookupTable(); + initHuffmanTbl(); + initCategoryNumber(); + initRGBYUVTable(); + setQuality(quality2); + var duration = (/* @__PURE__ */ new Date()).getTime() - time_start; + } + init(); + } + if (typeof module2 !== "undefined") { + module2.exports = encode3; + } else if (typeof window !== "undefined") { + window["jpeg-js"] = window["jpeg-js"] || {}; + window["jpeg-js"].encode = encode3; + } + function encode3(imgData, qu) { + if (typeof qu === "undefined") qu = 50; + var encoder = new JPEGEncoder(qu); + var data = encoder.encode(imgData, qu); + return { + data, + width: imgData.width, + height: imgData.height + }; } - const originalFilePath = filePath; - for (const extension of extensions) { - filePath = originalFilePath + extension; - stats = void 0; - try { - stats = yield stat(filePath); - } catch (err) { - if (err.code !== "ENOENT") { - console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); + } +}); + +// ../node_modules/jpeg-js/lib/decoder.js +var require_decoder = __commonJS({ + "../node_modules/jpeg-js/lib/decoder.js"(exports2, module2) { + "use strict"; + var JpegImage = (function jpegImage() { + "use strict"; + var dctZigZag = new Int32Array([ + 0, + 1, + 8, + 16, + 9, + 2, + 3, + 10, + 17, + 24, + 32, + 25, + 18, + 11, + 4, + 5, + 12, + 19, + 26, + 33, + 40, + 48, + 41, + 34, + 27, + 20, + 13, + 6, + 7, + 14, + 21, + 28, + 35, + 42, + 49, + 56, + 57, + 50, + 43, + 36, + 29, + 22, + 15, + 23, + 30, + 37, + 44, + 51, + 58, + 59, + 52, + 45, + 38, + 31, + 39, + 46, + 53, + 60, + 61, + 54, + 47, + 55, + 62, + 63 + ]); + var dctCos1 = 4017; + var dctSin1 = 799; + var dctCos3 = 3406; + var dctSin3 = 2276; + var dctCos6 = 1567; + var dctSin6 = 3784; + var dctSqrt2 = 5793; + var dctSqrt1d2 = 2896; + function constructor() { + } + function buildHuffmanTable(codeLengths, values) { + var k6 = 0, code = [], i6, j6, length = 16; + while (length > 0 && !codeLengths[length - 1]) + length--; + code.push({ children: [], index: 0 }); + var p6 = code[0], q6; + for (i6 = 0; i6 < length; i6++) { + for (j6 = 0; j6 < codeLengths[i6]; j6++) { + p6 = code.pop(); + p6.children[p6.index] = values[k6]; + while (p6.index > 0) { + if (code.length === 0) + throw new Error("Could not recreate Huffman Table"); + p6 = code.pop(); + } + p6.index++; + code.push(p6); + while (code.length <= i6) { + code.push(q6 = { children: [], index: 0 }); + p6.children[p6.index] = q6.children; + p6 = q6; + } + k6++; + } + if (i6 + 1 < length) { + code.push(q6 = { children: [], index: 0 }); + p6.children[p6.index] = q6.children; + p6 = q6; + } + } + return code[0].children; + } + function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive, opts) { + var precision = frame.precision; + var samplesPerLine = frame.samplesPerLine; + var scanLines = frame.scanLines; + var mcusPerLine = frame.mcusPerLine; + var progressive = frame.progressive; + var maxH = frame.maxH, maxV = frame.maxV; + var startOffset = offset, bitsData = 0, bitsCount = 0; + function readBit() { + if (bitsCount > 0) { + bitsCount--; + return bitsData >> bitsCount & 1; + } + bitsData = data[offset++]; + if (bitsData == 255) { + var nextByte = data[offset++]; + if (nextByte) { + throw new Error("unexpected marker: " + (bitsData << 8 | nextByte).toString(16)); + } + } + bitsCount = 7; + return bitsData >>> 7; } - } - if (stats && stats.isFile()) { - if (IS_WINDOWS) { - try { - const directory = path.dirname(filePath); - const upperName = path.basename(filePath).toUpperCase(); - for (const actualName of yield readdir(directory)) { - if (upperName === actualName.toUpperCase()) { - filePath = path.join(directory, actualName); + function decodeHuffman(tree) { + var node = tree, bit; + while ((bit = readBit()) !== null) { + node = node[bit]; + if (typeof node === "number") + return node; + if (typeof node !== "object") + throw new Error("invalid huffman sequence"); + } + return null; + } + function receive(length) { + var n7 = 0; + while (length > 0) { + var bit = readBit(); + if (bit === null) return; + n7 = n7 << 1 | bit; + length--; + } + return n7; + } + function receiveAndExtend(length) { + var n7 = receive(length); + if (n7 >= 1 << length - 1) + return n7; + return n7 + (-1 << length) + 1; + } + function decodeBaseline(component2, zz) { + var t12 = decodeHuffman(component2.huffmanTableDC); + var diff2 = t12 === 0 ? 0 : receiveAndExtend(t12); + zz[0] = component2.pred += diff2; + var k7 = 1; + while (k7 < 64) { + var rs = decodeHuffman(component2.huffmanTableAC); + var s6 = rs & 15, r6 = rs >> 4; + if (s6 === 0) { + if (r6 < 15) + break; + k7 += 16; + continue; + } + k7 += r6; + var z3 = dctZigZag[k7]; + zz[z3] = receiveAndExtend(s6); + k7++; + } + } + function decodeDCFirst(component2, zz) { + var t12 = decodeHuffman(component2.huffmanTableDC); + var diff2 = t12 === 0 ? 0 : receiveAndExtend(t12) << successive; + zz[0] = component2.pred += diff2; + } + function decodeDCSuccessive(component2, zz) { + zz[0] |= readBit() << successive; + } + var eobrun = 0; + function decodeACFirst(component2, zz) { + if (eobrun > 0) { + eobrun--; + return; + } + var k7 = spectralStart, e6 = spectralEnd; + while (k7 <= e6) { + var rs = decodeHuffman(component2.huffmanTableAC); + var s6 = rs & 15, r6 = rs >> 4; + if (s6 === 0) { + if (r6 < 15) { + eobrun = receive(r6) + (1 << r6) - 1; break; } + k7 += 16; + continue; } - } catch (err) { - console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); + k7 += r6; + var z3 = dctZigZag[k7]; + zz[z3] = receiveAndExtend(s6) * (1 << successive); + k7++; + } + } + var successiveACState = 0, successiveACNextValue; + function decodeACSuccessive(component2, zz) { + var k7 = spectralStart, e6 = spectralEnd, r6 = 0; + while (k7 <= e6) { + var z3 = dctZigZag[k7]; + var direction = zz[z3] < 0 ? -1 : 1; + switch (successiveACState) { + case 0: + var rs = decodeHuffman(component2.huffmanTableAC); + var s6 = rs & 15, r6 = rs >> 4; + if (s6 === 0) { + if (r6 < 15) { + eobrun = receive(r6) + (1 << r6); + successiveACState = 4; + } else { + r6 = 16; + successiveACState = 1; + } + } else { + if (s6 !== 1) + throw new Error("invalid ACn encoding"); + successiveACNextValue = receiveAndExtend(s6); + successiveACState = r6 ? 2 : 3; + } + continue; + case 1: + // skipping r zero items + case 2: + if (zz[z3]) + zz[z3] += (readBit() << successive) * direction; + else { + r6--; + if (r6 === 0) + successiveACState = successiveACState == 2 ? 3 : 0; + } + break; + case 3: + if (zz[z3]) + zz[z3] += (readBit() << successive) * direction; + else { + zz[z3] = successiveACNextValue << successive; + successiveACState = 0; + } + break; + case 4: + if (zz[z3]) + zz[z3] += (readBit() << successive) * direction; + break; + } + k7++; } - return filePath; - } else { - if (isUnixExecutable(stats)) { - return filePath; + if (successiveACState === 4) { + eobrun--; + if (eobrun === 0) + successiveACState = 0; } } - } - } - return ""; - }); -} -function normalizeSeparators(p6) { - p6 = p6 || ""; - if (IS_WINDOWS) { - p6 = p6.replace(/\//g, "\\"); - return p6.replace(/\\\\+/g, "\\"); - } - return p6.replace(/\/\/+/g, "/"); -} -function isUnixExecutable(stats) { - return (stats.mode & 1) > 0 || (stats.mode & 8) > 0 && process.getgid !== void 0 && stats.gid === process.getgid() || (stats.mode & 64) > 0 && process.getuid !== void 0 && stats.uid === process.getuid(); -} - -// ../node_modules/@actions/io/lib/io.js -var __awaiter3 = function(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e6) { - reject(e6); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); - } - } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -function which(tool, check) { - return __awaiter3(this, void 0, void 0, function* () { - if (!tool) { - throw new Error("parameter 'tool' is required"); - } - if (check) { - const result = yield which(tool, false); - if (!result) { - if (IS_WINDOWS) { - throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); + function decodeMcu(component2, decode4, mcu2, row, col) { + var mcuRow = mcu2 / mcusPerLine | 0; + var mcuCol = mcu2 % mcusPerLine; + var blockRow = mcuRow * component2.v + row; + var blockCol = mcuCol * component2.h + col; + if (component2.blocks[blockRow] === void 0 && opts.tolerantDecoding) + return; + decode4(component2, component2.blocks[blockRow][blockCol]); + } + function decodeBlock(component2, decode4, mcu2) { + var blockRow = mcu2 / component2.blocksPerLine | 0; + var blockCol = mcu2 % component2.blocksPerLine; + if (component2.blocks[blockRow] === void 0 && opts.tolerantDecoding) + return; + decode4(component2, component2.blocks[blockRow][blockCol]); + } + var componentsLength = components.length; + var component, i6, j6, k6, n6; + var decodeFn; + if (progressive) { + if (spectralStart === 0) + decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive; + else + decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive; } else { - throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); + decodeFn = decodeBaseline; } - } - return result; - } - const matches = yield findInPath(tool); - if (matches && matches.length > 0) { - return matches[0]; - } - return ""; - }); -} -function findInPath(tool) { - return __awaiter3(this, void 0, void 0, function* () { - if (!tool) { - throw new Error("parameter 'tool' is required"); - } - const extensions = []; - if (IS_WINDOWS && process.env["PATHEXT"]) { - for (const extension of process.env["PATHEXT"].split(path2.delimiter)) { - if (extension) { - extensions.push(extension); + var mcu = 0, marker; + var mcuExpected; + if (componentsLength == 1) { + mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn; + } else { + mcuExpected = mcusPerLine * frame.mcusPerColumn; + } + if (!resetInterval) resetInterval = mcuExpected; + var h6, v7; + while (mcu < mcuExpected) { + for (i6 = 0; i6 < componentsLength; i6++) + components[i6].pred = 0; + eobrun = 0; + if (componentsLength == 1) { + component = components[0]; + for (n6 = 0; n6 < resetInterval; n6++) { + decodeBlock(component, decodeFn, mcu); + mcu++; + } + } else { + for (n6 = 0; n6 < resetInterval; n6++) { + for (i6 = 0; i6 < componentsLength; i6++) { + component = components[i6]; + h6 = component.h; + v7 = component.v; + for (j6 = 0; j6 < v7; j6++) { + for (k6 = 0; k6 < h6; k6++) { + decodeMcu(component, decodeFn, mcu, j6, k6); + } + } + } + mcu++; + if (mcu === mcuExpected) break; + } + } + if (mcu === mcuExpected) { + do { + if (data[offset] === 255) { + if (data[offset + 1] !== 0) { + break; + } + } + offset += 1; + } while (offset < data.length - 2); + } + bitsCount = 0; + marker = data[offset] << 8 | data[offset + 1]; + if (marker < 65280) { + throw new Error("marker was not found"); + } + if (marker >= 65488 && marker <= 65495) { + offset += 2; + } else + break; } - } - } - if (isRooted(tool)) { - const filePath = yield tryGetExecutablePath(tool, extensions); - if (filePath) { - return [filePath]; - } - return []; - } - if (tool.includes(path2.sep)) { - return []; - } - const directories = []; - if (process.env.PATH) { - for (const p6 of process.env.PATH.split(path2.delimiter)) { - if (p6) { - directories.push(p6); + return offset - startOffset; + } + function buildComponentData(frame, component) { + var lines = []; + var blocksPerLine = component.blocksPerLine; + var blocksPerColumn = component.blocksPerColumn; + var samplesPerLine = blocksPerLine << 3; + var R2 = new Int32Array(64), r6 = new Uint8Array(64); + function quantizeAndInverse(zz, dataOut, dataIn) { + var qt = component.quantizationTable; + var v0, v1, v22, v32, v42, v52, v62, v7, t12; + var p6 = dataIn; + var i7; + for (i7 = 0; i7 < 64; i7++) + p6[i7] = zz[i7] * qt[i7]; + for (i7 = 0; i7 < 8; ++i7) { + var row = 8 * i7; + if (p6[1 + row] == 0 && p6[2 + row] == 0 && p6[3 + row] == 0 && p6[4 + row] == 0 && p6[5 + row] == 0 && p6[6 + row] == 0 && p6[7 + row] == 0) { + t12 = dctSqrt2 * p6[0 + row] + 512 >> 10; + p6[0 + row] = t12; + p6[1 + row] = t12; + p6[2 + row] = t12; + p6[3 + row] = t12; + p6[4 + row] = t12; + p6[5 + row] = t12; + p6[6 + row] = t12; + p6[7 + row] = t12; + continue; + } + v0 = dctSqrt2 * p6[0 + row] + 128 >> 8; + v1 = dctSqrt2 * p6[4 + row] + 128 >> 8; + v22 = p6[2 + row]; + v32 = p6[6 + row]; + v42 = dctSqrt1d2 * (p6[1 + row] - p6[7 + row]) + 128 >> 8; + v7 = dctSqrt1d2 * (p6[1 + row] + p6[7 + row]) + 128 >> 8; + v52 = p6[3 + row] << 4; + v62 = p6[5 + row] << 4; + t12 = v0 - v1 + 1 >> 1; + v0 = v0 + v1 + 1 >> 1; + v1 = t12; + t12 = v22 * dctSin6 + v32 * dctCos6 + 128 >> 8; + v22 = v22 * dctCos6 - v32 * dctSin6 + 128 >> 8; + v32 = t12; + t12 = v42 - v62 + 1 >> 1; + v42 = v42 + v62 + 1 >> 1; + v62 = t12; + t12 = v7 + v52 + 1 >> 1; + v52 = v7 - v52 + 1 >> 1; + v7 = t12; + t12 = v0 - v32 + 1 >> 1; + v0 = v0 + v32 + 1 >> 1; + v32 = t12; + t12 = v1 - v22 + 1 >> 1; + v1 = v1 + v22 + 1 >> 1; + v22 = t12; + t12 = v42 * dctSin3 + v7 * dctCos3 + 2048 >> 12; + v42 = v42 * dctCos3 - v7 * dctSin3 + 2048 >> 12; + v7 = t12; + t12 = v52 * dctSin1 + v62 * dctCos1 + 2048 >> 12; + v52 = v52 * dctCos1 - v62 * dctSin1 + 2048 >> 12; + v62 = t12; + p6[0 + row] = v0 + v7; + p6[7 + row] = v0 - v7; + p6[1 + row] = v1 + v62; + p6[6 + row] = v1 - v62; + p6[2 + row] = v22 + v52; + p6[5 + row] = v22 - v52; + p6[3 + row] = v32 + v42; + p6[4 + row] = v32 - v42; + } + for (i7 = 0; i7 < 8; ++i7) { + var col = i7; + if (p6[1 * 8 + col] == 0 && p6[2 * 8 + col] == 0 && p6[3 * 8 + col] == 0 && p6[4 * 8 + col] == 0 && p6[5 * 8 + col] == 0 && p6[6 * 8 + col] == 0 && p6[7 * 8 + col] == 0) { + t12 = dctSqrt2 * dataIn[i7 + 0] + 8192 >> 14; + p6[0 * 8 + col] = t12; + p6[1 * 8 + col] = t12; + p6[2 * 8 + col] = t12; + p6[3 * 8 + col] = t12; + p6[4 * 8 + col] = t12; + p6[5 * 8 + col] = t12; + p6[6 * 8 + col] = t12; + p6[7 * 8 + col] = t12; + continue; + } + v0 = dctSqrt2 * p6[0 * 8 + col] + 2048 >> 12; + v1 = dctSqrt2 * p6[4 * 8 + col] + 2048 >> 12; + v22 = p6[2 * 8 + col]; + v32 = p6[6 * 8 + col]; + v42 = dctSqrt1d2 * (p6[1 * 8 + col] - p6[7 * 8 + col]) + 2048 >> 12; + v7 = dctSqrt1d2 * (p6[1 * 8 + col] + p6[7 * 8 + col]) + 2048 >> 12; + v52 = p6[3 * 8 + col]; + v62 = p6[5 * 8 + col]; + t12 = v0 - v1 + 1 >> 1; + v0 = v0 + v1 + 1 >> 1; + v1 = t12; + t12 = v22 * dctSin6 + v32 * dctCos6 + 2048 >> 12; + v22 = v22 * dctCos6 - v32 * dctSin6 + 2048 >> 12; + v32 = t12; + t12 = v42 - v62 + 1 >> 1; + v42 = v42 + v62 + 1 >> 1; + v62 = t12; + t12 = v7 + v52 + 1 >> 1; + v52 = v7 - v52 + 1 >> 1; + v7 = t12; + t12 = v0 - v32 + 1 >> 1; + v0 = v0 + v32 + 1 >> 1; + v32 = t12; + t12 = v1 - v22 + 1 >> 1; + v1 = v1 + v22 + 1 >> 1; + v22 = t12; + t12 = v42 * dctSin3 + v7 * dctCos3 + 2048 >> 12; + v42 = v42 * dctCos3 - v7 * dctSin3 + 2048 >> 12; + v7 = t12; + t12 = v52 * dctSin1 + v62 * dctCos1 + 2048 >> 12; + v52 = v52 * dctCos1 - v62 * dctSin1 + 2048 >> 12; + v62 = t12; + p6[0 * 8 + col] = v0 + v7; + p6[7 * 8 + col] = v0 - v7; + p6[1 * 8 + col] = v1 + v62; + p6[6 * 8 + col] = v1 - v62; + p6[2 * 8 + col] = v22 + v52; + p6[5 * 8 + col] = v22 - v52; + p6[3 * 8 + col] = v32 + v42; + p6[4 * 8 + col] = v32 - v42; + } + for (i7 = 0; i7 < 64; ++i7) { + var sample2 = 128 + (p6[i7] + 8 >> 4); + dataOut[i7] = sample2 < 0 ? 0 : sample2 > 255 ? 255 : sample2; + } + } + requestMemoryAllocation(samplesPerLine * blocksPerColumn * 8); + var i6, j6; + for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) { + var scanLine = blockRow << 3; + for (i6 = 0; i6 < 8; i6++) + lines.push(new Uint8Array(samplesPerLine)); + for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) { + quantizeAndInverse(component.blocks[blockRow][blockCol], r6, R2); + var offset = 0, sample = blockCol << 3; + for (j6 = 0; j6 < 8; j6++) { + var line = lines[scanLine + j6]; + for (i6 = 0; i6 < 8; i6++) + line[sample + i6] = r6[offset++]; + } + } } + return lines; } - } - const matches = []; - for (const directory of directories) { - const filePath = yield tryGetExecutablePath(path2.join(directory, tool), extensions); - if (filePath) { - matches.push(filePath); - } - } - return matches; - }); -} - -// ../node_modules/@actions/exec/lib/toolrunner.js -var import_timers = require("timers"); -var __awaiter4 = function(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e6) { - reject(e6); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); + function clampTo8bit(a6) { + return a6 < 0 ? 0 : a6 > 255 ? 255 : a6; } - } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var IS_WINDOWS2 = process.platform === "win32"; -var ToolRunner = class extends events.EventEmitter { - constructor(toolPath, args, options) { - super(); - if (!toolPath) { - throw new Error("Parameter 'toolPath' cannot be null or empty."); - } - this.toolPath = toolPath; - this.args = args || []; - this.options = options || {}; - } - _debug(message) { - if (this.options.listeners && this.options.listeners.debug) { - this.options.listeners.debug(message); + constructor.prototype = { + load: function load(path7) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", path7, true); + xhr.responseType = "arraybuffer"; + xhr.onload = (function() { + var data = new Uint8Array(xhr.response || xhr.mozResponseArrayBuffer); + this.parse(data); + if (this.onload) + this.onload(); + }).bind(this); + xhr.send(null); + }, + parse: function parse3(data) { + var maxResolutionInPixels = this.opts.maxResolutionInMP * 1e3 * 1e3; + var offset = 0, length = data.length; + function readUint16() { + var value = data[offset] << 8 | data[offset + 1]; + offset += 2; + return value; + } + function readDataBlock() { + var length2 = readUint16(); + var array = data.subarray(offset, offset + length2 - 2); + offset += array.length; + return array; + } + function prepareComponents(frame2) { + var maxH2 = 1, maxV2 = 1; + var component2, componentId2; + for (componentId2 in frame2.components) { + if (frame2.components.hasOwnProperty(componentId2)) { + component2 = frame2.components[componentId2]; + if (maxH2 < component2.h) maxH2 = component2.h; + if (maxV2 < component2.v) maxV2 = component2.v; + } + } + var mcusPerLine = Math.ceil(frame2.samplesPerLine / 8 / maxH2); + var mcusPerColumn = Math.ceil(frame2.scanLines / 8 / maxV2); + for (componentId2 in frame2.components) { + if (frame2.components.hasOwnProperty(componentId2)) { + component2 = frame2.components[componentId2]; + var blocksPerLine = Math.ceil(Math.ceil(frame2.samplesPerLine / 8) * component2.h / maxH2); + var blocksPerColumn = Math.ceil(Math.ceil(frame2.scanLines / 8) * component2.v / maxV2); + var blocksPerLineForMcu = mcusPerLine * component2.h; + var blocksPerColumnForMcu = mcusPerColumn * component2.v; + var blocksToAllocate = blocksPerColumnForMcu * blocksPerLineForMcu; + var blocks = []; + requestMemoryAllocation(blocksToAllocate * 256); + for (var i7 = 0; i7 < blocksPerColumnForMcu; i7++) { + var row = []; + for (var j7 = 0; j7 < blocksPerLineForMcu; j7++) + row.push(new Int32Array(64)); + blocks.push(row); + } + component2.blocksPerLine = blocksPerLine; + component2.blocksPerColumn = blocksPerColumn; + component2.blocks = blocks; + } + } + frame2.maxH = maxH2; + frame2.maxV = maxV2; + frame2.mcusPerLine = mcusPerLine; + frame2.mcusPerColumn = mcusPerColumn; + } + var jfif = null; + var adobe = null; + var pixels = null; + var frame, resetInterval; + var quantizationTables = [], frames = []; + var huffmanTablesAC = [], huffmanTablesDC = []; + var fileMarker = readUint16(); + var malformedDataOffset = -1; + this.comments = []; + if (fileMarker != 65496) { + throw new Error("SOI not found"); + } + fileMarker = readUint16(); + while (fileMarker != 65497) { + var i6, j6, l6; + switch (fileMarker) { + case 65280: + break; + case 65504: + // APP0 (Application Specific) + case 65505: + // APP1 + case 65506: + // APP2 + case 65507: + // APP3 + case 65508: + // APP4 + case 65509: + // APP5 + case 65510: + // APP6 + case 65511: + // APP7 + case 65512: + // APP8 + case 65513: + // APP9 + case 65514: + // APP10 + case 65515: + // APP11 + case 65516: + // APP12 + case 65517: + // APP13 + case 65518: + // APP14 + case 65519: + // APP15 + case 65534: + var appData = readDataBlock(); + if (fileMarker === 65534) { + var comment = String.fromCharCode.apply(null, appData); + this.comments.push(comment); + } + if (fileMarker === 65504) { + if (appData[0] === 74 && appData[1] === 70 && appData[2] === 73 && appData[3] === 70 && appData[4] === 0) { + jfif = { + version: { major: appData[5], minor: appData[6] }, + densityUnits: appData[7], + xDensity: appData[8] << 8 | appData[9], + yDensity: appData[10] << 8 | appData[11], + thumbWidth: appData[12], + thumbHeight: appData[13], + thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13]) + }; + } + } + if (fileMarker === 65505) { + if (appData[0] === 69 && appData[1] === 120 && appData[2] === 105 && appData[3] === 102 && appData[4] === 0) { + this.exifBuffer = appData.subarray(5, appData.length); + } + } + if (fileMarker === 65518) { + if (appData[0] === 65 && appData[1] === 100 && appData[2] === 111 && appData[3] === 98 && appData[4] === 101 && appData[5] === 0) { + adobe = { + version: appData[6], + flags0: appData[7] << 8 | appData[8], + flags1: appData[9] << 8 | appData[10], + transformCode: appData[11] + }; + } + } + break; + case 65499: + var quantizationTablesLength = readUint16(); + var quantizationTablesEnd = quantizationTablesLength + offset - 2; + while (offset < quantizationTablesEnd) { + var quantizationTableSpec = data[offset++]; + requestMemoryAllocation(64 * 4); + var tableData = new Int32Array(64); + if (quantizationTableSpec >> 4 === 0) { + for (j6 = 0; j6 < 64; j6++) { + var z3 = dctZigZag[j6]; + tableData[z3] = data[offset++]; + } + } else if (quantizationTableSpec >> 4 === 1) { + for (j6 = 0; j6 < 64; j6++) { + var z3 = dctZigZag[j6]; + tableData[z3] = readUint16(); + } + } else + throw new Error("DQT: invalid table spec"); + quantizationTables[quantizationTableSpec & 15] = tableData; + } + break; + case 65472: + // SOF0 (Start of Frame, Baseline DCT) + case 65473: + // SOF1 (Start of Frame, Extended DCT) + case 65474: + readUint16(); + frame = {}; + frame.extended = fileMarker === 65473; + frame.progressive = fileMarker === 65474; + frame.precision = data[offset++]; + frame.scanLines = readUint16(); + frame.samplesPerLine = readUint16(); + frame.components = {}; + frame.componentsOrder = []; + var pixelsInFrame = frame.scanLines * frame.samplesPerLine; + if (pixelsInFrame > maxResolutionInPixels) { + var exceededAmount = Math.ceil((pixelsInFrame - maxResolutionInPixels) / 1e6); + throw new Error(`maxResolutionInMP limit exceeded by ${exceededAmount}MP`); + } + var componentsCount = data[offset++], componentId; + var maxH = 0, maxV = 0; + for (i6 = 0; i6 < componentsCount; i6++) { + componentId = data[offset]; + var h6 = data[offset + 1] >> 4; + var v7 = data[offset + 1] & 15; + var qId = data[offset + 2]; + if (h6 <= 0 || v7 <= 0) { + throw new Error("Invalid sampling factor, expected values above 0"); + } + frame.componentsOrder.push(componentId); + frame.components[componentId] = { + h: h6, + v: v7, + quantizationIdx: qId + }; + offset += 3; + } + prepareComponents(frame); + frames.push(frame); + break; + case 65476: + var huffmanLength = readUint16(); + for (i6 = 2; i6 < huffmanLength; ) { + var huffmanTableSpec = data[offset++]; + var codeLengths = new Uint8Array(16); + var codeLengthSum = 0; + for (j6 = 0; j6 < 16; j6++, offset++) { + codeLengthSum += codeLengths[j6] = data[offset]; + } + requestMemoryAllocation(16 + codeLengthSum); + var huffmanValues = new Uint8Array(codeLengthSum); + for (j6 = 0; j6 < codeLengthSum; j6++, offset++) + huffmanValues[j6] = data[offset]; + i6 += 17 + codeLengthSum; + (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues); + } + break; + case 65501: + readUint16(); + resetInterval = readUint16(); + break; + case 65500: + readUint16(); + readUint16(); + break; + case 65498: + var scanLength = readUint16(); + var selectorsCount = data[offset++]; + var components = [], component; + for (i6 = 0; i6 < selectorsCount; i6++) { + component = frame.components[data[offset++]]; + var tableSpec = data[offset++]; + component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4]; + component.huffmanTableAC = huffmanTablesAC[tableSpec & 15]; + components.push(component); + } + var spectralStart = data[offset++]; + var spectralEnd = data[offset++]; + var successiveApproximation = data[offset++]; + var processed = decodeScan( + data, + offset, + frame, + components, + resetInterval, + spectralStart, + spectralEnd, + successiveApproximation >> 4, + successiveApproximation & 15, + this.opts + ); + offset += processed; + break; + case 65535: + if (data[offset] !== 255) { + offset--; + } + break; + default: + if (data[offset - 3] == 255 && data[offset - 2] >= 192 && data[offset - 2] <= 254) { + offset -= 3; + break; + } else if (fileMarker === 224 || fileMarker == 225) { + if (malformedDataOffset !== -1) { + throw new Error(`first unknown JPEG marker at offset ${malformedDataOffset.toString(16)}, second unknown JPEG marker ${fileMarker.toString(16)} at offset ${(offset - 1).toString(16)}`); + } + malformedDataOffset = offset - 1; + const nextOffset = readUint16(); + if (data[offset + nextOffset - 2] === 255) { + offset += nextOffset - 2; + break; + } + } + throw new Error("unknown JPEG marker " + fileMarker.toString(16)); + } + fileMarker = readUint16(); + } + if (frames.length != 1) + throw new Error("only single frame JPEGs supported"); + for (var i6 = 0; i6 < frames.length; i6++) { + var cp2 = frames[i6].components; + for (var j6 in cp2) { + cp2[j6].quantizationTable = quantizationTables[cp2[j6].quantizationIdx]; + delete cp2[j6].quantizationIdx; + } + } + this.width = frame.samplesPerLine; + this.height = frame.scanLines; + this.jfif = jfif; + this.adobe = adobe; + this.components = []; + for (var i6 = 0; i6 < frame.componentsOrder.length; i6++) { + var component = frame.components[frame.componentsOrder[i6]]; + this.components.push({ + lines: buildComponentData(frame, component), + scaleX: component.h / frame.maxH, + scaleY: component.v / frame.maxV + }); + } + }, + getData: function getData(width, height) { + var scaleX = this.width / width, scaleY = this.height / height; + var component1, component2, component3, component4; + var component1Line, component2Line, component3Line, component4Line; + var x7, y4; + var offset = 0; + var Y3, Cb, Cr, K3, C3, M2, Ye, R2, G3, B3; + var colorTransform; + var dataLength = width * height * this.components.length; + requestMemoryAllocation(dataLength); + var data = new Uint8Array(dataLength); + switch (this.components.length) { + case 1: + component1 = this.components[0]; + for (y4 = 0; y4 < height; y4++) { + component1Line = component1.lines[0 | y4 * component1.scaleY * scaleY]; + for (x7 = 0; x7 < width; x7++) { + Y3 = component1Line[0 | x7 * component1.scaleX * scaleX]; + data[offset++] = Y3; + } + } + break; + case 2: + component1 = this.components[0]; + component2 = this.components[1]; + for (y4 = 0; y4 < height; y4++) { + component1Line = component1.lines[0 | y4 * component1.scaleY * scaleY]; + component2Line = component2.lines[0 | y4 * component2.scaleY * scaleY]; + for (x7 = 0; x7 < width; x7++) { + Y3 = component1Line[0 | x7 * component1.scaleX * scaleX]; + data[offset++] = Y3; + Y3 = component2Line[0 | x7 * component2.scaleX * scaleX]; + data[offset++] = Y3; + } + } + break; + case 3: + colorTransform = true; + if (this.adobe && this.adobe.transformCode) + colorTransform = true; + else if (typeof this.opts.colorTransform !== "undefined") + colorTransform = !!this.opts.colorTransform; + component1 = this.components[0]; + component2 = this.components[1]; + component3 = this.components[2]; + for (y4 = 0; y4 < height; y4++) { + component1Line = component1.lines[0 | y4 * component1.scaleY * scaleY]; + component2Line = component2.lines[0 | y4 * component2.scaleY * scaleY]; + component3Line = component3.lines[0 | y4 * component3.scaleY * scaleY]; + for (x7 = 0; x7 < width; x7++) { + if (!colorTransform) { + R2 = component1Line[0 | x7 * component1.scaleX * scaleX]; + G3 = component2Line[0 | x7 * component2.scaleX * scaleX]; + B3 = component3Line[0 | x7 * component3.scaleX * scaleX]; + } else { + Y3 = component1Line[0 | x7 * component1.scaleX * scaleX]; + Cb = component2Line[0 | x7 * component2.scaleX * scaleX]; + Cr = component3Line[0 | x7 * component3.scaleX * scaleX]; + R2 = clampTo8bit(Y3 + 1.402 * (Cr - 128)); + G3 = clampTo8bit(Y3 - 0.3441363 * (Cb - 128) - 0.71413636 * (Cr - 128)); + B3 = clampTo8bit(Y3 + 1.772 * (Cb - 128)); + } + data[offset++] = R2; + data[offset++] = G3; + data[offset++] = B3; + } + } + break; + case 4: + if (!this.adobe) + throw new Error("Unsupported color mode (4 components)"); + colorTransform = false; + if (this.adobe && this.adobe.transformCode) + colorTransform = true; + else if (typeof this.opts.colorTransform !== "undefined") + colorTransform = !!this.opts.colorTransform; + component1 = this.components[0]; + component2 = this.components[1]; + component3 = this.components[2]; + component4 = this.components[3]; + for (y4 = 0; y4 < height; y4++) { + component1Line = component1.lines[0 | y4 * component1.scaleY * scaleY]; + component2Line = component2.lines[0 | y4 * component2.scaleY * scaleY]; + component3Line = component3.lines[0 | y4 * component3.scaleY * scaleY]; + component4Line = component4.lines[0 | y4 * component4.scaleY * scaleY]; + for (x7 = 0; x7 < width; x7++) { + if (!colorTransform) { + C3 = component1Line[0 | x7 * component1.scaleX * scaleX]; + M2 = component2Line[0 | x7 * component2.scaleX * scaleX]; + Ye = component3Line[0 | x7 * component3.scaleX * scaleX]; + K3 = component4Line[0 | x7 * component4.scaleX * scaleX]; + } else { + Y3 = component1Line[0 | x7 * component1.scaleX * scaleX]; + Cb = component2Line[0 | x7 * component2.scaleX * scaleX]; + Cr = component3Line[0 | x7 * component3.scaleX * scaleX]; + K3 = component4Line[0 | x7 * component4.scaleX * scaleX]; + C3 = 255 - clampTo8bit(Y3 + 1.402 * (Cr - 128)); + M2 = 255 - clampTo8bit(Y3 - 0.3441363 * (Cb - 128) - 0.71413636 * (Cr - 128)); + Ye = 255 - clampTo8bit(Y3 + 1.772 * (Cb - 128)); + } + data[offset++] = 255 - C3; + data[offset++] = 255 - M2; + data[offset++] = 255 - Ye; + data[offset++] = 255 - K3; + } + } + break; + default: + throw new Error("Unsupported color mode"); + } + return data; + }, + copyToImageData: function copyToImageData(imageData, formatAsRGBA) { + var width = imageData.width, height = imageData.height; + var imageDataArray = imageData.data; + var data = this.getData(width, height); + var i6 = 0, j6 = 0, x7, y4; + var Y3, K3, C3, M2, R2, G3, B3; + switch (this.components.length) { + case 1: + for (y4 = 0; y4 < height; y4++) { + for (x7 = 0; x7 < width; x7++) { + Y3 = data[i6++]; + imageDataArray[j6++] = Y3; + imageDataArray[j6++] = Y3; + imageDataArray[j6++] = Y3; + if (formatAsRGBA) { + imageDataArray[j6++] = 255; + } + } + } + break; + case 3: + for (y4 = 0; y4 < height; y4++) { + for (x7 = 0; x7 < width; x7++) { + R2 = data[i6++]; + G3 = data[i6++]; + B3 = data[i6++]; + imageDataArray[j6++] = R2; + imageDataArray[j6++] = G3; + imageDataArray[j6++] = B3; + if (formatAsRGBA) { + imageDataArray[j6++] = 255; + } + } + } + break; + case 4: + for (y4 = 0; y4 < height; y4++) { + for (x7 = 0; x7 < width; x7++) { + C3 = data[i6++]; + M2 = data[i6++]; + Y3 = data[i6++]; + K3 = data[i6++]; + R2 = 255 - clampTo8bit(C3 * (1 - K3 / 255) + K3); + G3 = 255 - clampTo8bit(M2 * (1 - K3 / 255) + K3); + B3 = 255 - clampTo8bit(Y3 * (1 - K3 / 255) + K3); + imageDataArray[j6++] = R2; + imageDataArray[j6++] = G3; + imageDataArray[j6++] = B3; + if (formatAsRGBA) { + imageDataArray[j6++] = 255; + } + } + } + break; + default: + throw new Error("Unsupported color mode"); + } + } + }; + var totalBytesAllocated = 0; + var maxMemoryUsageBytes = 0; + function requestMemoryAllocation(increaseAmount = 0) { + var totalMemoryImpactBytes = totalBytesAllocated + increaseAmount; + if (totalMemoryImpactBytes > maxMemoryUsageBytes) { + var exceededAmount = Math.ceil((totalMemoryImpactBytes - maxMemoryUsageBytes) / 1024 / 1024); + throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${exceededAmount}MB`); + } + totalBytesAllocated = totalMemoryImpactBytes; + } + constructor.resetMaxMemoryUsage = function(maxMemoryUsageBytes_) { + totalBytesAllocated = 0; + maxMemoryUsageBytes = maxMemoryUsageBytes_; + }; + constructor.getBytesAllocated = function() { + return totalBytesAllocated; + }; + constructor.requestMemoryAllocation = requestMemoryAllocation; + return constructor; + })(); + if (typeof module2 !== "undefined") { + module2.exports = decode3; + } else if (typeof window !== "undefined") { + window["jpeg-js"] = window["jpeg-js"] || {}; + window["jpeg-js"].decode = decode3; + } + function decode3(jpegData, userOpts = {}) { + var defaultOpts = { + // "undefined" means "Choose whether to transform colors based on the image’s color model." + colorTransform: void 0, + useTArray: false, + formatAsRGBA: true, + tolerantDecoding: true, + maxResolutionInMP: 100, + // Don't decode more than 100 megapixels + maxMemoryUsageInMB: 512 + // Don't decode if memory footprint is more than 512MB + }; + var opts = { ...defaultOpts, ...userOpts }; + var arr = new Uint8Array(jpegData); + var decoder = new JpegImage(); + decoder.opts = opts; + JpegImage.resetMaxMemoryUsage(opts.maxMemoryUsageInMB * 1024 * 1024); + decoder.parse(arr); + var channels = opts.formatAsRGBA ? 4 : 3; + var bytesNeeded = decoder.width * decoder.height * channels; + try { + JpegImage.requestMemoryAllocation(bytesNeeded); + var image2 = { + width: decoder.width, + height: decoder.height, + exifBuffer: decoder.exifBuffer, + data: opts.useTArray ? new Uint8Array(bytesNeeded) : Buffer.alloc(bytesNeeded) + }; + if (decoder.comments.length > 0) { + image2["comments"] = decoder.comments; + } + } catch (err) { + if (err instanceof RangeError) { + throw new Error("Could not allocate enough memory for the image. Required: " + bytesNeeded); + } + if (err instanceof ReferenceError) { + if (err.message === "Buffer is not defined") { + throw new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true"); + } + } + throw err; + } + decoder.copyToImageData(image2, opts.formatAsRGBA); + return image2; } } - _getCommandString(options, noPrefix) { - const toolPath = this._getSpawnFileName(); - const args = this._getSpawnArgs(options); - let cmd = noPrefix ? "" : "[command]"; - if (IS_WINDOWS2) { - if (this._isCmdFile()) { - cmd += toolPath; - for (const a6 of args) { - cmd += ` ${a6}`; +}); + +// ../node_modules/jpeg-js/index.js +var require_jpeg_js = __commonJS({ + "../node_modules/jpeg-js/index.js"(exports2, module2) { + "use strict"; + var encode3 = require_encoder(); + var decode3 = require_decoder(); + module2.exports = { + encode: encode3, + decode: decode3 + }; + } +}); + +// ../node_modules/pngjs/lib/chunkstream.js +var require_chunkstream = __commonJS({ + "../node_modules/pngjs/lib/chunkstream.js"(exports2, module2) { + "use strict"; + var util17 = require("util"); + var Stream2 = require("stream"); + var ChunkStream = module2.exports = function() { + Stream2.call(this); + this._buffers = []; + this._buffered = 0; + this._reads = []; + this._paused = false; + this._encoding = "utf8"; + this.writable = true; + }; + util17.inherits(ChunkStream, Stream2); + ChunkStream.prototype.read = function(length, callback) { + this._reads.push({ + length: Math.abs(length), + // if length < 0 then at most this length + allowLess: length < 0, + func: callback + }); + process.nextTick( + function() { + this._process(); + if (this._paused && this._reads && this._reads.length > 0) { + this._paused = false; + this.emit("drain"); + } + }.bind(this) + ); + }; + ChunkStream.prototype.write = function(data, encoding) { + if (!this.writable) { + this.emit("error", new Error("Stream not writable")); + return false; + } + let dataBuffer; + if (Buffer.isBuffer(data)) { + dataBuffer = data; + } else { + dataBuffer = Buffer.from(data, encoding || this._encoding); + } + this._buffers.push(dataBuffer); + this._buffered += dataBuffer.length; + this._process(); + if (this._reads && this._reads.length === 0) { + this._paused = true; + } + return this.writable && !this._paused; + }; + ChunkStream.prototype.end = function(data, encoding) { + if (data) { + this.write(data, encoding); + } + this.writable = false; + if (!this._buffers) { + return; + } + if (this._buffers.length === 0) { + this._end(); + } else { + this._buffers.push(null); + this._process(); + } + }; + ChunkStream.prototype.destroySoon = ChunkStream.prototype.end; + ChunkStream.prototype._end = function() { + if (this._reads.length > 0) { + this.emit("error", new Error("Unexpected end of input")); + } + this.destroy(); + }; + ChunkStream.prototype.destroy = function() { + if (!this._buffers) { + return; + } + this.writable = false; + this._reads = null; + this._buffers = null; + this.emit("close"); + }; + ChunkStream.prototype._processReadAllowingLess = function(read) { + this._reads.shift(); + let smallerBuf = this._buffers[0]; + if (smallerBuf.length > read.length) { + this._buffered -= read.length; + this._buffers[0] = smallerBuf.slice(read.length); + read.func.call(this, smallerBuf.slice(0, read.length)); + } else { + this._buffered -= smallerBuf.length; + this._buffers.shift(); + read.func.call(this, smallerBuf); + } + }; + ChunkStream.prototype._processRead = function(read) { + this._reads.shift(); + let pos = 0; + let count = 0; + let data = Buffer.alloc(read.length); + while (pos < read.length) { + let buf = this._buffers[count++]; + let len = Math.min(buf.length, read.length - pos); + buf.copy(data, pos, 0, len); + pos += len; + if (len !== buf.length) { + this._buffers[--count] = buf.slice(len); } - } else if (options.windowsVerbatimArguments) { - cmd += `"${toolPath}"`; - for (const a6 of args) { - cmd += ` ${a6}`; + } + if (count > 0) { + this._buffers.splice(0, count); + } + this._buffered -= read.length; + read.func.call(this, data); + }; + ChunkStream.prototype._process = function() { + try { + while (this._buffered > 0 && this._reads && this._reads.length > 0) { + let read = this._reads[0]; + if (read.allowLess) { + this._processReadAllowingLess(read); + } else if (this._buffered >= read.length) { + this._processRead(read); + } else { + break; + } } - } else { - cmd += this._windowsQuoteCmdArg(toolPath); - for (const a6 of args) { - cmd += ` ${this._windowsQuoteCmdArg(a6)}`; + if (this._buffers && !this.writable) { + this._end(); } + } catch (ex) { + this.emit("error", ex); } - } else { - cmd += toolPath; - for (const a6 of args) { - cmd += ` ${a6}`; + }; + } +}); + +// ../node_modules/pngjs/lib/interlace.js +var require_interlace = __commonJS({ + "../node_modules/pngjs/lib/interlace.js"(exports2) { + "use strict"; + var imagePasses = [ + { + // pass 1 - 1px + x: [0], + y: [0] + }, + { + // pass 2 - 1px + x: [4], + y: [0] + }, + { + // pass 3 - 2px + x: [0, 4], + y: [4] + }, + { + // pass 4 - 4px + x: [2, 6], + y: [0, 4] + }, + { + // pass 5 - 8px + x: [0, 2, 4, 6], + y: [2, 6] + }, + { + // pass 6 - 16px + x: [1, 3, 5, 7], + y: [0, 2, 4, 6] + }, + { + // pass 7 - 32px + x: [0, 1, 2, 3, 4, 5, 6, 7], + y: [1, 3, 5, 7] } - } - return cmd; + ]; + exports2.getImagePasses = function(width, height) { + let images = []; + let xLeftOver = width % 8; + let yLeftOver = height % 8; + let xRepeats = (width - xLeftOver) / 8; + let yRepeats = (height - yLeftOver) / 8; + for (let i6 = 0; i6 < imagePasses.length; i6++) { + let pass = imagePasses[i6]; + let passWidth = xRepeats * pass.x.length; + let passHeight = yRepeats * pass.y.length; + for (let j6 = 0; j6 < pass.x.length; j6++) { + if (pass.x[j6] < xLeftOver) { + passWidth++; + } else { + break; + } + } + for (let j6 = 0; j6 < pass.y.length; j6++) { + if (pass.y[j6] < yLeftOver) { + passHeight++; + } else { + break; + } + } + if (passWidth > 0 && passHeight > 0) { + images.push({ width: passWidth, height: passHeight, index: i6 }); + } + } + return images; + }; + exports2.getInterlaceIterator = function(width) { + return function(x7, y4, pass) { + let outerXLeftOver = x7 % imagePasses[pass].x.length; + let outerX = (x7 - outerXLeftOver) / imagePasses[pass].x.length * 8 + imagePasses[pass].x[outerXLeftOver]; + let outerYLeftOver = y4 % imagePasses[pass].y.length; + let outerY = (y4 - outerYLeftOver) / imagePasses[pass].y.length * 8 + imagePasses[pass].y[outerYLeftOver]; + return outerX * 4 + outerY * width * 4; + }; + }; } - _processLineBuffer(data, strBuffer, onLine) { - try { - let s6 = strBuffer + data.toString(); - let n6 = s6.indexOf(os2.EOL); - while (n6 > -1) { - const line = s6.substring(0, n6); - onLine(line); - s6 = s6.substring(n6 + os2.EOL.length); - n6 = s6.indexOf(os2.EOL); +}); + +// ../node_modules/pngjs/lib/paeth-predictor.js +var require_paeth_predictor = __commonJS({ + "../node_modules/pngjs/lib/paeth-predictor.js"(exports2, module2) { + "use strict"; + module2.exports = function paethPredictor(left, above, upLeft) { + let paeth = left + above - upLeft; + let pLeft = Math.abs(paeth - left); + let pAbove = Math.abs(paeth - above); + let pUpLeft = Math.abs(paeth - upLeft); + if (pLeft <= pAbove && pLeft <= pUpLeft) { + return left; } - return s6; - } catch (err) { - this._debug(`error processing line. Failed with error ${err}`); - return ""; - } + if (pAbove <= pUpLeft) { + return above; + } + return upLeft; + }; } - _getSpawnFileName() { - if (IS_WINDOWS2) { - if (this._isCmdFile()) { - return process.env["COMSPEC"] || "cmd.exe"; +}); + +// ../node_modules/pngjs/lib/filter-parse.js +var require_filter_parse = __commonJS({ + "../node_modules/pngjs/lib/filter-parse.js"(exports2, module2) { + "use strict"; + var interlaceUtils = require_interlace(); + var paethPredictor = require_paeth_predictor(); + function getByteWidth(width, bpp, depth) { + let byteWidth = width * bpp; + if (depth !== 8) { + byteWidth = Math.ceil(byteWidth / (8 / depth)); } + return byteWidth; } - return this.toolPath; - } - _getSpawnArgs(options) { - if (IS_WINDOWS2) { - if (this._isCmdFile()) { - let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`; - for (const a6 of this.args) { - argline += " "; - argline += options.windowsVerbatimArguments ? a6 : this._windowsQuoteCmdArg(a6); + var Filter = module2.exports = function(bitmapInfo, dependencies) { + let width = bitmapInfo.width; + let height = bitmapInfo.height; + let interlace = bitmapInfo.interlace; + let bpp = bitmapInfo.bpp; + let depth = bitmapInfo.depth; + this.read = dependencies.read; + this.write = dependencies.write; + this.complete = dependencies.complete; + this._imageIndex = 0; + this._images = []; + if (interlace) { + let passes = interlaceUtils.getImagePasses(width, height); + for (let i6 = 0; i6 < passes.length; i6++) { + this._images.push({ + byteWidth: getByteWidth(passes[i6].width, bpp, depth), + height: passes[i6].height, + lineIndex: 0 + }); } - argline += '"'; - return [argline]; + } else { + this._images.push({ + byteWidth: getByteWidth(width, bpp, depth), + height, + lineIndex: 0 + }); } - } - return this.args; + if (depth === 8) { + this._xComparison = bpp; + } else if (depth === 16) { + this._xComparison = bpp * 2; + } else { + this._xComparison = 1; + } + }; + Filter.prototype.start = function() { + this.read( + this._images[this._imageIndex].byteWidth + 1, + this._reverseFilterLine.bind(this) + ); + }; + Filter.prototype._unFilterType1 = function(rawData, unfilteredLine, byteWidth) { + let xComparison = this._xComparison; + let xBiggerThan = xComparison - 1; + for (let x7 = 0; x7 < byteWidth; x7++) { + let rawByte = rawData[1 + x7]; + let f1Left = x7 > xBiggerThan ? unfilteredLine[x7 - xComparison] : 0; + unfilteredLine[x7] = rawByte + f1Left; + } + }; + Filter.prototype._unFilterType2 = function(rawData, unfilteredLine, byteWidth) { + let lastLine = this._lastLine; + for (let x7 = 0; x7 < byteWidth; x7++) { + let rawByte = rawData[1 + x7]; + let f2Up = lastLine ? lastLine[x7] : 0; + unfilteredLine[x7] = rawByte + f2Up; + } + }; + Filter.prototype._unFilterType3 = function(rawData, unfilteredLine, byteWidth) { + let xComparison = this._xComparison; + let xBiggerThan = xComparison - 1; + let lastLine = this._lastLine; + for (let x7 = 0; x7 < byteWidth; x7++) { + let rawByte = rawData[1 + x7]; + let f3Up = lastLine ? lastLine[x7] : 0; + let f3Left = x7 > xBiggerThan ? unfilteredLine[x7 - xComparison] : 0; + let f3Add = Math.floor((f3Left + f3Up) / 2); + unfilteredLine[x7] = rawByte + f3Add; + } + }; + Filter.prototype._unFilterType4 = function(rawData, unfilteredLine, byteWidth) { + let xComparison = this._xComparison; + let xBiggerThan = xComparison - 1; + let lastLine = this._lastLine; + for (let x7 = 0; x7 < byteWidth; x7++) { + let rawByte = rawData[1 + x7]; + let f4Up = lastLine ? lastLine[x7] : 0; + let f4Left = x7 > xBiggerThan ? unfilteredLine[x7 - xComparison] : 0; + let f4UpLeft = x7 > xBiggerThan && lastLine ? lastLine[x7 - xComparison] : 0; + let f4Add = paethPredictor(f4Left, f4Up, f4UpLeft); + unfilteredLine[x7] = rawByte + f4Add; + } + }; + Filter.prototype._reverseFilterLine = function(rawData) { + let filter2 = rawData[0]; + let unfilteredLine; + let currentImage = this._images[this._imageIndex]; + let byteWidth = currentImage.byteWidth; + if (filter2 === 0) { + unfilteredLine = rawData.slice(1, byteWidth + 1); + } else { + unfilteredLine = Buffer.alloc(byteWidth); + switch (filter2) { + case 1: + this._unFilterType1(rawData, unfilteredLine, byteWidth); + break; + case 2: + this._unFilterType2(rawData, unfilteredLine, byteWidth); + break; + case 3: + this._unFilterType3(rawData, unfilteredLine, byteWidth); + break; + case 4: + this._unFilterType4(rawData, unfilteredLine, byteWidth); + break; + default: + throw new Error("Unrecognised filter type - " + filter2); + } + } + this.write(unfilteredLine); + currentImage.lineIndex++; + if (currentImage.lineIndex >= currentImage.height) { + this._lastLine = null; + this._imageIndex++; + currentImage = this._images[this._imageIndex]; + } else { + this._lastLine = unfilteredLine; + } + if (currentImage) { + this.read(currentImage.byteWidth + 1, this._reverseFilterLine.bind(this)); + } else { + this._lastLine = null; + this.complete(); + } + }; } - _endsWith(str, end) { - return str.endsWith(end); +}); + +// ../node_modules/pngjs/lib/filter-parse-async.js +var require_filter_parse_async = __commonJS({ + "../node_modules/pngjs/lib/filter-parse-async.js"(exports2, module2) { + "use strict"; + var util17 = require("util"); + var ChunkStream = require_chunkstream(); + var Filter = require_filter_parse(); + var FilterAsync = module2.exports = function(bitmapInfo) { + ChunkStream.call(this); + let buffers = []; + let that = this; + this._filter = new Filter(bitmapInfo, { + read: this.read.bind(this), + write: function(buffer) { + buffers.push(buffer); + }, + complete: function() { + that.emit("complete", Buffer.concat(buffers)); + } + }); + this._filter.start(); + }; + util17.inherits(FilterAsync, ChunkStream); } - _isCmdFile() { - const upperToolPath = this.toolPath.toUpperCase(); - return this._endsWith(upperToolPath, ".CMD") || this._endsWith(upperToolPath, ".BAT"); +}); + +// ../node_modules/pngjs/lib/constants.js +var require_constants6 = __commonJS({ + "../node_modules/pngjs/lib/constants.js"(exports2, module2) { + "use strict"; + module2.exports = { + PNG_SIGNATURE: [137, 80, 78, 71, 13, 10, 26, 10], + TYPE_IHDR: 1229472850, + TYPE_IEND: 1229278788, + TYPE_IDAT: 1229209940, + TYPE_PLTE: 1347179589, + TYPE_tRNS: 1951551059, + // eslint-disable-line camelcase + TYPE_gAMA: 1732332865, + // eslint-disable-line camelcase + // color-type bits + COLORTYPE_GRAYSCALE: 0, + COLORTYPE_PALETTE: 1, + COLORTYPE_COLOR: 2, + COLORTYPE_ALPHA: 4, + // e.g. grayscale and alpha + // color-type combinations + COLORTYPE_PALETTE_COLOR: 3, + COLORTYPE_COLOR_ALPHA: 6, + COLORTYPE_TO_BPP_MAP: { + 0: 1, + 2: 3, + 3: 1, + 4: 2, + 6: 4 + }, + GAMMA_DIVISION: 1e5 + }; } - _windowsQuoteCmdArg(arg) { - if (!this._isCmdFile()) { - return this._uvQuoteCmdArg(arg); - } - if (!arg) { - return '""'; - } - const cmdSpecialChars = [ - " ", - " ", - "&", - "(", - ")", - "[", - "]", - "{", - "}", - "^", - "=", - ";", - "!", - "'", - "+", - ",", - "`", - "~", - "|", - "<", - ">", - '"' +}); + +// ../node_modules/pngjs/lib/crc.js +var require_crc = __commonJS({ + "../node_modules/pngjs/lib/crc.js"(exports2, module2) { + "use strict"; + var crcTable = []; + (function() { + for (let i6 = 0; i6 < 256; i6++) { + let currentCrc = i6; + for (let j6 = 0; j6 < 8; j6++) { + if (currentCrc & 1) { + currentCrc = 3988292384 ^ currentCrc >>> 1; + } else { + currentCrc = currentCrc >>> 1; + } + } + crcTable[i6] = currentCrc; + } + })(); + var CrcCalculator = module2.exports = function() { + this._crc = -1; + }; + CrcCalculator.prototype.write = function(data) { + for (let i6 = 0; i6 < data.length; i6++) { + this._crc = crcTable[(this._crc ^ data[i6]) & 255] ^ this._crc >>> 8; + } + return true; + }; + CrcCalculator.prototype.crc32 = function() { + return this._crc ^ -1; + }; + CrcCalculator.crc32 = function(buf) { + let crc = -1; + for (let i6 = 0; i6 < buf.length; i6++) { + crc = crcTable[(crc ^ buf[i6]) & 255] ^ crc >>> 8; + } + return crc ^ -1; + }; + } +}); + +// ../node_modules/pngjs/lib/parser.js +var require_parser = __commonJS({ + "../node_modules/pngjs/lib/parser.js"(exports2, module2) { + "use strict"; + var constants4 = require_constants6(); + var CrcCalculator = require_crc(); + var Parser = module2.exports = function(options, dependencies) { + this._options = options; + options.checkCRC = options.checkCRC !== false; + this._hasIHDR = false; + this._hasIEND = false; + this._emittedHeadersFinished = false; + this._palette = []; + this._colorType = 0; + this._chunks = {}; + this._chunks[constants4.TYPE_IHDR] = this._handleIHDR.bind(this); + this._chunks[constants4.TYPE_IEND] = this._handleIEND.bind(this); + this._chunks[constants4.TYPE_IDAT] = this._handleIDAT.bind(this); + this._chunks[constants4.TYPE_PLTE] = this._handlePLTE.bind(this); + this._chunks[constants4.TYPE_tRNS] = this._handleTRNS.bind(this); + this._chunks[constants4.TYPE_gAMA] = this._handleGAMA.bind(this); + this.read = dependencies.read; + this.error = dependencies.error; + this.metadata = dependencies.metadata; + this.gamma = dependencies.gamma; + this.transColor = dependencies.transColor; + this.palette = dependencies.palette; + this.parsed = dependencies.parsed; + this.inflateData = dependencies.inflateData; + this.finished = dependencies.finished; + this.simpleTransparency = dependencies.simpleTransparency; + this.headersFinished = dependencies.headersFinished || function() { + }; + }; + Parser.prototype.start = function() { + this.read(constants4.PNG_SIGNATURE.length, this._parseSignature.bind(this)); + }; + Parser.prototype._parseSignature = function(data) { + let signature = constants4.PNG_SIGNATURE; + for (let i6 = 0; i6 < signature.length; i6++) { + if (data[i6] !== signature[i6]) { + this.error(new Error("Invalid file signature")); + return; + } + } + this.read(8, this._parseChunkBegin.bind(this)); + }; + Parser.prototype._parseChunkBegin = function(data) { + let length = data.readUInt32BE(0); + let type = data.readUInt32BE(4); + let name = ""; + for (let i6 = 4; i6 < 8; i6++) { + name += String.fromCharCode(data[i6]); + } + let ancillary = Boolean(data[4] & 32); + if (!this._hasIHDR && type !== constants4.TYPE_IHDR) { + this.error(new Error("Expected IHDR on beggining")); + return; + } + this._crc = new CrcCalculator(); + this._crc.write(Buffer.from(name)); + if (this._chunks[type]) { + return this._chunks[type](length); + } + if (!ancillary) { + this.error(new Error("Unsupported critical chunk type " + name)); + return; + } + this.read(length + 4, this._skipChunk.bind(this)); + }; + Parser.prototype._skipChunk = function() { + this.read(8, this._parseChunkBegin.bind(this)); + }; + Parser.prototype._handleChunkEnd = function() { + this.read(4, this._parseChunkEnd.bind(this)); + }; + Parser.prototype._parseChunkEnd = function(data) { + let fileCrc = data.readInt32BE(0); + let calcCrc = this._crc.crc32(); + if (this._options.checkCRC && calcCrc !== fileCrc) { + this.error(new Error("Crc error - " + fileCrc + " - " + calcCrc)); + return; + } + if (!this._hasIEND) { + this.read(8, this._parseChunkBegin.bind(this)); + } + }; + Parser.prototype._handleIHDR = function(length) { + this.read(length, this._parseIHDR.bind(this)); + }; + Parser.prototype._parseIHDR = function(data) { + this._crc.write(data); + let width = data.readUInt32BE(0); + let height = data.readUInt32BE(4); + let depth = data[8]; + let colorType = data[9]; + let compr = data[10]; + let filter2 = data[11]; + let interlace = data[12]; + if (depth !== 8 && depth !== 4 && depth !== 2 && depth !== 1 && depth !== 16) { + this.error(new Error("Unsupported bit depth " + depth)); + return; + } + if (!(colorType in constants4.COLORTYPE_TO_BPP_MAP)) { + this.error(new Error("Unsupported color type")); + return; + } + if (compr !== 0) { + this.error(new Error("Unsupported compression method")); + return; + } + if (filter2 !== 0) { + this.error(new Error("Unsupported filter method")); + return; + } + if (interlace !== 0 && interlace !== 1) { + this.error(new Error("Unsupported interlace method")); + return; + } + this._colorType = colorType; + let bpp = constants4.COLORTYPE_TO_BPP_MAP[this._colorType]; + this._hasIHDR = true; + this.metadata({ + width, + height, + depth, + interlace: Boolean(interlace), + palette: Boolean(colorType & constants4.COLORTYPE_PALETTE), + color: Boolean(colorType & constants4.COLORTYPE_COLOR), + alpha: Boolean(colorType & constants4.COLORTYPE_ALPHA), + bpp, + colorType + }); + this._handleChunkEnd(); + }; + Parser.prototype._handlePLTE = function(length) { + this.read(length, this._parsePLTE.bind(this)); + }; + Parser.prototype._parsePLTE = function(data) { + this._crc.write(data); + let entries = Math.floor(data.length / 3); + for (let i6 = 0; i6 < entries; i6++) { + this._palette.push([data[i6 * 3], data[i6 * 3 + 1], data[i6 * 3 + 2], 255]); + } + this.palette(this._palette); + this._handleChunkEnd(); + }; + Parser.prototype._handleTRNS = function(length) { + this.simpleTransparency(); + this.read(length, this._parseTRNS.bind(this)); + }; + Parser.prototype._parseTRNS = function(data) { + this._crc.write(data); + if (this._colorType === constants4.COLORTYPE_PALETTE_COLOR) { + if (this._palette.length === 0) { + this.error(new Error("Transparency chunk must be after palette")); + return; + } + if (data.length > this._palette.length) { + this.error(new Error("More transparent colors than palette size")); + return; + } + for (let i6 = 0; i6 < data.length; i6++) { + this._palette[i6][3] = data[i6]; + } + this.palette(this._palette); + } + if (this._colorType === constants4.COLORTYPE_GRAYSCALE) { + this.transColor([data.readUInt16BE(0)]); + } + if (this._colorType === constants4.COLORTYPE_COLOR) { + this.transColor([ + data.readUInt16BE(0), + data.readUInt16BE(2), + data.readUInt16BE(4) + ]); + } + this._handleChunkEnd(); + }; + Parser.prototype._handleGAMA = function(length) { + this.read(length, this._parseGAMA.bind(this)); + }; + Parser.prototype._parseGAMA = function(data) { + this._crc.write(data); + this.gamma(data.readUInt32BE(0) / constants4.GAMMA_DIVISION); + this._handleChunkEnd(); + }; + Parser.prototype._handleIDAT = function(length) { + if (!this._emittedHeadersFinished) { + this._emittedHeadersFinished = true; + this.headersFinished(); + } + this.read(-length, this._parseIDAT.bind(this, length)); + }; + Parser.prototype._parseIDAT = function(length, data) { + this._crc.write(data); + if (this._colorType === constants4.COLORTYPE_PALETTE_COLOR && this._palette.length === 0) { + throw new Error("Expected palette not found"); + } + this.inflateData(data); + let leftOverLength = length - data.length; + if (leftOverLength > 0) { + this._handleIDAT(leftOverLength); + } else { + this._handleChunkEnd(); + } + }; + Parser.prototype._handleIEND = function(length) { + this.read(length, this._parseIEND.bind(this)); + }; + Parser.prototype._parseIEND = function(data) { + this._crc.write(data); + this._hasIEND = true; + this._handleChunkEnd(); + if (this.finished) { + this.finished(); + } + }; + } +}); + +// ../node_modules/pngjs/lib/bitmapper.js +var require_bitmapper = __commonJS({ + "../node_modules/pngjs/lib/bitmapper.js"(exports2) { + "use strict"; + var interlaceUtils = require_interlace(); + var pixelBppMapper = [ + // 0 - dummy entry + function() { + }, + // 1 - L + // 0: 0, 1: 0, 2: 0, 3: 0xff + function(pxData, data, pxPos, rawPos) { + if (rawPos === data.length) { + throw new Error("Ran out of data"); + } + let pixel = data[rawPos]; + pxData[pxPos] = pixel; + pxData[pxPos + 1] = pixel; + pxData[pxPos + 2] = pixel; + pxData[pxPos + 3] = 255; + }, + // 2 - LA + // 0: 0, 1: 0, 2: 0, 3: 1 + function(pxData, data, pxPos, rawPos) { + if (rawPos + 1 >= data.length) { + throw new Error("Ran out of data"); + } + let pixel = data[rawPos]; + pxData[pxPos] = pixel; + pxData[pxPos + 1] = pixel; + pxData[pxPos + 2] = pixel; + pxData[pxPos + 3] = data[rawPos + 1]; + }, + // 3 - RGB + // 0: 0, 1: 1, 2: 2, 3: 0xff + function(pxData, data, pxPos, rawPos) { + if (rawPos + 2 >= data.length) { + throw new Error("Ran out of data"); + } + pxData[pxPos] = data[rawPos]; + pxData[pxPos + 1] = data[rawPos + 1]; + pxData[pxPos + 2] = data[rawPos + 2]; + pxData[pxPos + 3] = 255; + }, + // 4 - RGBA + // 0: 0, 1: 1, 2: 2, 3: 3 + function(pxData, data, pxPos, rawPos) { + if (rawPos + 3 >= data.length) { + throw new Error("Ran out of data"); + } + pxData[pxPos] = data[rawPos]; + pxData[pxPos + 1] = data[rawPos + 1]; + pxData[pxPos + 2] = data[rawPos + 2]; + pxData[pxPos + 3] = data[rawPos + 3]; + } ]; - let needsQuotes = false; - for (const char of arg) { - if (cmdSpecialChars.some((x6) => x6 === char)) { - needsQuotes = true; - break; + var pixelBppCustomMapper = [ + // 0 - dummy entry + function() { + }, + // 1 - L + // 0: 0, 1: 0, 2: 0, 3: 0xff + function(pxData, pixelData, pxPos, maxBit) { + let pixel = pixelData[0]; + pxData[pxPos] = pixel; + pxData[pxPos + 1] = pixel; + pxData[pxPos + 2] = pixel; + pxData[pxPos + 3] = maxBit; + }, + // 2 - LA + // 0: 0, 1: 0, 2: 0, 3: 1 + function(pxData, pixelData, pxPos) { + let pixel = pixelData[0]; + pxData[pxPos] = pixel; + pxData[pxPos + 1] = pixel; + pxData[pxPos + 2] = pixel; + pxData[pxPos + 3] = pixelData[1]; + }, + // 3 - RGB + // 0: 0, 1: 1, 2: 2, 3: 0xff + function(pxData, pixelData, pxPos, maxBit) { + pxData[pxPos] = pixelData[0]; + pxData[pxPos + 1] = pixelData[1]; + pxData[pxPos + 2] = pixelData[2]; + pxData[pxPos + 3] = maxBit; + }, + // 4 - RGBA + // 0: 0, 1: 1, 2: 2, 3: 3 + function(pxData, pixelData, pxPos) { + pxData[pxPos] = pixelData[0]; + pxData[pxPos + 1] = pixelData[1]; + pxData[pxPos + 2] = pixelData[2]; + pxData[pxPos + 3] = pixelData[3]; } + ]; + function bitRetriever(data, depth) { + let leftOver = []; + let i6 = 0; + function split() { + if (i6 === data.length) { + throw new Error("Ran out of data"); + } + let byte = data[i6]; + i6++; + let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1; + switch (depth) { + default: + throw new Error("unrecognised depth"); + case 16: + byte2 = data[i6]; + i6++; + leftOver.push((byte << 8) + byte2); + break; + case 4: + byte2 = byte & 15; + byte1 = byte >> 4; + leftOver.push(byte1, byte2); + break; + case 2: + byte4 = byte & 3; + byte3 = byte >> 2 & 3; + byte2 = byte >> 4 & 3; + byte1 = byte >> 6 & 3; + leftOver.push(byte1, byte2, byte3, byte4); + break; + case 1: + byte8 = byte & 1; + byte7 = byte >> 1 & 1; + byte6 = byte >> 2 & 1; + byte5 = byte >> 3 & 1; + byte4 = byte >> 4 & 1; + byte3 = byte >> 5 & 1; + byte2 = byte >> 6 & 1; + byte1 = byte >> 7 & 1; + leftOver.push(byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8); + break; + } + } + return { + get: function(count) { + while (leftOver.length < count) { + split(); + } + let returner = leftOver.slice(0, count); + leftOver = leftOver.slice(count); + return returner; + }, + resetAfterLine: function() { + leftOver.length = 0; + }, + end: function() { + if (i6 !== data.length) { + throw new Error("extra data found"); + } + } + }; } - if (!needsQuotes) { - return arg; - } - let reverse = '"'; - let quoteHit = true; - for (let i6 = arg.length; i6 > 0; i6--) { - reverse += arg[i6 - 1]; - if (quoteHit && arg[i6 - 1] === "\\") { - reverse += "\\"; - } else if (arg[i6 - 1] === '"') { - quoteHit = true; - reverse += '"'; + function mapImage8Bit(image2, pxData, getPxPos, bpp, data, rawPos) { + let imageWidth = image2.width; + let imageHeight = image2.height; + let imagePass = image2.index; + for (let y4 = 0; y4 < imageHeight; y4++) { + for (let x7 = 0; x7 < imageWidth; x7++) { + let pxPos = getPxPos(x7, y4, imagePass); + pixelBppMapper[bpp](pxData, data, pxPos, rawPos); + rawPos += bpp; + } + } + return rawPos; + } + function mapImageCustomBit(image2, pxData, getPxPos, bpp, bits, maxBit) { + let imageWidth = image2.width; + let imageHeight = image2.height; + let imagePass = image2.index; + for (let y4 = 0; y4 < imageHeight; y4++) { + for (let x7 = 0; x7 < imageWidth; x7++) { + let pixelData = bits.get(bpp); + let pxPos = getPxPos(x7, y4, imagePass); + pixelBppCustomMapper[bpp](pxData, pixelData, pxPos, maxBit); + } + bits.resetAfterLine(); + } + } + exports2.dataToBitMap = function(data, bitmapInfo) { + let width = bitmapInfo.width; + let height = bitmapInfo.height; + let depth = bitmapInfo.depth; + let bpp = bitmapInfo.bpp; + let interlace = bitmapInfo.interlace; + let bits; + if (depth !== 8) { + bits = bitRetriever(data, depth); + } + let pxData; + if (depth <= 8) { + pxData = Buffer.alloc(width * height * 4); } else { - quoteHit = false; + pxData = new Uint16Array(width * height * 4); + } + let maxBit = Math.pow(2, depth) - 1; + let rawPos = 0; + let images; + let getPxPos; + if (interlace) { + images = interlaceUtils.getImagePasses(width, height); + getPxPos = interlaceUtils.getInterlaceIterator(width, height); + } else { + let nonInterlacedPxPos = 0; + getPxPos = function() { + let returner = nonInterlacedPxPos; + nonInterlacedPxPos += 4; + return returner; + }; + images = [{ width, height }]; + } + for (let imageIndex = 0; imageIndex < images.length; imageIndex++) { + if (depth === 8) { + rawPos = mapImage8Bit( + images[imageIndex], + pxData, + getPxPos, + bpp, + data, + rawPos + ); + } else { + mapImageCustomBit( + images[imageIndex], + pxData, + getPxPos, + bpp, + bits, + maxBit + ); + } } - } - reverse += '"'; - return reverse.split("").reverse().join(""); + if (depth === 8) { + if (rawPos !== data.length) { + throw new Error("extra data found"); + } + } else { + bits.end(); + } + return pxData; + }; } - _uvQuoteCmdArg(arg) { - if (!arg) { - return '""'; +}); + +// ../node_modules/pngjs/lib/format-normaliser.js +var require_format_normaliser = __commonJS({ + "../node_modules/pngjs/lib/format-normaliser.js"(exports2, module2) { + "use strict"; + function dePalette(indata, outdata, width, height, palette2) { + let pxPos = 0; + for (let y4 = 0; y4 < height; y4++) { + for (let x7 = 0; x7 < width; x7++) { + let color = palette2[indata[pxPos]]; + if (!color) { + throw new Error("index " + indata[pxPos] + " not in palette"); + } + for (let i6 = 0; i6 < 4; i6++) { + outdata[pxPos + i6] = color[i6]; + } + pxPos += 4; + } + } } - if (!arg.includes(" ") && !arg.includes(" ") && !arg.includes('"')) { - return arg; + function replaceTransparentColor(indata, outdata, width, height, transColor) { + let pxPos = 0; + for (let y4 = 0; y4 < height; y4++) { + for (let x7 = 0; x7 < width; x7++) { + let makeTrans = false; + if (transColor.length === 1) { + if (transColor[0] === indata[pxPos]) { + makeTrans = true; + } + } else if (transColor[0] === indata[pxPos] && transColor[1] === indata[pxPos + 1] && transColor[2] === indata[pxPos + 2]) { + makeTrans = true; + } + if (makeTrans) { + for (let i6 = 0; i6 < 4; i6++) { + outdata[pxPos + i6] = 0; + } + } + pxPos += 4; + } + } } - if (!arg.includes('"') && !arg.includes("\\")) { - return `"${arg}"`; + function scaleDepth(indata, outdata, width, height, depth) { + let maxOutSample = 255; + let maxInSample = Math.pow(2, depth) - 1; + let pxPos = 0; + for (let y4 = 0; y4 < height; y4++) { + for (let x7 = 0; x7 < width; x7++) { + for (let i6 = 0; i6 < 4; i6++) { + outdata[pxPos + i6] = Math.floor( + indata[pxPos + i6] * maxOutSample / maxInSample + 0.5 + ); + } + pxPos += 4; + } + } } - let reverse = '"'; - let quoteHit = true; - for (let i6 = arg.length; i6 > 0; i6--) { - reverse += arg[i6 - 1]; - if (quoteHit && arg[i6 - 1] === "\\") { - reverse += "\\"; - } else if (arg[i6 - 1] === '"') { - quoteHit = true; - reverse += "\\"; + module2.exports = function(indata, imageData, skipRescale = false) { + let depth = imageData.depth; + let width = imageData.width; + let height = imageData.height; + let colorType = imageData.colorType; + let transColor = imageData.transColor; + let palette2 = imageData.palette; + let outdata = indata; + if (colorType === 3) { + dePalette(indata, outdata, width, height, palette2); } else { - quoteHit = false; + if (transColor) { + replaceTransparentColor(indata, outdata, width, height, transColor); + } + if (depth !== 8 && !skipRescale) { + if (depth === 16) { + outdata = Buffer.alloc(width * height * 4); + } + scaleDepth(indata, outdata, width, height, depth); + } } - } - reverse += '"'; - return reverse.split("").reverse().join(""); - } - _cloneExecOptions(options) { - options = options || {}; - const result = { - cwd: options.cwd || process.cwd(), - env: options.env || process.env, - silent: options.silent || false, - windowsVerbatimArguments: options.windowsVerbatimArguments || false, - failOnStdErr: options.failOnStdErr || false, - ignoreReturnCode: options.ignoreReturnCode || false, - delay: options.delay || 1e4 + return outdata; }; - result.outStream = options.outStream || process.stdout; - result.errStream = options.errStream || process.stderr; - return result; } - _getSpawnOptions(options, toolPath) { - options = options || {}; - const result = {}; - result.cwd = options.cwd; - result.env = options.env; - result["windowsVerbatimArguments"] = options.windowsVerbatimArguments || this._isCmdFile(); - if (options.windowsVerbatimArguments) { - result.argv0 = `"${toolPath}"`; - } - return result; - } - /** - * Exec a tool. - * Output will be streamed to the live console. - * Returns promise with return code - * - * @param tool path to tool to exec - * @param options optional exec options. See ExecOptions - * @returns number - */ - exec() { - return __awaiter4(this, void 0, void 0, function* () { - if (!isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS2 && this.toolPath.includes("\\"))) { - this.toolPath = path3.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); +}); + +// ../node_modules/pngjs/lib/parser-async.js +var require_parser_async = __commonJS({ + "../node_modules/pngjs/lib/parser-async.js"(exports2, module2) { + "use strict"; + var util17 = require("util"); + var zlib2 = require("zlib"); + var ChunkStream = require_chunkstream(); + var FilterAsync = require_filter_parse_async(); + var Parser = require_parser(); + var bitmapper = require_bitmapper(); + var formatNormaliser = require_format_normaliser(); + var ParserAsync = module2.exports = function(options) { + ChunkStream.call(this); + this._parser = new Parser(options, { + read: this.read.bind(this), + error: this._handleError.bind(this), + metadata: this._handleMetaData.bind(this), + gamma: this.emit.bind(this, "gamma"), + palette: this._handlePalette.bind(this), + transColor: this._handleTransColor.bind(this), + finished: this._finished.bind(this), + inflateData: this._inflateData.bind(this), + simpleTransparency: this._simpleTransparency.bind(this), + headersFinished: this._headersFinished.bind(this) + }); + this._options = options; + this.writable = true; + this._parser.start(); + }; + util17.inherits(ParserAsync, ChunkStream); + ParserAsync.prototype._handleError = function(err) { + this.emit("error", err); + this.writable = false; + this.destroy(); + if (this._inflate && this._inflate.destroy) { + this._inflate.destroy(); } - this.toolPath = yield which(this.toolPath, true); - return new Promise((resolve2, reject) => __awaiter4(this, void 0, void 0, function* () { - this._debug(`exec tool: ${this.toolPath}`); - this._debug("arguments:"); - for (const arg of this.args) { - this._debug(` ${arg}`); - } - const optionsNonNull = this._cloneExecOptions(this.options); - if (!optionsNonNull.silent && optionsNonNull.outStream) { - optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os2.EOL); - } - const state2 = new ExecState(optionsNonNull, this.toolPath); - state2.on("debug", (message) => { - this._debug(message); + if (this._filter) { + this._filter.destroy(); + this._filter.on("error", function() { }); - if (this.options.cwd && !(yield exists(this.options.cwd))) { - return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`)); - } - const fileName = this._getSpawnFileName(); - const cp2 = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); - let stdbuffer = ""; - if (cp2.stdout) { - cp2.stdout.on("data", (data) => { - if (this.options.listeners && this.options.listeners.stdout) { - this.options.listeners.stdout(data); - } - if (!optionsNonNull.silent && optionsNonNull.outStream) { - optionsNonNull.outStream.write(data); + } + this.errord = true; + }; + ParserAsync.prototype._inflateData = function(data) { + if (!this._inflate) { + if (this._bitmapInfo.interlace) { + this._inflate = zlib2.createInflate(); + this._inflate.on("error", this.emit.bind(this, "error")); + this._filter.on("complete", this._complete.bind(this)); + this._inflate.pipe(this._filter); + } else { + let rowSize = (this._bitmapInfo.width * this._bitmapInfo.bpp * this._bitmapInfo.depth + 7 >> 3) + 1; + let imageSize = rowSize * this._bitmapInfo.height; + let chunkSize = Math.max(imageSize, zlib2.Z_MIN_CHUNK); + this._inflate = zlib2.createInflate({ chunkSize }); + let leftToInflate = imageSize; + let emitError = this.emit.bind(this, "error"); + this._inflate.on("error", function(err) { + if (!leftToInflate) { + return; } - stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => { - if (this.options.listeners && this.options.listeners.stdline) { - this.options.listeners.stdline(line); - } - }); + emitError(err); }); - } - let errbuffer = ""; - if (cp2.stderr) { - cp2.stderr.on("data", (data) => { - state2.processStderr = true; - if (this.options.listeners && this.options.listeners.stderr) { - this.options.listeners.stderr(data); + this._filter.on("complete", this._complete.bind(this)); + let filterWrite = this._filter.write.bind(this._filter); + this._inflate.on("data", function(chunk) { + if (!leftToInflate) { + return; } - if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) { - const s6 = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream; - s6.write(data); + if (chunk.length > leftToInflate) { + chunk = chunk.slice(0, leftToInflate); } - errbuffer = this._processLineBuffer(data, errbuffer, (line) => { - if (this.options.listeners && this.options.listeners.errline) { - this.options.listeners.errline(line); - } - }); + leftToInflate -= chunk.length; + filterWrite(chunk); }); + this._inflate.on("end", this._filter.end.bind(this._filter)); } - cp2.on("error", (err) => { - state2.processError = err.message; - state2.processExited = true; - state2.processClosed = true; - state2.CheckComplete(); - }); - cp2.on("exit", (code) => { - state2.processExitCode = code; - state2.processExited = true; - this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); - state2.CheckComplete(); - }); - cp2.on("close", (code) => { - state2.processExitCode = code; - state2.processExited = true; - state2.processClosed = true; - this._debug(`STDIO streams have closed for tool '${this.toolPath}'`); - state2.CheckComplete(); - }); - state2.on("done", (error2, exitCode) => { - if (stdbuffer.length > 0) { - this.emit("stdline", stdbuffer); - } - if (errbuffer.length > 0) { - this.emit("errline", errbuffer); - } - cp2.removeAllListeners(); - if (error2) { - reject(error2); - } else { - resolve2(exitCode); + } + this._inflate.write(data); + }; + ParserAsync.prototype._handleMetaData = function(metaData) { + this._metaData = metaData; + this._bitmapInfo = Object.create(metaData); + this._filter = new FilterAsync(this._bitmapInfo); + }; + ParserAsync.prototype._handleTransColor = function(transColor) { + this._bitmapInfo.transColor = transColor; + }; + ParserAsync.prototype._handlePalette = function(palette2) { + this._bitmapInfo.palette = palette2; + }; + ParserAsync.prototype._simpleTransparency = function() { + this._metaData.alpha = true; + }; + ParserAsync.prototype._headersFinished = function() { + this.emit("metadata", this._metaData); + }; + ParserAsync.prototype._finished = function() { + if (this.errord) { + return; + } + if (!this._inflate) { + this.emit("error", "No Inflate block"); + } else { + this._inflate.end(); + } + }; + ParserAsync.prototype._complete = function(filteredData) { + if (this.errord) { + return; + } + let normalisedBitmapData; + try { + let bitmapData = bitmapper.dataToBitMap(filteredData, this._bitmapInfo); + normalisedBitmapData = formatNormaliser( + bitmapData, + this._bitmapInfo, + this._options.skipRescale + ); + bitmapData = null; + } catch (ex) { + this._handleError(ex); + return; + } + this.emit("parsed", normalisedBitmapData); + }; + } +}); + +// ../node_modules/pngjs/lib/bitpacker.js +var require_bitpacker = __commonJS({ + "../node_modules/pngjs/lib/bitpacker.js"(exports2, module2) { + "use strict"; + var constants4 = require_constants6(); + module2.exports = function(dataIn, width, height, options) { + let outHasAlpha = [constants4.COLORTYPE_COLOR_ALPHA, constants4.COLORTYPE_ALPHA].indexOf( + options.colorType + ) !== -1; + if (options.colorType === options.inputColorType) { + let bigEndian = (function() { + let buffer = new ArrayBuffer(2); + new DataView(buffer).setInt16( + 0, + 256, + true + /* littleEndian */ + ); + return new Int16Array(buffer)[0] !== 256; + })(); + if (options.bitDepth === 8 || options.bitDepth === 16 && bigEndian) { + return dataIn; + } + } + let data = options.bitDepth !== 16 ? dataIn : new Uint16Array(dataIn.buffer); + let maxValue = 255; + let inBpp = constants4.COLORTYPE_TO_BPP_MAP[options.inputColorType]; + if (inBpp === 4 && !options.inputHasAlpha) { + inBpp = 3; + } + let outBpp = constants4.COLORTYPE_TO_BPP_MAP[options.colorType]; + if (options.bitDepth === 16) { + maxValue = 65535; + outBpp *= 2; + } + let outData = Buffer.alloc(width * height * outBpp); + let inIndex = 0; + let outIndex = 0; + let bgColor = options.bgColor || {}; + if (bgColor.red === void 0) { + bgColor.red = maxValue; + } + if (bgColor.green === void 0) { + bgColor.green = maxValue; + } + if (bgColor.blue === void 0) { + bgColor.blue = maxValue; + } + function getRGBA() { + let red; + let green; + let blue; + let alpha = maxValue; + switch (options.inputColorType) { + case constants4.COLORTYPE_COLOR_ALPHA: + alpha = data[inIndex + 3]; + red = data[inIndex]; + green = data[inIndex + 1]; + blue = data[inIndex + 2]; + break; + case constants4.COLORTYPE_COLOR: + red = data[inIndex]; + green = data[inIndex + 1]; + blue = data[inIndex + 2]; + break; + case constants4.COLORTYPE_ALPHA: + alpha = data[inIndex + 1]; + red = data[inIndex]; + green = red; + blue = red; + break; + case constants4.COLORTYPE_GRAYSCALE: + red = data[inIndex]; + green = red; + blue = red; + break; + default: + throw new Error( + "input color type:" + options.inputColorType + " is not supported at present" + ); + } + if (options.inputHasAlpha) { + if (!outHasAlpha) { + alpha /= maxValue; + red = Math.min( + Math.max(Math.round((1 - alpha) * bgColor.red + alpha * red), 0), + maxValue + ); + green = Math.min( + Math.max(Math.round((1 - alpha) * bgColor.green + alpha * green), 0), + maxValue + ); + blue = Math.min( + Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0), + maxValue + ); } - }); - if (this.options.input) { - if (!cp2.stdin) { - throw new Error("child process missing stdin"); + } + return { red, green, blue, alpha }; + } + for (let y4 = 0; y4 < height; y4++) { + for (let x7 = 0; x7 < width; x7++) { + let rgba = getRGBA(data, inIndex); + switch (options.colorType) { + case constants4.COLORTYPE_COLOR_ALPHA: + case constants4.COLORTYPE_COLOR: + if (options.bitDepth === 8) { + outData[outIndex] = rgba.red; + outData[outIndex + 1] = rgba.green; + outData[outIndex + 2] = rgba.blue; + if (outHasAlpha) { + outData[outIndex + 3] = rgba.alpha; + } + } else { + outData.writeUInt16BE(rgba.red, outIndex); + outData.writeUInt16BE(rgba.green, outIndex + 2); + outData.writeUInt16BE(rgba.blue, outIndex + 4); + if (outHasAlpha) { + outData.writeUInt16BE(rgba.alpha, outIndex + 6); + } + } + break; + case constants4.COLORTYPE_ALPHA: + case constants4.COLORTYPE_GRAYSCALE: { + let grayscale = (rgba.red + rgba.green + rgba.blue) / 3; + if (options.bitDepth === 8) { + outData[outIndex] = grayscale; + if (outHasAlpha) { + outData[outIndex + 1] = rgba.alpha; + } + } else { + outData.writeUInt16BE(grayscale, outIndex); + if (outHasAlpha) { + outData.writeUInt16BE(rgba.alpha, outIndex + 2); + } + } + break; + } + default: + throw new Error("unrecognised color Type " + options.colorType); } - cp2.stdin.end(this.options.input); + inIndex += inBpp; + outIndex += outBpp; } - })); - }); - } -}; -function argStringToArray(argString) { - const args = []; - let inQuotes = false; - let escaped = false; - let arg = ""; - function append(c6) { - if (escaped && c6 !== '"') { - arg += "\\"; - } - arg += c6; - escaped = false; + } + return outData; + }; } - for (let i6 = 0; i6 < argString.length; i6++) { - const c6 = argString.charAt(i6); - if (c6 === '"') { - if (!escaped) { - inQuotes = !inQuotes; - } else { - append(c6); +}); + +// ../node_modules/pngjs/lib/filter-pack.js +var require_filter_pack = __commonJS({ + "../node_modules/pngjs/lib/filter-pack.js"(exports2, module2) { + "use strict"; + var paethPredictor = require_paeth_predictor(); + function filterNone(pxData, pxPos, byteWidth, rawData, rawPos) { + for (let x7 = 0; x7 < byteWidth; x7++) { + rawData[rawPos + x7] = pxData[pxPos + x7]; } - continue; - } - if (c6 === "\\" && escaped) { - append(c6); - continue; - } - if (c6 === "\\" && inQuotes) { - escaped = true; - continue; } - if (c6 === " " && !inQuotes) { - if (arg.length > 0) { - args.push(arg); - arg = ""; + function filterSumNone(pxData, pxPos, byteWidth) { + let sum = 0; + let length = pxPos + byteWidth; + for (let i6 = pxPos; i6 < length; i6++) { + sum += Math.abs(pxData[i6]); } - continue; + return sum; } - append(c6); - } - if (arg.length > 0) { - args.push(arg.trim()); - } - return args; -} -var ExecState = class _ExecState extends events.EventEmitter { - constructor(options, toolPath) { - super(); - this.processClosed = false; - this.processError = ""; - this.processExitCode = 0; - this.processExited = false; - this.processStderr = false; - this.delay = 1e4; - this.done = false; - this.timeout = null; - if (!toolPath) { - throw new Error("toolPath must not be empty"); + function filterSub(pxData, pxPos, byteWidth, rawData, rawPos, bpp) { + for (let x7 = 0; x7 < byteWidth; x7++) { + let left = x7 >= bpp ? pxData[pxPos + x7 - bpp] : 0; + let val = pxData[pxPos + x7] - left; + rawData[rawPos + x7] = val; + } } - this.options = options; - this.toolPath = toolPath; - if (options.delay) { - this.delay = options.delay; + function filterSumSub(pxData, pxPos, byteWidth, bpp) { + let sum = 0; + for (let x7 = 0; x7 < byteWidth; x7++) { + let left = x7 >= bpp ? pxData[pxPos + x7 - bpp] : 0; + let val = pxData[pxPos + x7] - left; + sum += Math.abs(val); + } + return sum; } - } - CheckComplete() { - if (this.done) { - return; + function filterUp(pxData, pxPos, byteWidth, rawData, rawPos) { + for (let x7 = 0; x7 < byteWidth; x7++) { + let up = pxPos > 0 ? pxData[pxPos + x7 - byteWidth] : 0; + let val = pxData[pxPos + x7] - up; + rawData[rawPos + x7] = val; + } } - if (this.processClosed) { - this._setResult(); - } else if (this.processExited) { - this.timeout = (0, import_timers.setTimeout)(_ExecState.HandleTimeout, this.delay, this); + function filterSumUp(pxData, pxPos, byteWidth) { + let sum = 0; + let length = pxPos + byteWidth; + for (let x7 = pxPos; x7 < length; x7++) { + let up = pxPos > 0 ? pxData[x7 - byteWidth] : 0; + let val = pxData[x7] - up; + sum += Math.abs(val); + } + return sum; } - } - _debug(message) { - this.emit("debug", message); - } - _setResult() { - let error2; - if (this.processExited) { - if (this.processError) { - error2 = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`); - } else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) { - error2 = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`); - } else if (this.processStderr && this.options.failOnStdErr) { - error2 = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`); + function filterAvg(pxData, pxPos, byteWidth, rawData, rawPos, bpp) { + for (let x7 = 0; x7 < byteWidth; x7++) { + let left = x7 >= bpp ? pxData[pxPos + x7 - bpp] : 0; + let up = pxPos > 0 ? pxData[pxPos + x7 - byteWidth] : 0; + let val = pxData[pxPos + x7] - (left + up >> 1); + rawData[rawPos + x7] = val; } } - if (this.timeout) { - clearTimeout(this.timeout); - this.timeout = null; + function filterSumAvg(pxData, pxPos, byteWidth, bpp) { + let sum = 0; + for (let x7 = 0; x7 < byteWidth; x7++) { + let left = x7 >= bpp ? pxData[pxPos + x7 - bpp] : 0; + let up = pxPos > 0 ? pxData[pxPos + x7 - byteWidth] : 0; + let val = pxData[pxPos + x7] - (left + up >> 1); + sum += Math.abs(val); + } + return sum; } - this.done = true; - this.emit("done", error2, this.processExitCode); - } - static HandleTimeout(state2) { - if (state2.done) { - return; + function filterPaeth(pxData, pxPos, byteWidth, rawData, rawPos, bpp) { + for (let x7 = 0; x7 < byteWidth; x7++) { + let left = x7 >= bpp ? pxData[pxPos + x7 - bpp] : 0; + let up = pxPos > 0 ? pxData[pxPos + x7 - byteWidth] : 0; + let upleft = pxPos > 0 && x7 >= bpp ? pxData[pxPos + x7 - (byteWidth + bpp)] : 0; + let val = pxData[pxPos + x7] - paethPredictor(left, up, upleft); + rawData[rawPos + x7] = val; + } } - if (!state2.processClosed && state2.processExited) { - const message = `The STDIO streams did not close within ${state2.delay / 1e3} seconds of the exit event from process '${state2.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`; - state2._debug(message); + function filterSumPaeth(pxData, pxPos, byteWidth, bpp) { + let sum = 0; + for (let x7 = 0; x7 < byteWidth; x7++) { + let left = x7 >= bpp ? pxData[pxPos + x7 - bpp] : 0; + let up = pxPos > 0 ? pxData[pxPos + x7 - byteWidth] : 0; + let upleft = pxPos > 0 && x7 >= bpp ? pxData[pxPos + x7 - (byteWidth + bpp)] : 0; + let val = pxData[pxPos + x7] - paethPredictor(left, up, upleft); + sum += Math.abs(val); + } + return sum; } - state2._setResult(); + var filters = { + 0: filterNone, + 1: filterSub, + 2: filterUp, + 3: filterAvg, + 4: filterPaeth + }; + var filterSums = { + 0: filterSumNone, + 1: filterSumSub, + 2: filterSumUp, + 3: filterSumAvg, + 4: filterSumPaeth + }; + module2.exports = function(pxData, width, height, options, bpp) { + let filterTypes; + if (!("filterType" in options) || options.filterType === -1) { + filterTypes = [0, 1, 2, 3, 4]; + } else if (typeof options.filterType === "number") { + filterTypes = [options.filterType]; + } else { + throw new Error("unrecognised filter types"); + } + if (options.bitDepth === 16) { + bpp *= 2; + } + let byteWidth = width * bpp; + let rawPos = 0; + let pxPos = 0; + let rawData = Buffer.alloc((byteWidth + 1) * height); + let sel = filterTypes[0]; + for (let y4 = 0; y4 < height; y4++) { + if (filterTypes.length > 1) { + let min = Infinity; + for (let i6 = 0; i6 < filterTypes.length; i6++) { + let sum = filterSums[filterTypes[i6]](pxData, pxPos, byteWidth, bpp); + if (sum < min) { + sel = filterTypes[i6]; + min = sum; + } + } + } + rawData[rawPos] = sel; + rawPos++; + filters[sel](pxData, pxPos, byteWidth, rawData, rawPos, bpp); + rawPos += byteWidth; + pxPos += byteWidth; + } + return rawData; + }; } -}; +}); -// ../node_modules/@actions/exec/lib/exec.js -var __awaiter5 = function(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); +// ../node_modules/pngjs/lib/packer.js +var require_packer = __commonJS({ + "../node_modules/pngjs/lib/packer.js"(exports2, module2) { + "use strict"; + var constants4 = require_constants6(); + var CrcStream = require_crc(); + var bitPacker = require_bitpacker(); + var filter2 = require_filter_pack(); + var zlib2 = require("zlib"); + var Packer = module2.exports = function(options) { + this._options = options; + options.deflateChunkSize = options.deflateChunkSize || 32 * 1024; + options.deflateLevel = options.deflateLevel != null ? options.deflateLevel : 9; + options.deflateStrategy = options.deflateStrategy != null ? options.deflateStrategy : 3; + options.inputHasAlpha = options.inputHasAlpha != null ? options.inputHasAlpha : true; + options.deflateFactory = options.deflateFactory || zlib2.createDeflate; + options.bitDepth = options.bitDepth || 8; + options.colorType = typeof options.colorType === "number" ? options.colorType : constants4.COLORTYPE_COLOR_ALPHA; + options.inputColorType = typeof options.inputColorType === "number" ? options.inputColorType : constants4.COLORTYPE_COLOR_ALPHA; + if ([ + constants4.COLORTYPE_GRAYSCALE, + constants4.COLORTYPE_COLOR, + constants4.COLORTYPE_COLOR_ALPHA, + constants4.COLORTYPE_ALPHA + ].indexOf(options.colorType) === -1) { + throw new Error( + "option color type:" + options.colorType + " is not supported at present" + ); + } + if ([ + constants4.COLORTYPE_GRAYSCALE, + constants4.COLORTYPE_COLOR, + constants4.COLORTYPE_COLOR_ALPHA, + constants4.COLORTYPE_ALPHA + ].indexOf(options.inputColorType) === -1) { + throw new Error( + "option input color type:" + options.inputColorType + " is not supported at present" + ); + } + if (options.bitDepth !== 8 && options.bitDepth !== 16) { + throw new Error( + "option bit depth:" + options.bitDepth + " is not supported at present" + ); + } + }; + Packer.prototype.getDeflateOptions = function() { + return { + chunkSize: this._options.deflateChunkSize, + level: this._options.deflateLevel, + strategy: this._options.deflateStrategy + }; + }; + Packer.prototype.createDeflate = function() { + return this._options.deflateFactory(this.getDeflateOptions()); + }; + Packer.prototype.filterData = function(data, width, height) { + let packedData = bitPacker(data, width, height, this._options); + let bpp = constants4.COLORTYPE_TO_BPP_MAP[this._options.colorType]; + let filteredData = filter2(packedData, width, height, this._options, bpp); + return filteredData; + }; + Packer.prototype._packChunk = function(type, data) { + let len = data ? data.length : 0; + let buf = Buffer.alloc(len + 12); + buf.writeUInt32BE(len, 0); + buf.writeUInt32BE(type, 4); + if (data) { + data.copy(buf, 8); + } + buf.writeInt32BE( + CrcStream.crc32(buf.slice(4, buf.length - 4)), + buf.length - 4 + ); + return buf; + }; + Packer.prototype.packGAMA = function(gamma) { + let buf = Buffer.alloc(4); + buf.writeUInt32BE(Math.floor(gamma * constants4.GAMMA_DIVISION), 0); + return this._packChunk(constants4.TYPE_gAMA, buf); + }; + Packer.prototype.packIHDR = function(width, height) { + let buf = Buffer.alloc(13); + buf.writeUInt32BE(width, 0); + buf.writeUInt32BE(height, 4); + buf[8] = this._options.bitDepth; + buf[9] = this._options.colorType; + buf[10] = 0; + buf[11] = 0; + buf[12] = 0; + return this._packChunk(constants4.TYPE_IHDR, buf); + }; + Packer.prototype.packIDAT = function(data) { + return this._packChunk(constants4.TYPE_IDAT, data); + }; + Packer.prototype.packIEND = function() { + return this._packChunk(constants4.TYPE_IEND, null); + }; + } +}); + +// ../node_modules/pngjs/lib/packer-async.js +var require_packer_async = __commonJS({ + "../node_modules/pngjs/lib/packer-async.js"(exports2, module2) { + "use strict"; + var util17 = require("util"); + var Stream2 = require("stream"); + var constants4 = require_constants6(); + var Packer = require_packer(); + var PackerAsync = module2.exports = function(opt) { + Stream2.call(this); + let options = opt || {}; + this._packer = new Packer(options); + this._deflate = this._packer.createDeflate(); + this.readable = true; + }; + util17.inherits(PackerAsync, Stream2); + PackerAsync.prototype.pack = function(data, width, height, gamma) { + this.emit("data", Buffer.from(constants4.PNG_SIGNATURE)); + this.emit("data", this._packer.packIHDR(width, height)); + if (gamma) { + this.emit("data", this._packer.packGAMA(gamma)); + } + let filteredData = this._packer.filterData(data, width, height); + this._deflate.on("error", this.emit.bind(this, "error")); + this._deflate.on( + "data", + function(compressedData) { + this.emit("data", this._packer.packIDAT(compressedData)); + }.bind(this) + ); + this._deflate.on( + "end", + function() { + this.emit("data", this._packer.packIEND()); + this.emit("end"); + }.bind(this) + ); + this._deflate.end(filteredData); + }; } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e6) { - reject(e6); +}); + +// ../node_modules/pngjs/lib/sync-inflate.js +var require_sync_inflate = __commonJS({ + "../node_modules/pngjs/lib/sync-inflate.js"(exports2, module2) { + "use strict"; + var assert = require("assert").ok; + var zlib2 = require("zlib"); + var util17 = require("util"); + var kMaxLength = require("buffer").kMaxLength; + function Inflate(opts) { + if (!(this instanceof Inflate)) { + return new Inflate(opts); } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); + if (opts && opts.chunkSize < zlib2.Z_MIN_CHUNK) { + opts.chunkSize = zlib2.Z_MIN_CHUNK; + } + zlib2.Inflate.call(this, opts); + this._offset = this._offset === void 0 ? this._outOffset : this._offset; + this._buffer = this._buffer || this._outBuffer; + if (opts && opts.maxLength != null) { + this._maxLength = opts.maxLength; } } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); + function createInflate(opts) { + return new Inflate(opts); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -function exec(commandLine, args, options) { - return __awaiter5(this, void 0, void 0, function* () { - const commandArgs = argStringToArray(commandLine); - if (commandArgs.length === 0) { - throw new Error(`Parameter 'commandLine' cannot be null or empty.`); + function _close(engine, callback) { + if (callback) { + process.nextTick(callback); + } + if (!engine._handle) { + return; + } + engine._handle.close(); + engine._handle = null; + } + Inflate.prototype._processChunk = function(chunk, flushFlag, asyncCb) { + if (typeof asyncCb === "function") { + return zlib2.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb); + } + let self2 = this; + let availInBefore = chunk && chunk.length; + let availOutBefore = this._chunkSize - this._offset; + let leftToInflate = this._maxLength; + let inOff = 0; + let buffers = []; + let nread = 0; + let error2; + this.on("error", function(err) { + error2 = err; + }); + function handleChunk(availInAfter, availOutAfter) { + if (self2._hadError) { + return; + } + let have = availOutBefore - availOutAfter; + assert(have >= 0, "have should not go down"); + if (have > 0) { + let out = self2._buffer.slice(self2._offset, self2._offset + have); + self2._offset += have; + if (out.length > leftToInflate) { + out = out.slice(0, leftToInflate); + } + buffers.push(out); + nread += out.length; + leftToInflate -= out.length; + if (leftToInflate === 0) { + return false; + } + } + if (availOutAfter === 0 || self2._offset >= self2._chunkSize) { + availOutBefore = self2._chunkSize; + self2._offset = 0; + self2._buffer = Buffer.allocUnsafe(self2._chunkSize); + } + if (availOutAfter === 0) { + inOff += availInBefore - availInAfter; + availInBefore = availInAfter; + return true; + } + return false; + } + assert(this._handle, "zlib binding closed"); + let res; + do { + res = this._handle.writeSync( + flushFlag, + chunk, + // in + inOff, + // in_off + availInBefore, + // in_len + this._buffer, + // out + this._offset, + //out_off + availOutBefore + ); + res = res || this._writeState; + } while (!this._hadError && handleChunk(res[0], res[1])); + if (this._hadError) { + throw error2; + } + if (nread >= kMaxLength) { + _close(this); + throw new RangeError( + "Cannot create final Buffer. It would be larger than 0x" + kMaxLength.toString(16) + " bytes" + ); + } + let buf = Buffer.concat(buffers, nread); + _close(this); + return buf; + }; + util17.inherits(Inflate, zlib2.Inflate); + function zlibBufferSync(engine, buffer) { + if (typeof buffer === "string") { + buffer = Buffer.from(buffer); + } + if (!(buffer instanceof Buffer)) { + throw new TypeError("Not a string or buffer"); + } + let flushFlag = engine._finishFlushFlag; + if (flushFlag == null) { + flushFlag = zlib2.Z_FINISH; + } + return engine._processChunk(buffer, flushFlag); } - const toolPath = commandArgs[0]; - args = commandArgs.slice(1).concat(args || []); - const runner = new ToolRunner(toolPath, args, options); - return runner.exec(); - }); -} - -// ../node_modules/@actions/core/lib/platform.js -var platform = import_os2.default.platform(); -var arch = import_os2.default.arch(); - -// ../node_modules/@actions/core/lib/core.js -var ExitCode; -(function(ExitCode2) { - ExitCode2[ExitCode2["Success"] = 0] = "Success"; - ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; -})(ExitCode || (ExitCode = {})); -function getInput(name, options) { - const val = process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; - if (options && options.required && !val) { - throw new Error(`Input required and not supplied: ${name}`); - } - if (options && options.trimWhitespace === false) { - return val; - } - return val.trim(); -} -function getMultilineInput(name, options) { - const inputs = getInput(name, options).split("\n").filter((x6) => x6 !== ""); - if (options && options.trimWhitespace === false) { - return inputs; + function inflateSync(buffer, opts) { + return zlibBufferSync(new Inflate(opts), buffer); + } + module2.exports = exports2 = inflateSync; + exports2.Inflate = Inflate; + exports2.createInflate = createInflate; + exports2.inflateSync = inflateSync; } - return inputs.map((input) => input.trim()); -} -function getBooleanInput(name, options) { - const trueValue = ["true", "True", "TRUE"]; - const falseValue = ["false", "False", "FALSE"]; - const val = getInput(name, options); - if (trueValue.includes(val)) - return true; - if (falseValue.includes(val)) - return false; - throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name} -Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); -} -function setFailed(message) { - process.exitCode = ExitCode.Failure; - error(message); -} -function error(message, properties = {}) { - issueCommand("error", toCommandProperties(properties), message instanceof Error ? message.toString() : message); -} -function warning(message, properties = {}) { - issueCommand("warning", toCommandProperties(properties), message instanceof Error ? message.toString() : message); -} -function info(message) { - process.stdout.write(message + os4.EOL); -} +}); -// ../node_modules/@aws-sdk/middleware-expect-continue/dist-es/index.js -init_dist_es2(); -function addExpectContinueMiddleware(options) { - return (next) => async (args) => { - const { request: request4 } = args; - if (options.expectContinueHeader !== false && HttpRequest.isInstance(request4) && request4.body && options.runtime === "node" && options.requestHandler?.constructor?.name !== "FetchHttpHandler") { - let sendHeader = true; - if (typeof options.expectContinueHeader === "number") { - try { - const bodyLength = Number(request4.headers?.["content-length"]) ?? options.bodyLengthChecker?.(request4.body) ?? Infinity; - sendHeader = bodyLength >= options.expectContinueHeader; - } catch (e6) { +// ../node_modules/pngjs/lib/sync-reader.js +var require_sync_reader = __commonJS({ + "../node_modules/pngjs/lib/sync-reader.js"(exports2, module2) { + "use strict"; + var SyncReader = module2.exports = function(buffer) { + this._buffer = buffer; + this._reads = []; + }; + SyncReader.prototype.read = function(length, callback) { + this._reads.push({ + length: Math.abs(length), + // if length < 0 then at most this length + allowLess: length < 0, + func: callback + }); + }; + SyncReader.prototype.process = function() { + while (this._reads.length > 0 && this._buffer.length) { + let read = this._reads[0]; + if (this._buffer.length && (this._buffer.length >= read.length || read.allowLess)) { + this._reads.shift(); + let buf = this._buffer; + this._buffer = buf.slice(read.length); + read.func.call(this, buf.slice(0, read.length)); + } else { + break; } - } else { - sendHeader = !!options.expectContinueHeader; } - if (sendHeader) { - request4.headers.Expect = "100-continue"; + if (this._reads.length > 0) { + throw new Error("There are some read requests waitng on finished stream"); } - } - return next({ - ...args, - request: request4 - }); - }; -} -var addExpectContinueMiddlewareOptions = { - step: "build", - tags: ["SET_EXPECT_HEADER", "EXPECT_HEADER"], - name: "addExpectContinueMiddleware", - override: true -}; -var getAddExpectContinuePlugin = (options) => ({ - applyToStack: (clientStack) => { - clientStack.add(addExpectContinueMiddleware(options), addExpectContinueMiddlewareOptions); + if (this._buffer.length > 0) { + throw new Error("unrecognised content at end of stream"); + } + }; } }); -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/constants.js -var RequestChecksumCalculation = { - WHEN_SUPPORTED: "WHEN_SUPPORTED", - WHEN_REQUIRED: "WHEN_REQUIRED" -}; -var DEFAULT_REQUEST_CHECKSUM_CALCULATION = RequestChecksumCalculation.WHEN_SUPPORTED; -var ResponseChecksumValidation = { - WHEN_SUPPORTED: "WHEN_SUPPORTED", - WHEN_REQUIRED: "WHEN_REQUIRED" -}; -var DEFAULT_RESPONSE_CHECKSUM_VALIDATION = RequestChecksumCalculation.WHEN_SUPPORTED; -var ChecksumAlgorithm; -(function(ChecksumAlgorithm2) { - ChecksumAlgorithm2["MD5"] = "MD5"; - ChecksumAlgorithm2["CRC32"] = "CRC32"; - ChecksumAlgorithm2["CRC32C"] = "CRC32C"; - ChecksumAlgorithm2["CRC64NVME"] = "CRC64NVME"; - ChecksumAlgorithm2["SHA1"] = "SHA1"; - ChecksumAlgorithm2["SHA256"] = "SHA256"; -})(ChecksumAlgorithm || (ChecksumAlgorithm = {})); -var ChecksumLocation; -(function(ChecksumLocation2) { - ChecksumLocation2["HEADER"] = "header"; - ChecksumLocation2["TRAILER"] = "trailer"; -})(ChecksumLocation || (ChecksumLocation = {})); -var DEFAULT_CHECKSUM_ALGORITHM = ChecksumAlgorithm.CRC32; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/stringUnionSelector.js -var SelectorType; -(function(SelectorType3) { - SelectorType3["ENV"] = "env"; - SelectorType3["CONFIG"] = "shared config entry"; -})(SelectorType || (SelectorType = {})); -var stringUnionSelector = (obj2, key, union, type) => { - if (!(key in obj2)) - return void 0; - const value = obj2[key].toUpperCase(); - if (!Object.values(union).includes(value)) { - throw new TypeError(`Cannot load ${type} '${key}'. Expected one of ${Object.values(union)}, got '${obj2[key]}'.`); +// ../node_modules/pngjs/lib/filter-parse-sync.js +var require_filter_parse_sync = __commonJS({ + "../node_modules/pngjs/lib/filter-parse-sync.js"(exports2) { + "use strict"; + var SyncReader = require_sync_reader(); + var Filter = require_filter_parse(); + exports2.process = function(inBuffer, bitmapInfo) { + let outBuffers = []; + let reader = new SyncReader(inBuffer); + let filter2 = new Filter(bitmapInfo, { + read: reader.read.bind(reader), + write: function(bufferPart) { + outBuffers.push(bufferPart); + }, + complete: function() { + } + }); + filter2.start(); + reader.process(); + return Buffer.concat(outBuffers); + }; } - return value; -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS.js -var ENV_REQUEST_CHECKSUM_CALCULATION = "AWS_REQUEST_CHECKSUM_CALCULATION"; -var CONFIG_REQUEST_CHECKSUM_CALCULATION = "request_checksum_calculation"; -var NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS = { - environmentVariableSelector: (env3) => stringUnionSelector(env3, ENV_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.ENV), - configFileSelector: (profile) => stringUnionSelector(profile, CONFIG_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.CONFIG), - default: DEFAULT_REQUEST_CHECKSUM_CALCULATION -}; +}); -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS.js -var ENV_RESPONSE_CHECKSUM_VALIDATION = "AWS_RESPONSE_CHECKSUM_VALIDATION"; -var CONFIG_RESPONSE_CHECKSUM_VALIDATION = "response_checksum_validation"; -var NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS = { - environmentVariableSelector: (env3) => stringUnionSelector(env3, ENV_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.ENV), - configFileSelector: (profile) => stringUnionSelector(profile, CONFIG_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.CONFIG), - default: DEFAULT_RESPONSE_CHECKSUM_VALIDATION -}; +// ../node_modules/pngjs/lib/parser-sync.js +var require_parser_sync = __commonJS({ + "../node_modules/pngjs/lib/parser-sync.js"(exports2, module2) { + "use strict"; + var hasSyncZlib = true; + var zlib2 = require("zlib"); + var inflateSync = require_sync_inflate(); + if (!zlib2.deflateSync) { + hasSyncZlib = false; + } + var SyncReader = require_sync_reader(); + var FilterSync = require_filter_parse_sync(); + var Parser = require_parser(); + var bitmapper = require_bitmapper(); + var formatNormaliser = require_format_normaliser(); + module2.exports = function(buffer, options) { + if (!hasSyncZlib) { + throw new Error( + "To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0" + ); + } + let err; + function handleError(_err_) { + err = _err_; + } + let metaData; + function handleMetaData(_metaData_) { + metaData = _metaData_; + } + function handleTransColor(transColor) { + metaData.transColor = transColor; + } + function handlePalette(palette2) { + metaData.palette = palette2; + } + function handleSimpleTransparency() { + metaData.alpha = true; + } + let gamma; + function handleGamma(_gamma_) { + gamma = _gamma_; + } + let inflateDataList = []; + function handleInflateData(inflatedData2) { + inflateDataList.push(inflatedData2); + } + let reader = new SyncReader(buffer); + let parser2 = new Parser(options, { + read: reader.read.bind(reader), + error: handleError, + metadata: handleMetaData, + gamma: handleGamma, + palette: handlePalette, + transColor: handleTransColor, + inflateData: handleInflateData, + simpleTransparency: handleSimpleTransparency + }); + parser2.start(); + reader.process(); + if (err) { + throw err; + } + let inflateData = Buffer.concat(inflateDataList); + inflateDataList.length = 0; + let inflatedData; + if (metaData.interlace) { + inflatedData = zlib2.inflateSync(inflateData); + } else { + let rowSize = (metaData.width * metaData.bpp * metaData.depth + 7 >> 3) + 1; + let imageSize = rowSize * metaData.height; + inflatedData = inflateSync(inflateData, { + chunkSize: imageSize, + maxLength: imageSize + }); + } + inflateData = null; + if (!inflatedData || !inflatedData.length) { + throw new Error("bad png - invalid inflate data response"); + } + let unfilteredData = FilterSync.process(inflatedData, metaData); + inflateData = null; + let bitmapData = bitmapper.dataToBitMap(unfilteredData, metaData); + unfilteredData = null; + let normalisedBitmapData = formatNormaliser( + bitmapData, + metaData, + options.skipRescale + ); + metaData.data = normalisedBitmapData; + metaData.gamma = gamma || 0; + return metaData; + }; + } +}); -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/flexibleChecksumsMiddleware.js -init_dist_es22(); -init_dist_es2(); -init_dist_es14(); - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/types.js -var CLIENT_SUPPORTED_ALGORITHMS = [ - ChecksumAlgorithm.CRC32, - ChecksumAlgorithm.CRC32C, - ChecksumAlgorithm.CRC64NVME, - ChecksumAlgorithm.SHA1, - ChecksumAlgorithm.SHA256 -]; -var PRIORITY_ORDER_ALGORITHMS = [ - ChecksumAlgorithm.SHA256, - ChecksumAlgorithm.SHA1, - ChecksumAlgorithm.CRC32, - ChecksumAlgorithm.CRC32C, - ChecksumAlgorithm.CRC64NVME -]; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/getChecksumAlgorithmForRequest.js -var getChecksumAlgorithmForRequest = (input, { requestChecksumRequired, requestAlgorithmMember, requestChecksumCalculation }) => { - if (!requestAlgorithmMember) { - return requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired ? DEFAULT_CHECKSUM_ALGORITHM : void 0; - } - if (!input[requestAlgorithmMember]) { - return void 0; - } - const checksumAlgorithm = input[requestAlgorithmMember]; - if (!CLIENT_SUPPORTED_ALGORITHMS.includes(checksumAlgorithm)) { - throw new Error(`The checksum algorithm "${checksumAlgorithm}" is not supported by the client. Select one of ${CLIENT_SUPPORTED_ALGORITHMS}.`); - } - return checksumAlgorithm; -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/getChecksumLocationName.js -var getChecksumLocationName = (algorithm) => algorithm === ChecksumAlgorithm.MD5 ? "content-md5" : `x-amz-checksum-${algorithm.toLowerCase()}`; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/hasHeader.js -var hasHeader2 = (header, headers) => { - const soughtHeader = header.toLowerCase(); - for (const headerName of Object.keys(headers)) { - if (soughtHeader === headerName.toLowerCase()) { +// ../node_modules/pngjs/lib/packer-sync.js +var require_packer_sync = __commonJS({ + "../node_modules/pngjs/lib/packer-sync.js"(exports2, module2) { + "use strict"; + var hasSyncZlib = true; + var zlib2 = require("zlib"); + if (!zlib2.deflateSync) { + hasSyncZlib = false; + } + var constants4 = require_constants6(); + var Packer = require_packer(); + module2.exports = function(metaData, opt) { + if (!hasSyncZlib) { + throw new Error( + "To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0" + ); + } + let options = opt || {}; + let packer = new Packer(options); + let chunks = []; + chunks.push(Buffer.from(constants4.PNG_SIGNATURE)); + chunks.push(packer.packIHDR(metaData.width, metaData.height)); + if (metaData.gamma) { + chunks.push(packer.packGAMA(metaData.gamma)); + } + let filteredData = packer.filterData( + metaData.data, + metaData.width, + metaData.height + ); + let compressedData = zlib2.deflateSync( + filteredData, + packer.getDeflateOptions() + ); + filteredData = null; + if (!compressedData || !compressedData.length) { + throw new Error("bad png - invalid compressed data response"); + } + chunks.push(packer.packIDAT(compressedData)); + chunks.push(packer.packIEND()); + return Buffer.concat(chunks); + }; + } +}); + +// ../node_modules/pngjs/lib/png-sync.js +var require_png_sync = __commonJS({ + "../node_modules/pngjs/lib/png-sync.js"(exports2) { + "use strict"; + var parse3 = require_parser_sync(); + var pack = require_packer_sync(); + exports2.read = function(buffer, options) { + return parse3(buffer, options || {}); + }; + exports2.write = function(png2, options) { + return pack(png2, options); + }; + } +}); + +// ../node_modules/pngjs/lib/png.js +var require_png = __commonJS({ + "../node_modules/pngjs/lib/png.js"(exports2) { + "use strict"; + var util17 = require("util"); + var Stream2 = require("stream"); + var Parser = require_parser_async(); + var Packer = require_packer_async(); + var PNGSync = require_png_sync(); + var PNG2 = exports2.PNG = function(options) { + Stream2.call(this); + options = options || {}; + this.width = options.width | 0; + this.height = options.height | 0; + this.data = this.width > 0 && this.height > 0 ? Buffer.alloc(4 * this.width * this.height) : null; + if (options.fill && this.data) { + this.data.fill(0); + } + this.gamma = 0; + this.readable = this.writable = true; + this._parser = new Parser(options); + this._parser.on("error", this.emit.bind(this, "error")); + this._parser.on("close", this._handleClose.bind(this)); + this._parser.on("metadata", this._metadata.bind(this)); + this._parser.on("gamma", this._gamma.bind(this)); + this._parser.on( + "parsed", + function(data) { + this.data = data; + this.emit("parsed", data); + }.bind(this) + ); + this._packer = new Packer(options); + this._packer.on("data", this.emit.bind(this, "data")); + this._packer.on("end", this.emit.bind(this, "end")); + this._parser.on("close", this._handleClose.bind(this)); + this._packer.on("error", this.emit.bind(this, "error")); + }; + util17.inherits(PNG2, Stream2); + PNG2.sync = PNGSync; + PNG2.prototype.pack = function() { + if (!this.data || !this.data.length) { + this.emit("error", "No data provided"); + return this; + } + process.nextTick( + function() { + this._packer.pack(this.data, this.width, this.height, this.gamma); + }.bind(this) + ); + return this; + }; + PNG2.prototype.parse = function(data, callback) { + if (callback) { + let onParsed, onError; + onParsed = function(parsedData) { + this.removeListener("error", onError); + this.data = parsedData; + callback(null, this); + }.bind(this); + onError = function(err) { + this.removeListener("parsed", onParsed); + callback(err, null); + }.bind(this); + this.once("parsed", onParsed); + this.once("error", onError); + } + this.end(data); + return this; + }; + PNG2.prototype.write = function(data) { + this._parser.write(data); return true; - } + }; + PNG2.prototype.end = function(data) { + this._parser.end(data); + }; + PNG2.prototype._metadata = function(metadata) { + this.width = metadata.width; + this.height = metadata.height; + this.emit("metadata", metadata); + }; + PNG2.prototype._gamma = function(gamma) { + this.gamma = gamma; + }; + PNG2.prototype._handleClose = function() { + if (!this._parser.writable && !this._packer.readable) { + this.emit("close"); + } + }; + PNG2.bitblt = function(src, dst, srcX, srcY, width, height, deltaX, deltaY) { + srcX |= 0; + srcY |= 0; + width |= 0; + height |= 0; + deltaX |= 0; + deltaY |= 0; + if (srcX > src.width || srcY > src.height || srcX + width > src.width || srcY + height > src.height) { + throw new Error("bitblt reading outside image"); + } + if (deltaX > dst.width || deltaY > dst.height || deltaX + width > dst.width || deltaY + height > dst.height) { + throw new Error("bitblt writing outside image"); + } + for (let y4 = 0; y4 < height; y4++) { + src.data.copy( + dst.data, + (deltaY + y4) * dst.width + deltaX << 2, + (srcY + y4) * src.width + srcX << 2, + (srcY + y4) * src.width + srcX + width << 2 + ); + } + }; + PNG2.prototype.bitblt = function(dst, srcX, srcY, width, height, deltaX, deltaY) { + PNG2.bitblt(this, dst, srcX, srcY, width, height, deltaX, deltaY); + return this; + }; + PNG2.adjustGamma = function(src) { + if (src.gamma) { + for (let y4 = 0; y4 < src.height; y4++) { + for (let x7 = 0; x7 < src.width; x7++) { + let idx = src.width * y4 + x7 << 2; + for (let i6 = 0; i6 < 3; i6++) { + let sample = src.data[idx + i6] / 255; + sample = Math.pow(sample, 1 / 2.2 / src.gamma); + src.data[idx + i6] = Math.round(sample * 255); + } + } + } + src.gamma = 0; + } + }; + PNG2.prototype.adjustGamma = function() { + PNG2.adjustGamma(this); + }; } - return false; -}; +}); -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/hasHeaderWithPrefix.js -var hasHeaderWithPrefix = (headerPrefix, headers) => { - const soughtHeaderPrefix = headerPrefix.toLowerCase(); - for (const headerName of Object.keys(headers)) { - if (headerName.toLowerCase().startsWith(soughtHeaderPrefix)) { - return true; +// ../node_modules/pako/lib/utils/common.js +var require_common = __commonJS({ + "../node_modules/pako/lib/utils/common.js"(exports2) { + "use strict"; + var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined"; + function _has(obj2, key) { + return Object.prototype.hasOwnProperty.call(obj2, key); } - } - return false; -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/isStreaming.js -init_dist_es5(); -var isStreaming = (body) => body !== void 0 && typeof body !== "string" && !ArrayBuffer.isView(body) && !isArrayBuffer(body); - -// ../node_modules/tslib/tslib.es6.mjs -function __awaiter6(thisArg, _arguments, P2, generator) { - function adopt(value) { - return value instanceof P2 ? value : new P2(function(resolve2) { - resolve2(value); - }); - } - return new (P2 || (P2 = Promise))(function(resolve2, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e6) { - reject(e6); + exports2.assign = function(obj2) { + var sources = Array.prototype.slice.call(arguments, 1); + while (sources.length) { + var source = sources.shift(); + if (!source) { + continue; + } + if (typeof source !== "object") { + throw new TypeError(source + "must be non-object"); + } + for (var p6 in source) { + if (_has(source, p6)) { + obj2[p6] = source[p6]; + } + } } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e6) { - reject(e6); + return obj2; + }; + exports2.shrinkBuf = function(buf, size) { + if (buf.length === size) { + return buf; + } + if (buf.subarray) { + return buf.subarray(0, size); + } + buf.length = size; + return buf; + }; + var fnTyped = { + arraySet: function(dest, src, src_offs, len, dest_offs) { + if (src.subarray && dest.subarray) { + dest.set(src.subarray(src_offs, src_offs + len), dest_offs); + return; + } + for (var i6 = 0; i6 < len; i6++) { + dest[dest_offs + i6] = src[src_offs + i6]; + } + }, + // Join array of chunks to single array. + flattenChunks: function(chunks) { + var i6, l6, len, pos, chunk, result; + len = 0; + for (i6 = 0, l6 = chunks.length; i6 < l6; i6++) { + len += chunks[i6].length; + } + result = new Uint8Array(len); + pos = 0; + for (i6 = 0, l6 = chunks.length; i6 < l6; i6++) { + chunk = chunks[i6]; + result.set(chunk, pos); + pos += chunk.length; + } + return result; + } + }; + var fnUntyped = { + arraySet: function(dest, src, src_offs, len, dest_offs) { + for (var i6 = 0; i6 < len; i6++) { + dest[dest_offs + i6] = src[src_offs + i6]; + } + }, + // Join array of chunks to single array. + flattenChunks: function(chunks) { + return [].concat.apply([], chunks); + } + }; + exports2.setTyped = function(on) { + if (on) { + exports2.Buf8 = Uint8Array; + exports2.Buf16 = Uint16Array; + exports2.Buf32 = Int32Array; + exports2.assign(exports2, fnTyped); + } else { + exports2.Buf8 = Array; + exports2.Buf16 = Array; + exports2.Buf32 = Array; + exports2.assign(exports2, fnUntyped); + } + }; + exports2.setTyped(TYPED_OK); + } +}); + +// ../node_modules/pako/lib/zlib/trees.js +var require_trees = __commonJS({ + "../node_modules/pako/lib/zlib/trees.js"(exports2) { + "use strict"; + var utils2 = require_common(); + var Z_FIXED = 4; + var Z_BINARY = 0; + var Z_TEXT = 1; + var Z_UNKNOWN = 2; + function zero(buf) { + var len = buf.length; + while (--len >= 0) { + buf[len] = 0; + } + } + var STORED_BLOCK = 0; + var STATIC_TREES = 1; + var DYN_TREES = 2; + var MIN_MATCH = 3; + var MAX_MATCH = 258; + var LENGTH_CODES = 29; + var LITERALS = 256; + var L_CODES = LITERALS + 1 + LENGTH_CODES; + var D_CODES = 30; + var BL_CODES = 19; + var HEAP_SIZE = 2 * L_CODES + 1; + var MAX_BITS = 15; + var Buf_size = 16; + var MAX_BL_BITS = 7; + var END_BLOCK = 256; + var REP_3_6 = 16; + var REPZ_3_10 = 17; + var REPZ_11_138 = 18; + var extra_lbits = ( + /* extra bits for each length code */ + [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0] + ); + var extra_dbits = ( + /* extra bits for each distance code */ + [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13] + ); + var extra_blbits = ( + /* extra bits for each bit length code */ + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7] + ); + var bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + var DIST_CODE_LEN = 512; + var static_ltree = new Array((L_CODES + 2) * 2); + zero(static_ltree); + var static_dtree = new Array(D_CODES * 2); + zero(static_dtree); + var _dist_code = new Array(DIST_CODE_LEN); + zero(_dist_code); + var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1); + zero(_length_code); + var base_length = new Array(LENGTH_CODES); + zero(base_length); + var base_dist = new Array(D_CODES); + zero(base_dist); + function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) { + this.static_tree = static_tree; + this.extra_bits = extra_bits; + this.extra_base = extra_base; + this.elems = elems; + this.max_length = max_length; + this.has_stree = static_tree && static_tree.length; + } + var static_l_desc; + var static_d_desc; + var static_bl_desc; + function TreeDesc(dyn_tree, stat_desc) { + this.dyn_tree = dyn_tree; + this.max_code = 0; + this.stat_desc = stat_desc; + } + function d_code(dist) { + return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)]; + } + function put_short(s6, w6) { + s6.pending_buf[s6.pending++] = w6 & 255; + s6.pending_buf[s6.pending++] = w6 >>> 8 & 255; + } + function send_bits(s6, value, length) { + if (s6.bi_valid > Buf_size - length) { + s6.bi_buf |= value << s6.bi_valid & 65535; + put_short(s6, s6.bi_buf); + s6.bi_buf = value >> Buf_size - s6.bi_valid; + s6.bi_valid += length - Buf_size; + } else { + s6.bi_buf |= value << s6.bi_valid & 65535; + s6.bi_valid += length; } } - function step(result) { - result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); + function send_code(s6, c7, tree) { + send_bits( + s6, + tree[c7 * 2], + tree[c7 * 2 + 1] + /*.Len*/ + ); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { - if (t12[0] & 1) throw t12[1]; - return t12[1]; - }, trys: [], ops: [] }, f6, y3, t12, g6 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); - return g6.next = verb(0), g6["throw"] = verb(1), g6["return"] = verb(2), typeof Symbol === "function" && (g6[Symbol.iterator] = function() { - return this; - }), g6; - function verb(n6) { - return function(v7) { - return step([n6, v7]); - }; - } - function step(op) { - if (f6) throw new TypeError("Generator is already executing."); - while (g6 && (g6 = 0, op[0] && (_ = 0)), _) try { - if (f6 = 1, y3 && (t12 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t12 = y3["return"]) && t12.call(y3), 0) : y3.next) && !(t12 = t12.call(y3, op[1])).done) return t12; - if (y3 = 0, t12) op = [op[0] & 2, t12.value]; - switch (op[0]) { - case 0: - case 1: - t12 = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y3 = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); + function bi_reverse(code, len) { + var res = 0; + do { + res |= code & 1; + code >>>= 1; + res <<= 1; + } while (--len > 0); + return res >>> 1; + } + function bi_flush(s6) { + if (s6.bi_valid === 16) { + put_short(s6, s6.bi_buf); + s6.bi_buf = 0; + s6.bi_valid = 0; + } else if (s6.bi_valid >= 8) { + s6.pending_buf[s6.pending++] = s6.bi_buf & 255; + s6.bi_buf >>= 8; + s6.bi_valid -= 8; + } + } + function gen_bitlen(s6, desc) { + var tree = desc.dyn_tree; + var max_code = desc.max_code; + var stree = desc.stat_desc.static_tree; + var has_stree = desc.stat_desc.has_stree; + var extra = desc.stat_desc.extra_bits; + var base = desc.stat_desc.extra_base; + var max_length = desc.stat_desc.max_length; + var h6; + var n6, m6; + var bits; + var xbits; + var f6; + var overflow = 0; + for (bits = 0; bits <= MAX_BITS; bits++) { + s6.bl_count[bits] = 0; + } + tree[s6.heap[s6.heap_max] * 2 + 1] = 0; + for (h6 = s6.heap_max + 1; h6 < HEAP_SIZE; h6++) { + n6 = s6.heap[h6]; + bits = tree[tree[n6 * 2 + 1] * 2 + 1] + 1; + if (bits > max_length) { + bits = max_length; + overflow++; + } + tree[n6 * 2 + 1] = bits; + if (n6 > max_code) { continue; - default: - if (!(t12 = _.trys, t12 = t12.length > 0 && t12[t12.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; + } + s6.bl_count[bits]++; + xbits = 0; + if (n6 >= base) { + xbits = extra[n6 - base]; + } + f6 = tree[n6 * 2]; + s6.opt_len += f6 * (bits + xbits); + if (has_stree) { + s6.static_len += f6 * (stree[n6 * 2 + 1] + xbits); + } + } + if (overflow === 0) { + return; + } + do { + bits = max_length - 1; + while (s6.bl_count[bits] === 0) { + bits--; + } + s6.bl_count[bits]--; + s6.bl_count[bits + 1] += 2; + s6.bl_count[max_length]--; + overflow -= 2; + } while (overflow > 0); + for (bits = max_length; bits !== 0; bits--) { + n6 = s6.bl_count[bits]; + while (n6 !== 0) { + m6 = s6.heap[--h6]; + if (m6 > max_code) { continue; } - if (op[0] === 3 && (!t12 || op[1] > t12[0] && op[1] < t12[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t12[1]) { - _.label = t12[1]; - t12 = op; - break; + if (tree[m6 * 2 + 1] !== bits) { + s6.opt_len += (bits - tree[m6 * 2 + 1]) * tree[m6 * 2]; + tree[m6 * 2 + 1] = bits; } - if (t12 && _.label < t12[2]) { - _.label = t12[2]; - _.ops.push(op); - break; + n6--; + } + } + } + function gen_codes(tree, max_code, bl_count) { + var next_code = new Array(MAX_BITS + 1); + var code = 0; + var bits; + var n6; + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = code + bl_count[bits - 1] << 1; + } + for (n6 = 0; n6 <= max_code; n6++) { + var len = tree[n6 * 2 + 1]; + if (len === 0) { + continue; + } + tree[n6 * 2] = bi_reverse(next_code[len]++, len); + } + } + function tr_static_init() { + var n6; + var bits; + var length; + var code; + var dist; + var bl_count = new Array(MAX_BITS + 1); + length = 0; + for (code = 0; code < LENGTH_CODES - 1; code++) { + base_length[code] = length; + for (n6 = 0; n6 < 1 << extra_lbits[code]; n6++) { + _length_code[length++] = code; + } + } + _length_code[length - 1] = code; + dist = 0; + for (code = 0; code < 16; code++) { + base_dist[code] = dist; + for (n6 = 0; n6 < 1 << extra_dbits[code]; n6++) { + _dist_code[dist++] = code; + } + } + dist >>= 7; + for (; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n6 = 0; n6 < 1 << extra_dbits[code] - 7; n6++) { + _dist_code[256 + dist++] = code; + } + } + for (bits = 0; bits <= MAX_BITS; bits++) { + bl_count[bits] = 0; + } + n6 = 0; + while (n6 <= 143) { + static_ltree[n6 * 2 + 1] = 8; + n6++; + bl_count[8]++; + } + while (n6 <= 255) { + static_ltree[n6 * 2 + 1] = 9; + n6++; + bl_count[9]++; + } + while (n6 <= 279) { + static_ltree[n6 * 2 + 1] = 7; + n6++; + bl_count[7]++; + } + while (n6 <= 287) { + static_ltree[n6 * 2 + 1] = 8; + n6++; + bl_count[8]++; + } + gen_codes(static_ltree, L_CODES + 1, bl_count); + for (n6 = 0; n6 < D_CODES; n6++) { + static_dtree[n6 * 2 + 1] = 5; + static_dtree[n6 * 2] = bi_reverse(n6, 5); + } + static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); + static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0, D_CODES, MAX_BITS); + static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0, BL_CODES, MAX_BL_BITS); + } + function init_block(s6) { + var n6; + for (n6 = 0; n6 < L_CODES; n6++) { + s6.dyn_ltree[n6 * 2] = 0; + } + for (n6 = 0; n6 < D_CODES; n6++) { + s6.dyn_dtree[n6 * 2] = 0; + } + for (n6 = 0; n6 < BL_CODES; n6++) { + s6.bl_tree[n6 * 2] = 0; + } + s6.dyn_ltree[END_BLOCK * 2] = 1; + s6.opt_len = s6.static_len = 0; + s6.last_lit = s6.matches = 0; + } + function bi_windup(s6) { + if (s6.bi_valid > 8) { + put_short(s6, s6.bi_buf); + } else if (s6.bi_valid > 0) { + s6.pending_buf[s6.pending++] = s6.bi_buf; + } + s6.bi_buf = 0; + s6.bi_valid = 0; + } + function copy_block(s6, buf, len, header) { + bi_windup(s6); + if (header) { + put_short(s6, len); + put_short(s6, ~len); + } + utils2.arraySet(s6.pending_buf, s6.window, buf, len, s6.pending); + s6.pending += len; + } + function smaller(tree, n6, m6, depth) { + var _n2 = n6 * 2; + var _m22 = m6 * 2; + return tree[_n2] < tree[_m22] || tree[_n2] === tree[_m22] && depth[n6] <= depth[m6]; + } + function pqdownheap(s6, tree, k6) { + var v7 = s6.heap[k6]; + var j6 = k6 << 1; + while (j6 <= s6.heap_len) { + if (j6 < s6.heap_len && smaller(tree, s6.heap[j6 + 1], s6.heap[j6], s6.depth)) { + j6++; + } + if (smaller(tree, v7, s6.heap[j6], s6.depth)) { + break; + } + s6.heap[k6] = s6.heap[j6]; + k6 = j6; + j6 <<= 1; + } + s6.heap[k6] = v7; + } + function compress_block(s6, ltree, dtree) { + var dist; + var lc; + var lx = 0; + var code; + var extra; + if (s6.last_lit !== 0) { + do { + dist = s6.pending_buf[s6.d_buf + lx * 2] << 8 | s6.pending_buf[s6.d_buf + lx * 2 + 1]; + lc = s6.pending_buf[s6.l_buf + lx]; + lx++; + if (dist === 0) { + send_code(s6, lc, ltree); + } else { + code = _length_code[lc]; + send_code(s6, code + LITERALS + 1, ltree); + extra = extra_lbits[code]; + if (extra !== 0) { + lc -= base_length[code]; + send_bits(s6, lc, extra); + } + dist--; + code = d_code(dist); + send_code(s6, code, dtree); + extra = extra_dbits[code]; + if (extra !== 0) { + dist -= base_dist[code]; + send_bits(s6, dist, extra); + } } - if (t12[2]) _.ops.pop(); - _.trys.pop(); + } while (lx < s6.last_lit); + } + send_code(s6, END_BLOCK, ltree); + } + function build_tree(s6, desc) { + var tree = desc.dyn_tree; + var stree = desc.stat_desc.static_tree; + var has_stree = desc.stat_desc.has_stree; + var elems = desc.stat_desc.elems; + var n6, m6; + var max_code = -1; + var node; + s6.heap_len = 0; + s6.heap_max = HEAP_SIZE; + for (n6 = 0; n6 < elems; n6++) { + if (tree[n6 * 2] !== 0) { + s6.heap[++s6.heap_len] = max_code = n6; + s6.depth[n6] = 0; + } else { + tree[n6 * 2 + 1] = 0; + } + } + while (s6.heap_len < 2) { + node = s6.heap[++s6.heap_len] = max_code < 2 ? ++max_code : 0; + tree[node * 2] = 1; + s6.depth[node] = 0; + s6.opt_len--; + if (has_stree) { + s6.static_len -= stree[node * 2 + 1]; + } + } + desc.max_code = max_code; + for (n6 = s6.heap_len >> 1; n6 >= 1; n6--) { + pqdownheap(s6, tree, n6); + } + node = elems; + do { + n6 = s6.heap[ + 1 + /*SMALLEST*/ + ]; + s6.heap[ + 1 + /*SMALLEST*/ + ] = s6.heap[s6.heap_len--]; + pqdownheap( + s6, + tree, + 1 + /*SMALLEST*/ + ); + m6 = s6.heap[ + 1 + /*SMALLEST*/ + ]; + s6.heap[--s6.heap_max] = n6; + s6.heap[--s6.heap_max] = m6; + tree[node * 2] = tree[n6 * 2] + tree[m6 * 2]; + s6.depth[node] = (s6.depth[n6] >= s6.depth[m6] ? s6.depth[n6] : s6.depth[m6]) + 1; + tree[n6 * 2 + 1] = tree[m6 * 2 + 1] = node; + s6.heap[ + 1 + /*SMALLEST*/ + ] = node++; + pqdownheap( + s6, + tree, + 1 + /*SMALLEST*/ + ); + } while (s6.heap_len >= 2); + s6.heap[--s6.heap_max] = s6.heap[ + 1 + /*SMALLEST*/ + ]; + gen_bitlen(s6, desc); + gen_codes(tree, max_code, s6.bl_count); + } + function scan_tree(s6, tree, max_code) { + var n6; + var prevlen = -1; + var curlen; + var nextlen = tree[0 * 2 + 1]; + var count = 0; + var max_count = 7; + var min_count = 4; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + tree[(max_code + 1) * 2 + 1] = 65535; + for (n6 = 0; n6 <= max_code; n6++) { + curlen = nextlen; + nextlen = tree[(n6 + 1) * 2 + 1]; + if (++count < max_count && curlen === nextlen) { + continue; + } else if (count < min_count) { + s6.bl_tree[curlen * 2] += count; + } else if (curlen !== 0) { + if (curlen !== prevlen) { + s6.bl_tree[curlen * 2]++; + } + s6.bl_tree[REP_3_6 * 2]++; + } else if (count <= 10) { + s6.bl_tree[REPZ_3_10 * 2]++; + } else { + s6.bl_tree[REPZ_11_138 * 2]++; + } + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen === nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } + } + } + function send_tree(s6, tree, max_code) { + var n6; + var prevlen = -1; + var curlen; + var nextlen = tree[0 * 2 + 1]; + var count = 0; + var max_count = 7; + var min_count = 4; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + for (n6 = 0; n6 <= max_code; n6++) { + curlen = nextlen; + nextlen = tree[(n6 + 1) * 2 + 1]; + if (++count < max_count && curlen === nextlen) { continue; + } else if (count < min_count) { + do { + send_code(s6, curlen, s6.bl_tree); + } while (--count !== 0); + } else if (curlen !== 0) { + if (curlen !== prevlen) { + send_code(s6, curlen, s6.bl_tree); + count--; + } + send_code(s6, REP_3_6, s6.bl_tree); + send_bits(s6, count - 3, 2); + } else if (count <= 10) { + send_code(s6, REPZ_3_10, s6.bl_tree); + send_bits(s6, count - 3, 3); + } else { + send_code(s6, REPZ_11_138, s6.bl_tree); + send_bits(s6, count - 11, 7); + } + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen === nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } } - op = body.call(thisArg, _); - } catch (e6) { - op = [6, e6]; - y3 = 0; - } finally { - f6 = t12 = 0; } - if (op[0] & 5) throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} -function __values(o6) { - var s6 = typeof Symbol === "function" && Symbol.iterator, m6 = s6 && o6[s6], i6 = 0; - if (m6) return m6.call(o6); - if (o6 && typeof o6.length === "number") return { - next: function() { - if (o6 && i6 >= o6.length) o6 = void 0; - return { value: o6 && o6[i6++], done: !o6 }; + function build_bl_tree(s6) { + var max_blindex; + scan_tree(s6, s6.dyn_ltree, s6.l_desc.max_code); + scan_tree(s6, s6.dyn_dtree, s6.d_desc.max_code); + build_tree(s6, s6.bl_desc); + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (s6.bl_tree[bl_order[max_blindex] * 2 + 1] !== 0) { + break; + } + } + s6.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; + return max_blindex; } - }; - throw new TypeError(s6 ? "Object is not iterable." : "Symbol.iterator is not defined."); -} - -// ../node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/node_modules/@smithy/util-buffer-from/dist-es/index.js -var import_buffer2 = require("buffer"); -var fromString2 = (input, encoding) => { - if (typeof input !== "string") { - throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`); - } - return encoding ? import_buffer2.Buffer.from(input, encoding) : import_buffer2.Buffer.from(input); -}; - -// ../node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js -var fromUtf82 = (input) => { - const buf = fromString2(input, "utf8"); - return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT); -}; - -// ../node_modules/@aws-crypto/util/build/module/convertToBuffer.js -var fromUtf83 = typeof Buffer !== "undefined" && Buffer.from ? function(input) { - return Buffer.from(input, "utf8"); -} : fromUtf82; -function convertToBuffer(data) { - if (data instanceof Uint8Array) - return data; - if (typeof data === "string") { - return fromUtf83(data); - } - if (ArrayBuffer.isView(data)) { - return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT); + function send_all_trees(s6, lcodes, dcodes, blcodes) { + var rank; + send_bits(s6, lcodes - 257, 5); + send_bits(s6, dcodes - 1, 5); + send_bits(s6, blcodes - 4, 4); + for (rank = 0; rank < blcodes; rank++) { + send_bits(s6, s6.bl_tree[bl_order[rank] * 2 + 1], 3); + } + send_tree(s6, s6.dyn_ltree, lcodes - 1); + send_tree(s6, s6.dyn_dtree, dcodes - 1); + } + function detect_data_type(s6) { + var black_mask = 4093624447; + var n6; + for (n6 = 0; n6 <= 31; n6++, black_mask >>>= 1) { + if (black_mask & 1 && s6.dyn_ltree[n6 * 2] !== 0) { + return Z_BINARY; + } + } + if (s6.dyn_ltree[9 * 2] !== 0 || s6.dyn_ltree[10 * 2] !== 0 || s6.dyn_ltree[13 * 2] !== 0) { + return Z_TEXT; + } + for (n6 = 32; n6 < LITERALS; n6++) { + if (s6.dyn_ltree[n6 * 2] !== 0) { + return Z_TEXT; + } + } + return Z_BINARY; + } + var static_init_done = false; + function _tr_init(s6) { + if (!static_init_done) { + tr_static_init(); + static_init_done = true; + } + s6.l_desc = new TreeDesc(s6.dyn_ltree, static_l_desc); + s6.d_desc = new TreeDesc(s6.dyn_dtree, static_d_desc); + s6.bl_desc = new TreeDesc(s6.bl_tree, static_bl_desc); + s6.bi_buf = 0; + s6.bi_valid = 0; + init_block(s6); + } + function _tr_stored_block(s6, buf, stored_len, last) { + send_bits(s6, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); + copy_block(s6, buf, stored_len, true); + } + function _tr_align(s6) { + send_bits(s6, STATIC_TREES << 1, 3); + send_code(s6, END_BLOCK, static_ltree); + bi_flush(s6); + } + function _tr_flush_block(s6, buf, stored_len, last) { + var opt_lenb, static_lenb; + var max_blindex = 0; + if (s6.level > 0) { + if (s6.strm.data_type === Z_UNKNOWN) { + s6.strm.data_type = detect_data_type(s6); + } + build_tree(s6, s6.l_desc); + build_tree(s6, s6.d_desc); + max_blindex = build_bl_tree(s6); + opt_lenb = s6.opt_len + 3 + 7 >>> 3; + static_lenb = s6.static_len + 3 + 7 >>> 3; + if (static_lenb <= opt_lenb) { + opt_lenb = static_lenb; + } + } else { + opt_lenb = static_lenb = stored_len + 5; + } + if (stored_len + 4 <= opt_lenb && buf !== -1) { + _tr_stored_block(s6, buf, stored_len, last); + } else if (s6.strategy === Z_FIXED || static_lenb === opt_lenb) { + send_bits(s6, (STATIC_TREES << 1) + (last ? 1 : 0), 3); + compress_block(s6, static_ltree, static_dtree); + } else { + send_bits(s6, (DYN_TREES << 1) + (last ? 1 : 0), 3); + send_all_trees(s6, s6.l_desc.max_code + 1, s6.d_desc.max_code + 1, max_blindex + 1); + compress_block(s6, s6.dyn_ltree, s6.dyn_dtree); + } + init_block(s6); + if (last) { + bi_windup(s6); + } + } + function _tr_tally(s6, dist, lc) { + s6.pending_buf[s6.d_buf + s6.last_lit * 2] = dist >>> 8 & 255; + s6.pending_buf[s6.d_buf + s6.last_lit * 2 + 1] = dist & 255; + s6.pending_buf[s6.l_buf + s6.last_lit] = lc & 255; + s6.last_lit++; + if (dist === 0) { + s6.dyn_ltree[lc * 2]++; + } else { + s6.matches++; + dist--; + s6.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++; + s6.dyn_dtree[d_code(dist) * 2]++; + } + return s6.last_lit === s6.lit_bufsize - 1; + } + exports2._tr_init = _tr_init; + exports2._tr_stored_block = _tr_stored_block; + exports2._tr_flush_block = _tr_flush_block; + exports2._tr_tally = _tr_tally; + exports2._tr_align = _tr_align; } - return new Uint8Array(data); -} +}); -// ../node_modules/@aws-crypto/util/build/module/isEmptyData.js -function isEmptyData(data) { - if (typeof data === "string") { - return data.length === 0; +// ../node_modules/pako/lib/zlib/adler32.js +var require_adler32 = __commonJS({ + "../node_modules/pako/lib/zlib/adler32.js"(exports2, module2) { + "use strict"; + function adler32(adler, buf, len, pos) { + var s1 = adler & 65535 | 0, s22 = adler >>> 16 & 65535 | 0, n6 = 0; + while (len !== 0) { + n6 = len > 2e3 ? 2e3 : len; + len -= n6; + do { + s1 = s1 + buf[pos++] | 0; + s22 = s22 + s1 | 0; + } while (--n6); + s1 %= 65521; + s22 %= 65521; + } + return s1 | s22 << 16 | 0; + } + module2.exports = adler32; } - return data.byteLength === 0; -} - -// ../node_modules/@aws-crypto/util/build/module/numToUint8.js -function numToUint8(num) { - return new Uint8Array([ - (num & 4278190080) >> 24, - (num & 16711680) >> 16, - (num & 65280) >> 8, - num & 255 - ]); -} +}); -// ../node_modules/@aws-crypto/util/build/module/uint32ArrayFrom.js -function uint32ArrayFrom(a_lookUpTable2) { - if (!Uint32Array.from) { - var return_array = new Uint32Array(a_lookUpTable2.length); - var a_index = 0; - while (a_index < a_lookUpTable2.length) { - return_array[a_index] = a_lookUpTable2[a_index]; - a_index += 1; +// ../node_modules/pako/lib/zlib/crc32.js +var require_crc32 = __commonJS({ + "../node_modules/pako/lib/zlib/crc32.js"(exports2, module2) { + "use strict"; + function makeTable() { + var c7, table = []; + for (var n6 = 0; n6 < 256; n6++) { + c7 = n6; + for (var k6 = 0; k6 < 8; k6++) { + c7 = c7 & 1 ? 3988292384 ^ c7 >>> 1 : c7 >>> 1; + } + table[n6] = c7; + } + return table; } - return return_array; + var crcTable = makeTable(); + function crc322(crc, buf, len, pos) { + var t12 = crcTable, end = pos + len; + crc ^= -1; + for (var i6 = pos; i6 < end; i6++) { + crc = crc >>> 8 ^ t12[(crc ^ buf[i6]) & 255]; + } + return crc ^ -1; + } + module2.exports = crc322; } - return Uint32Array.from(a_lookUpTable2); -} +}); -// ../node_modules/@aws-crypto/crc32c/build/module/aws_crc32c.js -var AwsCrc32c = ( - /** @class */ - (function() { - function AwsCrc32c2() { - this.crc32c = new Crc32c(); - } - AwsCrc32c2.prototype.update = function(toHash) { - if (isEmptyData(toHash)) +// ../node_modules/pako/lib/zlib/messages.js +var require_messages = __commonJS({ + "../node_modules/pako/lib/zlib/messages.js"(exports2, module2) { + "use strict"; + module2.exports = { + 2: "need dictionary", + /* Z_NEED_DICT 2 */ + 1: "stream end", + /* Z_STREAM_END 1 */ + 0: "", + /* Z_OK 0 */ + "-1": "file error", + /* Z_ERRNO (-1) */ + "-2": "stream error", + /* Z_STREAM_ERROR (-2) */ + "-3": "data error", + /* Z_DATA_ERROR (-3) */ + "-4": "insufficient memory", + /* Z_MEM_ERROR (-4) */ + "-5": "buffer error", + /* Z_BUF_ERROR (-5) */ + "-6": "incompatible version" + /* Z_VERSION_ERROR (-6) */ + }; + } +}); + +// ../node_modules/pako/lib/zlib/deflate.js +var require_deflate = __commonJS({ + "../node_modules/pako/lib/zlib/deflate.js"(exports2) { + "use strict"; + var utils2 = require_common(); + var trees = require_trees(); + var adler32 = require_adler32(); + var crc322 = require_crc32(); + var msg = require_messages(); + var Z_NO_FLUSH = 0; + var Z_PARTIAL_FLUSH = 1; + var Z_FULL_FLUSH = 3; + var Z_FINISH = 4; + var Z_BLOCK = 5; + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_STREAM_ERROR = -2; + var Z_DATA_ERROR = -3; + var Z_BUF_ERROR = -5; + var Z_DEFAULT_COMPRESSION = -1; + var Z_FILTERED = 1; + var Z_HUFFMAN_ONLY = 2; + var Z_RLE = 3; + var Z_FIXED = 4; + var Z_DEFAULT_STRATEGY = 0; + var Z_UNKNOWN = 2; + var Z_DEFLATED = 8; + var MAX_MEM_LEVEL = 9; + var MAX_WBITS = 15; + var DEF_MEM_LEVEL = 8; + var LENGTH_CODES = 29; + var LITERALS = 256; + var L_CODES = LITERALS + 1 + LENGTH_CODES; + var D_CODES = 30; + var BL_CODES = 19; + var HEAP_SIZE = 2 * L_CODES + 1; + var MAX_BITS = 15; + var MIN_MATCH = 3; + var MAX_MATCH = 258; + var MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; + var PRESET_DICT = 32; + var INIT_STATE = 42; + var EXTRA_STATE = 69; + var NAME_STATE = 73; + var COMMENT_STATE = 91; + var HCRC_STATE = 103; + var BUSY_STATE = 113; + var FINISH_STATE = 666; + var BS_NEED_MORE = 1; + var BS_BLOCK_DONE = 2; + var BS_FINISH_STARTED = 3; + var BS_FINISH_DONE = 4; + var OS_CODE = 3; + function err(strm, errorCode) { + strm.msg = msg[errorCode]; + return errorCode; + } + function rank(f6) { + return (f6 << 1) - (f6 > 4 ? 9 : 0); + } + function zero(buf) { + var len = buf.length; + while (--len >= 0) { + buf[len] = 0; + } + } + function flush_pending(strm) { + var s6 = strm.state; + var len = s6.pending; + if (len > strm.avail_out) { + len = strm.avail_out; + } + if (len === 0) { return; - this.crc32c.update(convertToBuffer(toHash)); - }; - AwsCrc32c2.prototype.digest = function() { - return __awaiter6(this, void 0, void 0, function() { - return __generator(this, function(_a2) { - return [2, numToUint8(this.crc32c.digest())]; - }); - }); - }; - AwsCrc32c2.prototype.reset = function() { - this.crc32c = new Crc32c(); - }; - return AwsCrc32c2; - })() -); - -// ../node_modules/@aws-crypto/crc32c/build/module/index.js -var Crc32c = ( - /** @class */ - (function() { - function Crc32c2() { - this.checksum = 4294967295; + } + utils2.arraySet(strm.output, s6.pending_buf, s6.pending_out, len, strm.next_out); + strm.next_out += len; + s6.pending_out += len; + strm.total_out += len; + strm.avail_out -= len; + s6.pending -= len; + if (s6.pending === 0) { + s6.pending_out = 0; + } } - Crc32c2.prototype.update = function(data) { - var e_1, _a2; - try { - for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) { - var byte = data_1_1.value; - this.checksum = this.checksum >>> 8 ^ lookupTable[(this.checksum ^ byte) & 255]; + function flush_block_only(s6, last) { + trees._tr_flush_block(s6, s6.block_start >= 0 ? s6.block_start : -1, s6.strstart - s6.block_start, last); + s6.block_start = s6.strstart; + flush_pending(s6.strm); + } + function put_byte(s6, b6) { + s6.pending_buf[s6.pending++] = b6; + } + function putShortMSB(s6, b6) { + s6.pending_buf[s6.pending++] = b6 >>> 8 & 255; + s6.pending_buf[s6.pending++] = b6 & 255; + } + function read_buf(strm, buf, start, size) { + var len = strm.avail_in; + if (len > size) { + len = size; + } + if (len === 0) { + return 0; + } + strm.avail_in -= len; + utils2.arraySet(buf, strm.input, strm.next_in, len, start); + if (strm.state.wrap === 1) { + strm.adler = adler32(strm.adler, buf, len, start); + } else if (strm.state.wrap === 2) { + strm.adler = crc322(strm.adler, buf, len, start); + } + strm.next_in += len; + strm.total_in += len; + return len; + } + function longest_match(s6, cur_match) { + var chain_length = s6.max_chain_length; + var scan2 = s6.strstart; + var match2; + var len; + var best_len = s6.prev_length; + var nice_match = s6.nice_match; + var limit = s6.strstart > s6.w_size - MIN_LOOKAHEAD ? s6.strstart - (s6.w_size - MIN_LOOKAHEAD) : 0; + var _win = s6.window; + var wmask = s6.w_mask; + var prev = s6.prev; + var strend = s6.strstart + MAX_MATCH; + var scan_end1 = _win[scan2 + best_len - 1]; + var scan_end = _win[scan2 + best_len]; + if (s6.prev_length >= s6.good_match) { + chain_length >>= 2; + } + if (nice_match > s6.lookahead) { + nice_match = s6.lookahead; + } + do { + match2 = cur_match; + if (_win[match2 + best_len] !== scan_end || _win[match2 + best_len - 1] !== scan_end1 || _win[match2] !== _win[scan2] || _win[++match2] !== _win[scan2 + 1]) { + continue; } - } catch (e_1_1) { - e_1 = { error: e_1_1 }; - } finally { - try { - if (data_1_1 && !data_1_1.done && (_a2 = data_1.return)) _a2.call(data_1); - } finally { - if (e_1) throw e_1.error; + scan2 += 2; + match2++; + do { + } while (_win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && _win[++scan2] === _win[++match2] && scan2 < strend); + len = MAX_MATCH - (strend - scan2); + scan2 = strend - MAX_MATCH; + if (len > best_len) { + s6.match_start = cur_match; + best_len = len; + if (len >= nice_match) { + break; + } + scan_end1 = _win[scan2 + best_len - 1]; + scan_end = _win[scan2 + best_len]; + } + } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0); + if (best_len <= s6.lookahead) { + return best_len; + } + return s6.lookahead; + } + function fill_window(s6) { + var _w_size = s6.w_size; + var p6, n6, m6, more, str; + do { + more = s6.window_size - s6.lookahead - s6.strstart; + if (s6.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) { + utils2.arraySet(s6.window, s6.window, _w_size, _w_size, 0); + s6.match_start -= _w_size; + s6.strstart -= _w_size; + s6.block_start -= _w_size; + n6 = s6.hash_size; + p6 = n6; + do { + m6 = s6.head[--p6]; + s6.head[p6] = m6 >= _w_size ? m6 - _w_size : 0; + } while (--n6); + n6 = _w_size; + p6 = n6; + do { + m6 = s6.prev[--p6]; + s6.prev[p6] = m6 >= _w_size ? m6 - _w_size : 0; + } while (--n6); + more += _w_size; + } + if (s6.strm.avail_in === 0) { + break; } + n6 = read_buf(s6.strm, s6.window, s6.strstart + s6.lookahead, more); + s6.lookahead += n6; + if (s6.lookahead + s6.insert >= MIN_MATCH) { + str = s6.strstart - s6.insert; + s6.ins_h = s6.window[str]; + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[str + 1]) & s6.hash_mask; + while (s6.insert) { + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[str + MIN_MATCH - 1]) & s6.hash_mask; + s6.prev[str & s6.w_mask] = s6.head[s6.ins_h]; + s6.head[s6.ins_h] = str; + str++; + s6.insert--; + if (s6.lookahead + s6.insert < MIN_MATCH) { + break; + } + } + } + } while (s6.lookahead < MIN_LOOKAHEAD && s6.strm.avail_in !== 0); + } + function deflate_stored(s6, flush2) { + var max_block_size = 65535; + if (max_block_size > s6.pending_buf_size - 5) { + max_block_size = s6.pending_buf_size - 5; } - return this; - }; - Crc32c2.prototype.digest = function() { - return (this.checksum ^ 4294967295) >>> 0; - }; - return Crc32c2; - })() -); -var a_lookupTable = [ - 0, - 4067132163, - 3778769143, - 324072436, - 3348797215, - 904991772, - 648144872, - 3570033899, - 2329499855, - 2024987596, - 1809983544, - 2575936315, - 1296289744, - 3207089363, - 2893594407, - 1578318884, - 274646895, - 3795141740, - 4049975192, - 51262619, - 3619967088, - 632279923, - 922689671, - 3298075524, - 2592579488, - 1760304291, - 2075979607, - 2312596564, - 1562183871, - 2943781820, - 3156637768, - 1313733451, - 549293790, - 3537243613, - 3246849577, - 871202090, - 3878099393, - 357341890, - 102525238, - 4101499445, - 2858735121, - 1477399826, - 1264559846, - 3107202533, - 1845379342, - 2677391885, - 2361733625, - 2125378298, - 820201905, - 3263744690, - 3520608582, - 598981189, - 4151959214, - 85089709, - 373468761, - 3827903834, - 3124367742, - 1213305469, - 1526817161, - 2842354314, - 2107672161, - 2412447074, - 2627466902, - 1861252501, - 1098587580, - 3004210879, - 2688576843, - 1378610760, - 2262928035, - 1955203488, - 1742404180, - 2511436119, - 3416409459, - 969524848, - 714683780, - 3639785095, - 205050476, - 4266873199, - 3976438427, - 526918040, - 1361435347, - 2739821008, - 2954799652, - 1114974503, - 2529119692, - 1691668175, - 2005155131, - 2247081528, - 3690758684, - 697762079, - 986182379, - 3366744552, - 476452099, - 3993867776, - 4250756596, - 255256311, - 1640403810, - 2477592673, - 2164122517, - 1922457750, - 2791048317, - 1412925310, - 1197962378, - 3037525897, - 3944729517, - 427051182, - 170179418, - 4165941337, - 746937522, - 3740196785, - 3451792453, - 1070968646, - 1905808397, - 2213795598, - 2426610938, - 1657317369, - 3053634322, - 1147748369, - 1463399397, - 2773627110, - 4215344322, - 153784257, - 444234805, - 3893493558, - 1021025245, - 3467647198, - 3722505002, - 797665321, - 2197175160, - 1889384571, - 1674398607, - 2443626636, - 1164749927, - 3070701412, - 2757221520, - 1446797203, - 137323447, - 4198817972, - 3910406976, - 461344835, - 3484808360, - 1037989803, - 781091935, - 3705997148, - 2460548119, - 1623424788, - 1939049696, - 2180517859, - 1429367560, - 2807687179, - 3020495871, - 1180866812, - 410100952, - 3927582683, - 4182430767, - 186734380, - 3756733383, - 763408580, - 1053836080, - 3434856499, - 2722870694, - 1344288421, - 1131464017, - 2971354706, - 1708204729, - 2545590714, - 2229949006, - 1988219213, - 680717673, - 3673779818, - 3383336350, - 1002577565, - 4010310262, - 493091189, - 238226049, - 4233660802, - 2987750089, - 1082061258, - 1395524158, - 2705686845, - 1972364758, - 2279892693, - 2494862625, - 1725896226, - 952904198, - 3399985413, - 3656866545, - 731699698, - 4283874585, - 222117402, - 510512622, - 3959836397, - 3280807620, - 837199303, - 582374963, - 3504198960, - 68661723, - 4135334616, - 3844915500, - 390545967, - 1230274059, - 3141532936, - 2825850620, - 1510247935, - 2395924756, - 2091215383, - 1878366691, - 2644384480, - 3553878443, - 565732008, - 854102364, - 3229815391, - 340358836, - 3861050807, - 4117890627, - 119113024, - 1493875044, - 2875275879, - 3090270611, - 1247431312, - 2660249211, - 1828433272, - 2141937292, - 2378227087, - 3811616794, - 291187481, - 34330861, - 4032846830, - 615137029, - 3603020806, - 3314634738, - 939183345, - 1776939221, - 2609017814, - 2295496738, - 2058945313, - 2926798794, - 1545135305, - 1330124605, - 3173225534, - 4084100981, - 17165430, - 307568514, - 3762199681, - 888469610, - 3332340585, - 3587147933, - 665062302, - 2042050490, - 2346497209, - 2559330125, - 1793573966, - 3190661285, - 1279665062, - 1595330642, - 2910671697 -]; -var lookupTable = uint32ArrayFrom(a_lookupTable); - -// ../node_modules/@aws-sdk/crc64-nvme/dist-es/Crc64Nvme.js -var generateCRC64NVMETable = () => { - const sliceLength = 8; - const tables = new Array(sliceLength); - for (let slice = 0; slice < sliceLength; slice++) { - const table = new Array(512); - for (let i6 = 0; i6 < 256; i6++) { - let crc = BigInt(i6); - for (let j6 = 0; j6 < 8 * (slice + 1); j6++) { - if (crc & 1n) { - crc = crc >> 1n ^ 0x9a6c9329ac4bc9b5n; + for (; ; ) { + if (s6.lookahead <= 1) { + fill_window(s6); + if (s6.lookahead === 0 && flush2 === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s6.lookahead === 0) { + break; + } + } + s6.strstart += s6.lookahead; + s6.lookahead = 0; + var max_start = s6.block_start + max_block_size; + if (s6.strstart === 0 || s6.strstart >= max_start) { + s6.lookahead = s6.strstart - max_start; + s6.strstart = max_start; + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + if (s6.strstart - s6.block_start >= s6.w_size - MIN_LOOKAHEAD) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + } + s6.insert = 0; + if (flush2 === Z_FINISH) { + flush_block_only(s6, true); + if (s6.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s6.strstart > s6.block_start) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_NEED_MORE; + } + function deflate_fast(s6, flush2) { + var hash_head; + var bflush; + for (; ; ) { + if (s6.lookahead < MIN_LOOKAHEAD) { + fill_window(s6); + if (s6.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s6.lookahead === 0) { + break; + } + } + hash_head = 0; + if (s6.lookahead >= MIN_MATCH) { + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[s6.strstart + MIN_MATCH - 1]) & s6.hash_mask; + hash_head = s6.prev[s6.strstart & s6.w_mask] = s6.head[s6.ins_h]; + s6.head[s6.ins_h] = s6.strstart; + } + if (hash_head !== 0 && s6.strstart - hash_head <= s6.w_size - MIN_LOOKAHEAD) { + s6.match_length = longest_match(s6, hash_head); + } + if (s6.match_length >= MIN_MATCH) { + bflush = trees._tr_tally(s6, s6.strstart - s6.match_start, s6.match_length - MIN_MATCH); + s6.lookahead -= s6.match_length; + if (s6.match_length <= s6.max_lazy_match && s6.lookahead >= MIN_MATCH) { + s6.match_length--; + do { + s6.strstart++; + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[s6.strstart + MIN_MATCH - 1]) & s6.hash_mask; + hash_head = s6.prev[s6.strstart & s6.w_mask] = s6.head[s6.ins_h]; + s6.head[s6.ins_h] = s6.strstart; + } while (--s6.match_length !== 0); + s6.strstart++; + } else { + s6.strstart += s6.match_length; + s6.match_length = 0; + s6.ins_h = s6.window[s6.strstart]; + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[s6.strstart + 1]) & s6.hash_mask; + } } else { - crc = crc >> 1n; + bflush = trees._tr_tally(s6, 0, s6.window[s6.strstart]); + s6.lookahead--; + s6.strstart++; + } + if (bflush) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } } } - table[i6 * 2] = Number(crc >> 32n & 0xffffffffn); - table[i6 * 2 + 1] = Number(crc & 0xffffffffn); + s6.insert = s6.strstart < MIN_MATCH - 1 ? s6.strstart : MIN_MATCH - 1; + if (flush2 === Z_FINISH) { + flush_block_only(s6, true); + if (s6.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s6.last_lit) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; } - tables[slice] = new Uint32Array(table); - } - return tables; -}; -var CRC64_NVME_REVERSED_TABLE; -var t0; -var t1; -var t2; -var t3; -var t4; -var t5; -var t6; -var t7; -var ensureTablesInitialized = () => { - if (!CRC64_NVME_REVERSED_TABLE) { - CRC64_NVME_REVERSED_TABLE = generateCRC64NVMETable(); - [t0, t1, t2, t3, t4, t5, t6, t7] = CRC64_NVME_REVERSED_TABLE; - } -}; -var Crc64Nvme = class { - c1 = 0; - c2 = 0; - constructor() { - ensureTablesInitialized(); - this.reset(); - } - update(data) { - const len = data.length; - let i6 = 0; - let crc1 = this.c1; - let crc2 = this.c2; - while (i6 + 8 <= len) { - const idx0 = ((crc2 ^ data[i6++]) & 255) << 1; - const idx1 = ((crc2 >>> 8 ^ data[i6++]) & 255) << 1; - const idx2 = ((crc2 >>> 16 ^ data[i6++]) & 255) << 1; - const idx3 = ((crc2 >>> 24 ^ data[i6++]) & 255) << 1; - const idx4 = ((crc1 ^ data[i6++]) & 255) << 1; - const idx5 = ((crc1 >>> 8 ^ data[i6++]) & 255) << 1; - const idx6 = ((crc1 >>> 16 ^ data[i6++]) & 255) << 1; - const idx7 = ((crc1 >>> 24 ^ data[i6++]) & 255) << 1; - crc1 = t7[idx0] ^ t6[idx1] ^ t5[idx2] ^ t4[idx3] ^ t3[idx4] ^ t2[idx5] ^ t1[idx6] ^ t0[idx7]; - crc2 = t7[idx0 + 1] ^ t6[idx1 + 1] ^ t5[idx2 + 1] ^ t4[idx3 + 1] ^ t3[idx4 + 1] ^ t2[idx5 + 1] ^ t1[idx6 + 1] ^ t0[idx7 + 1]; + function deflate_slow(s6, flush2) { + var hash_head; + var bflush; + var max_insert; + for (; ; ) { + if (s6.lookahead < MIN_LOOKAHEAD) { + fill_window(s6); + if (s6.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s6.lookahead === 0) { + break; + } + } + hash_head = 0; + if (s6.lookahead >= MIN_MATCH) { + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[s6.strstart + MIN_MATCH - 1]) & s6.hash_mask; + hash_head = s6.prev[s6.strstart & s6.w_mask] = s6.head[s6.ins_h]; + s6.head[s6.ins_h] = s6.strstart; + } + s6.prev_length = s6.match_length; + s6.prev_match = s6.match_start; + s6.match_length = MIN_MATCH - 1; + if (hash_head !== 0 && s6.prev_length < s6.max_lazy_match && s6.strstart - hash_head <= s6.w_size - MIN_LOOKAHEAD) { + s6.match_length = longest_match(s6, hash_head); + if (s6.match_length <= 5 && (s6.strategy === Z_FILTERED || s6.match_length === MIN_MATCH && s6.strstart - s6.match_start > 4096)) { + s6.match_length = MIN_MATCH - 1; + } + } + if (s6.prev_length >= MIN_MATCH && s6.match_length <= s6.prev_length) { + max_insert = s6.strstart + s6.lookahead - MIN_MATCH; + bflush = trees._tr_tally(s6, s6.strstart - 1 - s6.prev_match, s6.prev_length - MIN_MATCH); + s6.lookahead -= s6.prev_length - 1; + s6.prev_length -= 2; + do { + if (++s6.strstart <= max_insert) { + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[s6.strstart + MIN_MATCH - 1]) & s6.hash_mask; + hash_head = s6.prev[s6.strstart & s6.w_mask] = s6.head[s6.ins_h]; + s6.head[s6.ins_h] = s6.strstart; + } + } while (--s6.prev_length !== 0); + s6.match_available = 0; + s6.match_length = MIN_MATCH - 1; + s6.strstart++; + if (bflush) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + } else if (s6.match_available) { + bflush = trees._tr_tally(s6, 0, s6.window[s6.strstart - 1]); + if (bflush) { + flush_block_only(s6, false); + } + s6.strstart++; + s6.lookahead--; + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } else { + s6.match_available = 1; + s6.strstart++; + s6.lookahead--; + } + } + if (s6.match_available) { + bflush = trees._tr_tally(s6, 0, s6.window[s6.strstart - 1]); + s6.match_available = 0; + } + s6.insert = s6.strstart < MIN_MATCH - 1 ? s6.strstart : MIN_MATCH - 1; + if (flush2 === Z_FINISH) { + flush_block_only(s6, true); + if (s6.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s6.last_lit) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; } - while (i6 < len) { - const idx = ((crc2 ^ data[i6]) & 255) << 1; - crc2 = (crc2 >>> 8 | (crc1 & 255) << 24) >>> 0; - crc1 = crc1 >>> 8 ^ t0[idx]; - crc2 ^= t0[idx + 1]; - i6++; + function deflate_rle(s6, flush2) { + var bflush; + var prev; + var scan2, strend; + var _win = s6.window; + for (; ; ) { + if (s6.lookahead <= MAX_MATCH) { + fill_window(s6); + if (s6.lookahead <= MAX_MATCH && flush2 === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + if (s6.lookahead === 0) { + break; + } + } + s6.match_length = 0; + if (s6.lookahead >= MIN_MATCH && s6.strstart > 0) { + scan2 = s6.strstart - 1; + prev = _win[scan2]; + if (prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2]) { + strend = s6.strstart + MAX_MATCH; + do { + } while (prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2] && prev === _win[++scan2] && scan2 < strend); + s6.match_length = MAX_MATCH - (strend - scan2); + if (s6.match_length > s6.lookahead) { + s6.match_length = s6.lookahead; + } + } + } + if (s6.match_length >= MIN_MATCH) { + bflush = trees._tr_tally(s6, 1, s6.match_length - MIN_MATCH); + s6.lookahead -= s6.match_length; + s6.strstart += s6.match_length; + s6.match_length = 0; + } else { + bflush = trees._tr_tally(s6, 0, s6.window[s6.strstart]); + s6.lookahead--; + s6.strstart++; + } + if (bflush) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + } + s6.insert = 0; + if (flush2 === Z_FINISH) { + flush_block_only(s6, true); + if (s6.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s6.last_lit) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; } - this.c1 = crc1; - this.c2 = crc2; - } - async digest() { - const c1 = this.c1 ^ 4294967295; - const c22 = this.c2 ^ 4294967295; - return new Uint8Array([ - c1 >>> 24, - c1 >>> 16 & 255, - c1 >>> 8 & 255, - c1 & 255, - c22 >>> 24, - c22 >>> 16 & 255, - c22 >>> 8 & 255, - c22 & 255 - ]); - } - reset() { - this.c1 = 4294967295; - this.c2 = 4294967295; - } -}; - -// ../node_modules/@aws-sdk/crc64-nvme/dist-es/crc64-nvme-crt-container.js -var crc64NvmeCrtContainer = { - CrtCrc64Nvme: null -}; - -// ../node_modules/@aws-crypto/crc32/build/module/aws_crc32.js -var AwsCrc32 = ( - /** @class */ - (function() { - function AwsCrc322() { - this.crc32 = new Crc32(); + function deflate_huff(s6, flush2) { + var bflush; + for (; ; ) { + if (s6.lookahead === 0) { + fill_window(s6); + if (s6.lookahead === 0) { + if (flush2 === Z_NO_FLUSH) { + return BS_NEED_MORE; + } + break; + } + } + s6.match_length = 0; + bflush = trees._tr_tally(s6, 0, s6.window[s6.strstart]); + s6.lookahead--; + s6.strstart++; + if (bflush) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + } + s6.insert = 0; + if (flush2 === Z_FINISH) { + flush_block_only(s6, true); + if (s6.strm.avail_out === 0) { + return BS_FINISH_STARTED; + } + return BS_FINISH_DONE; + } + if (s6.last_lit) { + flush_block_only(s6, false); + if (s6.strm.avail_out === 0) { + return BS_NEED_MORE; + } + } + return BS_BLOCK_DONE; + } + function Config(good_length, max_lazy, nice_length, max_chain, func) { + this.good_length = good_length; + this.max_lazy = max_lazy; + this.nice_length = nice_length; + this.max_chain = max_chain; + this.func = func; + } + var configuration_table; + configuration_table = [ + /* good lazy nice chain */ + new Config(0, 0, 0, 0, deflate_stored), + /* 0 store only */ + new Config(4, 4, 8, 4, deflate_fast), + /* 1 max speed, no lazy matches */ + new Config(4, 5, 16, 8, deflate_fast), + /* 2 */ + new Config(4, 6, 32, 32, deflate_fast), + /* 3 */ + new Config(4, 4, 16, 16, deflate_slow), + /* 4 lazy matches */ + new Config(8, 16, 32, 32, deflate_slow), + /* 5 */ + new Config(8, 16, 128, 128, deflate_slow), + /* 6 */ + new Config(8, 32, 128, 256, deflate_slow), + /* 7 */ + new Config(32, 128, 258, 1024, deflate_slow), + /* 8 */ + new Config(32, 258, 258, 4096, deflate_slow) + /* 9 max compression */ + ]; + function lm_init(s6) { + s6.window_size = 2 * s6.w_size; + zero(s6.head); + s6.max_lazy_match = configuration_table[s6.level].max_lazy; + s6.good_match = configuration_table[s6.level].good_length; + s6.nice_match = configuration_table[s6.level].nice_length; + s6.max_chain_length = configuration_table[s6.level].max_chain; + s6.strstart = 0; + s6.block_start = 0; + s6.lookahead = 0; + s6.insert = 0; + s6.match_length = s6.prev_length = MIN_MATCH - 1; + s6.match_available = 0; + s6.ins_h = 0; + } + function DeflateState() { + this.strm = null; + this.status = 0; + this.pending_buf = null; + this.pending_buf_size = 0; + this.pending_out = 0; + this.pending = 0; + this.wrap = 0; + this.gzhead = null; + this.gzindex = 0; + this.method = Z_DEFLATED; + this.last_flush = -1; + this.w_size = 0; + this.w_bits = 0; + this.w_mask = 0; + this.window = null; + this.window_size = 0; + this.prev = null; + this.head = null; + this.ins_h = 0; + this.hash_size = 0; + this.hash_bits = 0; + this.hash_mask = 0; + this.hash_shift = 0; + this.block_start = 0; + this.match_length = 0; + this.prev_match = 0; + this.match_available = 0; + this.strstart = 0; + this.match_start = 0; + this.lookahead = 0; + this.prev_length = 0; + this.max_chain_length = 0; + this.max_lazy_match = 0; + this.level = 0; + this.strategy = 0; + this.good_match = 0; + this.nice_match = 0; + this.dyn_ltree = new utils2.Buf16(HEAP_SIZE * 2); + this.dyn_dtree = new utils2.Buf16((2 * D_CODES + 1) * 2); + this.bl_tree = new utils2.Buf16((2 * BL_CODES + 1) * 2); + zero(this.dyn_ltree); + zero(this.dyn_dtree); + zero(this.bl_tree); + this.l_desc = null; + this.d_desc = null; + this.bl_desc = null; + this.bl_count = new utils2.Buf16(MAX_BITS + 1); + this.heap = new utils2.Buf16(2 * L_CODES + 1); + zero(this.heap); + this.heap_len = 0; + this.heap_max = 0; + this.depth = new utils2.Buf16(2 * L_CODES + 1); + zero(this.depth); + this.l_buf = 0; + this.lit_bufsize = 0; + this.last_lit = 0; + this.d_buf = 0; + this.opt_len = 0; + this.static_len = 0; + this.matches = 0; + this.insert = 0; + this.bi_buf = 0; + this.bi_valid = 0; + } + function deflateResetKeep(strm) { + var s6; + if (!strm || !strm.state) { + return err(strm, Z_STREAM_ERROR); + } + strm.total_in = strm.total_out = 0; + strm.data_type = Z_UNKNOWN; + s6 = strm.state; + s6.pending = 0; + s6.pending_out = 0; + if (s6.wrap < 0) { + s6.wrap = -s6.wrap; + } + s6.status = s6.wrap ? INIT_STATE : BUSY_STATE; + strm.adler = s6.wrap === 2 ? 0 : 1; + s6.last_flush = Z_NO_FLUSH; + trees._tr_init(s6); + return Z_OK; + } + function deflateReset(strm) { + var ret2 = deflateResetKeep(strm); + if (ret2 === Z_OK) { + lm_init(strm.state); + } + return ret2; } - AwsCrc322.prototype.update = function(toHash) { - if (isEmptyData(toHash)) - return; - this.crc32.update(convertToBuffer(toHash)); + function deflateSetHeader(strm, head) { + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + if (strm.state.wrap !== 2) { + return Z_STREAM_ERROR; + } + strm.state.gzhead = head; + return Z_OK; + } + function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { + if (!strm) { + return Z_STREAM_ERROR; + } + var wrap = 1; + if (level === Z_DEFAULT_COMPRESSION) { + level = 6; + } + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } else if (windowBits > 15) { + wrap = 2; + windowBits -= 16; + } + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { + return err(strm, Z_STREAM_ERROR); + } + if (windowBits === 8) { + windowBits = 9; + } + var s6 = new DeflateState(); + strm.state = s6; + s6.strm = strm; + s6.wrap = wrap; + s6.gzhead = null; + s6.w_bits = windowBits; + s6.w_size = 1 << s6.w_bits; + s6.w_mask = s6.w_size - 1; + s6.hash_bits = memLevel + 7; + s6.hash_size = 1 << s6.hash_bits; + s6.hash_mask = s6.hash_size - 1; + s6.hash_shift = ~~((s6.hash_bits + MIN_MATCH - 1) / MIN_MATCH); + s6.window = new utils2.Buf8(s6.w_size * 2); + s6.head = new utils2.Buf16(s6.hash_size); + s6.prev = new utils2.Buf16(s6.w_size); + s6.lit_bufsize = 1 << memLevel + 6; + s6.pending_buf_size = s6.lit_bufsize * 4; + s6.pending_buf = new utils2.Buf8(s6.pending_buf_size); + s6.d_buf = 1 * s6.lit_bufsize; + s6.l_buf = (1 + 2) * s6.lit_bufsize; + s6.level = level; + s6.strategy = strategy; + s6.method = method; + return deflateReset(strm); + } + function deflateInit(strm, level) { + return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); + } + function deflate(strm, flush2) { + var old_flush, s6; + var beg, val; + if (!strm || !strm.state || flush2 > Z_BLOCK || flush2 < 0) { + return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR; + } + s6 = strm.state; + if (!strm.output || !strm.input && strm.avail_in !== 0 || s6.status === FINISH_STATE && flush2 !== Z_FINISH) { + return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR); + } + s6.strm = strm; + old_flush = s6.last_flush; + s6.last_flush = flush2; + if (s6.status === INIT_STATE) { + if (s6.wrap === 2) { + strm.adler = 0; + put_byte(s6, 31); + put_byte(s6, 139); + put_byte(s6, 8); + if (!s6.gzhead) { + put_byte(s6, 0); + put_byte(s6, 0); + put_byte(s6, 0); + put_byte(s6, 0); + put_byte(s6, 0); + put_byte(s6, s6.level === 9 ? 2 : s6.strategy >= Z_HUFFMAN_ONLY || s6.level < 2 ? 4 : 0); + put_byte(s6, OS_CODE); + s6.status = BUSY_STATE; + } else { + put_byte( + s6, + (s6.gzhead.text ? 1 : 0) + (s6.gzhead.hcrc ? 2 : 0) + (!s6.gzhead.extra ? 0 : 4) + (!s6.gzhead.name ? 0 : 8) + (!s6.gzhead.comment ? 0 : 16) + ); + put_byte(s6, s6.gzhead.time & 255); + put_byte(s6, s6.gzhead.time >> 8 & 255); + put_byte(s6, s6.gzhead.time >> 16 & 255); + put_byte(s6, s6.gzhead.time >> 24 & 255); + put_byte(s6, s6.level === 9 ? 2 : s6.strategy >= Z_HUFFMAN_ONLY || s6.level < 2 ? 4 : 0); + put_byte(s6, s6.gzhead.os & 255); + if (s6.gzhead.extra && s6.gzhead.extra.length) { + put_byte(s6, s6.gzhead.extra.length & 255); + put_byte(s6, s6.gzhead.extra.length >> 8 & 255); + } + if (s6.gzhead.hcrc) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending, 0); + } + s6.gzindex = 0; + s6.status = EXTRA_STATE; + } + } else { + var header = Z_DEFLATED + (s6.w_bits - 8 << 4) << 8; + var level_flags = -1; + if (s6.strategy >= Z_HUFFMAN_ONLY || s6.level < 2) { + level_flags = 0; + } else if (s6.level < 6) { + level_flags = 1; + } else if (s6.level === 6) { + level_flags = 2; + } else { + level_flags = 3; + } + header |= level_flags << 6; + if (s6.strstart !== 0) { + header |= PRESET_DICT; + } + header += 31 - header % 31; + s6.status = BUSY_STATE; + putShortMSB(s6, header); + if (s6.strstart !== 0) { + putShortMSB(s6, strm.adler >>> 16); + putShortMSB(s6, strm.adler & 65535); + } + strm.adler = 1; + } + } + if (s6.status === EXTRA_STATE) { + if (s6.gzhead.extra) { + beg = s6.pending; + while (s6.gzindex < (s6.gzhead.extra.length & 65535)) { + if (s6.pending === s6.pending_buf_size) { + if (s6.gzhead.hcrc && s6.pending > beg) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending - beg, beg); + } + flush_pending(strm); + beg = s6.pending; + if (s6.pending === s6.pending_buf_size) { + break; + } + } + put_byte(s6, s6.gzhead.extra[s6.gzindex] & 255); + s6.gzindex++; + } + if (s6.gzhead.hcrc && s6.pending > beg) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending - beg, beg); + } + if (s6.gzindex === s6.gzhead.extra.length) { + s6.gzindex = 0; + s6.status = NAME_STATE; + } + } else { + s6.status = NAME_STATE; + } + } + if (s6.status === NAME_STATE) { + if (s6.gzhead.name) { + beg = s6.pending; + do { + if (s6.pending === s6.pending_buf_size) { + if (s6.gzhead.hcrc && s6.pending > beg) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending - beg, beg); + } + flush_pending(strm); + beg = s6.pending; + if (s6.pending === s6.pending_buf_size) { + val = 1; + break; + } + } + if (s6.gzindex < s6.gzhead.name.length) { + val = s6.gzhead.name.charCodeAt(s6.gzindex++) & 255; + } else { + val = 0; + } + put_byte(s6, val); + } while (val !== 0); + if (s6.gzhead.hcrc && s6.pending > beg) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending - beg, beg); + } + if (val === 0) { + s6.gzindex = 0; + s6.status = COMMENT_STATE; + } + } else { + s6.status = COMMENT_STATE; + } + } + if (s6.status === COMMENT_STATE) { + if (s6.gzhead.comment) { + beg = s6.pending; + do { + if (s6.pending === s6.pending_buf_size) { + if (s6.gzhead.hcrc && s6.pending > beg) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending - beg, beg); + } + flush_pending(strm); + beg = s6.pending; + if (s6.pending === s6.pending_buf_size) { + val = 1; + break; + } + } + if (s6.gzindex < s6.gzhead.comment.length) { + val = s6.gzhead.comment.charCodeAt(s6.gzindex++) & 255; + } else { + val = 0; + } + put_byte(s6, val); + } while (val !== 0); + if (s6.gzhead.hcrc && s6.pending > beg) { + strm.adler = crc322(strm.adler, s6.pending_buf, s6.pending - beg, beg); + } + if (val === 0) { + s6.status = HCRC_STATE; + } + } else { + s6.status = HCRC_STATE; + } + } + if (s6.status === HCRC_STATE) { + if (s6.gzhead.hcrc) { + if (s6.pending + 2 > s6.pending_buf_size) { + flush_pending(strm); + } + if (s6.pending + 2 <= s6.pending_buf_size) { + put_byte(s6, strm.adler & 255); + put_byte(s6, strm.adler >> 8 & 255); + strm.adler = 0; + s6.status = BUSY_STATE; + } + } else { + s6.status = BUSY_STATE; + } + } + if (s6.pending !== 0) { + flush_pending(strm); + if (strm.avail_out === 0) { + s6.last_flush = -1; + return Z_OK; + } + } else if (strm.avail_in === 0 && rank(flush2) <= rank(old_flush) && flush2 !== Z_FINISH) { + return err(strm, Z_BUF_ERROR); + } + if (s6.status === FINISH_STATE && strm.avail_in !== 0) { + return err(strm, Z_BUF_ERROR); + } + if (strm.avail_in !== 0 || s6.lookahead !== 0 || flush2 !== Z_NO_FLUSH && s6.status !== FINISH_STATE) { + var bstate = s6.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s6, flush2) : s6.strategy === Z_RLE ? deflate_rle(s6, flush2) : configuration_table[s6.level].func(s6, flush2); + if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) { + s6.status = FINISH_STATE; + } + if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) { + if (strm.avail_out === 0) { + s6.last_flush = -1; + } + return Z_OK; + } + if (bstate === BS_BLOCK_DONE) { + if (flush2 === Z_PARTIAL_FLUSH) { + trees._tr_align(s6); + } else if (flush2 !== Z_BLOCK) { + trees._tr_stored_block(s6, 0, 0, false); + if (flush2 === Z_FULL_FLUSH) { + zero(s6.head); + if (s6.lookahead === 0) { + s6.strstart = 0; + s6.block_start = 0; + s6.insert = 0; + } + } + } + flush_pending(strm); + if (strm.avail_out === 0) { + s6.last_flush = -1; + return Z_OK; + } + } + } + if (flush2 !== Z_FINISH) { + return Z_OK; + } + if (s6.wrap <= 0) { + return Z_STREAM_END; + } + if (s6.wrap === 2) { + put_byte(s6, strm.adler & 255); + put_byte(s6, strm.adler >> 8 & 255); + put_byte(s6, strm.adler >> 16 & 255); + put_byte(s6, strm.adler >> 24 & 255); + put_byte(s6, strm.total_in & 255); + put_byte(s6, strm.total_in >> 8 & 255); + put_byte(s6, strm.total_in >> 16 & 255); + put_byte(s6, strm.total_in >> 24 & 255); + } else { + putShortMSB(s6, strm.adler >>> 16); + putShortMSB(s6, strm.adler & 65535); + } + flush_pending(strm); + if (s6.wrap > 0) { + s6.wrap = -s6.wrap; + } + return s6.pending !== 0 ? Z_OK : Z_STREAM_END; + } + function deflateEnd(strm) { + var status; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + status = strm.state.status; + if (status !== INIT_STATE && status !== EXTRA_STATE && status !== NAME_STATE && status !== COMMENT_STATE && status !== HCRC_STATE && status !== BUSY_STATE && status !== FINISH_STATE) { + return err(strm, Z_STREAM_ERROR); + } + strm.state = null; + return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK; + } + function deflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + var s6; + var str, n6; + var wrap; + var avail; + var next; + var input; + var tmpDict; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + s6 = strm.state; + wrap = s6.wrap; + if (wrap === 2 || wrap === 1 && s6.status !== INIT_STATE || s6.lookahead) { + return Z_STREAM_ERROR; + } + if (wrap === 1) { + strm.adler = adler32(strm.adler, dictionary, dictLength, 0); + } + s6.wrap = 0; + if (dictLength >= s6.w_size) { + if (wrap === 0) { + zero(s6.head); + s6.strstart = 0; + s6.block_start = 0; + s6.insert = 0; + } + tmpDict = new utils2.Buf8(s6.w_size); + utils2.arraySet(tmpDict, dictionary, dictLength - s6.w_size, s6.w_size, 0); + dictionary = tmpDict; + dictLength = s6.w_size; + } + avail = strm.avail_in; + next = strm.next_in; + input = strm.input; + strm.avail_in = dictLength; + strm.next_in = 0; + strm.input = dictionary; + fill_window(s6); + while (s6.lookahead >= MIN_MATCH) { + str = s6.strstart; + n6 = s6.lookahead - (MIN_MATCH - 1); + do { + s6.ins_h = (s6.ins_h << s6.hash_shift ^ s6.window[str + MIN_MATCH - 1]) & s6.hash_mask; + s6.prev[str & s6.w_mask] = s6.head[s6.ins_h]; + s6.head[s6.ins_h] = str; + str++; + } while (--n6); + s6.strstart = str; + s6.lookahead = MIN_MATCH - 1; + fill_window(s6); + } + s6.strstart += s6.lookahead; + s6.block_start = s6.strstart; + s6.insert = s6.lookahead; + s6.lookahead = 0; + s6.match_length = s6.prev_length = MIN_MATCH - 1; + s6.match_available = 0; + strm.next_in = next; + strm.input = input; + strm.avail_in = avail; + s6.wrap = wrap; + return Z_OK; + } + exports2.deflateInit = deflateInit; + exports2.deflateInit2 = deflateInit2; + exports2.deflateReset = deflateReset; + exports2.deflateResetKeep = deflateResetKeep; + exports2.deflateSetHeader = deflateSetHeader; + exports2.deflate = deflate; + exports2.deflateEnd = deflateEnd; + exports2.deflateSetDictionary = deflateSetDictionary; + exports2.deflateInfo = "pako deflate (from Nodeca project)"; + } +}); + +// ../node_modules/pako/lib/utils/strings.js +var require_strings = __commonJS({ + "../node_modules/pako/lib/utils/strings.js"(exports2) { + "use strict"; + var utils2 = require_common(); + var STR_APPLY_OK = true; + var STR_APPLY_UIA_OK = true; + try { + String.fromCharCode.apply(null, [0]); + } catch (__) { + STR_APPLY_OK = false; + } + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch (__) { + STR_APPLY_UIA_OK = false; + } + var _utf8len = new utils2.Buf8(256); + for (q6 = 0; q6 < 256; q6++) { + _utf8len[q6] = q6 >= 252 ? 6 : q6 >= 248 ? 5 : q6 >= 240 ? 4 : q6 >= 224 ? 3 : q6 >= 192 ? 2 : 1; + } + var q6; + _utf8len[254] = _utf8len[254] = 1; + exports2.string2buf = function(str) { + var buf, c7, c22, m_pos, i6, str_len = str.length, buf_len = 0; + for (m_pos = 0; m_pos < str_len; m_pos++) { + c7 = str.charCodeAt(m_pos); + if ((c7 & 64512) === 55296 && m_pos + 1 < str_len) { + c22 = str.charCodeAt(m_pos + 1); + if ((c22 & 64512) === 56320) { + c7 = 65536 + (c7 - 55296 << 10) + (c22 - 56320); + m_pos++; + } + } + buf_len += c7 < 128 ? 1 : c7 < 2048 ? 2 : c7 < 65536 ? 3 : 4; + } + buf = new utils2.Buf8(buf_len); + for (i6 = 0, m_pos = 0; i6 < buf_len; m_pos++) { + c7 = str.charCodeAt(m_pos); + if ((c7 & 64512) === 55296 && m_pos + 1 < str_len) { + c22 = str.charCodeAt(m_pos + 1); + if ((c22 & 64512) === 56320) { + c7 = 65536 + (c7 - 55296 << 10) + (c22 - 56320); + m_pos++; + } + } + if (c7 < 128) { + buf[i6++] = c7; + } else if (c7 < 2048) { + buf[i6++] = 192 | c7 >>> 6; + buf[i6++] = 128 | c7 & 63; + } else if (c7 < 65536) { + buf[i6++] = 224 | c7 >>> 12; + buf[i6++] = 128 | c7 >>> 6 & 63; + buf[i6++] = 128 | c7 & 63; + } else { + buf[i6++] = 240 | c7 >>> 18; + buf[i6++] = 128 | c7 >>> 12 & 63; + buf[i6++] = 128 | c7 >>> 6 & 63; + buf[i6++] = 128 | c7 & 63; + } + } + return buf; }; - AwsCrc322.prototype.digest = function() { - return __awaiter6(this, void 0, void 0, function() { - return __generator(this, function(_a2) { - return [2, numToUint8(this.crc32.digest())]; - }); - }); + function buf2binstring(buf, len) { + if (len < 65534) { + if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) { + return String.fromCharCode.apply(null, utils2.shrinkBuf(buf, len)); + } + } + var result = ""; + for (var i6 = 0; i6 < len; i6++) { + result += String.fromCharCode(buf[i6]); + } + return result; + } + exports2.buf2binstring = function(buf) { + return buf2binstring(buf, buf.length); }; - AwsCrc322.prototype.reset = function() { - this.crc32 = new Crc32(); + exports2.binstring2buf = function(str) { + var buf = new utils2.Buf8(str.length); + for (var i6 = 0, len = buf.length; i6 < len; i6++) { + buf[i6] = str.charCodeAt(i6); + } + return buf; }; - return AwsCrc322; - })() -); - -// ../node_modules/@aws-crypto/crc32/build/module/index.js -var Crc32 = ( - /** @class */ - (function() { - function Crc322() { - this.checksum = 4294967295; + exports2.buf2string = function(buf, max) { + var i6, out, c7, c_len; + var len = max || buf.length; + var utf16buf = new Array(len * 2); + for (out = 0, i6 = 0; i6 < len; ) { + c7 = buf[i6++]; + if (c7 < 128) { + utf16buf[out++] = c7; + continue; + } + c_len = _utf8len[c7]; + if (c_len > 4) { + utf16buf[out++] = 65533; + i6 += c_len - 1; + continue; + } + c7 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7; + while (c_len > 1 && i6 < len) { + c7 = c7 << 6 | buf[i6++] & 63; + c_len--; + } + if (c_len > 1) { + utf16buf[out++] = 65533; + continue; + } + if (c7 < 65536) { + utf16buf[out++] = c7; + } else { + c7 -= 65536; + utf16buf[out++] = 55296 | c7 >> 10 & 1023; + utf16buf[out++] = 56320 | c7 & 1023; + } + } + return buf2binstring(utf16buf, out); + }; + exports2.utf8border = function(buf, max) { + var pos; + max = max || buf.length; + if (max > buf.length) { + max = buf.length; + } + pos = max - 1; + while (pos >= 0 && (buf[pos] & 192) === 128) { + pos--; + } + if (pos < 0) { + return max; + } + if (pos === 0) { + return max; + } + return pos + _utf8len[buf[pos]] > max ? pos : max; + }; + } +}); + +// ../node_modules/pako/lib/zlib/zstream.js +var require_zstream = __commonJS({ + "../node_modules/pako/lib/zlib/zstream.js"(exports2, module2) { + "use strict"; + function ZStream() { + this.input = null; + this.next_in = 0; + this.avail_in = 0; + this.total_in = 0; + this.output = null; + this.next_out = 0; + this.avail_out = 0; + this.total_out = 0; + this.msg = ""; + this.state = null; + this.data_type = 2; + this.adler = 0; + } + module2.exports = ZStream; + } +}); + +// ../node_modules/pako/lib/deflate.js +var require_deflate2 = __commonJS({ + "../node_modules/pako/lib/deflate.js"(exports2) { + "use strict"; + var zlib_deflate = require_deflate(); + var utils2 = require_common(); + var strings = require_strings(); + var msg = require_messages(); + var ZStream = require_zstream(); + var toString2 = Object.prototype.toString; + var Z_NO_FLUSH = 0; + var Z_FINISH = 4; + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_SYNC_FLUSH = 2; + var Z_DEFAULT_COMPRESSION = -1; + var Z_DEFAULT_STRATEGY = 0; + var Z_DEFLATED = 8; + function Deflate(options) { + if (!(this instanceof Deflate)) return new Deflate(options); + this.options = utils2.assign({ + level: Z_DEFAULT_COMPRESSION, + method: Z_DEFLATED, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: Z_DEFAULT_STRATEGY, + to: "" + }, options || {}); + var opt = this.options; + if (opt.raw && opt.windowBits > 0) { + opt.windowBits = -opt.windowBits; + } else if (opt.gzip && opt.windowBits > 0 && opt.windowBits < 16) { + opt.windowBits += 16; + } + this.err = 0; + this.msg = ""; + this.ended = false; + this.chunks = []; + this.strm = new ZStream(); + this.strm.avail_out = 0; + var status = zlib_deflate.deflateInit2( + this.strm, + opt.level, + opt.method, + opt.windowBits, + opt.memLevel, + opt.strategy + ); + if (status !== Z_OK) { + throw new Error(msg[status]); + } + if (opt.header) { + zlib_deflate.deflateSetHeader(this.strm, opt.header); + } + if (opt.dictionary) { + var dict; + if (typeof opt.dictionary === "string") { + dict = strings.string2buf(opt.dictionary); + } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") { + dict = new Uint8Array(opt.dictionary); + } else { + dict = opt.dictionary; + } + status = zlib_deflate.deflateSetDictionary(this.strm, dict); + if (status !== Z_OK) { + throw new Error(msg[status]); + } + this._dict_set = true; + } } - Crc322.prototype.update = function(data) { - var e_1, _a2; - try { - for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) { - var byte = data_1_1.value; - this.checksum = this.checksum >>> 8 ^ lookupTable2[(this.checksum ^ byte) & 255]; + Deflate.prototype.push = function(data, mode) { + var strm = this.strm; + var chunkSize = this.options.chunkSize; + var status, _mode; + if (this.ended) { + return false; + } + _mode = mode === ~~mode ? mode : mode === true ? Z_FINISH : Z_NO_FLUSH; + if (typeof data === "string") { + strm.input = strings.string2buf(data); + } else if (toString2.call(data) === "[object ArrayBuffer]") { + strm.input = new Uint8Array(data); + } else { + strm.input = data; + } + strm.next_in = 0; + strm.avail_in = strm.input.length; + do { + if (strm.avail_out === 0) { + strm.output = new utils2.Buf8(chunkSize); + strm.next_out = 0; + strm.avail_out = chunkSize; + } + status = zlib_deflate.deflate(strm, _mode); + if (status !== Z_STREAM_END && status !== Z_OK) { + this.onEnd(status); + this.ended = true; + return false; } - } catch (e_1_1) { - e_1 = { error: e_1_1 }; - } finally { - try { - if (data_1_1 && !data_1_1.done && (_a2 = data_1.return)) _a2.call(data_1); - } finally { - if (e_1) throw e_1.error; + if (strm.avail_out === 0 || strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH)) { + if (this.options.to === "string") { + this.onData(strings.buf2binstring(utils2.shrinkBuf(strm.output, strm.next_out))); + } else { + this.onData(utils2.shrinkBuf(strm.output, strm.next_out)); + } } + } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END); + if (_mode === Z_FINISH) { + status = zlib_deflate.deflateEnd(this.strm); + this.onEnd(status); + this.ended = true; + return status === Z_OK; } - return this; + if (_mode === Z_SYNC_FLUSH) { + this.onEnd(Z_OK); + strm.avail_out = 0; + return true; + } + return true; }; - Crc322.prototype.digest = function() { - return (this.checksum ^ 4294967295) >>> 0; + Deflate.prototype.onData = function(chunk) { + this.chunks.push(chunk); + }; + Deflate.prototype.onEnd = function(status) { + if (status === Z_OK) { + if (this.options.to === "string") { + this.result = this.chunks.join(""); + } else { + this.result = utils2.flattenChunks(this.chunks); + } + } + this.chunks = []; + this.err = status; + this.msg = this.strm.msg; + }; + function deflate(input, options) { + var deflator = new Deflate(options); + deflator.push(input, true); + if (deflator.err) { + throw deflator.msg || msg[deflator.err]; + } + return deflator.result; + } + function deflateRaw(input, options) { + options = options || {}; + options.raw = true; + return deflate(input, options); + } + function gzip(input, options) { + options = options || {}; + options.gzip = true; + return deflate(input, options); + } + exports2.Deflate = Deflate; + exports2.deflate = deflate; + exports2.deflateRaw = deflateRaw; + exports2.gzip = gzip; + } +}); + +// ../node_modules/pako/lib/zlib/inffast.js +var require_inffast = __commonJS({ + "../node_modules/pako/lib/zlib/inffast.js"(exports2, module2) { + "use strict"; + var BAD = 30; + var TYPE = 12; + module2.exports = function inflate_fast(strm, start) { + var state2; + var _in; + var last; + var _out; + var beg; + var end; + var dmax; + var wsize; + var whave; + var wnext; + var s_window; + var hold; + var bits; + var lcode; + var dcode; + var lmask; + var dmask; + var here; + var op; + var len; + var dist; + var from; + var from_source; + var input, output; + state2 = strm.state; + _in = strm.next_in; + input = strm.input; + last = _in + (strm.avail_in - 5); + _out = strm.next_out; + output = strm.output; + beg = _out - (start - strm.avail_out); + end = _out + (strm.avail_out - 257); + dmax = state2.dmax; + wsize = state2.wsize; + whave = state2.whave; + wnext = state2.wnext; + s_window = state2.window; + hold = state2.hold; + bits = state2.bits; + lcode = state2.lencode; + dcode = state2.distcode; + lmask = (1 << state2.lenbits) - 1; + dmask = (1 << state2.distbits) - 1; + top: + do { + if (bits < 15) { + hold += input[_in++] << bits; + bits += 8; + hold += input[_in++] << bits; + bits += 8; + } + here = lcode[hold & lmask]; + dolen: + for (; ; ) { + op = here >>> 24; + hold >>>= op; + bits -= op; + op = here >>> 16 & 255; + if (op === 0) { + output[_out++] = here & 65535; + } else if (op & 16) { + len = here & 65535; + op &= 15; + if (op) { + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + } + len += hold & (1 << op) - 1; + hold >>>= op; + bits -= op; + } + if (bits < 15) { + hold += input[_in++] << bits; + bits += 8; + hold += input[_in++] << bits; + bits += 8; + } + here = dcode[hold & dmask]; + dodist: + for (; ; ) { + op = here >>> 24; + hold >>>= op; + bits -= op; + op = here >>> 16 & 255; + if (op & 16) { + dist = here & 65535; + op &= 15; + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + if (bits < op) { + hold += input[_in++] << bits; + bits += 8; + } + } + dist += hold & (1 << op) - 1; + if (dist > dmax) { + strm.msg = "invalid distance too far back"; + state2.mode = BAD; + break top; + } + hold >>>= op; + bits -= op; + op = _out - beg; + if (dist > op) { + op = dist - op; + if (op > whave) { + if (state2.sane) { + strm.msg = "invalid distance too far back"; + state2.mode = BAD; + break top; + } + } + from = 0; + from_source = s_window; + if (wnext === 0) { + from += wsize - op; + if (op < len) { + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = _out - dist; + from_source = output; + } + } else if (wnext < op) { + from += wsize + wnext - op; + op -= wnext; + if (op < len) { + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = 0; + if (wnext < len) { + op = wnext; + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = _out - dist; + from_source = output; + } + } + } else { + from += wnext - op; + if (op < len) { + len -= op; + do { + output[_out++] = s_window[from++]; + } while (--op); + from = _out - dist; + from_source = output; + } + } + while (len > 2) { + output[_out++] = from_source[from++]; + output[_out++] = from_source[from++]; + output[_out++] = from_source[from++]; + len -= 3; + } + if (len) { + output[_out++] = from_source[from++]; + if (len > 1) { + output[_out++] = from_source[from++]; + } + } + } else { + from = _out - dist; + do { + output[_out++] = output[from++]; + output[_out++] = output[from++]; + output[_out++] = output[from++]; + len -= 3; + } while (len > 2); + if (len) { + output[_out++] = output[from++]; + if (len > 1) { + output[_out++] = output[from++]; + } + } + } + } else if ((op & 64) === 0) { + here = dcode[(here & 65535) + (hold & (1 << op) - 1)]; + continue dodist; + } else { + strm.msg = "invalid distance code"; + state2.mode = BAD; + break top; + } + break; + } + } else if ((op & 64) === 0) { + here = lcode[(here & 65535) + (hold & (1 << op) - 1)]; + continue dolen; + } else if (op & 32) { + state2.mode = TYPE; + break top; + } else { + strm.msg = "invalid literal/length code"; + state2.mode = BAD; + break top; + } + break; + } + } while (_in < last && _out < end); + len = bits >> 3; + _in -= len; + bits -= len << 3; + hold &= (1 << bits) - 1; + strm.next_in = _in; + strm.next_out = _out; + strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last); + strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end); + state2.hold = hold; + state2.bits = bits; + return; }; - return Crc322; - })() -); -var a_lookUpTable = [ - 0, - 1996959894, - 3993919788, - 2567524794, - 124634137, - 1886057615, - 3915621685, - 2657392035, - 249268274, - 2044508324, - 3772115230, - 2547177864, - 162941995, - 2125561021, - 3887607047, - 2428444049, - 498536548, - 1789927666, - 4089016648, - 2227061214, - 450548861, - 1843258603, - 4107580753, - 2211677639, - 325883990, - 1684777152, - 4251122042, - 2321926636, - 335633487, - 1661365465, - 4195302755, - 2366115317, - 997073096, - 1281953886, - 3579855332, - 2724688242, - 1006888145, - 1258607687, - 3524101629, - 2768942443, - 901097722, - 1119000684, - 3686517206, - 2898065728, - 853044451, - 1172266101, - 3705015759, - 2882616665, - 651767980, - 1373503546, - 3369554304, - 3218104598, - 565507253, - 1454621731, - 3485111705, - 3099436303, - 671266974, - 1594198024, - 3322730930, - 2970347812, - 795835527, - 1483230225, - 3244367275, - 3060149565, - 1994146192, - 31158534, - 2563907772, - 4023717930, - 1907459465, - 112637215, - 2680153253, - 3904427059, - 2013776290, - 251722036, - 2517215374, - 3775830040, - 2137656763, - 141376813, - 2439277719, - 3865271297, - 1802195444, - 476864866, - 2238001368, - 4066508878, - 1812370925, - 453092731, - 2181625025, - 4111451223, - 1706088902, - 314042704, - 2344532202, - 4240017532, - 1658658271, - 366619977, - 2362670323, - 4224994405, - 1303535960, - 984961486, - 2747007092, - 3569037538, - 1256170817, - 1037604311, - 2765210733, - 3554079995, - 1131014506, - 879679996, - 2909243462, - 3663771856, - 1141124467, - 855842277, - 2852801631, - 3708648649, - 1342533948, - 654459306, - 3188396048, - 3373015174, - 1466479909, - 544179635, - 3110523913, - 3462522015, - 1591671054, - 702138776, - 2966460450, - 3352799412, - 1504918807, - 783551873, - 3082640443, - 3233442989, - 3988292384, - 2596254646, - 62317068, - 1957810842, - 3939845945, - 2647816111, - 81470997, - 1943803523, - 3814918930, - 2489596804, - 225274430, - 2053790376, - 3826175755, - 2466906013, - 167816743, - 2097651377, - 4027552580, - 2265490386, - 503444072, - 1762050814, - 4150417245, - 2154129355, - 426522225, - 1852507879, - 4275313526, - 2312317920, - 282753626, - 1742555852, - 4189708143, - 2394877945, - 397917763, - 1622183637, - 3604390888, - 2714866558, - 953729732, - 1340076626, - 3518719985, - 2797360999, - 1068828381, - 1219638859, - 3624741850, - 2936675148, - 906185462, - 1090812512, - 3747672003, - 2825379669, - 829329135, - 1181335161, - 3412177804, - 3160834842, - 628085408, - 1382605366, - 3423369109, - 3138078467, - 570562233, - 1426400815, - 3317316542, - 2998733608, - 733239954, - 1555261956, - 3268935591, - 3050360625, - 752459403, - 1541320221, - 2607071920, - 3965973030, - 1969922972, - 40735498, - 2617837225, - 3943577151, - 1913087877, - 83908371, - 2512341634, - 3803740692, - 2075208622, - 213261112, - 2463272603, - 3855990285, - 2094854071, - 198958881, - 2262029012, - 4057260610, - 1759359992, - 534414190, - 2176718541, - 4139329115, - 1873836001, - 414664567, - 2282248934, - 4279200368, - 1711684554, - 285281116, - 2405801727, - 4167216745, - 1634467795, - 376229701, - 2685067896, - 3608007406, - 1308918612, - 956543938, - 2808555105, - 3495958263, - 1231636301, - 1047427035, - 2932959818, - 3654703836, - 1088359270, - 936918e3, - 2847714899, - 3736837829, - 1202900863, - 817233897, - 3183342108, - 3401237130, - 1404277552, - 615818150, - 3134207493, - 3453421203, - 1423857449, - 601450431, - 3009837614, - 3294710456, - 1567103746, - 711928724, - 3020668471, - 3272380065, - 1510334235, - 755167117 -]; -var lookupTable2 = uint32ArrayFrom(a_lookUpTable); - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/getCrc32ChecksumAlgorithmFunction.js -var zlib = __toESM(require("zlib")); -var NodeCrc32 = class { - checksum = 0; - update(data) { - this.checksum = zlib.crc32(data, this.checksum); - } - async digest() { - return numToUint8(this.checksum); - } - reset() { - this.checksum = 0; - } -}; -var getCrc32ChecksumAlgorithmFunction = () => { - if (typeof zlib.crc32 === "undefined") { - return AwsCrc32; } - return NodeCrc32; -}; +}); -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/selectChecksumAlgorithmFunction.js -var selectChecksumAlgorithmFunction = (checksumAlgorithm, config) => { - switch (checksumAlgorithm) { - case ChecksumAlgorithm.MD5: - return config.md5; - case ChecksumAlgorithm.CRC32: - return getCrc32ChecksumAlgorithmFunction(); - case ChecksumAlgorithm.CRC32C: - return AwsCrc32c; - case ChecksumAlgorithm.CRC64NVME: - if (typeof crc64NvmeCrtContainer.CrtCrc64Nvme !== "function") { - return Crc64Nvme; +// ../node_modules/pako/lib/zlib/inftrees.js +var require_inftrees = __commonJS({ + "../node_modules/pako/lib/zlib/inftrees.js"(exports2, module2) { + "use strict"; + var utils2 = require_common(); + var MAXBITS = 15; + var ENOUGH_LENS = 852; + var ENOUGH_DISTS = 592; + var CODES = 0; + var LENS = 1; + var DISTS = 2; + var lbase = [ + /* Length codes 257..285 base */ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 13, + 15, + 17, + 19, + 23, + 27, + 31, + 35, + 43, + 51, + 59, + 67, + 83, + 99, + 115, + 131, + 163, + 195, + 227, + 258, + 0, + 0 + ]; + var lext = [ + /* Length codes 257..285 extra */ + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 17, + 17, + 17, + 17, + 18, + 18, + 18, + 18, + 19, + 19, + 19, + 19, + 20, + 20, + 20, + 20, + 21, + 21, + 21, + 21, + 16, + 72, + 78 + ]; + var dbase = [ + /* Distance codes 0..29 base */ + 1, + 2, + 3, + 4, + 5, + 7, + 9, + 13, + 17, + 25, + 33, + 49, + 65, + 97, + 129, + 193, + 257, + 385, + 513, + 769, + 1025, + 1537, + 2049, + 3073, + 4097, + 6145, + 8193, + 12289, + 16385, + 24577, + 0, + 0 + ]; + var dext = [ + /* Distance codes 0..29 extra */ + 16, + 16, + 16, + 16, + 17, + 17, + 18, + 18, + 19, + 19, + 20, + 20, + 21, + 21, + 22, + 22, + 23, + 23, + 24, + 24, + 25, + 25, + 26, + 26, + 27, + 27, + 28, + 28, + 29, + 29, + 64, + 64 + ]; + module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) { + var bits = opts.bits; + var len = 0; + var sym = 0; + var min = 0, max = 0; + var root = 0; + var curr = 0; + var drop = 0; + var left = 0; + var used = 0; + var huff = 0; + var incr; + var fill; + var low; + var mask; + var next; + var base = null; + var base_index = 0; + var end; + var count = new utils2.Buf16(MAXBITS + 1); + var offs = new utils2.Buf16(MAXBITS + 1); + var extra = null; + var extra_index = 0; + var here_bits, here_op, here_val; + for (len = 0; len <= MAXBITS; len++) { + count[len] = 0; + } + for (sym = 0; sym < codes; sym++) { + count[lens[lens_index + sym]]++; + } + root = bits; + for (max = MAXBITS; max >= 1; max--) { + if (count[max] !== 0) { + break; + } } - return crc64NvmeCrtContainer.CrtCrc64Nvme; - case ChecksumAlgorithm.SHA1: - return config.sha1; - case ChecksumAlgorithm.SHA256: - return config.sha256; - default: - throw new Error(`Unsupported checksum algorithm: ${checksumAlgorithm}`); - } -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/stringHasher.js -init_dist_es7(); -var stringHasher = (checksumAlgorithmFn, body) => { - const hash = new checksumAlgorithmFn(); - hash.update(toUint8Array(body || "")); - return hash.digest(); -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/flexibleChecksumsMiddleware.js -var flexibleChecksumsMiddlewareOptions = { - name: "flexibleChecksumsMiddleware", - step: "build", - tags: ["BODY_CHECKSUM"], - override: true -}; -var flexibleChecksumsMiddleware = (config, middlewareConfig) => (next, context3) => async (args) => { - if (!HttpRequest.isInstance(args.request)) { - return next(args); - } - if (hasHeaderWithPrefix("x-amz-checksum-", args.request.headers)) { - return next(args); - } - const { request: request4, input } = args; - const { body: requestBody, headers } = request4; - const { base64Encoder, streamHasher } = config; - const { requestChecksumRequired, requestAlgorithmMember } = middlewareConfig; - const requestChecksumCalculation = await config.requestChecksumCalculation(); - const requestAlgorithmMemberName = requestAlgorithmMember?.name; - const requestAlgorithmMemberHttpHeader = requestAlgorithmMember?.httpHeader; - if (requestAlgorithmMemberName && !input[requestAlgorithmMemberName]) { - if (requestChecksumCalculation === RequestChecksumCalculation.WHEN_SUPPORTED || requestChecksumRequired) { - input[requestAlgorithmMemberName] = DEFAULT_CHECKSUM_ALGORITHM; - if (requestAlgorithmMemberHttpHeader) { - headers[requestAlgorithmMemberHttpHeader] = DEFAULT_CHECKSUM_ALGORITHM; + if (root > max) { + root = max; } - } - } - const checksumAlgorithm = getChecksumAlgorithmForRequest(input, { - requestChecksumRequired, - requestAlgorithmMember: requestAlgorithmMember?.name, - requestChecksumCalculation - }); - let updatedBody = requestBody; - let updatedHeaders = headers; - if (checksumAlgorithm) { - switch (checksumAlgorithm) { - case ChecksumAlgorithm.CRC32: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_CRC32", "U"); - break; - case ChecksumAlgorithm.CRC32C: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_CRC32C", "V"); - break; - case ChecksumAlgorithm.CRC64NVME: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_CRC64", "W"); - break; - case ChecksumAlgorithm.SHA1: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_SHA1", "X"); - break; - case ChecksumAlgorithm.SHA256: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_SHA256", "Y"); - break; - } - const checksumLocationName = getChecksumLocationName(checksumAlgorithm); - const checksumAlgorithmFn = selectChecksumAlgorithmFunction(checksumAlgorithm, config); - if (isStreaming(requestBody)) { - const { getAwsChunkedEncodingStream: getAwsChunkedEncodingStream3, bodyLengthChecker } = config; - updatedBody = getAwsChunkedEncodingStream3(typeof config.requestStreamBufferSize === "number" && config.requestStreamBufferSize >= 8 * 1024 ? createBufferedReadable(requestBody, config.requestStreamBufferSize, context3.logger) : requestBody, { - base64Encoder, - bodyLengthChecker, - checksumLocationName, - checksumAlgorithmFn, - streamHasher - }); - updatedHeaders = { - ...headers, - "content-encoding": headers["content-encoding"] ? `${headers["content-encoding"]},aws-chunked` : "aws-chunked", - "transfer-encoding": "chunked", - "x-amz-decoded-content-length": headers["content-length"], - "x-amz-content-sha256": "STREAMING-UNSIGNED-PAYLOAD-TRAILER", - "x-amz-trailer": checksumLocationName - }; - delete updatedHeaders["content-length"]; - } else if (!hasHeader2(checksumLocationName, headers)) { - const rawChecksum = await stringHasher(checksumAlgorithmFn, requestBody); - updatedHeaders = { - ...headers, - [checksumLocationName]: base64Encoder(rawChecksum) - }; - } - } - try { - const result = await next({ - ...args, - request: { - ...request4, - headers: updatedHeaders, - body: updatedBody + if (max === 0) { + table[table_index++] = 1 << 24 | 64 << 16 | 0; + table[table_index++] = 1 << 24 | 64 << 16 | 0; + opts.bits = 1; + return 0; } - }); - return result; - } catch (e6) { - if (e6 instanceof Error && e6.name === "InvalidChunkSizeError") { - try { - if (!e6.message.endsWith(".")) { - e6.message += "."; + for (min = 1; min < max; min++) { + if (count[min] !== 0) { + break; } - e6.message += " Set [requestStreamBufferSize=number e.g. 65_536] in client constructor to instruct AWS SDK to buffer your input stream."; - } catch (ignored) { } - } - throw e6; - } -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/flexibleChecksumsInputMiddleware.js -init_dist_es22(); -var flexibleChecksumsInputMiddlewareOptions = { - name: "flexibleChecksumsInputMiddleware", - toMiddleware: "serializerMiddleware", - relation: "before", - tags: ["BODY_CHECKSUM"], - override: true -}; -var flexibleChecksumsInputMiddleware = (config, middlewareConfig) => (next, context3) => async (args) => { - const input = args.input; - const { requestValidationModeMember } = middlewareConfig; - const requestChecksumCalculation = await config.requestChecksumCalculation(); - const responseChecksumValidation = await config.responseChecksumValidation(); - switch (requestChecksumCalculation) { - case RequestChecksumCalculation.WHEN_REQUIRED: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_WHEN_REQUIRED", "a"); - break; - case RequestChecksumCalculation.WHEN_SUPPORTED: - setFeature(context3, "FLEXIBLE_CHECKSUMS_REQ_WHEN_SUPPORTED", "Z"); - break; - } - switch (responseChecksumValidation) { - case ResponseChecksumValidation.WHEN_REQUIRED: - setFeature(context3, "FLEXIBLE_CHECKSUMS_RES_WHEN_REQUIRED", "c"); - break; - case ResponseChecksumValidation.WHEN_SUPPORTED: - setFeature(context3, "FLEXIBLE_CHECKSUMS_RES_WHEN_SUPPORTED", "b"); - break; - } - if (requestValidationModeMember && !input[requestValidationModeMember]) { - if (responseChecksumValidation === ResponseChecksumValidation.WHEN_SUPPORTED) { - input[requestValidationModeMember] = "ENABLED"; - } - } - return next(args); -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/flexibleChecksumsResponseMiddleware.js -init_dist_es2(); - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/getChecksumAlgorithmListForResponse.js -var getChecksumAlgorithmListForResponse = (responseAlgorithms = []) => { - const validChecksumAlgorithms = []; - for (const algorithm of PRIORITY_ORDER_ALGORITHMS) { - if (!responseAlgorithms.includes(algorithm) || !CLIENT_SUPPORTED_ALGORITHMS.includes(algorithm)) { - continue; - } - validChecksumAlgorithms.push(algorithm); - } - return validChecksumAlgorithms; -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/isChecksumWithPartNumber.js -var isChecksumWithPartNumber = (checksum) => { - const lastHyphenIndex = checksum.lastIndexOf("-"); - if (lastHyphenIndex !== -1) { - const numberPart = checksum.slice(lastHyphenIndex + 1); - if (!numberPart.startsWith("0")) { - const number = parseInt(numberPart, 10); - if (!isNaN(number) && number >= 1 && number <= 1e4) { - return true; + if (root < min) { + root = min; } - } - } - return false; -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/validateChecksumFromResponse.js -init_dist_es14(); - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/getChecksum.js -var getChecksum = async (body, { checksumAlgorithmFn, base64Encoder }) => base64Encoder(await stringHasher(checksumAlgorithmFn, body)); - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/validateChecksumFromResponse.js -var validateChecksumFromResponse = async (response, { config, responseAlgorithms, logger: logger2 }) => { - const checksumAlgorithms = getChecksumAlgorithmListForResponse(responseAlgorithms); - const { body: responseBody, headers: responseHeaders } = response; - for (const algorithm of checksumAlgorithms) { - const responseHeader = getChecksumLocationName(algorithm); - const checksumFromResponse = responseHeaders[responseHeader]; - if (checksumFromResponse) { - let checksumAlgorithmFn; - try { - checksumAlgorithmFn = selectChecksumAlgorithmFunction(algorithm, config); - } catch (error2) { - if (algorithm === ChecksumAlgorithm.CRC64NVME) { - logger2?.warn(`Skipping ${ChecksumAlgorithm.CRC64NVME} checksum validation: ${error2.message}`); - continue; + left = 1; + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; + left -= count[len]; + if (left < 0) { + return -1; } - throw error2; } - const { base64Encoder } = config; - if (isStreaming(responseBody)) { - response.body = createChecksumStream2({ - expectedChecksum: checksumFromResponse, - checksumSourceLocation: responseHeader, - checksum: new checksumAlgorithmFn(), - source: responseBody, - base64Encoder - }); - return; + if (left > 0 && (type === CODES || max !== 1)) { + return -1; } - const checksum = await getChecksum(responseBody, { checksumAlgorithmFn, base64Encoder }); - if (checksum === checksumFromResponse) { - break; + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) { + offs[len + 1] = offs[len] + count[len]; } - throw new Error(`Checksum mismatch: expected "${checksum}" but received "${checksumFromResponse}" in response header "${responseHeader}".`); + for (sym = 0; sym < codes; sym++) { + if (lens[lens_index + sym] !== 0) { + work[offs[lens[lens_index + sym]]++] = sym; + } + } + if (type === CODES) { + base = extra = work; + end = 19; + } else if (type === LENS) { + base = lbase; + base_index -= 257; + extra = lext; + extra_index -= 257; + end = 256; + } else { + base = dbase; + extra = dext; + end = -1; + } + huff = 0; + sym = 0; + len = min; + next = table_index; + curr = root; + drop = 0; + low = -1; + used = 1 << root; + mask = used - 1; + if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { + return 1; + } + for (; ; ) { + here_bits = len - drop; + if (work[sym] < end) { + here_op = 0; + here_val = work[sym]; + } else if (work[sym] > end) { + here_op = extra[extra_index + work[sym]]; + here_val = base[base_index + work[sym]]; + } else { + here_op = 32 + 64; + here_val = 0; + } + incr = 1 << len - drop; + fill = 1 << curr; + min = fill; + do { + fill -= incr; + table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0; + } while (fill !== 0); + incr = 1 << len - 1; + while (huff & incr) { + incr >>= 1; + } + if (incr !== 0) { + huff &= incr - 1; + huff += incr; + } else { + huff = 0; + } + sym++; + if (--count[len] === 0) { + if (len === max) { + break; + } + len = lens[lens_index + work[sym]]; + } + if (len > root && (huff & mask) !== low) { + if (drop === 0) { + drop = root; + } + next += min; + curr = len - drop; + left = 1 << curr; + while (curr + drop < max) { + left -= count[curr + drop]; + if (left <= 0) { + break; + } + curr++; + left <<= 1; + } + used += 1 << curr; + if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) { + return 1; + } + low = huff & mask; + table[low] = root << 24 | curr << 16 | next - table_index | 0; + } + } + if (huff !== 0) { + table[next + huff] = len - drop << 24 | 64 << 16 | 0; + } + opts.bits = root; + return 0; + }; + } +}); + +// ../node_modules/pako/lib/zlib/inflate.js +var require_inflate = __commonJS({ + "../node_modules/pako/lib/zlib/inflate.js"(exports2) { + "use strict"; + var utils2 = require_common(); + var adler32 = require_adler32(); + var crc322 = require_crc32(); + var inflate_fast = require_inffast(); + var inflate_table = require_inftrees(); + var CODES = 0; + var LENS = 1; + var DISTS = 2; + var Z_FINISH = 4; + var Z_BLOCK = 5; + var Z_TREES = 6; + var Z_OK = 0; + var Z_STREAM_END = 1; + var Z_NEED_DICT = 2; + var Z_STREAM_ERROR = -2; + var Z_DATA_ERROR = -3; + var Z_MEM_ERROR = -4; + var Z_BUF_ERROR = -5; + var Z_DEFLATED = 8; + var HEAD = 1; + var FLAGS = 2; + var TIME = 3; + var OS = 4; + var EXLEN = 5; + var EXTRA = 6; + var NAME = 7; + var COMMENT = 8; + var HCRC = 9; + var DICTID = 10; + var DICT = 11; + var TYPE = 12; + var TYPEDO = 13; + var STORED = 14; + var COPY_ = 15; + var COPY = 16; + var TABLE = 17; + var LENLENS = 18; + var CODELENS = 19; + var LEN_ = 20; + var LEN = 21; + var LENEXT = 22; + var DIST = 23; + var DISTEXT = 24; + var MATCH = 25; + var LIT = 26; + var CHECK = 27; + var LENGTH = 28; + var DONE = 29; + var BAD = 30; + var MEM = 31; + var SYNC = 32; + var ENOUGH_LENS = 852; + var ENOUGH_DISTS = 592; + var MAX_WBITS = 15; + var DEF_WBITS = MAX_WBITS; + function zswap32(q6) { + return (q6 >>> 24 & 255) + (q6 >>> 8 & 65280) + ((q6 & 65280) << 8) + ((q6 & 255) << 24); + } + function InflateState() { + this.mode = 0; + this.last = false; + this.wrap = 0; + this.havedict = false; + this.flags = 0; + this.dmax = 0; + this.check = 0; + this.total = 0; + this.head = null; + this.wbits = 0; + this.wsize = 0; + this.whave = 0; + this.wnext = 0; + this.window = null; + this.hold = 0; + this.bits = 0; + this.length = 0; + this.offset = 0; + this.extra = 0; + this.lencode = null; + this.distcode = null; + this.lenbits = 0; + this.distbits = 0; + this.ncode = 0; + this.nlen = 0; + this.ndist = 0; + this.have = 0; + this.next = null; + this.lens = new utils2.Buf16(320); + this.work = new utils2.Buf16(288); + this.lendyn = null; + this.distdyn = null; + this.sane = 0; + this.back = 0; + this.was = 0; + } + function inflateResetKeep(strm) { + var state2; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + state2 = strm.state; + strm.total_in = strm.total_out = state2.total = 0; + strm.msg = ""; + if (state2.wrap) { + strm.adler = state2.wrap & 1; + } + state2.mode = HEAD; + state2.last = 0; + state2.havedict = 0; + state2.dmax = 32768; + state2.head = null; + state2.hold = 0; + state2.bits = 0; + state2.lencode = state2.lendyn = new utils2.Buf32(ENOUGH_LENS); + state2.distcode = state2.distdyn = new utils2.Buf32(ENOUGH_DISTS); + state2.sane = 1; + state2.back = -1; + return Z_OK; + } + function inflateReset(strm) { + var state2; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + state2 = strm.state; + state2.wsize = 0; + state2.whave = 0; + state2.wnext = 0; + return inflateResetKeep(strm); + } + function inflateReset2(strm, windowBits) { + var wrap; + var state2; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + state2 = strm.state; + if (windowBits < 0) { + wrap = 0; + windowBits = -windowBits; + } else { + wrap = (windowBits >> 4) + 1; + if (windowBits < 48) { + windowBits &= 15; + } + } + if (windowBits && (windowBits < 8 || windowBits > 15)) { + return Z_STREAM_ERROR; + } + if (state2.window !== null && state2.wbits !== windowBits) { + state2.window = null; + } + state2.wrap = wrap; + state2.wbits = windowBits; + return inflateReset(strm); } - } -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/flexibleChecksumsResponseMiddleware.js -var flexibleChecksumsResponseMiddlewareOptions = { - name: "flexibleChecksumsResponseMiddleware", - toMiddleware: "deserializerMiddleware", - relation: "after", - tags: ["BODY_CHECKSUM"], - override: true -}; -var flexibleChecksumsResponseMiddleware = (config, middlewareConfig) => (next, context3) => async (args) => { - if (!HttpRequest.isInstance(args.request)) { - return next(args); - } - const input = args.input; - const result = await next(args); - const response = result.response; - const { requestValidationModeMember, responseAlgorithms } = middlewareConfig; - if (requestValidationModeMember && input[requestValidationModeMember] === "ENABLED") { - const { clientName, commandName } = context3; - const isS3WholeObjectMultipartGetResponseChecksum = clientName === "S3Client" && commandName === "GetObjectCommand" && getChecksumAlgorithmListForResponse(responseAlgorithms).every((algorithm) => { - const responseHeader = getChecksumLocationName(algorithm); - const checksumFromResponse = response.headers[responseHeader]; - return !checksumFromResponse || isChecksumWithPartNumber(checksumFromResponse); - }); - if (isS3WholeObjectMultipartGetResponseChecksum) { - return result; + function inflateInit2(strm, windowBits) { + var ret2; + var state2; + if (!strm) { + return Z_STREAM_ERROR; + } + state2 = new InflateState(); + strm.state = state2; + state2.window = null; + ret2 = inflateReset2(strm, windowBits); + if (ret2 !== Z_OK) { + strm.state = null; + } + return ret2; } - await validateChecksumFromResponse(response, { - config, - responseAlgorithms, - logger: context3.logger - }); - } - return result; -}; - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/getFlexibleChecksumsPlugin.js -var getFlexibleChecksumsPlugin = (config, middlewareConfig) => ({ - applyToStack: (clientStack) => { - clientStack.add(flexibleChecksumsMiddleware(config, middlewareConfig), flexibleChecksumsMiddlewareOptions); - clientStack.addRelativeTo(flexibleChecksumsInputMiddleware(config, middlewareConfig), flexibleChecksumsInputMiddlewareOptions); - clientStack.addRelativeTo(flexibleChecksumsResponseMiddleware(config, middlewareConfig), flexibleChecksumsResponseMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-es/resolveFlexibleChecksumsConfig.js -init_dist_es3(); -var resolveFlexibleChecksumsConfig = (input) => { - const { requestChecksumCalculation, responseChecksumValidation, requestStreamBufferSize } = input; - return Object.assign(input, { - requestChecksumCalculation: normalizeProvider(requestChecksumCalculation ?? DEFAULT_REQUEST_CHECKSUM_CALCULATION), - responseChecksumValidation: normalizeProvider(responseChecksumValidation ?? DEFAULT_RESPONSE_CHECKSUM_VALIDATION), - requestStreamBufferSize: Number(requestStreamBufferSize ?? 0) - }); -}; - -// ../node_modules/@aws-sdk/client-s3/dist-es/S3Client.js -init_dist_es23(); -init_dist_es24(); -init_dist_es25(); - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/check-content-length-header.js -init_dist_es2(); -init_dist_es20(); -var CONTENT_LENGTH_HEADER = "content-length"; -var DECODED_CONTENT_LENGTH_HEADER = "x-amz-decoded-content-length"; -function checkContentLengthHeader() { - return (next, context3) => async (args) => { - const { request: request4 } = args; - if (HttpRequest.isInstance(request4)) { - if (!(CONTENT_LENGTH_HEADER in request4.headers) && !(DECODED_CONTENT_LENGTH_HEADER in request4.headers)) { - const message = `Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.`; - if (typeof context3?.logger?.warn === "function" && !(context3.logger instanceof NoOpLogger)) { - context3.logger.warn(message); + function inflateInit(strm) { + return inflateInit2(strm, DEF_WBITS); + } + var virgin = true; + var lenfix; + var distfix; + function fixedtables(state2) { + if (virgin) { + var sym; + lenfix = new utils2.Buf32(512); + distfix = new utils2.Buf32(32); + sym = 0; + while (sym < 144) { + state2.lens[sym++] = 8; + } + while (sym < 256) { + state2.lens[sym++] = 9; + } + while (sym < 280) { + state2.lens[sym++] = 7; + } + while (sym < 288) { + state2.lens[sym++] = 8; + } + inflate_table(LENS, state2.lens, 0, 288, lenfix, 0, state2.work, { bits: 9 }); + sym = 0; + while (sym < 32) { + state2.lens[sym++] = 5; + } + inflate_table(DISTS, state2.lens, 0, 32, distfix, 0, state2.work, { bits: 5 }); + virgin = false; + } + state2.lencode = lenfix; + state2.lenbits = 9; + state2.distcode = distfix; + state2.distbits = 5; + } + function updatewindow(strm, src, end, copy) { + var dist; + var state2 = strm.state; + if (state2.window === null) { + state2.wsize = 1 << state2.wbits; + state2.wnext = 0; + state2.whave = 0; + state2.window = new utils2.Buf8(state2.wsize); + } + if (copy >= state2.wsize) { + utils2.arraySet(state2.window, src, end - state2.wsize, state2.wsize, 0); + state2.wnext = 0; + state2.whave = state2.wsize; + } else { + dist = state2.wsize - state2.wnext; + if (dist > copy) { + dist = copy; + } + utils2.arraySet(state2.window, src, end - copy, dist, state2.wnext); + copy -= dist; + if (copy) { + utils2.arraySet(state2.window, src, end - copy, copy, 0); + state2.wnext = copy; + state2.whave = state2.wsize; } else { - console.warn(message); - } + state2.wnext += dist; + if (state2.wnext === state2.wsize) { + state2.wnext = 0; + } + if (state2.whave < state2.wsize) { + state2.whave += dist; + } + } + } + return 0; + } + function inflate(strm, flush2) { + var state2; + var input, output; + var next; + var put; + var have, left; + var hold; + var bits; + var _in, _out; + var copy; + var from; + var from_source; + var here = 0; + var here_bits, here_op, here_val; + var last_bits, last_op, last_val; + var len; + var ret2; + var hbuf = new utils2.Buf8(4); + var opts; + var n6; + var order = ( + /* permutation of code lengths */ + [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15] + ); + if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) { + return Z_STREAM_ERROR; + } + state2 = strm.state; + if (state2.mode === TYPE) { + state2.mode = TYPEDO; + } + put = strm.next_out; + output = strm.output; + left = strm.avail_out; + next = strm.next_in; + input = strm.input; + have = strm.avail_in; + hold = state2.hold; + bits = state2.bits; + _in = have; + _out = left; + ret2 = Z_OK; + inf_leave: + for (; ; ) { + switch (state2.mode) { + case HEAD: + if (state2.wrap === 0) { + state2.mode = TYPEDO; + break; + } + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (state2.wrap & 2 && hold === 35615) { + state2.check = 0; + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state2.check = crc322(state2.check, hbuf, 2, 0); + hold = 0; + bits = 0; + state2.mode = FLAGS; + break; + } + state2.flags = 0; + if (state2.head) { + state2.head.done = false; + } + if (!(state2.wrap & 1) || /* check if zlib header allowed */ + (((hold & 255) << 8) + (hold >> 8)) % 31) { + strm.msg = "incorrect header check"; + state2.mode = BAD; + break; + } + if ((hold & 15) !== Z_DEFLATED) { + strm.msg = "unknown compression method"; + state2.mode = BAD; + break; + } + hold >>>= 4; + bits -= 4; + len = (hold & 15) + 8; + if (state2.wbits === 0) { + state2.wbits = len; + } else if (len > state2.wbits) { + strm.msg = "invalid window size"; + state2.mode = BAD; + break; + } + state2.dmax = 1 << len; + strm.adler = state2.check = 1; + state2.mode = hold & 512 ? DICTID : TYPE; + hold = 0; + bits = 0; + break; + case FLAGS: + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.flags = hold; + if ((state2.flags & 255) !== Z_DEFLATED) { + strm.msg = "unknown compression method"; + state2.mode = BAD; + break; + } + if (state2.flags & 57344) { + strm.msg = "unknown header flags set"; + state2.mode = BAD; + break; + } + if (state2.head) { + state2.head.text = hold >> 8 & 1; + } + if (state2.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state2.check = crc322(state2.check, hbuf, 2, 0); + } + hold = 0; + bits = 0; + state2.mode = TIME; + /* falls through */ + case TIME: + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (state2.head) { + state2.head.time = hold; + } + if (state2.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + hbuf[2] = hold >>> 16 & 255; + hbuf[3] = hold >>> 24 & 255; + state2.check = crc322(state2.check, hbuf, 4, 0); + } + hold = 0; + bits = 0; + state2.mode = OS; + /* falls through */ + case OS: + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (state2.head) { + state2.head.xflags = hold & 255; + state2.head.os = hold >> 8; + } + if (state2.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state2.check = crc322(state2.check, hbuf, 2, 0); + } + hold = 0; + bits = 0; + state2.mode = EXLEN; + /* falls through */ + case EXLEN: + if (state2.flags & 1024) { + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.length = hold; + if (state2.head) { + state2.head.extra_len = hold; + } + if (state2.flags & 512) { + hbuf[0] = hold & 255; + hbuf[1] = hold >>> 8 & 255; + state2.check = crc322(state2.check, hbuf, 2, 0); + } + hold = 0; + bits = 0; + } else if (state2.head) { + state2.head.extra = null; + } + state2.mode = EXTRA; + /* falls through */ + case EXTRA: + if (state2.flags & 1024) { + copy = state2.length; + if (copy > have) { + copy = have; + } + if (copy) { + if (state2.head) { + len = state2.head.extra_len - state2.length; + if (!state2.head.extra) { + state2.head.extra = new Array(state2.head.extra_len); + } + utils2.arraySet( + state2.head.extra, + input, + next, + // extra field is limited to 65536 bytes + // - no need for additional size check + copy, + /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ + len + ); + } + if (state2.flags & 512) { + state2.check = crc322(state2.check, input, copy, next); + } + have -= copy; + next += copy; + state2.length -= copy; + } + if (state2.length) { + break inf_leave; + } + } + state2.length = 0; + state2.mode = NAME; + /* falls through */ + case NAME: + if (state2.flags & 2048) { + if (have === 0) { + break inf_leave; + } + copy = 0; + do { + len = input[next + copy++]; + if (state2.head && len && state2.length < 65536) { + state2.head.name += String.fromCharCode(len); + } + } while (len && copy < have); + if (state2.flags & 512) { + state2.check = crc322(state2.check, input, copy, next); + } + have -= copy; + next += copy; + if (len) { + break inf_leave; + } + } else if (state2.head) { + state2.head.name = null; + } + state2.length = 0; + state2.mode = COMMENT; + /* falls through */ + case COMMENT: + if (state2.flags & 4096) { + if (have === 0) { + break inf_leave; + } + copy = 0; + do { + len = input[next + copy++]; + if (state2.head && len && state2.length < 65536) { + state2.head.comment += String.fromCharCode(len); + } + } while (len && copy < have); + if (state2.flags & 512) { + state2.check = crc322(state2.check, input, copy, next); + } + have -= copy; + next += copy; + if (len) { + break inf_leave; + } + } else if (state2.head) { + state2.head.comment = null; + } + state2.mode = HCRC; + /* falls through */ + case HCRC: + if (state2.flags & 512) { + while (bits < 16) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (hold !== (state2.check & 65535)) { + strm.msg = "header crc mismatch"; + state2.mode = BAD; + break; + } + hold = 0; + bits = 0; + } + if (state2.head) { + state2.head.hcrc = state2.flags >> 9 & 1; + state2.head.done = true; + } + strm.adler = state2.check = 0; + state2.mode = TYPE; + break; + case DICTID: + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + strm.adler = state2.check = zswap32(hold); + hold = 0; + bits = 0; + state2.mode = DICT; + /* falls through */ + case DICT: + if (state2.havedict === 0) { + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state2.hold = hold; + state2.bits = bits; + return Z_NEED_DICT; + } + strm.adler = state2.check = 1; + state2.mode = TYPE; + /* falls through */ + case TYPE: + if (flush2 === Z_BLOCK || flush2 === Z_TREES) { + break inf_leave; + } + /* falls through */ + case TYPEDO: + if (state2.last) { + hold >>>= bits & 7; + bits -= bits & 7; + state2.mode = CHECK; + break; + } + while (bits < 3) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.last = hold & 1; + hold >>>= 1; + bits -= 1; + switch (hold & 3) { + case 0: + state2.mode = STORED; + break; + case 1: + fixedtables(state2); + state2.mode = LEN_; + if (flush2 === Z_TREES) { + hold >>>= 2; + bits -= 2; + break inf_leave; + } + break; + case 2: + state2.mode = TABLE; + break; + case 3: + strm.msg = "invalid block type"; + state2.mode = BAD; + } + hold >>>= 2; + bits -= 2; + break; + case STORED: + hold >>>= bits & 7; + bits -= bits & 7; + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if ((hold & 65535) !== (hold >>> 16 ^ 65535)) { + strm.msg = "invalid stored block lengths"; + state2.mode = BAD; + break; + } + state2.length = hold & 65535; + hold = 0; + bits = 0; + state2.mode = COPY_; + if (flush2 === Z_TREES) { + break inf_leave; + } + /* falls through */ + case COPY_: + state2.mode = COPY; + /* falls through */ + case COPY: + copy = state2.length; + if (copy) { + if (copy > have) { + copy = have; + } + if (copy > left) { + copy = left; + } + if (copy === 0) { + break inf_leave; + } + utils2.arraySet(output, input, next, copy, put); + have -= copy; + next += copy; + left -= copy; + put += copy; + state2.length -= copy; + break; + } + state2.mode = TYPE; + break; + case TABLE: + while (bits < 14) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.nlen = (hold & 31) + 257; + hold >>>= 5; + bits -= 5; + state2.ndist = (hold & 31) + 1; + hold >>>= 5; + bits -= 5; + state2.ncode = (hold & 15) + 4; + hold >>>= 4; + bits -= 4; + if (state2.nlen > 286 || state2.ndist > 30) { + strm.msg = "too many length or distance symbols"; + state2.mode = BAD; + break; + } + state2.have = 0; + state2.mode = LENLENS; + /* falls through */ + case LENLENS: + while (state2.have < state2.ncode) { + while (bits < 3) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.lens[order[state2.have++]] = hold & 7; + hold >>>= 3; + bits -= 3; + } + while (state2.have < 19) { + state2.lens[order[state2.have++]] = 0; + } + state2.lencode = state2.lendyn; + state2.lenbits = 7; + opts = { bits: state2.lenbits }; + ret2 = inflate_table(CODES, state2.lens, 0, 19, state2.lencode, 0, state2.work, opts); + state2.lenbits = opts.bits; + if (ret2) { + strm.msg = "invalid code lengths set"; + state2.mode = BAD; + break; + } + state2.have = 0; + state2.mode = CODELENS; + /* falls through */ + case CODELENS: + while (state2.have < state2.nlen + state2.ndist) { + for (; ; ) { + here = state2.lencode[hold & (1 << state2.lenbits) - 1]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (here_val < 16) { + hold >>>= here_bits; + bits -= here_bits; + state2.lens[state2.have++] = here_val; + } else { + if (here_val === 16) { + n6 = here_bits + 2; + while (bits < n6) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= here_bits; + bits -= here_bits; + if (state2.have === 0) { + strm.msg = "invalid bit length repeat"; + state2.mode = BAD; + break; + } + len = state2.lens[state2.have - 1]; + copy = 3 + (hold & 3); + hold >>>= 2; + bits -= 2; + } else if (here_val === 17) { + n6 = here_bits + 3; + while (bits < n6) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= here_bits; + bits -= here_bits; + len = 0; + copy = 3 + (hold & 7); + hold >>>= 3; + bits -= 3; + } else { + n6 = here_bits + 7; + while (bits < n6) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= here_bits; + bits -= here_bits; + len = 0; + copy = 11 + (hold & 127); + hold >>>= 7; + bits -= 7; + } + if (state2.have + copy > state2.nlen + state2.ndist) { + strm.msg = "invalid bit length repeat"; + state2.mode = BAD; + break; + } + while (copy--) { + state2.lens[state2.have++] = len; + } + } + } + if (state2.mode === BAD) { + break; + } + if (state2.lens[256] === 0) { + strm.msg = "invalid code -- missing end-of-block"; + state2.mode = BAD; + break; + } + state2.lenbits = 9; + opts = { bits: state2.lenbits }; + ret2 = inflate_table(LENS, state2.lens, 0, state2.nlen, state2.lencode, 0, state2.work, opts); + state2.lenbits = opts.bits; + if (ret2) { + strm.msg = "invalid literal/lengths set"; + state2.mode = BAD; + break; + } + state2.distbits = 6; + state2.distcode = state2.distdyn; + opts = { bits: state2.distbits }; + ret2 = inflate_table(DISTS, state2.lens, state2.nlen, state2.ndist, state2.distcode, 0, state2.work, opts); + state2.distbits = opts.bits; + if (ret2) { + strm.msg = "invalid distances set"; + state2.mode = BAD; + break; + } + state2.mode = LEN_; + if (flush2 === Z_TREES) { + break inf_leave; + } + /* falls through */ + case LEN_: + state2.mode = LEN; + /* falls through */ + case LEN: + if (have >= 6 && left >= 258) { + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state2.hold = hold; + state2.bits = bits; + inflate_fast(strm, _out); + put = strm.next_out; + output = strm.output; + left = strm.avail_out; + next = strm.next_in; + input = strm.input; + have = strm.avail_in; + hold = state2.hold; + bits = state2.bits; + if (state2.mode === TYPE) { + state2.back = -1; + } + break; + } + state2.back = 0; + for (; ; ) { + here = state2.lencode[hold & (1 << state2.lenbits) - 1]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (here_op && (here_op & 240) === 0) { + last_bits = here_bits; + last_op = here_op; + last_val = here_val; + for (; ; ) { + here = state2.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (last_bits + here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= last_bits; + bits -= last_bits; + state2.back += last_bits; + } + hold >>>= here_bits; + bits -= here_bits; + state2.back += here_bits; + state2.length = here_val; + if (here_op === 0) { + state2.mode = LIT; + break; + } + if (here_op & 32) { + state2.back = -1; + state2.mode = TYPE; + break; + } + if (here_op & 64) { + strm.msg = "invalid literal/length code"; + state2.mode = BAD; + break; + } + state2.extra = here_op & 15; + state2.mode = LENEXT; + /* falls through */ + case LENEXT: + if (state2.extra) { + n6 = state2.extra; + while (bits < n6) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.length += hold & (1 << state2.extra) - 1; + hold >>>= state2.extra; + bits -= state2.extra; + state2.back += state2.extra; + } + state2.was = state2.length; + state2.mode = DIST; + /* falls through */ + case DIST: + for (; ; ) { + here = state2.distcode[hold & (1 << state2.distbits) - 1]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if ((here_op & 240) === 0) { + last_bits = here_bits; + last_op = here_op; + last_val = here_val; + for (; ; ) { + here = state2.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)]; + here_bits = here >>> 24; + here_op = here >>> 16 & 255; + here_val = here & 65535; + if (last_bits + here_bits <= bits) { + break; + } + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + hold >>>= last_bits; + bits -= last_bits; + state2.back += last_bits; + } + hold >>>= here_bits; + bits -= here_bits; + state2.back += here_bits; + if (here_op & 64) { + strm.msg = "invalid distance code"; + state2.mode = BAD; + break; + } + state2.offset = here_val; + state2.extra = here_op & 15; + state2.mode = DISTEXT; + /* falls through */ + case DISTEXT: + if (state2.extra) { + n6 = state2.extra; + while (bits < n6) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + state2.offset += hold & (1 << state2.extra) - 1; + hold >>>= state2.extra; + bits -= state2.extra; + state2.back += state2.extra; + } + if (state2.offset > state2.dmax) { + strm.msg = "invalid distance too far back"; + state2.mode = BAD; + break; + } + state2.mode = MATCH; + /* falls through */ + case MATCH: + if (left === 0) { + break inf_leave; + } + copy = _out - left; + if (state2.offset > copy) { + copy = state2.offset - copy; + if (copy > state2.whave) { + if (state2.sane) { + strm.msg = "invalid distance too far back"; + state2.mode = BAD; + break; + } + } + if (copy > state2.wnext) { + copy -= state2.wnext; + from = state2.wsize - copy; + } else { + from = state2.wnext - copy; + } + if (copy > state2.length) { + copy = state2.length; + } + from_source = state2.window; + } else { + from_source = output; + from = put - state2.offset; + copy = state2.length; + } + if (copy > left) { + copy = left; + } + left -= copy; + state2.length -= copy; + do { + output[put++] = from_source[from++]; + } while (--copy); + if (state2.length === 0) { + state2.mode = LEN; + } + break; + case LIT: + if (left === 0) { + break inf_leave; + } + output[put++] = state2.length; + left--; + state2.mode = LEN; + break; + case CHECK: + if (state2.wrap) { + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold |= input[next++] << bits; + bits += 8; + } + _out -= left; + strm.total_out += _out; + state2.total += _out; + if (_out) { + strm.adler = state2.check = /*UPDATE(state.check, put - _out, _out);*/ + state2.flags ? crc322(state2.check, output, _out, put - _out) : adler32(state2.check, output, _out, put - _out); + } + _out = left; + if ((state2.flags ? hold : zswap32(hold)) !== state2.check) { + strm.msg = "incorrect data check"; + state2.mode = BAD; + break; + } + hold = 0; + bits = 0; + } + state2.mode = LENGTH; + /* falls through */ + case LENGTH: + if (state2.wrap && state2.flags) { + while (bits < 32) { + if (have === 0) { + break inf_leave; + } + have--; + hold += input[next++] << bits; + bits += 8; + } + if (hold !== (state2.total & 4294967295)) { + strm.msg = "incorrect length check"; + state2.mode = BAD; + break; + } + hold = 0; + bits = 0; + } + state2.mode = DONE; + /* falls through */ + case DONE: + ret2 = Z_STREAM_END; + break inf_leave; + case BAD: + ret2 = Z_DATA_ERROR; + break inf_leave; + case MEM: + return Z_MEM_ERROR; + case SYNC: + /* falls through */ + default: + return Z_STREAM_ERROR; + } + } + strm.next_out = put; + strm.avail_out = left; + strm.next_in = next; + strm.avail_in = have; + state2.hold = hold; + state2.bits = bits; + if (state2.wsize || _out !== strm.avail_out && state2.mode < BAD && (state2.mode < CHECK || flush2 !== Z_FINISH)) { + if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) { + state2.mode = MEM; + return Z_MEM_ERROR; + } + } + _in -= strm.avail_in; + _out -= strm.avail_out; + strm.total_in += _in; + strm.total_out += _out; + state2.total += _out; + if (state2.wrap && _out) { + strm.adler = state2.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/ + state2.flags ? crc322(state2.check, output, _out, strm.next_out - _out) : adler32(state2.check, output, _out, strm.next_out - _out); + } + strm.data_type = state2.bits + (state2.last ? 64 : 0) + (state2.mode === TYPE ? 128 : 0) + (state2.mode === LEN_ || state2.mode === COPY_ ? 256 : 0); + if ((_in === 0 && _out === 0 || flush2 === Z_FINISH) && ret2 === Z_OK) { + ret2 = Z_BUF_ERROR; } + return ret2; } - return next({ ...args }); - }; -} -var checkContentLengthHeaderMiddlewareOptions = { - step: "finalizeRequest", - tags: ["CHECK_CONTENT_LENGTH_HEADER"], - name: "getCheckContentLengthHeaderPlugin", - override: true -}; -var getCheckContentLengthHeaderPlugin = (unused) => ({ - applyToStack: (clientStack) => { - clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/region-redirect-endpoint-middleware.js -var regionRedirectEndpointMiddleware = (config) => { - return (next, context3) => async (args) => { - const originalRegion = await config.region(); - const regionProviderRef = config.region; - let unlock = () => { - }; - if (context3.__s3RegionRedirect) { - Object.defineProperty(config, "region", { - writable: false, - value: async () => { - return context3.__s3RegionRedirect; - } - }); - unlock = () => Object.defineProperty(config, "region", { - writable: true, - value: regionProviderRef - }); + function inflateEnd(strm) { + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + var state2 = strm.state; + if (state2.window) { + state2.window = null; + } + strm.state = null; + return Z_OK; } - try { - const result = await next(args); - if (context3.__s3RegionRedirect) { - unlock(); - const region = await config.region(); - if (originalRegion !== region) { - throw new Error("Region was not restored following S3 region redirect."); - } + function inflateGetHeader(strm, head) { + var state2; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; } - return result; - } catch (e6) { - unlock(); - throw e6; + state2 = strm.state; + if ((state2.wrap & 2) === 0) { + return Z_STREAM_ERROR; + } + state2.head = head; + head.done = false; + return Z_OK; } - }; -}; -var regionRedirectEndpointMiddlewareOptions = { - tags: ["REGION_REDIRECT", "S3"], - name: "regionRedirectEndpointMiddleware", - override: true, - relation: "before", - toMiddleware: "endpointV2Middleware" -}; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/region-redirect-middleware.js -function regionRedirectMiddleware(clientConfig) { - return (next, context3) => async (args) => { - try { - return await next(args); - } catch (err) { - if (clientConfig.followRegionRedirects) { - const statusCode = err?.$metadata?.httpStatusCode; - const isHeadBucket = context3.commandName === "HeadBucketCommand"; - const bucketRegionHeader = err?.$response?.headers?.["x-amz-bucket-region"]; - if (bucketRegionHeader) { - if (statusCode === 301 || statusCode === 400 && (err?.name === "IllegalLocationConstraintException" || isHeadBucket)) { - try { - const actualRegion = bucketRegionHeader; - context3.logger?.debug(`Redirecting from ${await clientConfig.region()} to ${actualRegion}`); - context3.__s3RegionRedirect = actualRegion; - } catch (e6) { - throw new Error("Region redirect failed: " + e6); - } - return next(args); - } + function inflateSetDictionary(strm, dictionary) { + var dictLength = dictionary.length; + var state2; + var dictid; + var ret2; + if (!strm || !strm.state) { + return Z_STREAM_ERROR; + } + state2 = strm.state; + if (state2.wrap !== 0 && state2.mode !== DICT) { + return Z_STREAM_ERROR; + } + if (state2.mode === DICT) { + dictid = 1; + dictid = adler32(dictid, dictionary, dictLength, 0); + if (dictid !== state2.check) { + return Z_DATA_ERROR; } } - throw err; + ret2 = updatewindow(strm, dictionary, dictLength, dictLength); + if (ret2) { + state2.mode = MEM; + return Z_MEM_ERROR; + } + state2.havedict = 1; + return Z_OK; } - }; -} -var regionRedirectMiddlewareOptions = { - step: "initialize", - tags: ["REGION_REDIRECT", "S3"], - name: "regionRedirectMiddleware", - override: true -}; -var getRegionRedirectMiddlewarePlugin = (clientConfig) => ({ - applyToStack: (clientStack) => { - clientStack.add(regionRedirectMiddleware(clientConfig), regionRedirectMiddlewareOptions); - clientStack.addRelativeTo(regionRedirectEndpointMiddleware(clientConfig), regionRedirectEndpointMiddlewareOptions); + exports2.inflateReset = inflateReset; + exports2.inflateReset2 = inflateReset2; + exports2.inflateResetKeep = inflateResetKeep; + exports2.inflateInit = inflateInit; + exports2.inflateInit2 = inflateInit2; + exports2.inflate = inflate; + exports2.inflateEnd = inflateEnd; + exports2.inflateGetHeader = inflateGetHeader; + exports2.inflateSetDictionary = inflateSetDictionary; + exports2.inflateInfo = "pako inflate (from Nodeca project)"; } }); -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-expires-middleware.js -init_dist_es2(); -init_dist_es20(); -var s3ExpiresMiddleware = (config) => { - return (next, context3) => async (args) => { - const result = await next(args); - const { response } = result; - if (HttpResponse.isInstance(response)) { - if (response.headers.expires) { - response.headers.expiresstring = response.headers.expires; - try { - parseRfc7231DateTime(response.headers.expires); - } catch (e6) { - context3.logger?.warn(`AWS SDK Warning for ${context3.clientName}::${context3.commandName} response parsing (${response.headers.expires}): ${e6}`); - delete response.headers.expires; +// ../node_modules/pako/lib/zlib/constants.js +var require_constants7 = __commonJS({ + "../node_modules/pako/lib/zlib/constants.js"(exports2, module2) { + "use strict"; + module2.exports = { + /* Allowed flush values; see deflate() and inflate() below for details */ + 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, + /* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + //Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + //Z_VERSION_ERROR: -6, + /* compression levels */ + 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, + /* Possible values of the data_type field (though see inflate()) */ + Z_BINARY: 0, + Z_TEXT: 1, + //Z_ASCII: 1, // = Z_TEXT (deprecated) + Z_UNKNOWN: 2, + /* The deflate compression method */ + Z_DEFLATED: 8 + //Z_NULL: null // Use -1 or null inline, depending on var type + }; + } +}); + +// ../node_modules/pako/lib/zlib/gzheader.js +var require_gzheader = __commonJS({ + "../node_modules/pako/lib/zlib/gzheader.js"(exports2, module2) { + "use strict"; + function GZheader() { + this.text = 0; + this.time = 0; + this.xflags = 0; + this.os = 0; + this.extra = null; + this.extra_len = 0; + this.name = ""; + this.comment = ""; + this.hcrc = 0; + this.done = false; + } + module2.exports = GZheader; + } +}); + +// ../node_modules/pako/lib/inflate.js +var require_inflate2 = __commonJS({ + "../node_modules/pako/lib/inflate.js"(exports2) { + "use strict"; + var zlib_inflate = require_inflate(); + var utils2 = require_common(); + var strings = require_strings(); + var c7 = require_constants7(); + var msg = require_messages(); + var ZStream = require_zstream(); + var GZheader = require_gzheader(); + var toString2 = Object.prototype.toString; + function Inflate(options) { + if (!(this instanceof Inflate)) return new Inflate(options); + this.options = utils2.assign({ + chunkSize: 16384, + windowBits: 0, + to: "" + }, options || {}); + var opt = this.options; + if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) { + opt.windowBits = -opt.windowBits; + if (opt.windowBits === 0) { + opt.windowBits = -15; + } + } + if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) { + opt.windowBits += 32; + } + if (opt.windowBits > 15 && opt.windowBits < 48) { + if ((opt.windowBits & 15) === 0) { + opt.windowBits |= 15; + } + } + this.err = 0; + this.msg = ""; + this.ended = false; + this.chunks = []; + this.strm = new ZStream(); + this.strm.avail_out = 0; + var status = zlib_inflate.inflateInit2( + this.strm, + opt.windowBits + ); + if (status !== c7.Z_OK) { + throw new Error(msg[status]); + } + this.header = new GZheader(); + zlib_inflate.inflateGetHeader(this.strm, this.header); + if (opt.dictionary) { + if (typeof opt.dictionary === "string") { + opt.dictionary = strings.string2buf(opt.dictionary); + } else if (toString2.call(opt.dictionary) === "[object ArrayBuffer]") { + opt.dictionary = new Uint8Array(opt.dictionary); + } + if (opt.raw) { + status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary); + if (status !== c7.Z_OK) { + throw new Error(msg[status]); + } } } } - return result; - }; -}; -var s3ExpiresMiddlewareOptions = { - tags: ["S3"], - name: "s3ExpiresMiddleware", - override: true, - relation: "after", - toMiddleware: "deserializerMiddleware" -}; -var getS3ExpiresMiddlewarePlugin = (clientConfig) => ({ - applyToStack: (clientStack) => { - clientStack.addRelativeTo(s3ExpiresMiddleware(clientConfig), s3ExpiresMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/classes/S3ExpressIdentityCache.js -var S3ExpressIdentityCache = class _S3ExpressIdentityCache { - data; - lastPurgeTime = Date.now(); - static EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS = 3e4; - constructor(data = {}) { - this.data = data; - } - get(key) { - const entry = this.data[key]; - if (!entry) { - return; - } - return entry; - } - set(key, entry) { - this.data[key] = entry; - return entry; - } - delete(key) { - delete this.data[key]; - } - async purgeExpired() { - const now = Date.now(); - if (this.lastPurgeTime + _S3ExpressIdentityCache.EXPIRED_CREDENTIAL_PURGE_INTERVAL_MS > now) { - return; - } - for (const key in this.data) { - const entry = this.data[key]; - if (!entry.isRefreshing) { - const credential = await entry.identity; - if (credential.expiration) { - if (credential.expiration.getTime() < now) { - delete this.data[key]; + Inflate.prototype.push = function(data, mode) { + var strm = this.strm; + var chunkSize = this.options.chunkSize; + var dictionary = this.options.dictionary; + var status, _mode; + var next_out_utf8, tail, utf8str; + var allowBufError = false; + if (this.ended) { + return false; + } + _mode = mode === ~~mode ? mode : mode === true ? c7.Z_FINISH : c7.Z_NO_FLUSH; + if (typeof data === "string") { + strm.input = strings.binstring2buf(data); + } else if (toString2.call(data) === "[object ArrayBuffer]") { + strm.input = new Uint8Array(data); + } else { + strm.input = data; + } + strm.next_in = 0; + strm.avail_in = strm.input.length; + do { + if (strm.avail_out === 0) { + strm.output = new utils2.Buf8(chunkSize); + strm.next_out = 0; + strm.avail_out = chunkSize; + } + status = zlib_inflate.inflate(strm, c7.Z_NO_FLUSH); + if (status === c7.Z_NEED_DICT && dictionary) { + status = zlib_inflate.inflateSetDictionary(this.strm, dictionary); + } + if (status === c7.Z_BUF_ERROR && allowBufError === true) { + status = c7.Z_OK; + allowBufError = false; + } + if (status !== c7.Z_STREAM_END && status !== c7.Z_OK) { + this.onEnd(status); + this.ended = true; + return false; + } + if (strm.next_out) { + if (strm.avail_out === 0 || status === c7.Z_STREAM_END || strm.avail_in === 0 && (_mode === c7.Z_FINISH || _mode === c7.Z_SYNC_FLUSH)) { + if (this.options.to === "string") { + next_out_utf8 = strings.utf8border(strm.output, strm.next_out); + tail = strm.next_out - next_out_utf8; + utf8str = strings.buf2string(strm.output, next_out_utf8); + strm.next_out = tail; + strm.avail_out = chunkSize - tail; + if (tail) { + utils2.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); + } + this.onData(utf8str); + } else { + this.onData(utils2.shrinkBuf(strm.output, strm.next_out)); + } } } + if (strm.avail_in === 0 && strm.avail_out === 0) { + allowBufError = true; + } + } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c7.Z_STREAM_END); + if (status === c7.Z_STREAM_END) { + _mode = c7.Z_FINISH; + } + if (_mode === c7.Z_FINISH) { + status = zlib_inflate.inflateEnd(this.strm); + this.onEnd(status); + this.ended = true; + return status === c7.Z_OK; + } + if (_mode === c7.Z_SYNC_FLUSH) { + this.onEnd(c7.Z_OK); + strm.avail_out = 0; + return true; + } + return true; + }; + Inflate.prototype.onData = function(chunk) { + this.chunks.push(chunk); + }; + Inflate.prototype.onEnd = function(status) { + if (status === c7.Z_OK) { + if (this.options.to === "string") { + this.result = this.chunks.join(""); + } else { + this.result = utils2.flattenChunks(this.chunks); + } } + this.chunks = []; + this.err = status; + this.msg = this.strm.msg; + }; + function inflate(input, options) { + var inflator = new Inflate(options); + inflator.push(input, true); + if (inflator.err) { + throw inflator.msg || msg[inflator.err]; + } + return inflator.result; } + function inflateRaw(input, options) { + options = options || {}; + options.raw = true; + return inflate(input, options); + } + exports2.Inflate = Inflate; + exports2.inflate = inflate; + exports2.inflateRaw = inflateRaw; + exports2.ungzip = inflate; } -}; +}); -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/classes/S3ExpressIdentityCacheEntry.js -var S3ExpressIdentityCacheEntry = class { - _identity; - isRefreshing; - accessed; - constructor(_identity, isRefreshing = false, accessed = Date.now()) { - this._identity = _identity; - this.isRefreshing = isRefreshing; - this.accessed = accessed; - } - get identity() { - this.accessed = Date.now(); - return this._identity; +// ../node_modules/pako/index.js +var require_pako = __commonJS({ + "../node_modules/pako/index.js"(exports2, module2) { + "use strict"; + var assign = require_common().assign; + var deflate = require_deflate2(); + var inflate = require_inflate2(); + var constants4 = require_constants7(); + var pako = {}; + assign(pako, deflate, inflate, constants4); + module2.exports = pako; } -}; +}); -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/classes/S3ExpressIdentityProviderImpl.js -var S3ExpressIdentityProviderImpl = class _S3ExpressIdentityProviderImpl { - createSessionFn; - cache; - static REFRESH_WINDOW_MS = 6e4; - constructor(createSessionFn, cache6 = new S3ExpressIdentityCache()) { - this.createSessionFn = createSessionFn; - this.cache = cache6; - } - async getS3ExpressIdentity(awsIdentity, identityProperties) { - const key = identityProperties.Bucket; - const { cache: cache6 } = this; - const entry = cache6.get(key); - if (entry) { - return entry.identity.then((identity) => { - const isExpired = (identity.expiration?.getTime() ?? 0) < Date.now(); - if (isExpired) { - return cache6.set(key, new S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity; - } - const isExpiringSoon = (identity.expiration?.getTime() ?? 0) < Date.now() + _S3ExpressIdentityProviderImpl.REFRESH_WINDOW_MS; - if (isExpiringSoon && !entry.isRefreshing) { - entry.isRefreshing = true; - this.getIdentity(key).then((id) => { - cache6.set(key, new S3ExpressIdentityCacheEntry(Promise.resolve(id))); - }); - } - return identity; - }); - } - return cache6.set(key, new S3ExpressIdentityCacheEntry(this.getIdentity(key))).identity; - } - async getIdentity(key) { - await this.cache.purgeExpired().catch((error2) => { - console.warn("Error while clearing expired entries in S3ExpressIdentityCache: \n" + error2); - }); - const session = await this.createSessionFn(key); - if (!session.Credentials?.AccessKeyId || !session.Credentials?.SecretAccessKey) { - throw new Error("s3#createSession response credential missing AccessKeyId or SecretAccessKey."); - } - const identity = { - accessKeyId: session.Credentials.AccessKeyId, - secretAccessKey: session.Credentials.SecretAccessKey, - sessionToken: session.Credentials.SessionToken, - expiration: session.Credentials.Expiration ? new Date(session.Credentials.Expiration) : void 0 - }; - return identity; - } -}; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/constants.js -init_dist_es26(); -var S3_EXPRESS_BUCKET_TYPE = "Directory"; -var S3_EXPRESS_BACKEND = "S3Express"; -var S3_EXPRESS_AUTH_SCHEME = "sigv4-s3express"; -var SESSION_TOKEN_QUERY_PARAM = "X-Amz-S3session-Token"; -var SESSION_TOKEN_HEADER = SESSION_TOKEN_QUERY_PARAM.toLowerCase(); -var NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME = "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH"; -var NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME = "s3_disable_express_session_auth"; -var NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_OPTIONS = { - environmentVariableSelector: (env3) => booleanSelector(env3, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_ENV_NAME, SelectorType2.ENV), - configFileSelector: (profile) => booleanSelector(profile, NODE_DISABLE_S3_EXPRESS_SESSION_AUTH_INI_NAME, SelectorType2.CONFIG), - default: false -}; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/functions/s3ExpressMiddleware.js -init_dist_es22(); -init_dist_es2(); -var s3ExpressMiddleware = (options) => { - return (next, context3) => async (args) => { - if (context3.endpointV2) { - const endpoint2 = context3.endpointV2; - const isS3ExpressAuth = endpoint2.properties?.authSchemes?.[0]?.name === S3_EXPRESS_AUTH_SCHEME; - const isS3ExpressBucket = endpoint2.properties?.backend === S3_EXPRESS_BACKEND || endpoint2.properties?.bucketType === S3_EXPRESS_BUCKET_TYPE; - if (isS3ExpressBucket) { - setFeature(context3, "S3_EXPRESS_BUCKET", "J"); - context3.isS3ExpressBucket = true; - } - if (isS3ExpressAuth) { - const requestBucket = args.input.Bucket; - if (requestBucket) { - const s3ExpressIdentity = await options.s3ExpressIdentityProvider.getS3ExpressIdentity(await options.credentials(), { - Bucket: requestBucket - }); - context3.s3ExpressIdentity = s3ExpressIdentity; - if (HttpRequest.isInstance(args.request) && s3ExpressIdentity.sessionToken) { - args.request.headers[SESSION_TOKEN_HEADER] = s3ExpressIdentity.sessionToken; +// ../node_modules/utif2/UTIF.js +var require_UTIF = __commonJS({ + "../node_modules/utif2/UTIF.js"(exports2, module2) { + "use strict"; + (function() { + var UTIF = {}; + if (typeof module2 == "object") { + module2.exports = UTIF; + } else { + self.UTIF = UTIF; + } + var pako = typeof require === "function" ? require_pako() : self.pako; + function log() { + if (typeof process == "undefined" || process.env.NODE_ENV == "development") console.log.apply(console, arguments); + } + (function(UTIF2, pako2) { + (function() { + "use strict"; + var W2 = (function a1() { + function W3(p6) { + this.message = "JPEG error: " + p6; + } + W3.prototype = new Error(); + W3.prototype.name = "JpegError"; + W3.constructor = W3; + return W3; + })(), ak2 = (function ag2() { + var p6 = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]), t12 = 4017, ac2 = 799, ah2 = 3406, ao2 = 2276, ar2 = 1567, ai2 = 3784, s6 = 5793, ad2 = 2896; + function ak3(Q2) { + if (Q2 == null) Q2 = {}; + if (Q2.w == null) Q2.w = -1; + this.V = Q2.n; + this.N = Q2.w; + } + function a52(Q2, h6) { + var f6 = 0, G3 = [], n6, E3, a6 = 16, F3; + while (a6 > 0 && !Q2[a6 - 1]) { + a6--; + } + G3.push({ children: [], index: 0 }); + var C3 = G3[0]; + for (n6 = 0; n6 < a6; n6++) { + for (E3 = 0; E3 < Q2[n6]; E3++) { + C3 = G3.pop(); + C3.children[C3.index] = h6[f6]; + while (C3.index > 0) { + C3 = G3.pop(); + } + C3.index++; + G3.push(C3); + while (G3.length <= n6) { + G3.push(F3 = { children: [], index: 0 }); + C3.children[C3.index] = F3.children; + C3 = F3; + } + f6++; + } + if (n6 + 1 < a6) { + G3.push(F3 = { children: [], index: 0 }); + C3.children[C3.index] = F3.children; + C3 = F3; + } + } + return G3[0].children; + } + function a22(Q2, h6, f6) { + return 64 * ((Q2.P + 1) * h6 + f6); + } + function a7(Q2, h6, f6, G3, n6, E3, a6, C3, F3, d6) { + if (d6 == null) d6 = false; + var T2 = f6.m, U2 = f6.Z, z3 = h6, J3 = 0, V2 = 0, r6 = 0, D3 = 0, a8, q6 = 0, X2, O2, _, N2, e6, K3, x7 = 0, k6, g6, R2, c7; + function Y3() { + if (V2 > 0) { + V2--; + return J3 >> V2 & 1; + } + J3 = Q2[h6++]; + if (J3 === 255) { + var I3 = Q2[h6++]; + if (I3) { + if (I3 === 220 && d6) { + h6 += 2; + var l6 = Z2(Q2, h6); + h6 += 2; + if (l6 > 0 && l6 !== f6.s) { + throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", l6); + } + } else if (I3 === 217) { + if (d6) { + var M2 = q6 * 8; + if (M2 > 0 && M2 < f6.s / 10) { + throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter", M2); + } + } + throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data"); + } + throw new W2("unexpected marker"); + } + } + V2 = 7; + return J3 >>> 7; + } + function u6(I3) { + var l6 = I3; + while (true) { + l6 = l6[Y3()]; + switch (typeof l6) { + case "number": + return l6; + case "object": + continue; + } + throw new W2("invalid huffman sequence"); + } + } + function m6(I3) { + var e7 = 0; + while (I3 > 0) { + e7 = e7 << 1 | Y3(); + I3--; + } + return e7; + } + function j6(I3) { + if (I3 === 1) { + return Y3() === 1 ? 1 : -1; + } + var e7 = m6(I3); + if (e7 >= 1 << I3 - 1) { + return e7; + } + return e7 + (-1 << I3) + 1; + } + function v7(X3, I3) { + var l6 = u6(X3.J), M2 = l6 === 0 ? 0 : j6(l6), N3 = 1; + X3.D[I3] = X3.Q += M2; + while (N3 < 64) { + var S2 = u6(X3.i), i6 = S2 & 15, A3 = S2 >> 4; + if (i6 === 0) { + if (A3 < 15) { + break; + } + N3 += 16; + continue; + } + N3 += A3; + var o6 = p6[N3]; + X3.D[I3 + o6] = j6(i6); + N3++; + } + } + function $(X3, I3) { + var l6 = u6(X3.J), M2 = l6 === 0 ? 0 : j6(l6) << F3; + X3.D[I3] = X3.Q += M2; + } + function b6(X3, I3) { + X3.D[I3] |= Y3() << F3; + } + function P2(X3, I3) { + if (r6 > 0) { + r6--; + return; + } + var N3 = E3, l6 = a6; + while (N3 <= l6) { + var M2 = u6(X3.i), S2 = M2 & 15, i6 = M2 >> 4; + if (S2 === 0) { + if (i6 < 15) { + r6 = m6(i6) + (1 << i6) - 1; + break; + } + N3 += 16; + continue; + } + N3 += i6; + var A3 = p6[N3]; + X3.D[I3 + A3] = j6(S2) * (1 << F3); + N3++; + } + } + function a42(X3, I3) { + var N3 = E3, l6 = a6, M2 = 0, S2, i6; + while (N3 <= l6) { + var A3 = I3 + p6[N3], o6 = X3.D[A3] < 0 ? -1 : 1; + switch (D3) { + case 0: + i6 = u6(X3.i); + S2 = i6 & 15; + M2 = i6 >> 4; + if (S2 === 0) { + if (M2 < 15) { + r6 = m6(M2) + (1 << M2); + D3 = 4; + } else { + M2 = 16; + D3 = 1; + } + } else { + if (S2 !== 1) { + throw new W2("invalid ACn encoding"); + } + a8 = j6(S2); + D3 = M2 ? 2 : 3; + } + continue; + case 1: + case 2: + if (X3.D[A3]) { + X3.D[A3] += o6 * (Y3() << F3); + } else { + M2--; + if (M2 === 0) { + D3 = D3 === 2 ? 3 : 0; + } + } + break; + case 3: + if (X3.D[A3]) { + X3.D[A3] += o6 * (Y3() << F3); + } else { + X3.D[A3] = a8 << F3; + D3 = 0; + } + break; + case 4: + if (X3.D[A3]) { + X3.D[A3] += o6 * (Y3() << F3); + } + break; + } + N3++; + } + if (D3 === 4) { + r6--; + if (r6 === 0) { + D3 = 0; + } + } + } + function H3(X3, I3, x8, l6, M2) { + var S2 = x8 / T2 | 0, i6 = x8 % T2; + q6 = S2 * X3.A + l6; + var A3 = i6 * X3.h + M2, o6 = a22(X3, q6, A3); + I3(X3, o6); + } + function w6(X3, I3, x8) { + q6 = x8 / X3.P | 0; + var l6 = x8 % X3.P, M2 = a22(X3, q6, l6); + I3(X3, M2); + } + var y4 = G3.length; + if (U2) { + if (E3 === 0) { + K3 = C3 === 0 ? $ : b6; + } else { + K3 = C3 === 0 ? P2 : a42; + } + } else { + K3 = v7; + } + if (y4 === 1) { + g6 = G3[0].P * G3[0].c; + } else { + g6 = T2 * f6.R; + } + while (x7 <= g6) { + var L2 = n6 ? Math.min(g6 - x7, n6) : g6; + if (L2 > 0) { + for (O2 = 0; O2 < y4; O2++) { + G3[O2].Q = 0; + } + r6 = 0; + if (y4 === 1) { + X2 = G3[0]; + for (e6 = 0; e6 < L2; e6++) { + w6(X2, K3, x7); + x7++; + } + } else { + for (e6 = 0; e6 < L2; e6++) { + for (O2 = 0; O2 < y4; O2++) { + X2 = G3[O2]; + R2 = X2.h; + c7 = X2.A; + for (_ = 0; _ < c7; _++) { + for (N2 = 0; N2 < R2; N2++) { + H3(X2, K3, x7, _, N2); + } + } + } + x7++; + } + } + } + V2 = 0; + k6 = an2(Q2, h6); + if (!k6) { + break; + } + if (k6.u) { + var a62 = L2 > 0 ? "unexpected" : "excessive"; + h6 = k6.offset; + } + if (k6.M >= 65488 && k6.M <= 65495) { + h6 += 2; + } else { + break; + } + } + return h6 - z3; + } + function al2(Q2, h6, f6) { + var G3 = Q2.$, n6 = Q2.D, E3, a6, C3, F3, d6, T2, U2, z3, J3, V2, Y3, u6, m6, j6, v7, $, b6; + if (!G3) { + throw new W2("missing required Quantization Table."); + } + for (var r6 = 0; r6 < 64; r6 += 8) { + J3 = n6[h6 + r6]; + V2 = n6[h6 + r6 + 1]; + Y3 = n6[h6 + r6 + 2]; + u6 = n6[h6 + r6 + 3]; + m6 = n6[h6 + r6 + 4]; + j6 = n6[h6 + r6 + 5]; + v7 = n6[h6 + r6 + 6]; + $ = n6[h6 + r6 + 7]; + J3 *= G3[r6]; + if ((V2 | Y3 | u6 | m6 | j6 | v7 | $) === 0) { + b6 = s6 * J3 + 512 >> 10; + f6[r6] = b6; + f6[r6 + 1] = b6; + f6[r6 + 2] = b6; + f6[r6 + 3] = b6; + f6[r6 + 4] = b6; + f6[r6 + 5] = b6; + f6[r6 + 6] = b6; + f6[r6 + 7] = b6; + continue; + } + V2 *= G3[r6 + 1]; + Y3 *= G3[r6 + 2]; + u6 *= G3[r6 + 3]; + m6 *= G3[r6 + 4]; + j6 *= G3[r6 + 5]; + v7 *= G3[r6 + 6]; + $ *= G3[r6 + 7]; + E3 = s6 * J3 + 128 >> 8; + a6 = s6 * m6 + 128 >> 8; + C3 = Y3; + F3 = v7; + d6 = ad2 * (V2 - $) + 128 >> 8; + z3 = ad2 * (V2 + $) + 128 >> 8; + T2 = u6 << 4; + U2 = j6 << 4; + E3 = E3 + a6 + 1 >> 1; + a6 = E3 - a6; + b6 = C3 * ai2 + F3 * ar2 + 128 >> 8; + C3 = C3 * ar2 - F3 * ai2 + 128 >> 8; + F3 = b6; + d6 = d6 + U2 + 1 >> 1; + U2 = d6 - U2; + z3 = z3 + T2 + 1 >> 1; + T2 = z3 - T2; + E3 = E3 + F3 + 1 >> 1; + F3 = E3 - F3; + a6 = a6 + C3 + 1 >> 1; + C3 = a6 - C3; + b6 = d6 * ao2 + z3 * ah2 + 2048 >> 12; + d6 = d6 * ah2 - z3 * ao2 + 2048 >> 12; + z3 = b6; + b6 = T2 * ac2 + U2 * t12 + 2048 >> 12; + T2 = T2 * t12 - U2 * ac2 + 2048 >> 12; + U2 = b6; + f6[r6] = E3 + z3; + f6[r6 + 7] = E3 - z3; + f6[r6 + 1] = a6 + U2; + f6[r6 + 6] = a6 - U2; + f6[r6 + 2] = C3 + T2; + f6[r6 + 5] = C3 - T2; + f6[r6 + 3] = F3 + d6; + f6[r6 + 4] = F3 - d6; + } + for (var P2 = 0; P2 < 8; ++P2) { + J3 = f6[P2]; + V2 = f6[P2 + 8]; + Y3 = f6[P2 + 16]; + u6 = f6[P2 + 24]; + m6 = f6[P2 + 32]; + j6 = f6[P2 + 40]; + v7 = f6[P2 + 48]; + $ = f6[P2 + 56]; + if ((V2 | Y3 | u6 | m6 | j6 | v7 | $) === 0) { + b6 = s6 * J3 + 8192 >> 14; + if (b6 < -2040) { + b6 = 0; + } else if (b6 >= 2024) { + b6 = 255; + } else { + b6 = b6 + 2056 >> 4; + } + n6[h6 + P2] = b6; + n6[h6 + P2 + 8] = b6; + n6[h6 + P2 + 16] = b6; + n6[h6 + P2 + 24] = b6; + n6[h6 + P2 + 32] = b6; + n6[h6 + P2 + 40] = b6; + n6[h6 + P2 + 48] = b6; + n6[h6 + P2 + 56] = b6; + continue; + } + E3 = s6 * J3 + 2048 >> 12; + a6 = s6 * m6 + 2048 >> 12; + C3 = Y3; + F3 = v7; + d6 = ad2 * (V2 - $) + 2048 >> 12; + z3 = ad2 * (V2 + $) + 2048 >> 12; + T2 = u6; + U2 = j6; + E3 = (E3 + a6 + 1 >> 1) + 4112; + a6 = E3 - a6; + b6 = C3 * ai2 + F3 * ar2 + 2048 >> 12; + C3 = C3 * ar2 - F3 * ai2 + 2048 >> 12; + F3 = b6; + d6 = d6 + U2 + 1 >> 1; + U2 = d6 - U2; + z3 = z3 + T2 + 1 >> 1; + T2 = z3 - T2; + E3 = E3 + F3 + 1 >> 1; + F3 = E3 - F3; + a6 = a6 + C3 + 1 >> 1; + C3 = a6 - C3; + b6 = d6 * ao2 + z3 * ah2 + 2048 >> 12; + d6 = d6 * ah2 - z3 * ao2 + 2048 >> 12; + z3 = b6; + b6 = T2 * ac2 + U2 * t12 + 2048 >> 12; + T2 = T2 * t12 - U2 * ac2 + 2048 >> 12; + U2 = b6; + J3 = E3 + z3; + $ = E3 - z3; + V2 = a6 + U2; + v7 = a6 - U2; + Y3 = C3 + T2; + j6 = C3 - T2; + u6 = F3 + d6; + m6 = F3 - d6; + if (J3 < 16) { + J3 = 0; + } else if (J3 >= 4080) { + J3 = 255; + } else { + J3 >>= 4; + } + if (V2 < 16) { + V2 = 0; + } else if (V2 >= 4080) { + V2 = 255; + } else { + V2 >>= 4; + } + if (Y3 < 16) { + Y3 = 0; + } else if (Y3 >= 4080) { + Y3 = 255; + } else { + Y3 >>= 4; + } + if (u6 < 16) { + u6 = 0; + } else if (u6 >= 4080) { + u6 = 255; + } else { + u6 >>= 4; + } + if (m6 < 16) { + m6 = 0; + } else if (m6 >= 4080) { + m6 = 255; + } else { + m6 >>= 4; + } + if (j6 < 16) { + j6 = 0; + } else if (j6 >= 4080) { + j6 = 255; + } else { + j6 >>= 4; + } + if (v7 < 16) { + v7 = 0; + } else if (v7 >= 4080) { + v7 = 255; + } else { + v7 >>= 4; + } + if ($ < 16) { + $ = 0; + } else if ($ >= 4080) { + $ = 255; + } else { + $ >>= 4; + } + n6[h6 + P2] = J3; + n6[h6 + P2 + 8] = V2; + n6[h6 + P2 + 16] = Y3; + n6[h6 + P2 + 24] = u6; + n6[h6 + P2 + 32] = m6; + n6[h6 + P2 + 40] = j6; + n6[h6 + P2 + 48] = v7; + n6[h6 + P2 + 56] = $; + } + } + function a0(Q2, h6) { + var f6 = h6.P, G3 = h6.c, n6 = new Int16Array(64); + for (var E3 = 0; E3 < G3; E3++) { + for (var a6 = 0; a6 < f6; a6++) { + var C3 = a22(h6, E3, a6); + al2(h6, C3, n6); + } + } + return h6.D; + } + function an2(Q2, h6, f6) { + if (f6 == null) f6 = h6; + var G3 = Q2.length - 1, n6 = f6 < h6 ? f6 : h6; + if (h6 >= G3) { + return null; + } + var E3 = Z2(Q2, h6); + if (E3 >= 65472 && E3 <= 65534) { + return { u: null, M: E3, offset: h6 }; + } + var a6 = Z2(Q2, n6); + while (!(a6 >= 65472 && a6 <= 65534)) { + if (++n6 >= G3) { + return null; + } + a6 = Z2(Q2, n6); + } + return { u: E3.toString(16), M: a6, offset: n6 }; + } + ak3.prototype = { parse(Q2, h6) { + if (h6 == null) h6 = {}; + var f6 = h6.F, E3 = 0, a6 = null, C3 = null, F3, d6, T2 = 0; + function G3() { + var o6 = Z2(Q2, E3); + E3 += 2; + var B3 = E3 + o6 - 2, V3 = an2(Q2, B3, E3); + if (V3 && V3.u) { + B3 = V3.offset; + } + var ab2 = Q2.subarray(E3, B3); + E3 += ab2.length; + return ab2; + } + function n6(F4) { + var o6 = Math.ceil(F4.o / 8 / F4.X), B3 = Math.ceil(F4.s / 8 / F4.B); + for (var Y4 = 0; Y4 < F4.W.length; Y4++) { + R2 = F4.W[Y4]; + var ab2 = Math.ceil(Math.ceil(F4.o / 8) * R2.h / F4.X), af2 = Math.ceil(Math.ceil(F4.s / 8) * R2.A / F4.B), ap2 = o6 * R2.h, aq2 = B3 * R2.A, ae2 = 64 * aq2 * (ap2 + 1); + R2.D = new Int16Array(ae2); + R2.P = ab2; + R2.c = af2; + } + F4.m = o6; + F4.R = B3; + } + var U2 = [], z3 = [], J3 = [], V2 = Z2(Q2, E3); + E3 += 2; + if (V2 !== 65496) { + throw new W2("SOI not found"); + } + V2 = Z2(Q2, E3); + E3 += 2; + markerLoop: while (V2 !== 65497) { + var Y3, u6, m6; + switch (V2) { + case 65504: + case 65505: + case 65506: + case 65507: + case 65508: + case 65509: + case 65510: + case 65511: + case 65512: + case 65513: + case 65514: + case 65515: + case 65516: + case 65517: + case 65518: + case 65519: + case 65534: + var j6 = G3(); + if (V2 === 65504) { + if (j6[0] === 74 && j6[1] === 70 && j6[2] === 73 && j6[3] === 70 && j6[4] === 0) { + a6 = { version: { d: j6[5], T: j6[6] }, K: j6[7], j: j6[8] << 8 | j6[9], H: j6[10] << 8 | j6[11], S: j6[12], I: j6[13], C: j6.subarray(14, 14 + 3 * j6[12] * j6[13]) }; + } + } + if (V2 === 65518) { + if (j6[0] === 65 && j6[1] === 100 && j6[2] === 111 && j6[3] === 98 && j6[4] === 101) { + C3 = { version: j6[5] << 8 | j6[6], k: j6[7] << 8 | j6[8], q: j6[9] << 8 | j6[10], a: j6[11] }; + } + } + break; + case 65499: + var v7 = Z2(Q2, E3), b6; + E3 += 2; + var $ = v7 + E3 - 2; + while (E3 < $) { + var r6 = Q2[E3++], P2 = new Uint16Array(64); + if (r6 >> 4 === 0) { + for (u6 = 0; u6 < 64; u6++) { + b6 = p6[u6]; + P2[b6] = Q2[E3++]; + } + } else if (r6 >> 4 === 1) { + for (u6 = 0; u6 < 64; u6++) { + b6 = p6[u6]; + P2[b6] = Z2(Q2, E3); + E3 += 2; + } + } else { + throw new W2("DQT - invalid table spec"); + } + U2[r6 & 15] = P2; + } + break; + case 65472: + case 65473: + case 65474: + if (F3) { + throw new W2("Only single frame JPEGs supported"); + } + E3 += 2; + F3 = {}; + F3.G = V2 === 65473; + F3.Z = V2 === 65474; + F3.precision = Q2[E3++]; + var D3 = Z2(Q2, E3), a42, q6 = 0, H3 = 0; + E3 += 2; + F3.s = f6 || D3; + F3.o = Z2(Q2, E3); + E3 += 2; + F3.W = []; + F3._ = {}; + var a8 = Q2[E3++]; + for (Y3 = 0; Y3 < a8; Y3++) { + a42 = Q2[E3]; + var w6 = Q2[E3 + 1] >> 4, y4 = Q2[E3 + 1] & 15; + if (q6 < w6) { + q6 = w6; + } + if (H3 < y4) { + H3 = y4; + } + var X2 = Q2[E3 + 2]; + m6 = F3.W.push({ h: w6, A: y4, L: X2, $: null }); + F3._[a42] = m6 - 1; + E3 += 3; + } + F3.X = q6; + F3.B = H3; + n6(F3); + break; + case 65476: + var O2 = Z2(Q2, E3); + E3 += 2; + for (Y3 = 2; Y3 < O2; ) { + var _ = Q2[E3++], N2 = new Uint8Array(16), e6 = 0; + for (u6 = 0; u6 < 16; u6++, E3++) { + e6 += N2[u6] = Q2[E3]; + } + var K3 = new Uint8Array(e6); + for (u6 = 0; u6 < e6; u6++, E3++) { + K3[u6] = Q2[E3]; + } + Y3 += 17 + e6; + (_ >> 4 === 0 ? J3 : z3)[_ & 15] = a52(N2, K3); + } + break; + case 65501: + E3 += 2; + d6 = Z2(Q2, E3); + E3 += 2; + break; + case 65498: + var x7 = ++T2 === 1 && !f6, R2; + E3 += 2; + var k6 = Q2[E3++], g6 = []; + for (Y3 = 0; Y3 < k6; Y3++) { + var c7 = Q2[E3++], L2 = F3._[c7]; + R2 = F3.W[L2]; + R2.index = c7; + var a62 = Q2[E3++]; + R2.J = J3[a62 >> 4]; + R2.i = z3[a62 & 15]; + g6.push(R2); + } + var I3 = Q2[E3++], l6 = Q2[E3++], M2 = Q2[E3++]; + try { + var S2 = a7(Q2, E3, F3, g6, d6, I3, l6, M2 >> 4, M2 & 15, x7); + E3 += S2; + } catch (ex) { + if (ex instanceof DNLMarkerError) { + return this.parse(Q2, { F: ex.s }); + } else if (ex instanceof EOIMarkerError) { + break markerLoop; + } + throw ex; + } + break; + case 65500: + E3 += 4; + break; + case 65535: + if (Q2[E3] !== 255) { + E3--; + } + break; + default: + var i6 = an2(Q2, E3 - 2, E3 - 3); + if (i6 && i6.u) { + E3 = i6.offset; + break; + } + if (E3 >= Q2.length - 1) { + break markerLoop; + } + throw new W2("JpegImage.parse - unknown marker: " + V2.toString(16)); + } + V2 = Z2(Q2, E3); + E3 += 2; + } + this.width = F3.o; + this.height = F3.s; + this.g = a6; + this.b = C3; + this.W = []; + for (Y3 = 0; Y3 < F3.W.length; Y3++) { + R2 = F3.W[Y3]; + var A3 = U2[R2.L]; + if (A3) { + R2.$ = A3; + } + this.W.push({ index: R2.index, e: a0(F3, R2), l: R2.h / F3.X, t: R2.A / F3.B, P: R2.P, c: R2.c }); + } + this.p = this.W.length; + return void 0; + }, Y(Q2, h6, f6) { + if (f6 == null) f6 = false; + var G3 = this.width / Q2, n6 = this.height / h6, E3, a6, C3, F3, d6, T2, U2, z3, J3, V2, Y3 = 0, u6, m6 = this.W.length, j6 = Q2 * h6 * m6, v7 = new Uint8ClampedArray(j6), $ = new Uint32Array(Q2), b6 = 4294967288, r6; + for (U2 = 0; U2 < m6; U2++) { + E3 = this.W[U2]; + a6 = E3.l * G3; + C3 = E3.t * n6; + Y3 = U2; + u6 = E3.e; + F3 = E3.P + 1 << 3; + if (a6 !== r6) { + for (d6 = 0; d6 < Q2; d6++) { + z3 = 0 | d6 * a6; + $[d6] = (z3 & b6) << 3 | z3 & 7; + } + r6 = a6; + } + for (T2 = 0; T2 < h6; T2++) { + z3 = 0 | T2 * C3; + V2 = F3 * (z3 & b6) | (z3 & 7) << 3; + for (d6 = 0; d6 < Q2; d6++) { + v7[Y3] = u6[V2 + $[d6]]; + Y3 += m6; + } + } + } + var P2 = this.V; + if (!f6 && m6 === 4 && !P2) { + P2 = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]); + } + if (P2) { + for (U2 = 0; U2 < j6; ) { + for (z3 = 0, J3 = 0; z3 < m6; z3++, U2++, J3 += 2) { + v7[U2] = (v7[U2] * P2[J3] >> 8) + P2[J3 + 1]; + } + } + } + return v7; + }, get f() { + if (this.b) { + return !!this.b.a; + } + if (this.p === 3) { + if (this.N === 0) { + return false; + } else if (this.W[0].index === 82 && this.W[1].index === 71 && this.W[2].index === 66) { + return false; + } + return true; + } + if (this.N === 1) { + return true; + } + return false; + }, z: function aj2(Q2) { + var h6, f6, G3; + for (var n6 = 0, E3 = Q2.length; n6 < E3; n6 += 3) { + h6 = Q2[n6]; + f6 = Q2[n6 + 1]; + G3 = Q2[n6 + 2]; + Q2[n6] = h6 - 179.456 + 1.402 * G3; + Q2[n6 + 1] = h6 + 135.459 - 0.344 * f6 - 0.714 * G3; + Q2[n6 + 2] = h6 - 226.816 + 1.772 * f6; + } + return Q2; + }, O: function aa2(Q2) { + var h6, f6, G3, n6, E3 = 0; + for (var a6 = 0, C3 = Q2.length; a6 < C3; a6 += 4) { + h6 = Q2[a6]; + f6 = Q2[a6 + 1]; + G3 = Q2[a6 + 2]; + n6 = Q2[a6 + 3]; + Q2[E3++] = -122.67195406894 + f6 * (-660635669420364e-19 * f6 + 437130475926232e-18 * G3 - 54080610064599e-18 * h6 + 48449797120281e-17 * n6 - 0.154362151871126) + G3 * (-957964378445773e-18 * G3 + 817076911346625e-18 * h6 - 0.00477271405408747 * n6 + 1.53380253221734) + h6 * (961250184130688e-18 * h6 - 0.00266257332283933 * n6 + 0.48357088451265) + n6 * (-336197177618394e-18 * n6 + 0.484791561490776); + Q2[E3++] = 107.268039397724 + f6 * (219927104525741e-19 * f6 - 640992018297945e-18 * G3 + 659397001245577e-18 * h6 + 426105652938837e-18 * n6 - 0.176491792462875) + G3 * (-778269941513683e-18 * G3 + 0.00130872261408275 * h6 + 770482631801132e-18 * n6 - 0.151051492775562) + h6 * (0.00126935368114843 * h6 - 0.00265090189010898 * n6 + 0.25802910206845) + n6 * (-318913117588328e-18 * n6 - 0.213742400323665); + Q2[E3++] = -20.810012546947 + f6 * (-570115196973677e-18 * f6 - 263409051004589e-19 * G3 + 0.0020741088115012 * h6 - 0.00288260236853442 * n6 + 0.814272968359295) + G3 * (-153496057440975e-19 * G3 - 132689043961446e-18 * h6 + 560833691242812e-18 * n6 - 0.195152027534049) + h6 * (0.00174418132927582 * h6 - 0.00255243321439347 * n6 + 0.116935020465145) + n6 * (-343531996510555e-18 * n6 + 0.24165260232407); + } + return Q2.subarray(0, E3); + }, r: function a32(Q2) { + var h6, f6, G3; + for (var n6 = 0, E3 = Q2.length; n6 < E3; n6 += 4) { + h6 = Q2[n6]; + f6 = Q2[n6 + 1]; + G3 = Q2[n6 + 2]; + Q2[n6] = 434.456 - h6 - 1.402 * G3; + Q2[n6 + 1] = 119.541 - h6 + 0.344 * f6 + 0.714 * G3; + Q2[n6 + 2] = 481.816 - h6 - 1.772 * f6; + } + return Q2; + }, U: function as2(Q2) { + var h6, f6, G3, n6, E3 = 0; + for (var a6 = 0, C3 = Q2.length; a6 < C3; a6 += 4) { + h6 = Q2[a6]; + f6 = Q2[a6 + 1]; + G3 = Q2[a6 + 2]; + n6 = Q2[a6 + 3]; + Q2[E3++] = 255 + h6 * (-6747147073602441e-20 * h6 + 8379262121013727e-19 * f6 + 2894718188643294e-19 * G3 + 0.003264231057537806 * n6 - 1.1185611867203937) + f6 * (26374107616089405e-21 * f6 - 8626949158638572e-20 * G3 - 2748769067499491e-19 * n6 - 0.02155688794978967) + G3 * (-3878099212869363e-20 * G3 - 3267808279485286e-19 * n6 + 0.0686742238595345) - n6 * (3361971776183937e-19 * n6 + 0.7430659151342254); + Q2[E3++] = 255 + h6 * (13596372813588848e-20 * h6 + 924537132573585e-18 * f6 + 10567359618683593e-20 * G3 + 4791864687436512e-19 * n6 - 0.3109689587515875) + f6 * (-23545346108370344e-20 * f6 + 2702845253534714e-19 * G3 + 0.0020200308977307156 * n6 - 0.7488052167015494) + G3 * (6834815998235662e-20 * G3 + 15168452363460973e-20 * n6 - 0.09751927774728933) - n6 * (3189131175883281e-19 * n6 + 0.7364883807733168); + Q2[E3++] = 255 + h6 * (13598650411385307e-21 * h6 + 12423956175490851e-20 * f6 + 4751985097583589e-19 * G3 - 36729317476630422e-22 * n6 - 0.05562186980264034) + f6 * (16141380598724676e-20 * f6 + 9692239130725186e-19 * G3 + 7782692450036253e-19 * n6 - 0.44015232367526463) + G3 * (5068882914068769e-22 * G3 + 0.0017778369011375071 * n6 - 0.7591454649749609) - n6 * (3435319965105553e-19 * n6 + 0.7063770186160144); + } + return Q2.subarray(0, E3); + }, getData: function(Q2) { + var h6 = Q2.width, f6 = Q2.height, G3 = Q2.forceRGB, n6 = Q2.isSourcePDF; + if (this.p > 4) { + throw new W2("Unsupported color mode"); + } + var E3 = this.Y(h6, f6, n6); + if (this.p === 1 && G3) { + var a6 = E3.length, C3 = new Uint8ClampedArray(a6 * 3), F3 = 0; + for (var d6 = 0; d6 < a6; d6++) { + var T2 = E3[d6]; + C3[F3++] = T2; + C3[F3++] = T2; + C3[F3++] = T2; + } + return C3; + } else if (this.p === 3 && this.f) { + return this.z(E3); + } else if (this.p === 4) { + if (this.f) { + if (G3) { + return this.O(E3); + } + return this.r(E3); + } else if (G3) { + return this.U(E3); + } + } + return E3; + } }; + return ak3; + })(); + function a9(p6, t12) { + return p6[t12] << 24 >> 24; } - } - } - } - return next(args); - }; -}; -var s3ExpressMiddlewareOptions = { - name: "s3ExpressMiddleware", - step: "build", - tags: ["S3", "S3_EXPRESS"], - override: true -}; -var getS3ExpressPlugin = (options) => ({ - applyToStack: (clientStack) => { - clientStack.add(s3ExpressMiddleware(options), s3ExpressMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/functions/s3ExpressHttpSigningMiddleware.js -init_dist_es16(); -init_dist_es2(); -init_dist_es3(); - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/functions/signS3Express.js -var signS3Express = async (s3ExpressIdentity, signingOptions, request4, sigV4MultiRegionSigner) => { - const signedRequest = await sigV4MultiRegionSigner.signWithCredentials(request4, s3ExpressIdentity, {}); - if (signedRequest.headers["X-Amz-Security-Token"] || signedRequest.headers["x-amz-security-token"]) { - throw new Error("X-Amz-Security-Token must not be set for s3-express requests."); - } - return signedRequest; -}; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/functions/s3ExpressHttpSigningMiddleware.js -var defaultErrorHandler2 = (signingProperties) => (error2) => { - throw error2; -}; -var defaultSuccessHandler2 = (httpResponse, signingProperties) => { -}; -var s3ExpressHttpSigningMiddleware = (config) => (next, context3) => async (args) => { - if (!HttpRequest.isInstance(args.request)) { - return next(args); - } - const smithyContext = getSmithyContext(context3); - const scheme = smithyContext.selectedHttpAuthScheme; - if (!scheme) { - throw new Error(`No HttpAuthScheme was selected: unable to sign request`); - } - const { httpAuthOption: { signingProperties = {} }, identity, signer } = scheme; - let request4; - if (context3.s3ExpressIdentity) { - request4 = await signS3Express(context3.s3ExpressIdentity, signingProperties, args.request, await config.signer()); - } else { - request4 = await signer.sign(args.request, identity, signingProperties); - } - const output = await next({ - ...args, - request: request4 - }).catch((signer.errorHandler || defaultErrorHandler2)(signingProperties)); - (signer.successHandler || defaultSuccessHandler2)(output.response, signingProperties); - return output; -}; -var getS3ExpressHttpSigningPlugin = (config) => ({ - applyToStack: (clientStack) => { - clientStack.addRelativeTo(s3ExpressHttpSigningMiddleware(config), httpSigningMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3Configuration.js -var resolveS3Config = (input, { session }) => { - const [s3ClientProvider, CreateSessionCommandCtor] = session; - const { forcePathStyle, useAccelerateEndpoint, disableMultiregionAccessPoints, followRegionRedirects, s3ExpressIdentityProvider, bucketEndpoint, expectContinueHeader } = input; - return Object.assign(input, { - forcePathStyle: forcePathStyle ?? false, - useAccelerateEndpoint: useAccelerateEndpoint ?? false, - disableMultiregionAccessPoints: disableMultiregionAccessPoints ?? false, - followRegionRedirects: followRegionRedirects ?? false, - s3ExpressIdentityProvider: s3ExpressIdentityProvider ?? new S3ExpressIdentityProviderImpl(async (key) => s3ClientProvider().send(new CreateSessionCommandCtor({ - Bucket: key - }))), - bucketEndpoint: bucketEndpoint ?? false, - expectContinueHeader: expectContinueHeader ?? 2097152 - }); -}; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/throw-200-exceptions.js -init_dist_es2(); -init_dist_es14(); -var THROW_IF_EMPTY_BODY = { - CopyObjectCommand: true, - UploadPartCopyCommand: true, - CompleteMultipartUploadCommand: true -}; -var MAX_BYTES_TO_INSPECT = 3e3; -var throw200ExceptionsMiddleware = (config) => (next, context3) => async (args) => { - const result = await next(args); - const { response } = result; - if (!HttpResponse.isInstance(response)) { - return result; - } - const { statusCode, body: sourceBody } = response; - if (statusCode < 200 || statusCode >= 300) { - return result; - } - const isSplittableStream = typeof sourceBody?.stream === "function" || typeof sourceBody?.pipe === "function" || typeof sourceBody?.tee === "function"; - if (!isSplittableStream) { - return result; - } - let bodyCopy = sourceBody; - let body = sourceBody; - if (sourceBody && typeof sourceBody === "object" && !(sourceBody instanceof Uint8Array)) { - [bodyCopy, body] = await splitStream2(sourceBody); - } - response.body = body; - const bodyBytes = await collectBody2(bodyCopy, { - streamCollector: async (stream2) => { - return headStream2(stream2, MAX_BYTES_TO_INSPECT); - } - }); - if (typeof bodyCopy?.destroy === "function") { - bodyCopy.destroy(); - } - const bodyStringTail = config.utf8Encoder(bodyBytes.subarray(bodyBytes.length - 16)); - if (bodyBytes.length === 0 && THROW_IF_EMPTY_BODY[context3.commandName]) { - const err = new Error("S3 aborted request"); - err.name = "InternalError"; - throw err; - } - if (bodyStringTail && bodyStringTail.endsWith("")) { - response.statusCode = 400; - } - return result; -}; -var collectBody2 = (streamBody = new Uint8Array(), context3) => { - if (streamBody instanceof Uint8Array) { - return Promise.resolve(streamBody); - } - return context3.streamCollector(streamBody) || Promise.resolve(new Uint8Array()); -}; -var throw200ExceptionsMiddlewareOptions = { - relation: "after", - toMiddleware: "deserializerMiddleware", - tags: ["THROW_200_EXCEPTIONS", "S3"], - name: "throw200ExceptionsMiddleware", - override: true -}; -var getThrow200ExceptionsPlugin = (config) => ({ - applyToStack: (clientStack) => { - clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/util-arn-parser/dist-es/index.js -var validate2 = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/bucket-endpoint-middleware.js -function bucketEndpointMiddleware(options) { - return (next, context3) => async (args) => { - if (options.bucketEndpoint) { - const endpoint2 = context3.endpointV2; - if (endpoint2) { - const bucket = args.input.Bucket; - if (typeof bucket === "string") { - try { - const bucketEndpointUrl = new URL(bucket); - context3.endpointV2 = { - ...endpoint2, - url: bucketEndpointUrl - }; - } catch (e6) { - const warning3 = `@aws-sdk/middleware-sdk-s3: bucketEndpoint=true was set but Bucket=${bucket} could not be parsed as URL.`; - if (context3.logger?.constructor?.name === "NoOpLogger") { - console.warn(warning3); + function Z2(p6, t12) { + return p6[t12] << 8 | p6[t12 + 1]; + } + function am2(p6, t12) { + return (p6[t12] << 24 | p6[t12 + 1] << 16 | p6[t12 + 2] << 8 | p6[t12 + 3]) >>> 0; + } + UTIF2.JpegDecoder = ak2; + })(); + UTIF2.encodeImage = function(rgba, w6, h6, metadata) { + var idf = { + "t256": [w6], + "t257": [h6], + "t258": [8, 8, 8, 8], + "t259": [1], + "t262": [2], + "t273": [1e3], + // strips offset + "t277": [4], + "t278": [h6], + /* rows per strip */ + "t279": [w6 * h6 * 4], + // strip byte counts + "t282": [[72, 1]], + "t283": [[72, 1]], + "t284": [1], + "t286": [[0, 1]], + "t287": [[0, 1]], + "t296": [1], + "t305": ["Photopea (UTIF.js)"], + "t338": [1] + }; + if (metadata) for (var i6 in metadata) idf[i6] = metadata[i6]; + var prfx = new Uint8Array(UTIF2.encode([idf])); + var img = new Uint8Array(rgba); + var data = new Uint8Array(1e3 + w6 * h6 * 4); + for (var i6 = 0; i6 < prfx.length; i6++) data[i6] = prfx[i6]; + for (var i6 = 0; i6 < img.length; i6++) data[1e3 + i6] = img[i6]; + return data.buffer; + }; + UTIF2.encode = function(ifds) { + var LE = false; + var data = new Uint8Array(2e4), offset = 4, bin = LE ? UTIF2._binLE : UTIF2._binBE; + data[0] = data[1] = LE ? 73 : 77; + bin.writeUshort(data, 2, 42); + var ifdo = 8; + bin.writeUint(data, offset, ifdo); + offset += 4; + for (var i6 = 0; i6 < ifds.length; i6++) { + var noffs = UTIF2._writeIFD(bin, UTIF2._types.basic, data, ifdo, ifds[i6]); + ifdo = noffs[1]; + if (i6 < ifds.length - 1) { + if ((ifdo & 3) != 0) ifdo += 4 - (ifdo & 3); + bin.writeUint(data, noffs[0], ifdo); + } + } + return data.slice(0, ifdo).buffer; + }; + UTIF2.decode = function(buff, prm) { + if (prm == null) prm = { parseMN: true, debug: false }; + var data = new Uint8Array(buff), offset = 0; + var id = UTIF2._binBE.readASCII(data, offset, 2); + offset += 2; + var bin = id == "II" ? UTIF2._binLE : UTIF2._binBE; + var num = bin.readUshort(data, offset); + offset += 2; + var ifdo = bin.readUint(data, offset); + offset += 4; + var ifds = []; + while (true) { + var cnt = bin.readUshort(data, ifdo), typ = bin.readUshort(data, ifdo + 4); + if (cnt != 0) { + if (typ < 1 || 13 < typ) { + log("error in TIFF"); + break; + } + } + ; + UTIF2._readIFD(bin, data, ifdo, ifds, 0, prm); + ifdo = bin.readUint(data, ifdo + 2 + cnt * 12); + if (ifdo == 0) break; + } + return ifds; + }; + UTIF2.decodeImage = function(buff, img, ifds) { + if (img.data) return; + var data = new Uint8Array(buff); + var id = UTIF2._binBE.readASCII(data, 0, 2); + if (img["t256"] == null) return; + img.isLE = id == "II"; + img.width = img["t256"][0]; + img.height = img["t257"][0]; + var cmpr = img["t259"] ? img["t259"][0] : 1; + var fo = img["t266"] ? img["t266"][0] : 1; + if (img["t284"] && img["t284"][0] == 2) log("PlanarConfiguration 2 should not be used!"); + if (cmpr == 7 && img["t258"] && img["t258"].length > 3) img["t258"] = img["t258"].slice(0, 3); + var spp = img["t277"] ? img["t277"][0] : 1; + var bps = img["t258"] ? img["t258"][0] : 1; + var bipp = bps * spp; + if (cmpr == 1 && img["t279"] != null && img["t278"] && img["t262"][0] == 32803) { + bipp = Math.round(img["t279"][0] * 8 / (img.width * img["t278"][0])); + } + if (img["t50885"] && img["t50885"][0] == 4) bipp = img["t258"][0] * 3; + var bipl = Math.ceil(img.width * bipp / 8) * 8; + var soff = img["t273"]; + if (soff == null || img["t322"]) soff = img["t324"]; + var bcnt = img["t279"]; + if (cmpr == 1 && soff.length == 1) bcnt = [img.height * (bipl >>> 3)]; + if (bcnt == null || img["t322"]) bcnt = img["t325"]; + var bytes = new Uint8Array(img.height * (bipl >>> 3)), bilen = 0; + if (img["t322"] != null) { + var tw = img["t322"][0], th = img["t323"][0]; + var tx = Math.floor((img.width + tw - 1) / tw); + var ty = Math.floor((img.height + th - 1) / th); + var tbuff = new Uint8Array(Math.ceil(tw * th * bipp / 8) | 0); + console.log("====", tx, ty); + for (var y4 = 0; y4 < ty; y4++) + for (var x7 = 0; x7 < tx; x7++) { + var i6 = y4 * tx + x7; + tbuff.fill(0); + UTIF2.decode._decompress(img, ifds, data, soff[i6], bcnt[i6], cmpr, tbuff, 0, fo, tw, th); + if (cmpr == 6) bytes = tbuff; + else UTIF2._copyTile(tbuff, Math.ceil(tw * bipp / 8) | 0, th, bytes, Math.ceil(img.width * bipp / 8) | 0, img.height, Math.ceil(x7 * tw * bipp / 8) | 0, y4 * th); + } + bilen = bytes.length * 8; + } else { + if (soff == null) return; + var rps2 = img["t278"] ? img["t278"][0] : img.height; + rps2 = Math.min(rps2, img.height); + for (var i6 = 0; i6 < soff.length; i6++) { + UTIF2.decode._decompress(img, ifds, data, soff[i6], bcnt[i6], cmpr, bytes, Math.ceil(bilen / 8) | 0, fo, img.width, rps2); + bilen += bipl * rps2; + } + bilen = Math.min(bilen, bytes.length * 8); + } + img.data = new Uint8Array(bytes.buffer, 0, Math.ceil(bilen / 8) | 0); + }; + UTIF2.decode._decompress = function(img, ifds, data, off, len, cmpr, tgt, toff, fo, w6, h6) { + if (img["t271"] && img["t271"][0] == "Panasonic" && img["t45"] && img["t45"][0] == 6) cmpr = 34316; + if (false) { + } else if (cmpr == 1) for (var j6 = 0; j6 < len; j6++) tgt[toff + j6] = data[off + j6]; + else if (cmpr == 2) UTIF2.decode._decodeG2(data, off, len, tgt, toff, w6, fo); + else if (cmpr == 3) UTIF2.decode._decodeG3(data, off, len, tgt, toff, w6, fo, img["t292"] ? (img["t292"][0] & 1) == 1 : false); + else if (cmpr == 4) UTIF2.decode._decodeG4(data, off, len, tgt, toff, w6, fo); + else if (cmpr == 5) UTIF2.decode._decodeLZW(data, off, len, tgt, toff, 8); + else if (cmpr == 6) UTIF2.decode._decodeOldJPEG(img, data, off, len, tgt, toff); + else if (cmpr == 7 || cmpr == 34892) UTIF2.decode._decodeNewJPEG(img, data, off, len, tgt, toff); + else if (cmpr == 8 || cmpr == 32946) { + var src = new Uint8Array(data.buffer, off + 2, len - 6); + var bin = pako2["inflateRaw"](src); + if (toff + bin.length <= tgt.length) tgt.set(bin, toff); + } else if (cmpr == 9) UTIF2.decode._decodeVC5(data, off, len, tgt, toff, img["t33422"]); + else if (cmpr == 32767) UTIF2.decode._decodeARW(img, data, off, len, tgt, toff); + else if (cmpr == 32773) UTIF2.decode._decodePackBits(data, off, len, tgt, toff); + else if (cmpr == 32809) UTIF2.decode._decodeThunder(data, off, len, tgt, toff); + else if (cmpr == 34316) UTIF2.decode._decodePanasonic(img, data, off, len, tgt, toff); + else if (cmpr == 34713) + UTIF2.decode._decodeNikon(img, ifds, data, off, len, tgt, toff); + else if (cmpr == 34676) UTIF2.decode._decodeLogLuv32(img, data, off, len, tgt, toff); + else log("Unknown compression", cmpr); + var bps = img["t258"] ? Math.min(32, img["t258"][0]) : 1; + var noc = img["t277"] ? img["t277"][0] : 1, bpp = bps * noc >>> 3, bpl = Math.ceil(bps * noc * w6 / 8); + if (bps == 16 && !img.isLE && img["t33422"] == null) + for (var y4 = 0; y4 < h6; y4++) { + var roff = toff + y4 * bpl; + for (var x7 = 1; x7 < bpl; x7 += 2) { + var t12 = tgt[roff + x7]; + tgt[roff + x7] = tgt[roff + x7 - 1]; + tgt[roff + x7 - 1] = t12; + } + } + if (img["t317"] && img["t317"][0] == 2) { + for (var y4 = 0; y4 < h6; y4++) { + var ntoff = toff + y4 * bpl; + if (bps == 16) for (var j6 = bpp; j6 < bpl; j6 += 2) { + var nv = (tgt[ntoff + j6 + 1] << 8 | tgt[ntoff + j6]) + (tgt[ntoff + j6 - bpp + 1] << 8 | tgt[ntoff + j6 - bpp]); + tgt[ntoff + j6] = nv & 255; + tgt[ntoff + j6 + 1] = nv >>> 8 & 255; + } + else if (noc == 3) for (var j6 = 3; j6 < bpl; j6 += 3) { + tgt[ntoff + j6] = tgt[ntoff + j6] + tgt[ntoff + j6 - 3] & 255; + tgt[ntoff + j6 + 1] = tgt[ntoff + j6 + 1] + tgt[ntoff + j6 - 2] & 255; + tgt[ntoff + j6 + 2] = tgt[ntoff + j6 + 2] + tgt[ntoff + j6 - 1] & 255; + } + else for (var j6 = bpp; j6 < bpl; j6++) tgt[ntoff + j6] = tgt[ntoff + j6] + tgt[ntoff + j6 - bpp] & 255; + } + } + }; + UTIF2.decode._decodePanasonic = function(img, data, off, len, tgt, toff) { + var img_buffer = data.buffer; + var rawWidth = img["t2"][0]; + var rawHeight = img["t3"][0]; + var bitsPerSample = img["t10"][0]; + var RW2_Format = img["t45"][0]; + var bidx = 0; + var imageIndex = 0; + var vpos = 0; + var byte = 0; + var arr_a, arr_b; + var bytes = RW2_Format == 6 ? new Uint32Array(18) : new Uint8Array(16); + var i6, j6, sh, pred = [0, 0], nonz = [0, 0], isOdd, idx = 0, pixel_base; + var row, col, crow; + var buffer = new Uint8Array(16384); + var result = new Uint16Array(tgt.buffer); + function getDataRaw(bits) { + if (vpos == 0) { + var arr_a2 = new Uint8Array(img_buffer, off + imageIndex + 8184, 16384 - 8184); + var arr_b2 = new Uint8Array(img_buffer, off + imageIndex, 8184); + buffer.set(arr_a2); + buffer.set(arr_b2, arr_a2.length); + imageIndex += 16384; + } + if (RW2_Format == 5) { + for (i6 = 0; i6 < 16; i6++) { + bytes[i6] = buffer[vpos++]; + vpos &= 16383; + } } else { - context3.logger?.warn?.(warning3); + vpos = vpos - bits & 131071; + byte = vpos >> 3 ^ 16368; + return (buffer[byte] | buffer[byte + 1] << 8) >> (vpos & 7) & ~(-1 << bits); } - throw e6; } - } - } - } - return next(args); - }; -} -var bucketEndpointMiddlewareOptions = { - name: "bucketEndpointMiddleware", - override: true, - relation: "after", - toMiddleware: "endpointV2Middleware" -}; - -// ../node_modules/@aws-sdk/middleware-sdk-s3/dist-es/validate-bucket-name.js -function validateBucketNameMiddleware({ bucketEndpoint }) { - return (next) => async (args) => { - const { input: { Bucket } } = args; - if (!bucketEndpoint && typeof Bucket === "string" && !validate2(Bucket) && Bucket.indexOf("/") >= 0) { - const err = new Error(`Bucket name shouldn't contain '/', received '${Bucket}'`); - err.name = "InvalidBucketName"; - throw err; - } - return next({ ...args }); - }; -} -var validateBucketNameMiddlewareOptions = { - step: "initialize", - tags: ["VALIDATE_BUCKET_NAME"], - name: "validateBucketNameMiddleware", - override: true -}; -var getValidateBucketNamePlugin = (options) => ({ - applyToStack: (clientStack) => { - clientStack.add(validateBucketNameMiddleware(options), validateBucketNameMiddlewareOptions); - clientStack.addRelativeTo(bucketEndpointMiddleware(options), bucketEndpointMiddlewareOptions); - } -}); - -// ../node_modules/@aws-sdk/client-s3/dist-es/S3Client.js -init_dist_es31(); -init_dist_es32(); -init_dist_es16(); -init_schema2(); - -// ../node_modules/@smithy/eventstream-serde-config-resolver/dist-es/EventStreamSerdeConfig.js -var resolveEventStreamSerdeConfig = (input) => Object.assign(input, { - eventStreamMarshaller: input.eventStreamSerdeProvider(input) -}); - -// ../node_modules/@aws-sdk/client-s3/dist-es/S3Client.js -init_dist_es33(); -init_dist_es36(); -init_dist_es39(); -init_dist_es20(); - -// ../node_modules/@aws-sdk/client-s3/dist-es/auth/httpAuthSchemeProvider.js -init_dist_es22(); - -// ../node_modules/@aws-sdk/signature-v4-multi-region/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/classes/SignatureV4S3Express.js -init_dist_es18(); - -// ../node_modules/@aws-sdk/signature-v4-multi-region/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/constants.js -var SESSION_TOKEN_QUERY_PARAM2 = "X-Amz-S3session-Token"; -var SESSION_TOKEN_HEADER2 = SESSION_TOKEN_QUERY_PARAM2.toLowerCase(); - -// ../node_modules/@aws-sdk/signature-v4-multi-region/node_modules/@aws-sdk/middleware-sdk-s3/dist-es/s3-express/classes/SignatureV4S3Express.js -var SignatureV4S3Express = class extends SignatureV4 { - async signWithCredentials(requestToSign, credentials, options) { - const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials); - requestToSign.headers[SESSION_TOKEN_HEADER2] = credentials.sessionToken; - const privateAccess = this; - setSingleOverride(privateAccess, credentialsWithoutSessionToken); - return privateAccess.signRequest(requestToSign, options ?? {}); - } - async presignWithCredentials(requestToSign, credentials, options) { - const credentialsWithoutSessionToken = getCredentialsWithoutSessionToken(credentials); - delete requestToSign.headers[SESSION_TOKEN_HEADER2]; - requestToSign.headers[SESSION_TOKEN_QUERY_PARAM2] = credentials.sessionToken; - requestToSign.query = requestToSign.query ?? {}; - requestToSign.query[SESSION_TOKEN_QUERY_PARAM2] = credentials.sessionToken; - const privateAccess = this; - setSingleOverride(privateAccess, credentialsWithoutSessionToken); - return this.presign(requestToSign, options); - } -}; -function getCredentialsWithoutSessionToken(credentials) { - const credentialsWithoutSessionToken = { - accessKeyId: credentials.accessKeyId, - secretAccessKey: credentials.secretAccessKey, - expiration: credentials.expiration - }; - return credentialsWithoutSessionToken; -} -function setSingleOverride(privateAccess, credentialsWithoutSessionToken) { - const id = setTimeout(() => { - throw new Error("SignatureV4S3Express credential override was created but not called."); - }, 10); - const currentCredentialProvider = privateAccess.credentialProvider; - const overrideCredentialsProviderOnce = () => { - clearTimeout(id); - privateAccess.credentialProvider = currentCredentialProvider; - return Promise.resolve(credentialsWithoutSessionToken); - }; - privateAccess.credentialProvider = overrideCredentialsProviderOnce; -} - -// ../node_modules/@aws-sdk/signature-v4-multi-region/dist-es/SignatureV4MultiRegion.js -init_dist_es18(); - -// ../node_modules/@aws-sdk/signature-v4-multi-region/dist-es/signature-v4-crt-container.js -var signatureV4CrtContainer = { - CrtSignerV4: null -}; - -// ../node_modules/@aws-sdk/signature-v4-multi-region/dist-es/SignatureV4MultiRegion.js -var SignatureV4MultiRegion = class { - sigv4aSigner; - sigv4Signer; - signerOptions; - static sigv4aDependency() { - if (typeof signatureV4CrtContainer.CrtSignerV4 === "function") { - return "crt"; - } else if (typeof signatureV4aContainer.SignatureV4a === "function") { - return "js"; - } - return "none"; - } - constructor(options) { - this.sigv4Signer = new SignatureV4S3Express(options); - this.signerOptions = options; - } - async sign(requestToSign, options = {}) { - if (options.signingRegion === "*") { - return this.getSigv4aSigner().sign(requestToSign, options); - } - return this.sigv4Signer.sign(requestToSign, options); + function getBufferDataRW6(i7) { + return buffer[vpos + 15 - i7]; + } + function readPageRW6() { + bytes[0] = getBufferDataRW6(0) << 6 | getBufferDataRW6(1) >> 2; + bytes[1] = ((getBufferDataRW6(1) & 3) << 12 | getBufferDataRW6(2) << 4 | getBufferDataRW6(3) >> 4) & 16383; + bytes[2] = getBufferDataRW6(3) >> 2 & 3; + bytes[3] = (getBufferDataRW6(3) & 3) << 8 | getBufferDataRW6(4); + bytes[4] = getBufferDataRW6(5) << 2 | getBufferDataRW6(6) >> 6; + bytes[5] = (getBufferDataRW6(6) & 63) << 4 | getBufferDataRW6(7) >> 4; + bytes[6] = getBufferDataRW6(7) >> 2 & 3; + bytes[7] = (getBufferDataRW6(7) & 3) << 8 | getBufferDataRW6(8); + bytes[8] = getBufferDataRW6(9) << 2 & 1020 | getBufferDataRW6(10) >> 6; + bytes[9] = (getBufferDataRW6(10) << 4 | getBufferDataRW6(11) >> 4) & 1023; + bytes[10] = getBufferDataRW6(11) >> 2 & 3; + bytes[11] = (getBufferDataRW6(11) & 3) << 8 | getBufferDataRW6(12); + bytes[12] = (getBufferDataRW6(13) << 2 & 1020 | getBufferDataRW6(14) >> 6) & 1023; + bytes[13] = (getBufferDataRW6(14) << 4 | getBufferDataRW6(15) >> 4) & 1023; + vpos += 16; + byte = 0; + } + function readPageRw6_bps12() { + bytes[0] = getBufferDataRW6(0) << 4 | getBufferDataRW6(1) >> 4; + bytes[1] = ((getBufferDataRW6(1) & 15) << 8 | getBufferDataRW6(2)) & 4095; + bytes[2] = getBufferDataRW6(3) >> 6 & 3; + bytes[3] = (getBufferDataRW6(3) & 63) << 2 | getBufferDataRW6(4) >> 6; + bytes[4] = (getBufferDataRW6(4) & 63) << 2 | getBufferDataRW6(5) >> 6; + bytes[5] = (getBufferDataRW6(5) & 63) << 2 | getBufferDataRW6(6) >> 6; + bytes[6] = getBufferDataRW6(6) >> 4 & 3; + bytes[7] = (getBufferDataRW6(6) & 15) << 4 | getBufferDataRW6(7) >> 4; + bytes[8] = (getBufferDataRW6(7) & 15) << 4 | getBufferDataRW6(8) >> 4; + bytes[9] = (getBufferDataRW6(8) & 15) << 4 | getBufferDataRW6(9) >> 4; + bytes[10] = getBufferDataRW6(9) >> 2 & 3; + bytes[11] = (getBufferDataRW6(9) & 3) << 6 | getBufferDataRW6(10) >> 2; + bytes[12] = (getBufferDataRW6(10) & 3) << 6 | getBufferDataRW6(11) >> 2; + bytes[13] = (getBufferDataRW6(11) & 3) << 6 | getBufferDataRW6(12) >> 2; + bytes[14] = getBufferDataRW6(12) & 3; + bytes[15] = getBufferDataRW6(13); + bytes[16] = getBufferDataRW6(14); + bytes[17] = getBufferDataRW6(15); + vpos += 16; + byte = 0; + } + function resetPredNonzeros() { + pred[0] = 0; + pred[1] = 0; + nonz[0] = 0; + nonz[1] = 0; + } + if (RW2_Format == 7) { + throw RW2_Format; + } else if (RW2_Format == 6) { + var is12bit = bitsPerSample == 12, readPageRw6Fn = is12bit ? readPageRw6_bps12 : readPageRW6, pixelsPerBlock = is12bit ? 14 : 11, pixelbase0 = is12bit ? 128 : 512, pixelbase_compare = is12bit ? 2048 : 8192, spix_compare = is12bit ? 16383 : 65535, pixel_mask = is12bit ? 4095 : 16383, blocksperrow = rawWidth / pixelsPerBlock, rowbytes = blocksperrow * 16, bufferSize = is12bit ? 18 : 14; + for (row = 0; row < rawHeight - 15; row += 16) { + var rowstoread = Math.min(16, rawHeight - row); + var readlen = rowbytes * rowstoread; + buffer = new Uint8Array(img_buffer, off + bidx, readlen); + vpos = 0; + bidx += readlen; + for (crow = 0, col = 0; crow < rowstoread; crow++, col = 0) { + idx = (row + crow) * rawWidth; + for (var rblock = 0; rblock < blocksperrow; rblock++) { + readPageRw6Fn(); + resetPredNonzeros(); + sh = 0; + pixel_base = 0; + for (i6 = 0; i6 < pixelsPerBlock; i6++) { + isOdd = i6 & 1; + if (i6 % 3 == 2) { + var base = byte < bufferSize ? bytes[byte++] : 0; + if (base == 3) base = 4; + pixel_base = pixelbase0 << base; + sh = 1 << base; + } + var epixel = byte < bufferSize ? bytes[byte++] : 0; + if (pred[isOdd]) { + epixel *= sh; + if (pixel_base < pixelbase_compare && nonz[isOdd] > pixel_base) + epixel += nonz[isOdd] - pixel_base; + nonz[isOdd] = epixel; + } else { + pred[isOdd] = epixel; + if (epixel) + nonz[isOdd] = epixel; + else + epixel = nonz[isOdd]; + } + result[idx + col++] = epixel - 15 <= spix_compare ? epixel - 15 & spix_compare : epixel + 2147483633 >> 31 & pixel_mask; + } + } + } + } + } else if (RW2_Format == 5) { + var blockSize = bitsPerSample == 12 ? 10 : 9; + for (row = 0; row < rawHeight; row++) { + for (col = 0; col < rawWidth; col += blockSize) { + getDataRaw(0); + if (bitsPerSample == 12) { + result[idx++] = ((bytes[1] & 15) << 8) + bytes[0]; + result[idx++] = 16 * bytes[2] + (bytes[1] >> 4); + result[idx++] = ((bytes[4] & 15) << 8) + bytes[3]; + result[idx++] = 16 * bytes[5] + (bytes[4] >> 4); + result[idx++] = ((bytes[7] & 15) << 8) + bytes[6]; + result[idx++] = 16 * bytes[8] + (bytes[7] >> 4); + result[idx++] = ((bytes[10] & 15) << 8) + bytes[9]; + result[idx++] = 16 * bytes[11] + (bytes[10] >> 4); + result[idx++] = ((bytes[13] & 15) << 8) + bytes[12]; + result[idx++] = 16 * bytes[14] + (bytes[13] >> 4); + } else if (bitsPerSample == 14) { + result[idx++] = bytes[0] + ((bytes[1] & 63) << 8); + result[idx++] = (bytes[1] >> 6) + 4 * bytes[2] + ((bytes[3] & 15) << 10); + result[idx++] = (bytes[3] >> 4) + 16 * bytes[4] + ((bytes[5] & 3) << 12); + result[idx++] = ((bytes[5] & 252) >> 2) + (bytes[6] << 6); + result[idx++] = bytes[7] + ((bytes[8] & 63) << 8); + result[idx++] = (bytes[8] >> 6) + 4 * bytes[9] + ((bytes[10] & 15) << 10); + result[idx++] = (bytes[10] >> 4) + 16 * bytes[11] + ((bytes[12] & 3) << 12); + result[idx++] = ((bytes[12] & 252) >> 2) + (bytes[13] << 6); + result[idx++] = bytes[14] + ((bytes[15] & 63) << 8); + } + } + } + } else if (RW2_Format == 4) { + for (row = 0; row < rawHeight; row++) { + for (col = 0; col < rawWidth; col++) { + i6 = col % 14; + isOdd = i6 & 1; + if (i6 == 0) resetPredNonzeros(); + if (i6 % 3 == 2) + sh = 4 >> 3 - getDataRaw(2); + if (nonz[isOdd]) { + j6 = getDataRaw(8); + if (j6 != 0) { + pred[isOdd] -= 128 << sh; + if (pred[isOdd] < 0 || sh == 4) + pred[isOdd] &= ~(-1 << sh); + pred[isOdd] += j6 << sh; + } + } else { + nonz[isOdd] = getDataRaw(8); + if (nonz[isOdd] || i6 > 11) + pred[isOdd] = nonz[isOdd] << 4 | getDataRaw(4); + } + result[idx++] = pred[col & 1]; + } + } + } else throw RW2_Format; + }; + UTIF2.decode._decodeVC5 = (function() { + var x7 = [1, 0, 1, 0, 2, 2, 1, 1, 3, 7, 1, 2, 5, 25, 1, 3, 6, 48, 1, 4, 6, 54, 1, 5, 7, 111, 1, 8, 7, 99, 1, 6, 7, 105, 12, 0, 7, 107, 1, 7, 8, 209, 20, 0, 8, 212, 1, 9, 8, 220, 1, 10, 9, 393, 1, 11, 9, 394, 32, 0, 9, 416, 1, 12, 9, 427, 1, 13, 10, 887, 1, 18, 10, 784, 1, 14, 10, 790, 1, 15, 10, 835, 60, 0, 10, 852, 1, 16, 10, 885, 1, 17, 11, 1571, 1, 19, 11, 1668, 1, 20, 11, 1669, 100, 0, 11, 1707, 1, 21, 11, 1772, 1, 22, 12, 3547, 1, 29, 12, 3164, 1, 24, 12, 3166, 1, 25, 12, 3140, 1, 23, 12, 3413, 1, 26, 12, 3537, 1, 27, 12, 3539, 1, 28, 13, 7093, 1, 35, 13, 6283, 1, 30, 13, 6331, 1, 31, 13, 6335, 180, 0, 13, 6824, 1, 32, 13, 7072, 1, 33, 13, 7077, 320, 0, 13, 7076, 1, 34, 14, 12565, 1, 36, 14, 12661, 1, 37, 14, 12669, 1, 38, 14, 13651, 1, 39, 14, 14184, 1, 40, 15, 28295, 1, 46, 15, 28371, 1, 47, 15, 25320, 1, 42, 15, 25336, 1, 43, 15, 25128, 1, 41, 15, 27300, 1, 44, 15, 28293, 1, 45, 16, 50259, 1, 48, 16, 50643, 1, 49, 16, 50675, 1, 50, 16, 56740, 1, 53, 16, 56584, 1, 51, 16, 56588, 1, 52, 17, 113483, 1, 61, 17, 113482, 1, 60, 17, 101285, 1, 55, 17, 101349, 1, 56, 17, 109205, 1, 57, 17, 109207, 1, 58, 17, 100516, 1, 54, 17, 113171, 1, 59, 18, 202568, 1, 62, 18, 202696, 1, 63, 18, 218408, 1, 64, 18, 218412, 1, 65, 18, 226340, 1, 66, 18, 226356, 1, 67, 18, 226358, 1, 68, 19, 402068, 1, 69, 19, 405138, 1, 70, 19, 405394, 1, 71, 19, 436818, 1, 72, 19, 436826, 1, 73, 19, 452714, 1, 75, 19, 452718, 1, 76, 19, 452682, 1, 74, 20, 804138, 1, 77, 20, 810279, 1, 78, 20, 810790, 1, 79, 20, 873638, 1, 80, 20, 873654, 1, 81, 20, 905366, 1, 82, 20, 905430, 1, 83, 20, 905438, 1, 84, 21, 1608278, 1, 85, 21, 1620557, 1, 86, 21, 1621582, 1, 87, 21, 1621583, 1, 88, 21, 1747310, 1, 89, 21, 1810734, 1, 90, 21, 1810735, 1, 91, 21, 1810863, 1, 92, 21, 1810879, 1, 93, 22, 3621725, 1, 99, 22, 3621757, 1, 100, 22, 3241112, 1, 94, 22, 3494556, 1, 95, 22, 3494557, 1, 96, 22, 3494622, 1, 97, 22, 3494623, 1, 98, 23, 6482227, 1, 102, 23, 6433117, 1, 101, 23, 6989117, 1, 103, 23, 6989119, 1, 105, 23, 6989118, 1, 104, 23, 7243449, 1, 106, 23, 7243512, 1, 107, 24, 13978233, 1, 111, 24, 12964453, 1, 109, 24, 12866232, 1, 108, 24, 14486897, 1, 113, 24, 13978232, 1, 110, 24, 14486896, 1, 112, 24, 14487026, 1, 114, 24, 14487027, 1, 115, 25, 25732598, 1, 225, 25, 25732597, 1, 189, 25, 25732596, 1, 188, 25, 25732595, 1, 203, 25, 25732594, 1, 202, 25, 25732593, 1, 197, 25, 25732592, 1, 207, 25, 25732591, 1, 169, 25, 25732590, 1, 223, 25, 25732589, 1, 159, 25, 25732522, 1, 235, 25, 25732579, 1, 152, 25, 25732575, 1, 192, 25, 25732489, 1, 179, 25, 25732573, 1, 201, 25, 25732472, 1, 172, 25, 25732576, 1, 149, 25, 25732488, 1, 178, 25, 25732566, 1, 120, 25, 25732571, 1, 219, 25, 25732577, 1, 150, 25, 25732487, 1, 127, 25, 25732506, 1, 211, 25, 25732548, 1, 125, 25, 25732588, 1, 158, 25, 25732486, 1, 247, 25, 25732467, 1, 238, 25, 25732508, 1, 163, 25, 25732552, 1, 228, 25, 25732603, 1, 183, 25, 25732513, 1, 217, 25, 25732587, 1, 168, 25, 25732520, 1, 122, 25, 25732484, 1, 128, 25, 25732562, 1, 249, 25, 25732505, 1, 187, 25, 25732504, 1, 186, 25, 25732483, 1, 136, 25, 25928905, 1, 181, 25, 25732560, 1, 255, 25, 25732500, 1, 230, 25, 25732482, 1, 135, 25, 25732555, 1, 233, 25, 25732568, 1, 222, 25, 25732583, 1, 145, 25, 25732481, 1, 134, 25, 25732586, 1, 167, 25, 25732521, 1, 248, 25, 25732518, 1, 209, 25, 25732480, 1, 243, 25, 25732512, 1, 216, 25, 25732509, 1, 164, 25, 25732547, 1, 140, 25, 25732479, 1, 157, 25, 25732544, 1, 239, 25, 25732574, 1, 191, 25, 25732564, 1, 251, 25, 25732478, 1, 156, 25, 25732546, 1, 139, 25, 25732498, 1, 242, 25, 25732557, 1, 133, 25, 25732477, 1, 162, 25, 25732515, 1, 213, 25, 25732584, 1, 165, 25, 25732514, 1, 212, 25, 25732476, 1, 227, 25, 25732494, 1, 198, 25, 25732531, 1, 236, 25, 25732530, 1, 234, 25, 25732529, 1, 117, 25, 25732528, 1, 215, 25, 25732527, 1, 124, 25, 25732526, 1, 123, 25, 25732525, 1, 254, 25, 25732524, 1, 253, 25, 25732523, 1, 148, 25, 25732570, 1, 218, 25, 25732580, 1, 146, 25, 25732581, 1, 147, 25, 25732569, 1, 224, 25, 25732533, 1, 143, 25, 25732540, 1, 184, 25, 25732541, 1, 185, 25, 25732585, 1, 166, 25, 25732556, 1, 132, 25, 25732485, 1, 129, 25, 25732563, 1, 250, 25, 25732578, 1, 151, 25, 25732501, 1, 119, 25, 25732502, 1, 193, 25, 25732536, 1, 176, 25, 25732496, 1, 245, 25, 25732553, 1, 229, 25, 25732516, 1, 206, 25, 25732582, 1, 144, 25, 25732517, 1, 208, 25, 25732558, 1, 137, 25, 25732543, 1, 241, 25, 25732466, 1, 237, 25, 25732507, 1, 190, 25, 25732542, 1, 240, 25, 25732551, 1, 131, 25, 25732554, 1, 232, 25, 25732565, 1, 252, 25, 25732475, 1, 171, 25, 25732493, 1, 205, 25, 25732492, 1, 204, 25, 25732491, 1, 118, 25, 25732490, 1, 214, 25, 25928904, 1, 180, 25, 25732549, 1, 126, 25, 25732602, 1, 182, 25, 25732539, 1, 175, 25, 25732545, 1, 141, 25, 25732559, 1, 138, 25, 25732537, 1, 177, 25, 25732534, 1, 153, 25, 25732503, 1, 194, 25, 25732606, 1, 160, 25, 25732567, 1, 121, 25, 25732538, 1, 174, 25, 25732497, 1, 246, 25, 25732550, 1, 130, 25, 25732572, 1, 200, 25, 25732474, 1, 170, 25, 25732511, 1, 221, 25, 25732601, 1, 196, 25, 25732532, 1, 142, 25, 25732519, 1, 210, 25, 25732495, 1, 199, 25, 25732605, 1, 155, 25, 25732535, 1, 154, 25, 25732499, 1, 244, 25, 25732510, 1, 220, 25, 25732600, 1, 195, 25, 25732607, 1, 161, 25, 25732604, 1, 231, 25, 25732473, 1, 173, 25, 25732599, 1, 226, 26, 51465122, 1, 116, 26, 51465123, 0, 1], o6, C3, k6, P2 = [3, 3, 3, 3, 2, 2, 2, 1, 1, 1], V2 = 24576, ar2 = 16384, H3 = 8192, az2 = ar2 | H3; + function d6(t12) { + var E3 = t12[1], h6 = t12[0][E3 >>> 3] >>> 7 - (E3 & 7) & 1; + t12[1]++; + return h6; + } + function ag2(t12, E3) { + if (o6 == null) { + o6 = {}; + for (var h6 = 0; h6 < x7.length; h6 += 4) o6[x7[h6 + 1]] = x7.slice(h6, h6 + 4); + } + var L2 = d6(t12), g6 = o6[L2]; + while (g6 == null) { + L2 = L2 << 1 | d6(t12); + g6 = o6[L2]; + } + var n6 = g6[3]; + if (n6 != 0) n6 = d6(t12) == 0 ? n6 : -n6; + E3[0] = g6[2]; + E3[1] = n6; + } + function m6(t12, E3) { + for (var h6 = 0; h6 < E3; h6++) { + if ((t12 & 1) == 1) t12++; + t12 = t12 >>> 1; + } + return t12; + } + function A3(t12, E3) { + return t12 >> E3; + } + function O2(t12, E3, h6, L2, g6, n6) { + E3[h6] = A3(A3(11 * t12[g6] - 4 * t12[g6 + n6] + t12[g6 + n6 + n6] + 4, 3) + t12[L2], 1); + E3[h6 + n6] = A3(A3(5 * t12[g6] + 4 * t12[g6 + n6] - t12[g6 + n6 + n6] + 4, 3) - t12[L2], 1); + } + function J3(t12, E3, h6, L2, g6, n6) { + var W2 = t12[g6 - n6] - t12[g6 + n6], j6 = t12[g6], $ = t12[L2]; + E3[h6] = A3(A3(W2 + 4, 3) + j6 + $, 1); + E3[h6 + n6] = A3(A3(-W2 + 4, 3) + j6 - $, 1); + } + function y4(t12, E3, h6, L2, g6, n6) { + E3[h6] = A3(A3(5 * t12[g6] + 4 * t12[g6 - n6] - t12[g6 - n6 - n6] + 4, 3) + t12[L2], 1); + E3[h6 + n6] = A3(A3(11 * t12[g6] - 4 * t12[g6 - n6] + t12[g6 - n6 - n6] + 4, 3) - t12[L2], 1); + } + function q6(t12) { + t12 = t12 < 0 ? 0 : t12 > 4095 ? 4095 : t12; + t12 = k6[t12] >>> 2; + return t12; + } + function av2(t12, E3, h6, L2, g6, n6) { + L2 = new Uint16Array(L2.buffer); + var W2 = Date.now(), j6 = UTIF2._binBE, $ = E3 + h6, r6, u6, X2, I3, ax2, a32, R2, ai2, aa2, ap2, ah2, ae2, aD2, al2, i6, aE2, T2, B3; + E3 += 4; + var a52 = n6[0] == 1; + while (E3 < $) { + var S2 = j6.readShort(t12, E3), s6 = j6.readUshort(t12, E3 + 2); + E3 += 4; + if (S2 == 12) r6 = s6; + else if (S2 == 20) u6 = s6; + else if (S2 == 21) X2 = s6; + else if (S2 == 48) I3 = s6; + else if (S2 == 53) ax2 = s6; + else if (S2 == 35) a32 = s6; + else if (S2 == 62) R2 = s6; + else if (S2 == 101) ai2 = s6; + else if (S2 == 109) aa2 = s6; + else if (S2 == 84) ap2 = s6; + else if (S2 == 106) ah2 = s6; + else if (S2 == 107) ae2 = s6; + else if (S2 == 108) aD2 = s6; + else if (S2 == 102) al2 = s6; + else if (S2 == 104) i6 = s6; + else if (S2 == 105) aE2 = s6; + else { + var F3 = S2 < 0 ? -S2 : S2, D3 = F3 & 65280, _ = 0; + if (F3 & az2) { + if (F3 & H3) { + _ = s6 & 65535; + _ += (F3 & 255) << 16; + } else { + _ = s6 & 65535; + } + } + if ((F3 & V2) == V2) { + if (T2 == null) { + T2 = []; + for (var M2 = 0; M2 < 4; M2++) T2[M2] = new Int16Array((u6 >>> 1) * (X2 >>> 1)); + B3 = new Int16Array((u6 >>> 1) * (X2 >>> 1)); + C3 = new Int16Array(1024); + for (var M2 = 0; M2 < 1024; M2++) { + var aG2 = M2 - 512, p6 = Math.abs(aG2), r6 = Math.floor(768 * p6 * p6 * p6 / (255 * 255 * 255)) + p6; + C3[M2] = Math.sign(aG2) * r6; + } + k6 = new Uint16Array(4096); + var aA2 = (1 << 16) - 1; + for (var M2 = 0; M2 < 4096; M2++) { + var at2 = M2, a1 = aA2 * (Math.pow(113, at2 / 4095) - 1) / 112; + k6[M2] = Math.min(a1, aA2); + } + } + var w6 = T2[R2], v7 = m6(u6, 1 + P2[I3]), N2 = m6(X2, 1 + P2[I3]); + if (I3 == 0) { + for (var b6 = 0; b6 < N2; b6++) for (var G3 = 0; G3 < v7; G3++) { + var c7 = E3 + (b6 * v7 + G3) * 2; + w6[b6 * (u6 >>> 1) + G3] = t12[c7] << 8 | t12[c7 + 1]; + } + } else { + var a7 = [t12, E3 * 8], a42 = [], ay2 = 0, aw2 = v7 * N2, f6 = [0, 0], Q2 = 0, s6 = 0; + while (ay2 < aw2) { + ag2(a7, f6); + Q2 = f6[0]; + s6 = f6[1]; + while (Q2 > 0) { + a42[ay2++] = s6; + Q2--; + } + } + var l6 = (I3 - 1) % 3, aF2 = l6 != 1 ? v7 : 0, a22 = l6 != 0 ? N2 : 0; + for (var b6 = 0; b6 < N2; b6++) { + var af2 = (b6 + a22) * (u6 >>> 1) + aF2, au2 = b6 * v7; + for (var G3 = 0; G3 < v7; G3++) w6[af2 + G3] = C3[a42[au2 + G3] + 512] * ax2; + } + if (l6 == 2) { + var i6 = u6 >>> 1, an2 = v7 * 2, a9 = N2 * 2; + for (var b6 = 0; b6 < N2; b6++) { + for (var G3 = 0; G3 < an2; G3++) { + var M2 = b6 * 2 * i6 + G3, a6 = b6 * i6 + G3, e6 = N2 * i6 + a6; + if (b6 == 0) O2(w6, B3, M2, e6, a6, i6); + else if (b6 == N2 - 1) y4(w6, B3, M2, e6, a6, i6); + else J3(w6, B3, M2, e6, a6, i6); + } + } + var Z2 = w6; + w6 = B3; + B3 = Z2; + for (var b6 = 0; b6 < a9; b6++) { + for (var G3 = 0; G3 < v7; G3++) { + var M2 = b6 * i6 + 2 * G3, a6 = b6 * i6 + G3, e6 = v7 + a6; + if (G3 == 0) O2(w6, B3, M2, e6, a6, 1); + else if (G3 == v7 - 1) y4(w6, B3, M2, e6, a6, 1); + else J3(w6, B3, M2, e6, a6, 1); + } + } + var Z2 = w6; + w6 = B3; + B3 = Z2; + var aC2 = [], aB2 = 2 - ~~((I3 - 1) / 3); + for (var K3 = 0; K3 < 3; K3++) aC2[K3] = aa2 >> 14 - K3 * 2 & 3; + var a62 = aC2[aB2]; + if (a62 != 0) for (var b6 = 0; b6 < a9; b6++) for (var G3 = 0; G3 < an2; G3++) { + var M2 = b6 * i6 + G3; + w6[M2] = w6[M2] << a62; + } + } + } + if (I3 == 9 && R2 == 3) { + var a8 = T2[0], ab2 = T2[1], aq2 = T2[2], as2 = T2[3]; + for (var b6 = 0; b6 < X2; b6 += 2) for (var G3 = 0; G3 < u6; G3 += 2) { + var U2 = b6 * u6 + G3, c7 = (b6 >>> 1) * (u6 >>> 1) + (G3 >>> 1), z3 = a8[c7], ao2 = ab2[c7] - 2048, ak2 = aq2[c7] - 2048, ad2 = as2[c7] - 2048, aj2 = (ao2 << 1) + z3, a0 = (ak2 << 1) + z3, aH2 = z3 + ad2, am2 = z3 - ad2; + if (a52) { + L2[U2] = q6(aH2); + L2[U2 + 1] = q6(a0); + L2[U2 + u6] = q6(aj2); + L2[U2 + u6 + 1] = q6(am2); + } else { + L2[U2] = q6(aj2); + L2[U2 + 1] = q6(aH2); + L2[U2 + u6] = q6(am2); + L2[U2 + u6 + 1] = q6(a0); + } + } + } + E3 += _ * 4; + } else if (F3 == 16388) { + E3 += _ * 4; + } else if (D3 == 8192 || D3 == 8448 || D3 == 9216) { + } else throw F3.toString(16); + } + } + console.log(Date.now() - W2); + } + return av2; + })(); + UTIF2.decode._decodeLogLuv32 = function(img, data, off, len, tgt, toff) { + var w6 = img.width, qw = w6 * 4; + var io = 0, out = new Uint8Array(qw); + while (io < len) { + var oo = 0; + while (oo < qw) { + var c7 = data[off + io]; + io++; + if (c7 < 128) { + for (var j6 = 0; j6 < c7; j6++) out[oo + j6] = data[off + io + j6]; + oo += c7; + io += c7; + } else { + c7 = c7 - 126; + for (var j6 = 0; j6 < c7; j6++) out[oo + j6] = data[off + io]; + oo += c7; + io++; + } + } + for (var x7 = 0; x7 < w6; x7++) { + tgt[toff + 0] = out[x7]; + tgt[toff + 1] = out[x7 + w6]; + tgt[toff + 2] = out[x7 + w6 * 2]; + tgt[toff + 4] = out[x7 + w6 * 3]; + toff += 6; + } + } + }; + UTIF2.decode._ljpeg_diff = function(data, prm, huff) { + var getbithuff = UTIF2.decode._getbithuff; + var len, diff2; + len = getbithuff(data, prm, huff[0], huff); + diff2 = getbithuff(data, prm, len, 0); + if ((diff2 & 1 << len - 1) == 0) diff2 -= (1 << len) - 1; + return diff2; + }; + UTIF2.decode._decodeARW = function(img, inp, off, src_length, tgt, toff) { + var raw_width = img["t256"][0], height = img["t257"][0], tiff_bps = img["t258"][0]; + var bin = img.isLE ? UTIF2._binLE : UTIF2._binBE; + var arw2 = raw_width * height == src_length || raw_width * height * 1.5 == src_length; + if (!arw2) { + height += 8; + var prm = [off, 0, 0, 0]; + var huff = new Uint16Array(32770); + var tab = [ + 3857, + 3856, + 3599, + 3342, + 3085, + 2828, + 2571, + 2314, + 2057, + 1800, + 1543, + 1286, + 1029, + 772, + 771, + 768, + 514, + 513 + ]; + var i6, c7, n6, col, row, sum = 0; + var ljpeg_diff = UTIF2.decode._ljpeg_diff; + huff[0] = 15; + for (n6 = i6 = 0; i6 < 18; i6++) { + var lim = 32768 >>> (tab[i6] >>> 8); + for (var c7 = 0; c7 < lim; c7++) huff[++n6] = tab[i6]; + } + for (col = raw_width; col--; ) + for (row = 0; row < height + 1; row += 2) { + if (row == height) row = 1; + sum += ljpeg_diff(inp, prm, huff); + if (row < height) { + var clr = sum & 4095; + UTIF2.decode._putsF(tgt, (row * raw_width + col) * tiff_bps, clr << 16 - tiff_bps); + } + } + return; + } + if (raw_width * height * 1.5 == src_length) { + for (var i6 = 0; i6 < src_length; i6 += 3) { + var b0 = inp[off + i6 + 0], b1 = inp[off + i6 + 1], b22 = inp[off + i6 + 2]; + tgt[toff + i6] = b1 << 4 | b0 >>> 4; + tgt[toff + i6 + 1] = b0 << 4 | b22 >>> 4; + tgt[toff + i6 + 2] = b22 << 4 | b1 >>> 4; + } + return; + } + var pix = new Uint16Array(16); + var row, col, val, max, min, imax, imin, sh, bit, i6, dp; + var data = new Uint8Array(raw_width + 1); + for (row = 0; row < height; row++) { + for (var j6 = 0; j6 < raw_width; j6++) data[j6] = inp[off++]; + for (dp = 0, col = 0; col < raw_width - 30; dp += 16) { + max = 2047 & (val = bin.readUint(data, dp)); + min = 2047 & val >>> 11; + imax = 15 & val >>> 22; + imin = 15 & val >>> 26; + for (sh = 0; sh < 4 && 128 << sh <= max - min; sh++) ; + for (bit = 30, i6 = 0; i6 < 16; i6++) + if (i6 == imax) pix[i6] = max; + else if (i6 == imin) pix[i6] = min; + else { + pix[i6] = ((bin.readUshort(data, dp + (bit >> 3)) >>> (bit & 7) & 127) << sh) + min; + if (pix[i6] > 2047) pix[i6] = 2047; + bit += 7; + } + for (i6 = 0; i6 < 16; i6++, col += 2) { + var clr = pix[i6] << 1; + UTIF2.decode._putsF(tgt, (row * raw_width + col) * tiff_bps, clr << 16 - tiff_bps); + } + col -= col & 1 ? 1 : 31; + } + } + }; + UTIF2.decode._decodeNikon = function(img, imgs, data, off, src_length, tgt, toff) { + var nikon_tree = [ + [ + 0, + 0, + 1, + 5, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + /* 12-bit lossy */ + 5, + 4, + 3, + 6, + 2, + 7, + 1, + 0, + 8, + 9, + 11, + 10, + 12 + ], + [ + 0, + 0, + 1, + 5, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + /* 12-bit lossy after split */ + 57, + 90, + 56, + 39, + 22, + 5, + 4, + 3, + 2, + 1, + 0, + 11, + 12, + 12 + ], + [ + 0, + 0, + 1, + 4, + 2, + 3, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + /* 12-bit lossless */ + 5, + 4, + 6, + 3, + 7, + 2, + 8, + 1, + 9, + 0, + 10, + 11, + 12 + ], + [ + 0, + 0, + 1, + 4, + 3, + 1, + 1, + 1, + 1, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + /* 14-bit lossy */ + 5, + 6, + 4, + 7, + 8, + 3, + 9, + 2, + 1, + 0, + 10, + 11, + 12, + 13, + 14 + ], + [ + 0, + 0, + 1, + 5, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + /* 14-bit lossy after split */ + 8, + 92, + 75, + 58, + 41, + 7, + 6, + 5, + 4, + 3, + 2, + 1, + 0, + 13, + 14 + ], + [ + 0, + 0, + 1, + 4, + 2, + 2, + 3, + 1, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + /* 14-bit lossless */ + 7, + 6, + 8, + 5, + 9, + 4, + 10, + 3, + 11, + 12, + 2, + 0, + 1, + 13, + 14 + ] + ]; + var raw_width = img["t256"][0], height = img["t257"][0], tiff_bps = img["t258"][0]; + var tree = 0, split = 0; + var make_decoder = UTIF2.decode._make_decoder; + var getbithuff = UTIF2.decode._getbithuff; + var mn = imgs[0].exifIFD.makerNote, md = mn["t150"] ? mn["t150"] : mn["t140"], mdo = 0; + var ver0 = md[mdo++], ver1 = md[mdo++]; + if (ver0 == 73 || ver1 == 88) mdo += 2110; + if (ver0 == 70) tree = 2; + if (tiff_bps == 14) tree += 3; + var vpred = [[0, 0], [0, 0]], bin = img.isLE ? UTIF2._binLE : UTIF2._binBE; + for (var i6 = 0; i6 < 2; i6++) for (var j6 = 0; j6 < 2; j6++) { + vpred[i6][j6] = bin.readShort(md, mdo); + mdo += 2; + } + var max = 1 << tiff_bps & 32767, step = 0; + var csize = bin.readShort(md, mdo); + mdo += 2; + if (csize > 1) step = Math.floor(max / (csize - 1)); + if (ver0 == 68 && ver1 == 32 && step > 0) split = bin.readShort(md, 562); + var i6; + var row, col; + var len, shl, diff2; + var min_v = 0; + var hpred = [0, 0]; + var huff = make_decoder(nikon_tree[tree]); + var prm = [off, 0, 0, 0]; + for (min_v = row = 0; row < height; row++) { + if (split && row == split) { + huff = make_decoder(nikon_tree[tree + 1]); + } + for (col = 0; col < raw_width; col++) { + i6 = getbithuff(data, prm, huff[0], huff); + len = i6 & 15; + shl = i6 >>> 4; + diff2 = (getbithuff(data, prm, len - shl, 0) << 1) + 1 << shl >>> 1; + if ((diff2 & 1 << len - 1) == 0) + diff2 -= (1 << len) - (shl == 0 ? 1 : 0); + if (col < 2) hpred[col] = vpred[row & 1][col] += diff2; + else hpred[col & 1] += diff2; + var clr = Math.min(Math.max(hpred[col & 1], 0), (1 << tiff_bps) - 1); + var bti = (row * raw_width + col) * tiff_bps; + UTIF2.decode._putsF(tgt, bti, clr << 16 - tiff_bps); + } + } + }; + UTIF2.decode._putsF = function(dt, pos, val) { + val = val << 8 - (pos & 7); + var o6 = pos >>> 3; + dt[o6] |= val >>> 16; + dt[o6 + 1] |= val >>> 8; + dt[o6 + 2] |= val; + }; + UTIF2.decode._getbithuff = function(data, prm, nbits, huff) { + var zero_after_ff = 0; + var get_byte = UTIF2.decode._get_byte; + var c7; + var off = prm[0], bitbuf = prm[1], vbits = prm[2], reset = prm[3]; + if (nbits == 0 || vbits < 0) return 0; + while (!reset && vbits < nbits && (c7 = data[off++]) != -1 && !(reset = zero_after_ff && c7 == 255 && data[off++])) { + bitbuf = (bitbuf << 8) + c7; + vbits += 8; + } + c7 = bitbuf << 32 - vbits >>> 32 - nbits; + if (huff) { + vbits -= huff[c7 + 1] >>> 8; + c7 = huff[c7 + 1] & 255; + } else + vbits -= nbits; + if (vbits < 0) throw "e"; + prm[0] = off; + prm[1] = bitbuf; + prm[2] = vbits; + prm[3] = reset; + return c7; + }; + UTIF2.decode._make_decoder = function(source) { + var max, len, h6, i6, j6; + var huff = []; + for (max = 16; max != 0 && !source[max]; max--) ; + var si = 17; + huff[0] = max; + for (h6 = len = 1; len <= max; len++) + for (i6 = 0; i6 < source[len]; i6++, ++si) + for (j6 = 0; j6 < 1 << max - len; j6++) + if (h6 <= 1 << max) + huff[h6++] = len << 8 | source[si]; + return huff; + }; + UTIF2.decode._decodeNewJPEG = function(img, data, off, len, tgt, toff) { + len = Math.min(len, data.length - off); + var tables = img["t347"], tlen = tables ? tables.length : 0, buff = new Uint8Array(tlen + len); + if (tables) { + var SOI = 216, EOI2 = 217, boff = 0; + for (var i6 = 0; i6 < tlen - 1; i6++) { + if (tables[i6] == 255 && tables[i6 + 1] == EOI2) break; + buff[boff++] = tables[i6]; + } + var byte1 = data[off], byte2 = data[off + 1]; + if (byte1 != 255 || byte2 != SOI) { + buff[boff++] = byte1; + buff[boff++] = byte2; + } + for (var i6 = 2; i6 < len; i6++) buff[boff++] = data[off + i6]; + } else for (var i6 = 0; i6 < len; i6++) buff[i6] = data[off + i6]; + if (img["t262"][0] == 32803 || img["t259"][0] == 7 && img["t262"][0] == 34892) { + var bps = img["t258"][0]; + var out = UTIF2.LosslessJpegDecode(buff), olen = out.length; + if (false) { + } else if (bps == 16) { + if (img.isLE) for (var i6 = 0; i6 < olen; i6++) { + tgt[toff + (i6 << 1)] = out[i6] & 255; + tgt[toff + (i6 << 1) + 1] = out[i6] >>> 8; + } + else for (var i6 = 0; i6 < olen; i6++) { + tgt[toff + (i6 << 1)] = out[i6] >>> 8; + tgt[toff + (i6 << 1) + 1] = out[i6] & 255; + } + } else if (bps == 14 || bps == 12 || bps == 10) { + var rst = 16 - bps; + for (var i6 = 0; i6 < olen; i6++) UTIF2.decode._putsF(tgt, i6 * bps, out[i6] << rst); + } else if (bps == 8) { + for (var i6 = 0; i6 < olen; i6++) tgt[toff + i6] = out[i6]; + } else throw new Error("unsupported bit depth " + bps); + } else { + var parser2 = new UTIF2.JpegDecoder(); + parser2.parse(buff); + var decoded = parser2.getData({ "width": parser2.width, "height": parser2.height, "forceRGB": true, "isSourcePDF": false }); + for (var i6 = 0; i6 < decoded.length; i6++) tgt[toff + i6] = decoded[i6]; + } + if (img["t262"][0] == 6) img["t262"][0] = 2; + }; + UTIF2.decode._decodeOldJPEGInit = function(img, data, off, len) { + var SOI = 216, EOI2 = 217, DQT = 219, DHT = 196, DRI = 221, SOF0 = 192, SOS2 = 218; + var joff = 0, soff = 0, tables, sosMarker2, isTiled = false, i6, j6, k6; + var jpgIchgFmt = img["t513"], jifoff = jpgIchgFmt ? jpgIchgFmt[0] : 0; + var jpgIchgFmtLen = img["t514"], jiflen = jpgIchgFmtLen ? jpgIchgFmtLen[0] : 0; + var soffTag = img["t324"] || img["t273"] || jpgIchgFmt; + var ycbcrss = img["t530"], ssx = 0, ssy = 0; + var spp = img["t277"] ? img["t277"][0] : 1; + var jpgresint = img["t515"]; + if (soffTag) { + soff = soffTag[0]; + isTiled = soffTag.length > 1; + } + if (!isTiled) { + if (data[off] == 255 && data[off + 1] == SOI) return { jpegOffset: off }; + if (jpgIchgFmt != null) { + if (data[off + jifoff] == 255 && data[off + jifoff + 1] == SOI) joff = off + jifoff; + else log("JPEGInterchangeFormat does not point to SOI"); + if (jpgIchgFmtLen == null) log("JPEGInterchangeFormatLength field is missing"); + else if (jifoff >= soff || jifoff + jiflen <= soff) log("JPEGInterchangeFormatLength field value is invalid"); + if (joff != null) return { jpegOffset: joff }; + } + } + if (ycbcrss != null) { + ssx = ycbcrss[0]; + ssy = ycbcrss[1]; + } + if (jpgIchgFmt != null) { + if (jpgIchgFmtLen != null) + if (jiflen >= 2 && jifoff + jiflen <= soff) { + if (data[off + jifoff + jiflen - 2] == 255 && data[off + jifoff + jiflen - 1] == SOI) tables = new Uint8Array(jiflen - 2); + else tables = new Uint8Array(jiflen); + for (i6 = 0; i6 < tables.length; i6++) tables[i6] = data[off + jifoff + i6]; + log("Incorrect JPEG interchange format: using JPEGInterchangeFormat offset to derive tables"); + } else log("JPEGInterchangeFormat+JPEGInterchangeFormatLength > offset to first strip or tile"); + } + if (tables == null) { + var ooff = 0, out = []; + out[ooff++] = 255; + out[ooff++] = SOI; + var qtables = img["t519"]; + if (qtables == null) throw new Error("JPEGQTables tag is missing"); + for (i6 = 0; i6 < qtables.length; i6++) { + out[ooff++] = 255; + out[ooff++] = DQT; + out[ooff++] = 0; + out[ooff++] = 67; + out[ooff++] = i6; + for (j6 = 0; j6 < 64; j6++) out[ooff++] = data[off + qtables[i6] + j6]; + } + for (k6 = 0; k6 < 2; k6++) { + var htables = img[k6 == 0 ? "t520" : "t521"]; + if (htables == null) throw new Error((k6 == 0 ? "JPEGDCTables" : "JPEGACTables") + " tag is missing"); + for (i6 = 0; i6 < htables.length; i6++) { + out[ooff++] = 255; + out[ooff++] = DHT; + var nc = 19; + for (j6 = 0; j6 < 16; j6++) nc += data[off + htables[i6] + j6]; + out[ooff++] = nc >>> 8; + out[ooff++] = nc & 255; + out[ooff++] = i6 | k6 << 4; + for (j6 = 0; j6 < 16; j6++) out[ooff++] = data[off + htables[i6] + j6]; + for (j6 = 0; j6 < nc; j6++) out[ooff++] = data[off + htables[i6] + 16 + j6]; + } + } + out[ooff++] = 255; + out[ooff++] = SOF0; + out[ooff++] = 0; + out[ooff++] = 8 + 3 * spp; + out[ooff++] = 8; + out[ooff++] = img.height >>> 8 & 255; + out[ooff++] = img.height & 255; + out[ooff++] = img.width >>> 8 & 255; + out[ooff++] = img.width & 255; + out[ooff++] = spp; + if (spp == 1) { + out[ooff++] = 1; + out[ooff++] = 17; + out[ooff++] = 0; + } else for (i6 = 0; i6 < 3; i6++) { + out[ooff++] = i6 + 1; + out[ooff++] = i6 != 0 ? 17 : (ssx & 15) << 4 | ssy & 15; + out[ooff++] = i6; + } + if (jpgresint != null && jpgresint[0] != 0) { + out[ooff++] = 255; + out[ooff++] = DRI; + out[ooff++] = 0; + out[ooff++] = 4; + out[ooff++] = jpgresint[0] >>> 8 & 255; + out[ooff++] = jpgresint[0] & 255; + } + tables = new Uint8Array(out); + } + var sofpos = -1; + i6 = 0; + while (i6 < tables.length - 1) { + if (tables[i6] == 255 && tables[i6 + 1] == SOF0) { + sofpos = i6; + break; + } + i6++; + } + if (sofpos == -1) { + var tmptab = new Uint8Array(tables.length + 10 + 3 * spp); + tmptab.set(tables); + var tmpoff = tables.length; + sofpos = tables.length; + tables = tmptab; + tables[tmpoff++] = 255; + tables[tmpoff++] = SOF0; + tables[tmpoff++] = 0; + tables[tmpoff++] = 8 + 3 * spp; + tables[tmpoff++] = 8; + tables[tmpoff++] = img.height >>> 8 & 255; + tables[tmpoff++] = img.height & 255; + tables[tmpoff++] = img.width >>> 8 & 255; + tables[tmpoff++] = img.width & 255; + tables[tmpoff++] = spp; + if (spp == 1) { + tables[tmpoff++] = 1; + tables[tmpoff++] = 17; + tables[tmpoff++] = 0; + } else for (i6 = 0; i6 < 3; i6++) { + tables[tmpoff++] = i6 + 1; + tables[tmpoff++] = i6 != 0 ? 17 : (ssx & 15) << 4 | ssy & 15; + tables[tmpoff++] = i6; + } + } + if (data[soff] == 255 && data[soff + 1] == SOS2) { + var soslen = data[soff + 2] << 8 | data[soff + 3]; + sosMarker2 = new Uint8Array(soslen + 2); + sosMarker2[0] = data[soff]; + sosMarker2[1] = data[soff + 1]; + sosMarker2[2] = data[soff + 2]; + sosMarker2[3] = data[soff + 3]; + for (i6 = 0; i6 < soslen - 2; i6++) sosMarker2[i6 + 4] = data[soff + i6 + 4]; + } else { + sosMarker2 = new Uint8Array(2 + 6 + 2 * spp); + var sosoff = 0; + sosMarker2[sosoff++] = 255; + sosMarker2[sosoff++] = SOS2; + sosMarker2[sosoff++] = 0; + sosMarker2[sosoff++] = 6 + 2 * spp; + sosMarker2[sosoff++] = spp; + if (spp == 1) { + sosMarker2[sosoff++] = 1; + sosMarker2[sosoff++] = 0; + } else for (i6 = 0; i6 < 3; i6++) { + sosMarker2[sosoff++] = i6 + 1; + sosMarker2[sosoff++] = i6 << 4 | i6; + } + sosMarker2[sosoff++] = 0; + sosMarker2[sosoff++] = 63; + sosMarker2[sosoff++] = 0; + } + return { jpegOffset: off, tables, sosMarker: sosMarker2, sofPosition: sofpos }; + }; + UTIF2.decode._decodeOldJPEG = function(img, data, off, len, tgt, toff) { + var i6, dlen, tlen, buff, buffoff; + var jpegData = UTIF2.decode._decodeOldJPEGInit(img, data, off, len); + if (jpegData.jpegOffset != null) { + dlen = off + len - jpegData.jpegOffset; + buff = new Uint8Array(dlen); + for (i6 = 0; i6 < dlen; i6++) buff[i6] = data[jpegData.jpegOffset + i6]; + } else { + tlen = jpegData.tables.length; + buff = new Uint8Array(tlen + jpegData.sosMarker.length + len + 2); + buff.set(jpegData.tables); + buffoff = tlen; + buff[jpegData.sofPosition + 5] = img.height >>> 8 & 255; + buff[jpegData.sofPosition + 6] = img.height & 255; + buff[jpegData.sofPosition + 7] = img.width >>> 8 & 255; + buff[jpegData.sofPosition + 8] = img.width & 255; + if (data[off] != 255 || data[off + 1] != SOS) { + buff.set(jpegData.sosMarker, buffoff); + buffoff += sosMarker.length; + } + for (i6 = 0; i6 < len; i6++) buff[buffoff++] = data[off + i6]; + buff[buffoff++] = 255; + buff[buffoff++] = EOI; + } + var parser2 = new UTIF2.JpegDecoder(); + parser2.parse(buff); + var decoded = parser2.getData({ "width": parser2.width, "height": parser2.height, "forceRGB": true, "isSourcePDF": false }); + for (var i6 = 0; i6 < decoded.length; i6++) tgt[toff + i6] = decoded[i6]; + if (img["t262"] && img["t262"][0] == 6) img["t262"][0] = 2; + }; + UTIF2.decode._decodePackBits = function(data, off, len, tgt, toff) { + var sa = new Int8Array(data.buffer), ta = new Int8Array(tgt.buffer), lim = off + len; + while (off < lim) { + var n6 = sa[off]; + off++; + if (n6 >= 0 && n6 < 128) for (var i6 = 0; i6 < n6 + 1; i6++) { + ta[toff] = sa[off]; + toff++; + off++; + } + if (n6 >= -127 && n6 < 0) { + for (var i6 = 0; i6 < -n6 + 1; i6++) { + ta[toff] = sa[off]; + toff++; + } + off++; + } + } + return toff; + }; + UTIF2.decode._decodeThunder = function(data, off, len, tgt, toff) { + var d22 = [0, 1, 0, -1], d32 = [0, 1, 2, 3, 0, -3, -2, -1]; + var lim = off + len, qoff = toff * 2, px = 0; + while (off < lim) { + var b6 = data[off], msk = b6 >>> 6, n6 = b6 & 63; + off++; + if (msk == 3) { + px = n6 & 15; + tgt[qoff >>> 1] |= px << 4 * (1 - qoff & 1); + qoff++; + } + if (msk == 0) for (var i6 = 0; i6 < n6; i6++) { + tgt[qoff >>> 1] |= px << 4 * (1 - qoff & 1); + qoff++; + } + if (msk == 2) for (var i6 = 0; i6 < 2; i6++) { + var d6 = n6 >>> 3 * (1 - i6) & 7; + if (d6 != 4) { + px += d32[d6]; + tgt[qoff >>> 1] |= px << 4 * (1 - qoff & 1); + qoff++; + } + } + if (msk == 1) for (var i6 = 0; i6 < 3; i6++) { + var d6 = n6 >>> 2 * (2 - i6) & 3; + if (d6 != 2) { + px += d22[d6]; + tgt[qoff >>> 1] |= px << 4 * (1 - qoff & 1); + qoff++; + } + } + } + }; + UTIF2.decode._dmap = { "1": 0, "011": 1, "000011": 2, "0000011": 3, "010": -1, "000010": -2, "0000010": -3 }; + UTIF2.decode._lens = (function() { + var addKeys = function(lens, arr, i0, inc) { + for (var i6 = 0; i6 < arr.length; i6++) lens[arr[i6]] = i0 + i6 * inc; + }; + var termW = "00110101,000111,0111,1000,1011,1100,1110,1111,10011,10100,00111,01000,001000,000011,110100,110101,101010,101011,0100111,0001100,0001000,0010111,0000011,0000100,0101000,0101011,0010011,0100100,0011000,00000010,00000011,00011010,00011011,00010010,00010011,00010100,00010101,00010110,00010111,00101000,00101001,00101010,00101011,00101100,00101101,00000100,00000101,00001010,00001011,01010010,01010011,01010100,01010101,00100100,00100101,01011000,01011001,01011010,01011011,01001010,01001011,00110010,00110011,00110100"; + var termB = "0000110111,010,11,10,011,0011,0010,00011,000101,000100,0000100,0000101,0000111,00000100,00000111,000011000,0000010111,0000011000,0000001000,00001100111,00001101000,00001101100,00000110111,00000101000,00000010111,00000011000,000011001010,000011001011,000011001100,000011001101,000001101000,000001101001,000001101010,000001101011,000011010010,000011010011,000011010100,000011010101,000011010110,000011010111,000001101100,000001101101,000011011010,000011011011,000001010100,000001010101,000001010110,000001010111,000001100100,000001100101,000001010010,000001010011,000000100100,000000110111,000000111000,000000100111,000000101000,000001011000,000001011001,000000101011,000000101100,000001011010,000001100110,000001100111"; + var makeW = "11011,10010,010111,0110111,00110110,00110111,01100100,01100101,01101000,01100111,011001100,011001101,011010010,011010011,011010100,011010101,011010110,011010111,011011000,011011001,011011010,011011011,010011000,010011001,010011010,011000,010011011"; + var makeB = "0000001111,000011001000,000011001001,000001011011,000000110011,000000110100,000000110101,0000001101100,0000001101101,0000001001010,0000001001011,0000001001100,0000001001101,0000001110010,0000001110011,0000001110100,0000001110101,0000001110110,0000001110111,0000001010010,0000001010011,0000001010100,0000001010101,0000001011010,0000001011011,0000001100100,0000001100101"; + var makeA = "00000001000,00000001100,00000001101,000000010010,000000010011,000000010100,000000010101,000000010110,000000010111,000000011100,000000011101,000000011110,000000011111"; + termW = termW.split(","); + termB = termB.split(","); + makeW = makeW.split(","); + makeB = makeB.split(","); + makeA = makeA.split(","); + var lensW = {}, lensB = {}; + addKeys(lensW, termW, 0, 1); + addKeys(lensW, makeW, 64, 64); + addKeys(lensW, makeA, 1792, 64); + addKeys(lensB, termB, 0, 1); + addKeys(lensB, makeB, 64, 64); + addKeys(lensB, makeA, 1792, 64); + return [lensW, lensB]; + })(); + UTIF2.decode._decodeG4 = function(data, off, slen, tgt, toff, w6, fo) { + var U2 = UTIF2.decode, boff = off << 3, len = 0, wrd = ""; + var line = [], pline = []; + for (var i6 = 0; i6 < w6; i6++) pline.push(0); + pline = U2._makeDiff(pline); + var a0 = 0, a1 = 0, a22 = 0, b1 = 0, b22 = 0, clr = 0; + var y4 = 0, mode = "", toRead = 0; + var bipl = Math.ceil(w6 / 8) * 8; + while (boff >>> 3 < off + slen) { + b1 = U2._findDiff(pline, a0 + (a0 == 0 ? 0 : 1), 1 - clr), b22 = U2._findDiff(pline, b1, clr); + var bit = 0; + if (fo == 1) bit = data[boff >>> 3] >>> 7 - (boff & 7) & 1; + if (fo == 2) bit = data[boff >>> 3] >>> (boff & 7) & 1; + boff++; + wrd += bit; + if (mode == "H") { + if (U2._lens[clr][wrd] != null) { + var dl = U2._lens[clr][wrd]; + wrd = ""; + len += dl; + if (dl < 64) { + U2._addNtimes(line, len, clr); + a0 += len; + clr = 1 - clr; + len = 0; + toRead--; + if (toRead == 0) mode = ""; + } + } + } else { + if (wrd == "0001") { + wrd = ""; + U2._addNtimes(line, b22 - a0, clr); + a0 = b22; + } + if (wrd == "001") { + wrd = ""; + mode = "H"; + toRead = 2; + } + if (U2._dmap[wrd] != null) { + a1 = b1 + U2._dmap[wrd]; + U2._addNtimes(line, a1 - a0, clr); + a0 = a1; + wrd = ""; + clr = 1 - clr; + } + } + if (line.length == w6 && mode == "") { + U2._writeBits(line, tgt, toff * 8 + y4 * bipl); + clr = 0; + y4++; + a0 = 0; + pline = U2._makeDiff(line); + line = []; + } + } + }; + UTIF2.decode._findDiff = function(line, x7, clr) { + for (var i6 = 0; i6 < line.length; i6 += 2) if (line[i6] >= x7 && line[i6 + 1] == clr) return line[i6]; + }; + UTIF2.decode._makeDiff = function(line) { + var out = []; + if (line[0] == 1) out.push(0, 1); + for (var i6 = 1; i6 < line.length; i6++) if (line[i6 - 1] != line[i6]) out.push(i6, line[i6]); + out.push(line.length, 0, line.length, 1); + return out; + }; + UTIF2.decode._decodeG2 = function(data, off, slen, tgt, toff, w6, fo) { + var U2 = UTIF2.decode, boff = off << 3, len = 0, wrd = ""; + var line = []; + var clr = 0; + var y4 = 0; + var bipl = Math.ceil(w6 / 8) * 8; + while (boff >>> 3 < off + slen) { + var bit = 0; + if (fo == 1) bit = data[boff >>> 3] >>> 7 - (boff & 7) & 1; + if (fo == 2) bit = data[boff >>> 3] >>> (boff & 7) & 1; + boff++; + wrd += bit; + len = U2._lens[clr][wrd]; + if (len != null) { + U2._addNtimes(line, len, clr); + wrd = ""; + if (len < 64) clr = 1 - clr; + if (line.length == w6) { + U2._writeBits(line, tgt, toff * 8 + y4 * bipl); + line = []; + y4++; + clr = 0; + if ((boff & 7) != 0) boff += 8 - (boff & 7); + if (len >= 64) boff += 8; + } + } + } + }; + UTIF2.decode._decodeG3 = function(data, off, slen, tgt, toff, w6, fo, twoDim) { + var U2 = UTIF2.decode, boff = off << 3, len = 0, wrd = ""; + var line = [], pline = []; + for (var i6 = 0; i6 < w6; i6++) line.push(0); + var a0 = 0, a1 = 0, a22 = 0, b1 = 0, b22 = 0, clr = 0; + var y4 = -1, mode = "", toRead = 0, is1D = true; + var bipl = Math.ceil(w6 / 8) * 8; + while (boff >>> 3 < off + slen) { + b1 = U2._findDiff(pline, a0 + (a0 == 0 ? 0 : 1), 1 - clr), b22 = U2._findDiff(pline, b1, clr); + var bit = 0; + if (fo == 1) bit = data[boff >>> 3] >>> 7 - (boff & 7) & 1; + if (fo == 2) bit = data[boff >>> 3] >>> (boff & 7) & 1; + boff++; + wrd += bit; + if (is1D) { + if (U2._lens[clr][wrd] != null) { + var dl = U2._lens[clr][wrd]; + wrd = ""; + len += dl; + if (dl < 64) { + U2._addNtimes(line, len, clr); + clr = 1 - clr; + len = 0; + } + } + } else { + if (mode == "H") { + if (U2._lens[clr][wrd] != null) { + var dl = U2._lens[clr][wrd]; + wrd = ""; + len += dl; + if (dl < 64) { + U2._addNtimes(line, len, clr); + a0 += len; + clr = 1 - clr; + len = 0; + toRead--; + if (toRead == 0) mode = ""; + } + } + } else { + if (wrd == "0001") { + wrd = ""; + U2._addNtimes(line, b22 - a0, clr); + a0 = b22; + } + if (wrd == "001") { + wrd = ""; + mode = "H"; + toRead = 2; + } + if (U2._dmap[wrd] != null) { + a1 = b1 + U2._dmap[wrd]; + U2._addNtimes(line, a1 - a0, clr); + a0 = a1; + wrd = ""; + clr = 1 - clr; + } + } + } + if (wrd.endsWith("000000000001")) { + if (y4 >= 0) U2._writeBits(line, tgt, toff * 8 + y4 * bipl); + if (twoDim) { + if (fo == 1) is1D = (data[boff >>> 3] >>> 7 - (boff & 7) & 1) == 1; + if (fo == 2) is1D = (data[boff >>> 3] >>> (boff & 7) & 1) == 1; + boff++; + } + wrd = ""; + clr = 0; + y4++; + a0 = 0; + pline = U2._makeDiff(line); + line = []; + } + } + if (line.length == w6) U2._writeBits(line, tgt, toff * 8 + y4 * bipl); + }; + UTIF2.decode._addNtimes = function(arr, n6, val) { + for (var i6 = 0; i6 < n6; i6++) arr.push(val); + }; + UTIF2.decode._writeBits = function(bits, tgt, boff) { + for (var i6 = 0; i6 < bits.length; i6++) tgt[boff + i6 >>> 3] |= bits[i6] << 7 - (boff + i6 & 7); + }; + UTIF2.decode._decodeLZW = UTIF2.decode._decodeLZW = (function() { + var e6, U2, Z2, u6, K3 = 0, V2 = 0, g6 = 0, N2 = 0, O2 = function() { + var S2 = e6 >>> 3, A3 = U2[S2] << 16 | U2[S2 + 1] << 8 | U2[S2 + 2], j6 = A3 >>> 24 - (e6 & 7) - V2 & (1 << V2) - 1; + e6 += V2; + return j6; + }, h6 = new Uint32Array(4096 * 4), w6 = 0, m6 = function(S2) { + if (S2 == w6) return; + w6 = S2; + g6 = 1 << S2; + N2 = g6 + 1; + for (var A3 = 0; A3 < N2 + 1; A3++) { + h6[4 * A3] = h6[4 * A3 + 3] = A3; + h6[4 * A3 + 1] = 65535; + h6[4 * A3 + 2] = 1; + } + }, i6 = function(S2) { + V2 = S2 + 1; + K3 = N2 + 1; + }, D3 = function(S2) { + var A3 = S2 << 2, j6 = h6[A3 + 2], a6 = u6 + j6 - 1; + while (A3 != 65535) { + Z2[a6--] = h6[A3]; + A3 = h6[A3 + 1]; + } + u6 += j6; + }, L2 = function(S2, A3) { + var j6 = K3 << 2, a6 = S2 << 2; + h6[j6] = h6[(A3 << 2) + 3]; + h6[j6 + 1] = a6; + h6[j6 + 2] = h6[a6 + 2] + 1; + h6[j6 + 3] = h6[a6 + 3]; + K3++; + if (K3 + 1 == 1 << V2 && V2 != 12) V2++; + }, T2 = function(S2, A3, j6, a6, n6, q6) { + e6 = A3 << 3; + U2 = S2; + Z2 = a6; + u6 = n6; + var B3 = A3 + j6 << 3, _ = 0, t12 = 0; + m6(q6); + i6(q6); + while (e6 < B3 && (_ = O2()) != N2) { + if (_ == g6) { + i6(q6); + _ = O2(); + if (_ == N2) break; + D3(_); + } else { + if (_ < K3) { + D3(_); + L2(t12, _); + } else { + L2(t12, t12); + D3(K3 - 1); + } + } + t12 = _; + } + return u6; + }; + return T2; + })(); + UTIF2.tags = {}; + UTIF2._types = (function() { + var main = new Array(250); + main.fill(0); + main = main.concat([0, 0, 0, 0, 4, 3, 3, 3, 3, 3, 0, 0, 3, 0, 0, 0, 3, 0, 0, 2, 2, 2, 2, 4, 3, 0, 0, 3, 4, 4, 3, 3, 5, 5, 3, 2, 5, 5, 0, 0, 0, 0, 4, 4, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 3, 5, 5, 3, 0, 3, 3, 4, 4, 4, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + var rest = { 33432: 2, 33434: 5, 33437: 5, 34665: 4, 34850: 3, 34853: 4, 34855: 3, 34864: 3, 34866: 4, 36864: 7, 36867: 2, 36868: 2, 37121: 7, 37377: 10, 37378: 5, 37380: 10, 37381: 5, 37383: 3, 37384: 3, 37385: 3, 37386: 5, 37510: 7, 37520: 2, 37521: 2, 37522: 2, 40960: 7, 40961: 3, 40962: 4, 40963: 4, 40965: 4, 41486: 5, 41487: 5, 41488: 3, 41985: 3, 41986: 3, 41987: 3, 41988: 5, 41989: 3, 41990: 3, 41993: 3, 41994: 3, 41995: 7, 41996: 3, 42032: 2, 42033: 2, 42034: 5, 42036: 2, 42037: 2, 59932: 7 }; + return { + basic: { + main, + rest + }, + gps: { + main: [1, 2, 5, 2, 5, 1, 5, 5, 0, 9], + rest: { 18: 2, 29: 2 } + } + }; + })(); + UTIF2._readIFD = function(bin, data, offset, ifds, depth, prm) { + var cnt = bin.readUshort(data, offset); + offset += 2; + var ifd = {}; + if (prm.debug) log(" ".repeat(depth), ifds.length - 1, ">>>----------------"); + for (var i6 = 0; i6 < cnt; i6++) { + var tag = bin.readUshort(data, offset); + offset += 2; + var type = bin.readUshort(data, offset); + offset += 2; + var num = bin.readUint(data, offset); + offset += 4; + var voff = bin.readUint(data, offset); + offset += 4; + var arr = []; + if (type == 1 || type == 7) { + var no = num < 5 ? offset - 4 : voff; + if (no + num > data.buffer.byteLength) num = data.buffer.byteLength - no; + arr = new Uint8Array(data.buffer, no, num); + } + if (type == 2) { + var o0 = num < 5 ? offset - 4 : voff, c7 = data[o0], len = Math.max(0, Math.min(num - 1, data.length - o0)); + if (c7 < 128 || len == 0) arr.push(bin.readASCII(data, o0, len)); + else arr = new Uint8Array(data.buffer, o0, len); + } + if (type == 3) { + for (var j6 = 0; j6 < num; j6++) arr.push(bin.readUshort(data, (num < 3 ? offset - 4 : voff) + 2 * j6)); + } + if (type == 4 || type == 13) { + for (var j6 = 0; j6 < num; j6++) arr.push(bin.readUint(data, (num < 2 ? offset - 4 : voff) + 4 * j6)); + } + if (type == 5 || type == 10) { + var ri = type == 5 ? bin.readUint : bin.readInt; + for (var j6 = 0; j6 < num; j6++) arr.push([ri(data, voff + j6 * 8), ri(data, voff + j6 * 8 + 4)]); + } + if (type == 8) { + for (var j6 = 0; j6 < num; j6++) arr.push(bin.readShort(data, (num < 3 ? offset - 4 : voff) + 2 * j6)); + } + if (type == 9) { + for (var j6 = 0; j6 < num; j6++) arr.push(bin.readInt(data, (num < 2 ? offset - 4 : voff) + 4 * j6)); + } + if (type == 11) { + for (var j6 = 0; j6 < num; j6++) arr.push(bin.readFloat(data, voff + j6 * 4)); + } + if (type == 12) { + for (var j6 = 0; j6 < num; j6++) arr.push(bin.readDouble(data, voff + j6 * 8)); + } + if (num != 0 && arr.length == 0) { + log(tag, "unknown TIFF tag type: ", type, "num:", num); + if (i6 == 0) return; + continue; + } + if (prm.debug) log(" ".repeat(depth), tag, type, UTIF2.tags[tag], arr); + ifd["t" + tag] = arr; + if (tag == 330 && ifd["t272"] && ifd["t272"][0] == "DSLR-A100") { + } else if (tag == 330 || tag == 34665 || tag == 34853 || tag == 50740 && bin.readUshort(data, bin.readUint(arr, 0)) < 300 || tag == 61440) { + var oarr = tag == 50740 ? [bin.readUint(arr, 0)] : arr; + var subfd = []; + for (var j6 = 0; j6 < oarr.length; j6++) UTIF2._readIFD(bin, data, oarr[j6], subfd, depth + 1, prm); + if (tag == 330) ifd.subIFD = subfd; + if (tag == 34665) ifd.exifIFD = subfd[0]; + if (tag == 34853) ifd.gpsiIFD = subfd[0]; + if (tag == 50740) ifd.dngPrvt = subfd[0]; + if (tag == 61440) ifd.fujiIFD = subfd[0]; + } + if (tag == 37500 && prm.parseMN) { + var mn = arr; + if (bin.readASCII(mn, 0, 5) == "Nikon") ifd.makerNote = UTIF2["decode"](mn.slice(10).buffer)[0]; + else if (bin.readASCII(mn, 0, 5) == "OLYMP" || bin.readASCII(mn, 0, 9) == "OM SYSTEM") { + var inds = [8208, 8224, 8240, 8256, 8272]; + var subsub = []; + UTIF2._readIFD(bin, mn, mn[1] == 77 ? 16 : mn[5] == 85 ? 12 : 8, subsub, depth + 1, prm); + var obj2 = ifd.makerNote = subsub.pop(); + for (var j6 = 0; j6 < inds.length; j6++) { + var k6 = "t" + inds[j6]; + if (obj2[k6] == null) continue; + UTIF2._readIFD(bin, mn, obj2[k6][0], subsub, depth + 1, prm); + obj2[k6] = subsub.pop(); + } + if (obj2["t12288"]) { + UTIF2._readIFD(bin, obj2["t12288"], 0, subsub, depth + 1, prm); + obj2["t12288"] = subsub.pop(); + } + } else if (bin.readUshort(data, voff) < 300 && bin.readUshort(data, voff + 4) <= 12) { + var subsub = []; + UTIF2._readIFD(bin, data, voff, subsub, depth + 1, prm); + ifd.makerNote = subsub[0]; + } + } + } + ifds.push(ifd); + if (prm.debug) log(" ".repeat(depth), "<<<---------------"); + return offset; + }; + UTIF2._writeIFD = function(bin, types2, data, offset, ifd) { + var keys = Object.keys(ifd), knum = keys.length; + if (ifd["exifIFD"]) knum--; + if (ifd["gpsiIFD"]) knum--; + bin.writeUshort(data, offset, knum); + offset += 2; + var eoff = offset + knum * 12 + 4; + for (var ki = 0; ki < keys.length; ki++) { + var key = keys[ki]; + if (key == "t34665" || key == "t34853") continue; + if (key == "exifIFD") key = "t34665"; + if (key == "gpsiIFD") key = "t34853"; + var tag = parseInt(key.slice(1)), type = types2.main[tag]; + if (type == null) type = types2.rest[tag]; + if (type == null || type == 0) throw new Error("unknown type of tag: " + tag); + var val = ifd[key]; + if (tag == 34665) { + var outp = UTIF2._writeIFD(bin, types2, data, eoff, ifd["exifIFD"]); + val = [eoff]; + eoff = outp[1]; + } + if (tag == 34853) { + var outp = UTIF2._writeIFD(bin, UTIF2._types.gps, data, eoff, ifd["gpsiIFD"]); + val = [eoff]; + eoff = outp[1]; + } + if (type == 2) val = val[0] + "\0"; + var num = val.length; + bin.writeUshort(data, offset, tag); + offset += 2; + bin.writeUshort(data, offset, type); + offset += 2; + bin.writeUint(data, offset, num); + offset += 4; + var dlen = [-1, 1, 1, 2, 4, 8, 0, 1, 0, 4, 8, 0, 8][type] * num; + var toff = offset; + if (dlen > 4) { + bin.writeUint(data, offset, eoff); + toff = eoff; + } + if (type == 1 || type == 7) { + for (var i6 = 0; i6 < num; i6++) data[toff + i6] = val[i6]; + } else if (type == 2) { + bin.writeASCII(data, toff, val); + } else if (type == 3) { + for (var i6 = 0; i6 < num; i6++) bin.writeUshort(data, toff + 2 * i6, val[i6]); + } else if (type == 4) { + for (var i6 = 0; i6 < num; i6++) bin.writeUint(data, toff + 4 * i6, val[i6]); + } else if (type == 5 || type == 10) { + var wr = type == 5 ? bin.writeUint : bin.writeInt; + for (var i6 = 0; i6 < num; i6++) { + var v7 = val[i6], nu = v7[0], de = v7[1]; + if (nu == null) throw "e"; + wr(data, toff + 8 * i6, nu); + wr(data, toff + 8 * i6 + 4, de); + } + } else if (type == 9) { + for (var i6 = 0; i6 < num; i6++) bin.writeInt(data, toff + 4 * i6, val[i6]); + } else if (type == 12) { + for (var i6 = 0; i6 < num; i6++) bin.writeDouble(data, toff + 8 * i6, val[i6]); + } else throw type; + if (dlen > 4) { + dlen += dlen & 1; + eoff += dlen; + } + offset += 4; + } + return [offset, eoff]; + }; + UTIF2.toRGBA8 = function(out, scl) { + function gamma(x8) { + return x8 < 31308e-7 ? 12.92 * x8 : 1.055 * Math.pow(x8, 1 / 2.4) - 0.055; + } + var w6 = out.width, h6 = out.height, area = w6 * h6, qarea = area * 4, data = out.data; + var img = new Uint8Array(area * 4); + var intp = out["t262"] ? out["t262"][0] : 2, bps = out["t258"] ? Math.min(32, out["t258"][0]) : 1; + if (out["t262"] == null && bps == 1) intp = 0; + var smpls = out["t277"] ? out["t277"][0] : out["t258"] ? out["t258"].length : [1, 1, 3, 1, 1, 4, 3][intp]; + var sfmt = out["t339"] ? out["t339"][0] : null; + if (intp == 1 && bps == 32 && sfmt != 3) throw "e"; + var bpl = Math.ceil(smpls * bps * w6 / 8); + if (false) { + } else if (intp == 0) { + scl = 1 / 256; + for (var y4 = 0; y4 < h6; y4++) { + var off = y4 * bpl, io = y4 * w6; + if (bps == 1) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, px = data[off + (i6 >> 3)] >> 7 - (i6 & 7) & 1; + img[qi] = img[qi + 1] = img[qi + 2] = (1 - px) * 255; + img[qi + 3] = 255; + } + if (bps == 4) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, px = data[off + (i6 >> 1)] >> 4 - 4 * (i6 & 1) & 15; + img[qi] = img[qi + 1] = img[qi + 2] = (15 - px) * 17; + img[qi + 3] = 255; + } + if (bps == 8) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, px = data[off + i6]; + img[qi] = img[qi + 1] = img[qi + 2] = 255 - px; + img[qi + 3] = 255; + } + if (bps == 16) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, o6 = off + 2 * i6, px = data[o6 + 1] << 8 | data[o6]; + img[qi] = img[qi + 1] = img[qi + 2] = Math.min(255, 255 - ~~(px * scl)); + img[qi + 3] = 255; + } + } + } else if (intp == 1) { + if (scl == null) scl = 1 / 256; + var f32 = (data.length & 3) == 0 ? new Float32Array(data.buffer) : null; + for (var y4 = 0; y4 < h6; y4++) { + var off = y4 * bpl, io = y4 * w6; + if (bps == 1) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, px = data[off + (i6 >> 3)] >> 7 - (i6 & 7) & 1; + img[qi] = img[qi + 1] = img[qi + 2] = px * 255; + img[qi + 3] = 255; + } + if (bps == 2) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, px = data[off + (i6 >> 2)] >> 6 - 2 * (i6 & 3) & 3; + img[qi] = img[qi + 1] = img[qi + 2] = px * 85; + img[qi + 3] = 255; + } + if (bps == 8) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, px = data[off + i6 * smpls]; + img[qi] = img[qi + 1] = img[qi + 2] = px; + img[qi + 3] = 255; + } + if (bps == 16) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, o6 = off + 2 * i6, px = data[o6 + 1] << 8 | data[o6]; + img[qi] = img[qi + 1] = img[qi + 2] = Math.min(255, ~~(px * scl)); + img[qi + 3] = 255; + } + if (bps == 32) for (var i6 = 0; i6 < w6; i6++) { + var qi = io + i6 << 2, o6 = (off >>> 2) + i6, px = f32[o6]; + img[qi] = img[qi + 1] = img[qi + 2] = ~~(0.5 + 255 * px); + img[qi + 3] = 255; + } + } + } else if (intp == 2) { + if (bps == 8) { + if (smpls == 1) for (var i6 = 0; i6 < area; i6++) { + img[4 * i6] = img[4 * i6 + 1] = img[4 * i6 + 2] = data[i6]; + img[4 * i6 + 3] = 255; + } + if (smpls == 3) for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, ti = i6 * 3; + img[qi] = data[ti]; + img[qi + 1] = data[ti + 1]; + img[qi + 2] = data[ti + 2]; + img[qi + 3] = 255; + } + if (smpls >= 4) for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, ti = i6 * smpls; + img[qi] = data[ti]; + img[qi + 1] = data[ti + 1]; + img[qi + 2] = data[ti + 2]; + img[qi + 3] = data[ti + 3]; + } + } else if (bps == 16) { + if (smpls == 4) for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, ti = i6 * 8 + 1; + img[qi] = data[ti]; + img[qi + 1] = data[ti + 2]; + img[qi + 2] = data[ti + 4]; + img[qi + 3] = data[ti + 6]; + } + if (smpls == 3) for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, ti = i6 * 6 + 1; + img[qi] = data[ti]; + img[qi + 1] = data[ti + 2]; + img[qi + 2] = data[ti + 4]; + img[qi + 3] = 255; + } + } else if (bps == 32) { + var ndt = new Float32Array(data.buffer); + var min = 0; + for (var i6 = 0; i6 < ndt.length; i6++) min = Math.min(min, ndt[i6]); + if (min < 0) for (var i6 = 0; i6 < data.length; i6 += 4) { + var t12 = data[i6]; + data[i6] = data[i6 + 3]; + data[i6 + 3] = t12; + t12 = data[i6 + 1]; + data[i6 + 1] = data[i6 + 2]; + data[i6 + 2] = t12; + } + var pmap = []; + for (var i6 = 0; i6 < 65536; i6++) pmap.push(gamma(i6 / 65535)); + for (var i6 = 0; i6 < ndt.length; i6++) { + var cv2 = Math.max(0, Math.min(1, ndt[i6])); + ndt[i6] = pmap[~~(0.5 + cv2 * 65535)]; + } + if (smpls == 3) for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, ti = i6 * 3; + img[qi] = ~~(0.5 + ndt[ti] * 255); + img[qi + 1] = ~~(0.5 + ndt[ti + 1] * 255); + img[qi + 2] = ~~(0.5 + ndt[ti + 2] * 255); + img[qi + 3] = 255; + } + else if (smpls == 4) for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, ti = i6 * 4; + img[qi] = ~~(0.5 + ndt[ti] * 255); + img[qi + 1] = ~~(0.5 + ndt[ti + 1] * 255); + img[qi + 2] = ~~(0.5 + ndt[ti + 2] * 255); + img[qi + 3] = ~~(0.5 + ndt[ti + 3] * 255); + } + else throw smpls; + } else throw bps; + } else if (intp == 3) { + var map2 = out["t320"]; + var cn2 = 1 << bps; + var nexta = bps == 8 && smpls > 1 && out["t338"] && out["t338"][0] != 0; + for (var y4 = 0; y4 < h6; y4++) + for (var x7 = 0; x7 < w6; x7++) { + var i6 = y4 * w6 + x7; + var qi = i6 << 2, mi = 0; + var dof = y4 * bpl; + if (false) { + } else if (bps == 1) mi = data[dof + (x7 >>> 3)] >>> 7 - (x7 & 7) & 1; + else if (bps == 2) mi = data[dof + (x7 >>> 2)] >>> 6 - 2 * (x7 & 3) & 3; + else if (bps == 4) mi = data[dof + (x7 >>> 1)] >>> 4 - 4 * (x7 & 1) & 15; + else if (bps == 8) mi = data[dof + x7 * smpls]; + else throw bps; + img[qi] = map2[mi] >> 8; + img[qi + 1] = map2[cn2 + mi] >> 8; + img[qi + 2] = map2[cn2 + cn2 + mi] >> 8; + img[qi + 3] = nexta ? data[dof + x7 * smpls + 1] : 255; + } + } else if (intp == 5) { + var gotAlpha = smpls > 4 ? 1 : 0; + for (var i6 = 0; i6 < area; i6++) { + var qi = i6 << 2, si = i6 * smpls; + if (window.UDOC) { + var C3 = data[si], M2 = data[si + 1], Y3 = data[si + 2], K3 = data[si + 3]; + var c7 = UDOC.C.cmykToRgb([C3 * (1 / 255), M2 * (1 / 255), Y3 * (1 / 255), K3 * (1 / 255)]); + img[qi] = ~~(0.5 + 255 * c7[0]); + img[qi + 1] = ~~(0.5 + 255 * c7[1]); + img[qi + 2] = ~~(0.5 + 255 * c7[2]); + } else { + var C3 = 255 - data[si], M2 = 255 - data[si + 1], Y3 = 255 - data[si + 2], K3 = (255 - data[si + 3]) * (1 / 255); + img[qi] = ~~(C3 * K3 + 0.5); + img[qi + 1] = ~~(M2 * K3 + 0.5); + img[qi + 2] = ~~(Y3 * K3 + 0.5); + } + img[qi + 3] = 255 * (1 - gotAlpha) + data[si + 4] * gotAlpha; + } + } else if (intp == 6 && out["t278"]) { + var rps2 = out["t278"][0]; + for (var y4 = 0; y4 < h6; y4 += rps2) { + var i6 = y4 * w6, len = rps2 * w6; + for (var j6 = 0; j6 < len; j6++) { + var qi = 4 * (i6 + j6), si = 3 * i6 + 4 * (j6 >>> 1); + var Y3 = data[si + (j6 & 1)], Cb = data[si + 2] - 128, Cr = data[si + 3] - 128; + var r6 = Y3 + ((Cr >> 2) + (Cr >> 3) + (Cr >> 5)); + var g6 = Y3 - ((Cb >> 2) + (Cb >> 4) + (Cb >> 5)) - ((Cr >> 1) + (Cr >> 3) + (Cr >> 4) + (Cr >> 5)); + var b6 = Y3 + (Cb + (Cb >> 1) + (Cb >> 2) + (Cb >> 6)); + img[qi] = Math.max(0, Math.min(255, r6)); + img[qi + 1] = Math.max(0, Math.min(255, g6)); + img[qi + 2] = Math.max(0, Math.min(255, b6)); + img[qi + 3] = 255; + } + } + } else if (intp == 32845) { + for (var y4 = 0; y4 < h6; y4++) + for (var x7 = 0; x7 < w6; x7++) { + var si = (y4 * w6 + x7) * 6, qi = (y4 * w6 + x7) * 4; + var L2 = data[si + 1] << 8 | data[si]; + var L2 = Math.pow(2, (L2 + 0.5) / 256 - 64); + var u6 = (data[si + 3] + 0.5) / 410; + var v7 = (data[si + 5] + 0.5) / 410; + var sX = 9 * u6 / (6 * u6 - 16 * v7 + 12); + var sY = 4 * v7 / (6 * u6 - 16 * v7 + 12); + var bY2 = L2; + var X2 = sX * bY2 / sY, Y3 = bY2, Z2 = (1 - sX - sY) * bY2 / sY; + var r6 = 2.69 * X2 - 1.276 * Y3 - 0.414 * Z2; + var g6 = -1.022 * X2 + 1.978 * Y3 + 0.044 * Z2; + var b6 = 0.061 * X2 - 0.224 * Y3 + 1.163 * Z2; + img[qi] = gamma(Math.min(r6, 1)) * 255; + img[qi + 1] = gamma(Math.min(g6, 1)) * 255; + img[qi + 2] = gamma(Math.min(b6, 1)) * 255; + img[qi + 3] = 255; + } + } else log("Unknown Photometric interpretation: " + intp); + return img; + }; + UTIF2.replaceIMG = function(imgs) { + if (imgs == null) imgs = document.getElementsByTagName("img"); + var sufs = ["tif", "tiff", "dng", "cr2", "nef"]; + for (var i6 = 0; i6 < imgs.length; i6++) { + var img = imgs[i6], src = img.getAttribute("src"); + if (src == null) continue; + var suff = src.split(".").pop().toLowerCase(); + if (sufs.indexOf(suff) == -1) continue; + var xhr = new XMLHttpRequest(); + UTIF2._xhrs.push(xhr); + UTIF2._imgs.push(img); + xhr.open("GET", src); + xhr.responseType = "arraybuffer"; + xhr.onload = UTIF2._imgLoaded; + xhr.send(); + } + }; + UTIF2._xhrs = []; + UTIF2._imgs = []; + UTIF2._imgLoaded = function(e6) { + var ind = UTIF2._xhrs.indexOf(e6.target), img = UTIF2._imgs[ind]; + UTIF2._xhrs.splice(ind, 1); + UTIF2._imgs.splice(ind, 1); + img.setAttribute("src", UTIF2.bufferToURI(e6.target.response)); + }; + UTIF2.bufferToURI = function(buff) { + var ifds = UTIF2.decode(buff); + var vsns = ifds, ma = 0, page = vsns[0]; + if (ifds[0].subIFD) vsns = vsns.concat(ifds[0].subIFD); + for (var i6 = 0; i6 < vsns.length; i6++) { + var img = vsns[i6]; + if (img["t258"] == null || img["t258"].length < 3) continue; + var ar2 = img["t256"] * img["t257"]; + if (ar2 > ma) { + ma = ar2; + page = img; + } + } + UTIF2.decodeImage(buff, page, ifds); + var rgba = UTIF2.toRGBA8(page), w6 = page.width, h6 = page.height; + var cnv = document.createElement("canvas"); + cnv.width = w6; + cnv.height = h6; + var ctx = cnv.getContext("2d"); + var imgd = new ImageData(new Uint8ClampedArray(rgba.buffer), w6, h6); + ctx.putImageData(imgd, 0, 0); + return cnv.toDataURL(); + }; + UTIF2._binBE = { + nextZero: function(data, o6) { + while (data[o6] != 0) o6++; + return o6; + }, + readUshort: function(buff, p6) { + return buff[p6] << 8 | buff[p6 + 1]; + }, + readShort: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + a6[0] = buff[p6 + 1]; + a6[1] = buff[p6 + 0]; + return UTIF2._binBE.i16[0]; + }, + readInt: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + a6[0] = buff[p6 + 3]; + a6[1] = buff[p6 + 2]; + a6[2] = buff[p6 + 1]; + a6[3] = buff[p6 + 0]; + return UTIF2._binBE.i32[0]; + }, + readUint: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + a6[0] = buff[p6 + 3]; + a6[1] = buff[p6 + 2]; + a6[2] = buff[p6 + 1]; + a6[3] = buff[p6 + 0]; + return UTIF2._binBE.ui32[0]; + }, + readASCII: function(buff, p6, l6) { + var s6 = ""; + for (var i6 = 0; i6 < l6; i6++) s6 += String.fromCharCode(buff[p6 + i6]); + return s6; + }, + readFloat: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + for (var i6 = 0; i6 < 4; i6++) a6[i6] = buff[p6 + 3 - i6]; + return UTIF2._binBE.fl32[0]; + }, + readDouble: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + for (var i6 = 0; i6 < 8; i6++) a6[i6] = buff[p6 + 7 - i6]; + return UTIF2._binBE.fl64[0]; + }, + writeUshort: function(buff, p6, n6) { + buff[p6] = n6 >> 8 & 255; + buff[p6 + 1] = n6 & 255; + }, + writeInt: function(buff, p6, n6) { + var a6 = UTIF2._binBE.ui8; + UTIF2._binBE.i32[0] = n6; + buff[p6 + 3] = a6[0]; + buff[p6 + 2] = a6[1]; + buff[p6 + 1] = a6[2]; + buff[p6 + 0] = a6[3]; + }, + writeUint: function(buff, p6, n6) { + buff[p6] = n6 >> 24 & 255; + buff[p6 + 1] = n6 >> 16 & 255; + buff[p6 + 2] = n6 >> 8 & 255; + buff[p6 + 3] = n6 >> 0 & 255; + }, + writeASCII: function(buff, p6, s6) { + for (var i6 = 0; i6 < s6.length; i6++) buff[p6 + i6] = s6.charCodeAt(i6); + }, + writeDouble: function(buff, p6, n6) { + UTIF2._binBE.fl64[0] = n6; + for (var i6 = 0; i6 < 8; i6++) buff[p6 + i6] = UTIF2._binBE.ui8[7 - i6]; + } + }; + UTIF2._binBE.ui8 = new Uint8Array(8); + UTIF2._binBE.i16 = new Int16Array(UTIF2._binBE.ui8.buffer); + UTIF2._binBE.i32 = new Int32Array(UTIF2._binBE.ui8.buffer); + UTIF2._binBE.ui32 = new Uint32Array(UTIF2._binBE.ui8.buffer); + UTIF2._binBE.fl32 = new Float32Array(UTIF2._binBE.ui8.buffer); + UTIF2._binBE.fl64 = new Float64Array(UTIF2._binBE.ui8.buffer); + UTIF2._binLE = { + nextZero: UTIF2._binBE.nextZero, + readUshort: function(buff, p6) { + return buff[p6 + 1] << 8 | buff[p6]; + }, + readShort: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + a6[0] = buff[p6 + 0]; + a6[1] = buff[p6 + 1]; + return UTIF2._binBE.i16[0]; + }, + readInt: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + a6[0] = buff[p6 + 0]; + a6[1] = buff[p6 + 1]; + a6[2] = buff[p6 + 2]; + a6[3] = buff[p6 + 3]; + return UTIF2._binBE.i32[0]; + }, + readUint: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + a6[0] = buff[p6 + 0]; + a6[1] = buff[p6 + 1]; + a6[2] = buff[p6 + 2]; + a6[3] = buff[p6 + 3]; + return UTIF2._binBE.ui32[0]; + }, + readASCII: UTIF2._binBE.readASCII, + readFloat: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + for (var i6 = 0; i6 < 4; i6++) a6[i6] = buff[p6 + i6]; + return UTIF2._binBE.fl32[0]; + }, + readDouble: function(buff, p6) { + var a6 = UTIF2._binBE.ui8; + for (var i6 = 0; i6 < 8; i6++) a6[i6] = buff[p6 + i6]; + return UTIF2._binBE.fl64[0]; + }, + writeUshort: function(buff, p6, n6) { + buff[p6] = n6 & 255; + buff[p6 + 1] = n6 >> 8 & 255; + }, + writeInt: function(buff, p6, n6) { + var a6 = UTIF2._binBE.ui8; + UTIF2._binBE.i32[0] = n6; + buff[p6 + 0] = a6[0]; + buff[p6 + 1] = a6[1]; + buff[p6 + 2] = a6[2]; + buff[p6 + 3] = a6[3]; + }, + writeUint: function(buff, p6, n6) { + buff[p6] = n6 >>> 0 & 255; + buff[p6 + 1] = n6 >>> 8 & 255; + buff[p6 + 2] = n6 >>> 16 & 255; + buff[p6 + 3] = n6 >>> 24 & 255; + }, + writeASCII: UTIF2._binBE.writeASCII + }; + UTIF2._copyTile = function(tb, tw, th, b6, w6, h6, xoff, yoff) { + var xlim = Math.min(tw, w6 - xoff); + var ylim = Math.min(th, h6 - yoff); + for (var y4 = 0; y4 < ylim; y4++) { + var tof = (yoff + y4) * w6 + xoff; + var sof = y4 * tw; + for (var x7 = 0; x7 < xlim; x7++) b6[tof + x7] = tb[sof + x7]; + } + }; + UTIF2.LosslessJpegDecode = /* @__PURE__ */ (function() { + var b6, O2; + function l6() { + return b6[O2++]; + } + function m6() { + return b6[O2++] << 8 | b6[O2++]; + } + function a0(h6) { + var V2 = l6(), I3 = [0, 0, 0, 255], f6 = [], G3 = 8; + for (var w6 = 0; w6 < 16; w6++) f6[w6] = l6(); + for (var w6 = 0; w6 < 16; w6++) { + for (var x7 = 0; x7 < f6[w6]; x7++) { + var T2 = z3(I3, 0, w6 + 1, 1); + I3[T2 + 3] = l6(); + } + } + var E3 = new Uint8Array(1 << G3); + h6[V2] = [new Uint8Array(I3), E3]; + for (var w6 = 0; w6 < 1 << G3; w6++) { + var s6 = G3, _ = w6, Y3 = 0, F3 = 0; + while (I3[Y3 + 3] == 255 && s6 != 0) { + F3 = _ >> --s6 & 1; + Y3 = I3[Y3 + F3]; + } + E3[w6] = Y3; + } + } + function z3(h6, V2, I3, f6) { + if (h6[V2 + 3] != 255) return 0; + if (I3 == 0) return V2; + for (var w6 = 0; w6 < 2; w6++) { + if (h6[V2 + w6] == 0) { + h6[V2 + w6] = h6.length; + h6.push(0, 0, f6, 255); + } + var x7 = z3(h6, h6[V2 + w6], I3 - 1, f6 + 1); + if (x7 != 0) return x7; + } + return 0; + } + function i6(h6) { + var V2 = h6.b, I3 = h6.f; + while (V2 < 25 && h6.a < h6.d) { + var f6 = h6.data[h6.a++]; + if (f6 == 255 && !h6.c) h6.a++; + I3 = I3 << 8 | f6; + V2 += 8; + } + if (V2 < 0) throw "e"; + h6.b = V2; + h6.f = I3; + } + function H3(h6, V2) { + if (V2.b < h6) i6(V2); + return V2.f >> (V2.b -= h6) & 65535 >> 16 - h6; + } + function g6(h6, V2) { + var I3 = h6[0], f6 = 0, w6 = 255, x7 = 0; + if (V2.b < 16) i6(V2); + var T2 = V2.f >> V2.b - 8 & 255; + f6 = h6[1][T2]; + w6 = I3[f6 + 3]; + V2.b -= I3[f6 + 2]; + while (w6 == 255) { + x7 = V2.f >> --V2.b & 1; + f6 = I3[f6 + x7]; + w6 = I3[f6 + 3]; + } + return w6; + } + function P2(h6, V2) { + if (h6 < 32768 >> 16 - V2) h6 += -(1 << V2) + 1; + return h6; + } + function a22(h6, V2) { + var I3 = g6(h6, V2); + if (I3 == 0) return 0; + if (I3 == 16) return -32768; + var f6 = H3(I3, V2); + return P2(f6, I3); + } + function X2(h6, V2, I3, f6, w6, x7) { + var T2 = 0; + for (var G3 = 0; G3 < x7; G3++) { + var s6 = G3 * V2; + for (var _ = 0; _ < V2; _ += w6) { + T2++; + for (var Y3 = 0; Y3 < w6; Y3++) h6[s6 + _ + Y3] = a22(f6[Y3], I3); + } + if (I3.e != 0 && T2 % I3.e == 0 && G3 != 0) { + var F3 = I3.a, t12 = I3.data; + while (t12[F3] != 255 || !(208 <= t12[F3 + 1] && t12[F3 + 1] <= 215)) F3--; + I3.a = F3 + 2; + I3.f = 0; + I3.b = 0; + } + } + } + function o6(h6, V2) { + return P2(H3(h6, V2), h6); + } + function a1(h6, V2, I3, f6, w6) { + var x7 = b6.length - O2; + for (var T2 = 0; T2 < x7; T2 += 4) { + var G3 = b6[O2 + T2]; + b6[O2 + T2] = b6[O2 + T2 + 3]; + b6[O2 + T2 + 3] = G3; + var G3 = b6[O2 + T2 + 1]; + b6[O2 + T2 + 1] = b6[O2 + T2 + 2]; + b6[O2 + T2 + 2] = G3; + } + for (var E3 = 0; E3 < w6; E3++) { + var s6 = 32768, _ = 32768; + for (var Y3 = 0; Y3 < V2; Y3 += 2) { + var F3 = g6(f6, I3), t12 = g6(f6, I3); + if (F3 != 0) s6 += o6(F3, I3); + if (t12 != 0) _ += o6(t12, I3); + h6[E3 * V2 + Y3] = s6 & 65535; + h6[E3 * V2 + Y3 + 1] = _ & 65535; + } + } + } + function C3(h6) { + b6 = h6; + O2 = 0; + if (m6() != 65496) throw "e"; + var V2 = [], I3 = 0, f6 = 0, w6 = 0, x7 = [], T2 = [], G3 = [], E3 = 0, s6 = 0, _ = 0; + while (true) { + var Y3 = m6(); + if (Y3 == 65535) { + O2--; + continue; + } + var F3 = m6(); + if (Y3 == 65475) { + f6 = l6(); + s6 = m6(); + _ = m6(); + E3 = l6(); + for (var t12 = 0; t12 < E3; t12++) { + var a6 = l6(), J3 = l6(), r6 = l6(); + if (r6 != 0) throw "e"; + V2[a6] = [t12, J3 >> 4, J3 & 15]; + } + } else if (Y3 == 65476) { + var a32 = O2 + F3 - 2; + while (O2 < a32) a0(T2); + } else if (Y3 == 65498) { + O2++; + for (var t12 = 0; t12 < E3; t12++) { + var a52 = l6(), v7 = V2[a52]; + G3[v7[0]] = T2[l6() >>> 4]; + x7[v7[0]] = v7.slice(1); + } + I3 = l6(); + O2 += 2; + break; + } else if (Y3 == 65501) { + w6 = m6(); + } else { + O2 += F3 - 2; + } + } + var a42 = f6 > 8 ? Uint16Array : Uint8Array, $ = new a42(s6 * _ * E3), M2 = { b: 0, f: 0, c: I3 == 8, a: O2, data: b6, d: b6.length, e: w6 }; + if (M2.c) a1($, _ * E3, M2, G3[0], s6); + else { + var c7 = [], p6 = 0, D3 = 0; + for (var t12 = 0; t12 < E3; t12++) { + var N2 = x7[t12], S2 = N2[0], K3 = N2[1]; + if (S2 > p6) p6 = S2; + if (K3 > D3) D3 = K3; + c7.push(S2 * K3); + } + if (p6 != 1 || D3 != 1) { + if (E3 != 3 || c7[1] != 1 || c7[2] != 1) throw "e"; + if (p6 != 2 || D3 != 1 && D3 != 2) throw "e"; + var u6 = [], Z2 = 0; + for (var t12 = 0; t12 < E3; t12++) { + for (var R2 = 0; R2 < c7[t12]; R2++) u6.push(G3[t12]); + Z2 += c7[t12]; + } + var B3 = _ / p6, e6 = s6 / D3, d6 = B3 * e6; + X2($, B3 * Z2, M2, u6, Z2, e6); + j6($, I3, B3, e6, Z2 - 2, Z2, Z2, f6); + var A3 = new Uint16Array(d6 * c7[0]); + if (p6 == 2 && D3 == 2) { + for (var t12 = 0; t12 < d6; t12++) { + A3[4 * t12] = $[6 * t12]; + A3[4 * t12 + 1] = $[6 * t12 + 1]; + A3[4 * t12 + 2] = $[6 * t12 + 2]; + A3[4 * t12 + 3] = $[6 * t12 + 3]; + } + j6(A3, I3, B3 * 4, e6, 0, 1, 1, f6); + for (var t12 = 0; t12 < d6; t12++) { + $[6 * t12] = A3[4 * t12]; + $[6 * t12 + 1] = A3[4 * t12 + 1]; + $[6 * t12 + 2] = A3[4 * t12 + 2]; + $[6 * t12 + 3] = A3[4 * t12 + 3]; + } + } + if (p6 == 2 && D3 == 1) { + for (var t12 = 0; t12 < d6; t12++) { + A3[2 * t12] = $[4 * t12]; + A3[2 * t12 + 1] = $[4 * t12 + 1]; + } + j6(A3, I3, B3 * 2, e6, 0, 1, 1, f6); + for (var t12 = 0; t12 < d6; t12++) { + $[4 * t12] = A3[2 * t12]; + $[4 * t12 + 1] = A3[2 * t12 + 1]; + } + } + var n6 = $.slice(0); + for (var K3 = 0; K3 < s6; K3++) { + if (D3 == 2) for (var S2 = 0; S2 < _; S2++) { + var q6 = (K3 * _ + S2) * E3, k6 = ((K3 >>> 1) * B3 + (S2 >>> 1)) * Z2, y4 = (K3 & 1) * 2 + (S2 & 1); + $[q6] = n6[k6 + y4]; + $[q6 + 1] = n6[k6 + 4]; + $[q6 + 2] = n6[k6 + 5]; + } + else for (var S2 = 0; S2 < _; S2++) { + var q6 = (K3 * _ + S2) * E3, k6 = (K3 * B3 + (S2 >>> 1)) * Z2, y4 = S2 & 1; + $[q6] = n6[k6 + y4]; + $[q6 + 1] = n6[k6 + 2]; + $[q6 + 2] = n6[k6 + 3]; + } + } + } else { + X2($, _ * E3, M2, G3, E3, s6); + if (w6 == 0) j6($, I3, _, s6, 0, E3, E3, f6); + else { + var U2 = Math.floor(w6 / _); + for (var K3 = 0; K3 < s6; K3 += U2) { + var L2 = $.slice(K3 * _ * E3, (K3 + U2) * _ * E3); + j6(L2, I3, _, U2, 0, E3, E3, f6); + $.set(L2, K3 * _ * E3); + } + } + } + } + return $; + } + function j6(h6, V2, I3, f6, w6, x7, G3, E3) { + var s6 = I3 * G3; + for (var _ = w6; _ < x7; _++) h6[_] += 1 << E3 - 1; + for (var Y3 = G3; Y3 < s6; Y3 += G3) for (var _ = w6; _ < x7; _++) h6[Y3 + _] += h6[Y3 + _ - G3]; + for (var F3 = 1; F3 < f6; F3++) { + var t12 = F3 * s6; + for (var _ = w6; _ < x7; _++) h6[t12 + _] += h6[t12 + _ - s6]; + for (var Y3 = G3; Y3 < s6; Y3 += G3) { + for (var _ = w6; _ < x7; _++) { + var a6 = t12 + Y3 + _, J3 = a6 - s6, r6 = h6[a6 - G3], Q2 = 0; + if (V2 == 0) Q2 = 0; + else if (V2 == 1) Q2 = r6; + else if (V2 == 2) Q2 = h6[J3]; + else if (V2 == 3) Q2 = h6[J3 - G3]; + else if (V2 == 4) Q2 = r6 + (h6[J3] - h6[J3 - G3]); + else if (V2 == 5) Q2 = r6 + (h6[J3] - h6[J3 - G3] >>> 1); + else if (V2 == 6) Q2 = h6[J3] + (r6 - h6[J3 - G3] >>> 1); + else if (V2 == 7) Q2 = r6 + h6[J3] >>> 1; + else throw V2; + h6[a6] += Q2; + } + } + } + } + return C3; + })(); + (function() { + var G3 = 0, F3 = 1, i6 = 2, b6 = 3, J3 = 4, N2 = 5, E3 = 6, s6 = 7, c7 = 8, T2 = 9, a32 = 10, f6 = 11, q6 = 12, M2 = 13, m6 = 14, x7 = 15, L2 = 16, $ = 17, p6 = 18; + function a52(t12) { + var Z2 = UTIF2._binBE.readUshort, u6 = { b: Z2(t12, 0), i: t12[2], C: t12[3], u: t12[4], q: Z2(t12, 5), k: Z2(t12, 7), e: Z2(t12, 9), l: Z2(t12, 11), s: t12[13], d: Z2(t12, 14) }; + if (u6.b != 18771 || u6.i > 1 || u6.q < 6 || u6.q % 6 || u6.e < 768 || u6.e % 24 || u6.l != 768 || u6.k < u6.l || u6.k % u6.l || u6.k - u6.e >= u6.l || u6.s > 16 || u6.s != u6.k / u6.l || u6.s != Math.ceil(u6.e / u6.l) || u6.d != u6.q / 6 || u6.u != 12 && u6.u != 14 && u6.u != 16 || u6.C != 16 && u6.C != 0) { + throw "Invalid data"; + } + if (u6.i == 0) { + throw "Not implemented. We need this file!"; + } + u6.h = u6.C == 16; + u6.m = (u6.h ? u6.l * 2 / 3 : u6.l >>> 1) | 0; + u6.A = u6.m + 2; + u6.f = 64; + u6.g = (1 << u6.u) - 1; + u6.n = 4 * u6.u; + return u6; + } + function a7(t12, Z2) { + var u6 = new Array(Z2.s), e6 = 4 * Z2.s, Q2 = 16 + e6; + if (e6 & 12) Q2 += 16 - (e6 & 12); + for (var V2 = 0, O2 = 16; V2 < Z2.s; O2 += 4) { + var o6 = UTIF2._binBE.readUint(t12, O2); + u6[V2] = t12.slice(Q2, Q2 + o6); + u6[V2].j = 0; + u6[V2].a = 0; + Q2 += o6; + V2++; + } + if (Q2 != t12.length) throw "Invalid data"; + return u6; + } + function a6(t12, Z2) { + for (var u6 = -Z2[4], e6 = 0; u6 <= Z2[4]; e6++, u6++) { + t12[e6] = u6 <= -Z2[3] ? -4 : u6 <= -Z2[2] ? -3 : u6 <= -Z2[1] ? -2 : u6 < -Z2[0] ? -1 : u6 <= Z2[0] ? 0 : u6 < Z2[1] ? 1 : u6 < Z2[2] ? 2 : u6 < Z2[3] ? 3 : 4; + } + } + function a1(t12, Z2, u6) { + var e6 = [Z2, 3 * Z2 + 18, 5 * Z2 + 67, 7 * Z2 + 276, u6]; + t12.o = Z2; + t12.w = (e6[4] + 2 * Z2) / (2 * Z2 + 1) + 1 | 0; + t12.v = Math.ceil(Math.log2(t12.w)); + t12.t = 9; + a6(t12.c, e6); + } + function a22(t12) { + var Z2 = { c: new Int8Array(2 << t12.u) }; + a1(Z2, 0, t12.g); + return Z2; + } + function D3(t12) { + var Z2 = [[], [], []], u6 = Math.max(2, t12.w + 32 >>> 6); + for (var e6 = 0; e6 < 3; e6++) { + for (var Q2 = 0; Q2 < 41; Q2++) { + Z2[e6][Q2] = [u6, 1]; + } + } + return Z2; + } + function a42(t12) { + for (var Z2 = -1, u6 = 0; !u6; Z2++) { + u6 = t12[t12.j] >>> 7 - t12.a & 1; + t12.a++; + t12.a &= 7; + if (!t12.a) t12.j++; + } + return Z2; + } + function K3(t12, Z2) { + var u6 = 0, e6 = 8 - t12.a, Q2 = t12.j, V2 = t12.a; + if (Z2) { + if (Z2 >= e6) { + do { + u6 <<= e6; + Z2 -= e6; + u6 |= t12[t12.j] & (1 << e6) - 1; + t12.j++; + e6 = 8; + } while (Z2 >= 8); + } + if (Z2) { + u6 <<= Z2; + e6 -= Z2; + u6 |= t12[t12.j] >>> e6 & (1 << Z2) - 1; + } + t12.a = 8 - e6; + } + return u6; + } + function a0(t12, Z2) { + var u6 = 0; + if (Z2 < t12) { + while (u6 <= 14 && Z2 << ++u6 < t12) ; + } + return u6; + } + function r6(t12, Z2, u6, e6, Q2, V2, O2, o6) { + if (o6 == null) o6 = 0; + var X2 = V2 + 1, k6 = X2 % 2, j6 = 0, I3 = 0, a10 = 0, l6, R2, w6 = e6[Q2], S2 = e6[Q2 - 1], H3 = e6[Q2 - 2][X2], g6 = S2[X2 - 1], Y3 = S2[X2], P2 = S2[X2 + 1], A3 = w6[X2 - 1], v7 = w6[X2 + 1], y4 = Math.abs, d6, C3, n6, h6; + if (k6) { + d6 = y4(P2 - Y3); + C3 = y4(H3 - Y3); + n6 = y4(g6 - Y3); + } + if (k6) { + h6 = d6 > n6 && C3 < d6 ? H3 + g6 : d6 < n6 && C3 < n6 ? H3 + P2 : P2 + g6; + h6 = h6 + 2 * Y3 >>> 2; + if (o6) { + w6[X2] = h6; + return; + } + l6 = Z2.t * Z2.c[t12.g + Y3 - H3] + Z2.c[t12.g + g6 - Y3]; + } else { + h6 = Y3 > g6 && Y3 > P2 || Y3 < g6 && Y3 < P2 ? v7 + A3 + 2 * Y3 >>> 2 : A3 + v7 >>> 1; + l6 = Z2.t * Z2.c[t12.g + Y3 - g6] + Z2.c[t12.g + g6 - A3]; + } + R2 = y4(l6); + var W2 = a42(u6); + if (W2 < t12.n - Z2.v - 1) { + var z3 = a0(O2[R2][0], O2[R2][1]); + a10 = K3(u6, z3) + (W2 << z3); + } else { + a10 = K3(u6, Z2.v) + 1; + } + a10 = a10 & 1 ? -1 - (a10 >>> 1) : a10 >>> 1; + O2[R2][0] += y4(a10); + if (O2[R2][1] == t12.f) { + O2[R2][0] >>>= 1; + O2[R2][1] >>>= 1; + } + O2[R2][1]++; + h6 = l6 < 0 ? h6 - a10 : h6 + a10; + if (t12.i) { + if (h6 < 0) h6 += Z2.w; + else if (h6 > t12.g) h6 -= Z2.w; + } + w6[X2] = h6 >= 0 ? Math.min(h6, t12.g) : 0; + } + function U2(t12, Z2, u6) { + var e6 = t12[0].length; + for (var Q2 = Z2; Q2 <= u6; Q2++) { + t12[Q2][0] = t12[Q2 - 1][1]; + t12[Q2][e6 - 1] = t12[Q2 - 1][e6 - 2]; + } + } + function B3(t12) { + U2(t12, s6, q6); + U2(t12, i6, J3); + U2(t12, x7, $); + } + function _(t12, Z2, u6, e6, Q2, V2, O2, o6, X2, k6, j6, I3, a10) { + var l6 = 0, R2 = 1, w6 = Q2 < M2 && Q2 > J3; + while (R2 < t12.m) { + if (l6 < t12.m) { + r6(t12, Z2, u6, e6, Q2, l6, O2[X2], t12.h && (w6 && k6 || !w6 && (j6 || (l6 & I3) == a10))); + r6(t12, Z2, u6, e6, V2, l6, O2[X2], t12.h && (!w6 && k6 || w6 && (j6 || (l6 & I3) == a10))); + l6 += 2; + } + if (l6 > 8) { + r6(t12, Z2, u6, e6, Q2, R2, o6[X2]); + r6(t12, Z2, u6, e6, V2, R2, o6[X2]); + R2 += 2; + } + } + B3(e6); + } + function a8(t12, Z2, u6, e6, Q2, V2) { + _(t12, Z2, u6, e6, i6, s6, Q2, V2, 0, 0, 1, 0, 8); + _(t12, Z2, u6, e6, c7, x7, Q2, V2, 1, 0, 1, 0, 8); + _(t12, Z2, u6, e6, b6, T2, Q2, V2, 2, 1, 0, 3, 0); + _(t12, Z2, u6, e6, a32, L2, Q2, V2, 0, 0, 0, 3, 2); + _(t12, Z2, u6, e6, J3, f6, Q2, V2, 1, 0, 0, 3, 2); + _(t12, Z2, u6, e6, q6, $, Q2, V2, 2, 1, 0, 3, 0); + } + function a9(t12, Z2, u6, e6, Q2, V2) { + var O2 = V2.length, o6 = t12.l; + if (Q2 + 1 == t12.s) o6 = t12.e - Q2 * t12.l; + var X2 = 6 * t12.e * e6 + Q2 * t12.l; + for (var k6 = 0; k6 < 6; k6++) { + for (var j6 = 0; j6 < o6; j6++) { + var I3 = V2[k6 % O2][j6 % O2], a10; + if (I3 == 0) { + a10 = i6 + (k6 >>> 1); + } else if (I3 == 2) { + a10 = x7 + (k6 >>> 1); + } else { + a10 = s6 + k6; + } + var l6 = t12.h ? (j6 * 2 / 3 & 2147483646 | j6 % 3 & 1) + (j6 % 3 >>> 1) : j6 >>> 1; + Z2[X2 + j6] = u6[a10][l6 + 1]; + } + X2 += t12.e; + } + } + UTIF2._decompressRAF = function(t12, Z2) { + var u6 = a52(t12), e6 = a7(t12, u6), Q2 = a22(u6), V2 = new Int16Array(u6.e * u6.q); + if (Z2 == null) { + Z2 = u6.h ? [[1, 1, 0, 1, 1, 2], [1, 1, 2, 1, 1, 0], [2, 0, 1, 0, 2, 1], [1, 1, 2, 1, 1, 0], [1, 1, 0, 1, 1, 2], [0, 2, 1, 2, 0, 1]] : [[0, 1], [3, 2]]; + } + var O2 = [[G3, b6], [F3, J3], [N2, f6], [E3, q6], [M2, L2], [m6, $]], o6 = []; + for (var X2 = 0; X2 < p6; X2++) { + o6[X2] = new Uint16Array(u6.A); + } + for (var k6 = 0; k6 < u6.s; k6++) { + var j6 = D3(Q2), I3 = D3(Q2); + for (var X2 = 0; X2 < p6; X2++) { + for (var a10 = 0; a10 < u6.A; a10++) { + o6[X2][a10] = 0; + } + } + for (var l6 = 0; l6 < u6.d; l6++) { + a8(u6, Q2, e6[k6], o6, j6, I3); + for (var X2 = 0; X2 < 6; X2++) { + for (var a10 = 0; a10 < u6.A; a10++) { + o6[O2[X2][0]][a10] = o6[O2[X2][1]][a10]; + } + } + a9(u6, V2, o6, l6, k6, Z2); + for (var X2 = i6; X2 < p6; X2++) { + if ([N2, E3, M2, m6].indexOf(X2) == -1) { + for (var a10 = 0; a10 < u6.A; a10++) { + o6[X2][a10] = 0; + } + } + } + B3(o6); + } + } + return V2; + }; + })(); + })(UTIF, pako); + })(); } - async signWithCredentials(requestToSign, credentials, options = {}) { - if (options.signingRegion === "*") { - const signer = this.getSigv4aSigner(); - const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4; - if (CrtSignerV4 && signer instanceof CrtSignerV4) { - return signer.signWithCredentials(requestToSign, credentials, options); +}); + +// ../node_modules/ieee754/index.js +var require_ieee754 = __commonJS({ + "../node_modules/ieee754/index.js"(exports2) { + "use strict"; + exports2.read = function(buffer, offset, isLE, mLen, nBytes) { + var e6, m6; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var nBits = -7; + var i6 = isLE ? nBytes - 1 : 0; + var d6 = isLE ? -1 : 1; + var s6 = buffer[offset + i6]; + i6 += d6; + e6 = s6 & (1 << -nBits) - 1; + s6 >>= -nBits; + nBits += eLen; + for (; nBits > 0; e6 = e6 * 256 + buffer[offset + i6], i6 += d6, nBits -= 8) { + } + m6 = e6 & (1 << -nBits) - 1; + e6 >>= -nBits; + nBits += mLen; + for (; nBits > 0; m6 = m6 * 256 + buffer[offset + i6], i6 += d6, nBits -= 8) { + } + if (e6 === 0) { + e6 = 1 - eBias; + } else if (e6 === eMax) { + return m6 ? NaN : (s6 ? -1 : 1) * Infinity; } else { - throw new Error(`signWithCredentials with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`); - } - } - return this.sigv4Signer.signWithCredentials(requestToSign, credentials, options); - } - async presign(originalRequest, options = {}) { - if (options.signingRegion === "*") { - const signer = this.getSigv4aSigner(); - const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4; - if (CrtSignerV4 && signer instanceof CrtSignerV4) { - return signer.presign(originalRequest, options); + m6 = m6 + Math.pow(2, mLen); + e6 = e6 - eBias; + } + return (s6 ? -1 : 1) * m6 * Math.pow(2, e6 - mLen); + }; + exports2.write = function(buffer, value, offset, isLE, mLen, nBytes) { + var e6, m6, c7; + var eLen = nBytes * 8 - mLen - 1; + var eMax = (1 << eLen) - 1; + var eBias = eMax >> 1; + var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; + var i6 = isLE ? 0 : nBytes - 1; + var d6 = isLE ? 1 : -1; + var s6 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; + value = Math.abs(value); + if (isNaN(value) || value === Infinity) { + m6 = isNaN(value) ? 1 : 0; + e6 = eMax; } else { - throw new Error(`presign with signingRegion '*' is only supported when using the CRT dependency @aws-sdk/signature-v4-crt. Please check whether you have installed the "@aws-sdk/signature-v4-crt" package explicitly. You must also register the package by calling [require("@aws-sdk/signature-v4-crt");] or an ESM equivalent such as [import "@aws-sdk/signature-v4-crt";]. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt`); - } - } - return this.sigv4Signer.presign(originalRequest, options); - } - async presignWithCredentials(originalRequest, credentials, options = {}) { - if (options.signingRegion === "*") { - throw new Error("Method presignWithCredentials is not supported for [signingRegion=*]."); - } - return this.sigv4Signer.presignWithCredentials(originalRequest, credentials, options); - } - getSigv4aSigner() { - if (!this.sigv4aSigner) { - const CrtSignerV4 = signatureV4CrtContainer.CrtSignerV4; - const JsSigV4aSigner = signatureV4aContainer.SignatureV4a; - if (this.signerOptions.runtime === "node") { - if (!CrtSignerV4 && !JsSigV4aSigner) { - throw new Error("Neither CRT nor JS SigV4a implementation is available. Please load either @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a. For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt"); + e6 = Math.floor(Math.log(value) / Math.LN2); + if (value * (c7 = Math.pow(2, -e6)) < 1) { + e6--; + c7 *= 2; } - if (CrtSignerV4 && typeof CrtSignerV4 === "function") { - this.sigv4aSigner = new CrtSignerV4({ - ...this.signerOptions, - signingAlgorithm: 1 - }); - } else if (JsSigV4aSigner && typeof JsSigV4aSigner === "function") { - this.sigv4aSigner = new JsSigV4aSigner({ - ...this.signerOptions - }); + if (e6 + eBias >= 1) { + value += rt / c7; } else { - throw new Error("Available SigV4a implementation is not a valid constructor. Please ensure you've properly imported @aws-sdk/signature-v4-crt or @aws-sdk/signature-v4a.For more information please go to https://github.com/aws/aws-sdk-js-v3#functionality-requiring-aws-common-runtime-crt"); - } - } else { - if (!JsSigV4aSigner || typeof JsSigV4aSigner !== "function") { - throw new Error("JS SigV4a implementation is not available or not a valid constructor. Please check whether you have installed the @aws-sdk/signature-v4a package explicitly. The CRT implementation is not available for browsers. You must also register the package by calling [require('@aws-sdk/signature-v4a');] or an ESM equivalent such as [import '@aws-sdk/signature-v4a';]. For more information please go to https://github.com/aws/aws-sdk-js-v3#using-javascript-non-crt-implementation-of-sigv4a"); + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c7 >= 2) { + e6++; + c7 /= 2; + } + if (e6 + eBias >= eMax) { + m6 = 0; + e6 = eMax; + } else if (e6 + eBias >= 1) { + m6 = (value * c7 - 1) * Math.pow(2, mLen); + e6 = e6 + eBias; + } else { + m6 = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e6 = 0; } - this.sigv4aSigner = new JsSigV4aSigner({ - ...this.signerOptions - }); } - } - return this.sigv4aSigner; + for (; mLen >= 8; buffer[offset + i6] = m6 & 255, i6 += d6, m6 /= 256, mLen -= 8) { + } + e6 = e6 << mLen | m6; + eLen += mLen; + for (; eLen > 0; buffer[offset + i6] = e6 & 255, i6 += d6, e6 /= 256, eLen -= 8) { + } + buffer[offset + i6 - d6] |= s6 * 128; + }; } -}; - -// ../node_modules/@aws-sdk/client-s3/dist-es/auth/httpAuthSchemeProvider.js -init_dist_es36(); -init_dist_es3(); - -// ../node_modules/@aws-sdk/client-s3/dist-es/endpoint/endpointResolver.js -init_dist_es30(); -init_dist_es27(); +}); -// ../node_modules/@aws-sdk/client-s3/dist-es/endpoint/ruleset.js -var cs = "required"; -var ct = "type"; -var cu = "rules"; -var cv = "conditions"; -var cw = "fn"; -var cx = "argv"; -var cy = "ref"; -var cz = "assign"; -var cA = "url"; -var cB = "properties"; -var cC = "backend"; -var cD = "authSchemes"; -var cE = "disableDoubleEncoding"; -var cF = "signingName"; -var cG = "signingRegion"; -var cH = "headers"; -var cI = "signingRegionSet"; -var a = 6; -var b = false; -var c = true; -var d = "isSet"; -var e = "booleanEquals"; -var f = "error"; -var g = "aws.partition"; -var h = "stringEquals"; -var i = "getAttr"; -var j = "name"; -var k = "substring"; -var l = "bucketSuffix"; -var m = "parseURL"; -var n = "endpoint"; -var o = "tree"; -var p = "aws.isVirtualHostableS3Bucket"; -var q = "{url#scheme}://{Bucket}.{url#authority}{url#path}"; -var r = "not"; -var s = "accessPointSuffix"; -var t = "{url#scheme}://{url#authority}{url#path}"; -var u = "hardwareType"; -var v = "regionPrefix"; -var w = "bucketAliasSuffix"; -var x = "outpostId"; -var y = "isValidHostLabel"; -var z = "sigv4a"; -var A = "s3-outposts"; -var B = "s3"; -var C = "{url#scheme}://{url#authority}{url#normalizedPath}{Bucket}"; -var D = "https://{Bucket}.s3-accelerate.{partitionResult#dnsSuffix}"; -var E = "https://{Bucket}.s3.{partitionResult#dnsSuffix}"; -var F = "aws.parseArn"; -var G = "bucketArn"; -var H = "arnType"; -var I = ""; -var J = "s3-object-lambda"; -var K = "accesspoint"; -var L = "accessPointName"; -var M = "{url#scheme}://{accessPointName}-{bucketArn#accountId}.{url#authority}{url#path}"; -var N = "mrapPartition"; -var O = "outpostType"; -var P = "arnPrefix"; -var Q = "{url#scheme}://{url#authority}{url#normalizedPath}{uri_encoded_bucket}"; -var R = "https://s3.{partitionResult#dnsSuffix}/{uri_encoded_bucket}"; -var S = "https://s3.{partitionResult#dnsSuffix}"; -var T = { [cs]: false, [ct]: "string" }; -var U = { [cs]: true, "default": false, [ct]: "boolean" }; -var V = { [cs]: false, [ct]: "boolean" }; -var W = { [cw]: e, [cx]: [{ [cy]: "Accelerate" }, true] }; -var X = { [cw]: e, [cx]: [{ [cy]: "UseFIPS" }, true] }; -var Y = { [cw]: e, [cx]: [{ [cy]: "UseDualStack" }, true] }; -var Z = { [cw]: d, [cx]: [{ [cy]: "Endpoint" }] }; -var aa = { [cw]: g, [cx]: [{ [cy]: "Region" }], [cz]: "partitionResult" }; -var ab = { [cw]: h, [cx]: [{ [cw]: i, [cx]: [{ [cy]: "partitionResult" }, j] }, "aws-cn"] }; -var ac = { [cw]: d, [cx]: [{ [cy]: "Bucket" }] }; -var ad = { [cy]: "Bucket" }; -var ae = { [cv]: [W], [f]: "S3Express does not support S3 Accelerate.", [ct]: f }; -var af = { [cv]: [Z, { [cw]: m, [cx]: [{ [cy]: "Endpoint" }], [cz]: "url" }], [cu]: [{ [cv]: [{ [cw]: d, [cx]: [{ [cy]: "DisableS3ExpressSessionAuth" }] }, { [cw]: e, [cx]: [{ [cy]: "DisableS3ExpressSessionAuth" }, true] }], [cu]: [{ [cv]: [{ [cw]: e, [cx]: [{ [cw]: i, [cx]: [{ [cy]: "url" }, "isIp"] }, true] }], [cu]: [{ [cv]: [{ [cw]: "uriEncode", [cx]: [ad], [cz]: "uri_encoded_bucket" }], [cu]: [{ [n]: { [cA]: "{url#scheme}://{url#authority}/{uri_encoded_bucket}{url#path}", [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }], [ct]: o }], [ct]: o }, { [cv]: [{ [cw]: p, [cx]: [ad, false] }], [cu]: [{ [n]: { [cA]: q, [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }], [ct]: o }, { [f]: "S3Express bucket name is not a valid virtual hostable name.", [ct]: f }], [ct]: o }, { [cv]: [{ [cw]: e, [cx]: [{ [cw]: i, [cx]: [{ [cy]: "url" }, "isIp"] }, true] }], [cu]: [{ [cv]: [{ [cw]: "uriEncode", [cx]: [ad], [cz]: "uri_encoded_bucket" }], [cu]: [{ [n]: { [cA]: "{url#scheme}://{url#authority}/{uri_encoded_bucket}{url#path}", [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4-s3express", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }], [ct]: o }], [ct]: o }, { [cv]: [{ [cw]: p, [cx]: [ad, false] }], [cu]: [{ [n]: { [cA]: q, [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4-s3express", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }], [ct]: o }, { [f]: "S3Express bucket name is not a valid virtual hostable name.", [ct]: f }], [ct]: o }; -var ag = { [cw]: m, [cx]: [{ [cy]: "Endpoint" }], [cz]: "url" }; -var ah = { [cw]: e, [cx]: [{ [cw]: i, [cx]: [{ [cy]: "url" }, "isIp"] }, true] }; -var ai = { [cy]: "url" }; -var aj = { [cw]: "uriEncode", [cx]: [ad], [cz]: "uri_encoded_bucket" }; -var ak = { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: "s3express", [cG]: "{Region}" }] }; -var al = {}; -var am = { [cw]: p, [cx]: [ad, false] }; -var an = { [f]: "S3Express bucket name is not a valid virtual hostable name.", [ct]: f }; -var ao = { [cw]: d, [cx]: [{ [cy]: "UseS3ExpressControlEndpoint" }] }; -var ap = { [cw]: e, [cx]: [{ [cy]: "UseS3ExpressControlEndpoint" }, true] }; -var aq = { [cw]: r, [cx]: [Z] }; -var ar = { [cw]: e, [cx]: [{ [cy]: "UseDualStack" }, false] }; -var as = { [cw]: e, [cx]: [{ [cy]: "UseFIPS" }, false] }; -var at = { [f]: "Unrecognized S3Express bucket name format.", [ct]: f }; -var au = { [cw]: r, [cx]: [ac] }; -var av = { [cy]: u }; -var aw = { [cv]: [aq], [f]: "Expected a endpoint to be specified but no endpoint was found", [ct]: f }; -var ax = { [cD]: [{ [cE]: true, [j]: z, [cF]: A, [cI]: ["*"] }, { [cE]: true, [j]: "sigv4", [cF]: A, [cG]: "{Region}" }] }; -var ay = { [cw]: e, [cx]: [{ [cy]: "ForcePathStyle" }, false] }; -var az = { [cy]: "ForcePathStyle" }; -var aA = { [cw]: e, [cx]: [{ [cy]: "Accelerate" }, false] }; -var aB = { [cw]: h, [cx]: [{ [cy]: "Region" }, "aws-global"] }; -var aC = { [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: B, [cG]: "us-east-1" }] }; -var aD = { [cw]: r, [cx]: [aB] }; -var aE = { [cw]: e, [cx]: [{ [cy]: "UseGlobalEndpoint" }, true] }; -var aF = { [cA]: "https://{Bucket}.s3-fips.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: { [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: B, [cG]: "{Region}" }] }, [cH]: {} }; -var aG = { [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: B, [cG]: "{Region}" }] }; -var aH = { [cw]: e, [cx]: [{ [cy]: "UseGlobalEndpoint" }, false] }; -var aI = { [cA]: "https://{Bucket}.s3-fips.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var aJ = { [cA]: "https://{Bucket}.s3-accelerate.dualstack.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var aK = { [cA]: "https://{Bucket}.s3.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var aL = { [cw]: e, [cx]: [{ [cw]: i, [cx]: [ai, "isIp"] }, false] }; -var aM = { [cA]: C, [cB]: aG, [cH]: {} }; -var aN = { [cA]: q, [cB]: aG, [cH]: {} }; -var aO = { [n]: aN, [ct]: n }; -var aP = { [cA]: D, [cB]: aG, [cH]: {} }; -var aQ = { [cA]: "https://{Bucket}.s3.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var aR = { [f]: "Invalid region: region was not a valid DNS name.", [ct]: f }; -var aS = { [cy]: G }; -var aT = { [cy]: H }; -var aU = { [cw]: i, [cx]: [aS, "service"] }; -var aV = { [cy]: L }; -var aW = { [cv]: [Y], [f]: "S3 Object Lambda does not support Dual-stack", [ct]: f }; -var aX = { [cv]: [W], [f]: "S3 Object Lambda does not support S3 Accelerate", [ct]: f }; -var aY = { [cv]: [{ [cw]: d, [cx]: [{ [cy]: "DisableAccessPoints" }] }, { [cw]: e, [cx]: [{ [cy]: "DisableAccessPoints" }, true] }], [f]: "Access points are not supported for this operation", [ct]: f }; -var aZ = { [cv]: [{ [cw]: d, [cx]: [{ [cy]: "UseArnRegion" }] }, { [cw]: e, [cx]: [{ [cy]: "UseArnRegion" }, false] }, { [cw]: r, [cx]: [{ [cw]: h, [cx]: [{ [cw]: i, [cx]: [aS, "region"] }, "{Region}"] }] }], [f]: "Invalid configuration: region from ARN `{bucketArn#region}` does not match client region `{Region}` and UseArnRegion is `false`", [ct]: f }; -var ba = { [cw]: i, [cx]: [{ [cy]: "bucketPartition" }, j] }; -var bb = { [cw]: i, [cx]: [aS, "accountId"] }; -var bc = { [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: J, [cG]: "{bucketArn#region}" }] }; -var bd = { [f]: "Invalid ARN: The access point name may only contain a-z, A-Z, 0-9 and `-`. Found: `{accessPointName}`", [ct]: f }; -var be = { [f]: "Invalid ARN: The account id may only contain a-z, A-Z, 0-9 and `-`. Found: `{bucketArn#accountId}`", [ct]: f }; -var bf = { [f]: "Invalid region in ARN: `{bucketArn#region}` (invalid DNS name)", [ct]: f }; -var bg = { [f]: "Client was configured for partition `{partitionResult#name}` but ARN (`{Bucket}`) has `{bucketPartition#name}`", [ct]: f }; -var bh = { [f]: "Invalid ARN: The ARN may only contain a single resource component after `accesspoint`.", [ct]: f }; -var bi = { [f]: "Invalid ARN: Expected a resource of the format `accesspoint:` but no name was provided", [ct]: f }; -var bj = { [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: B, [cG]: "{bucketArn#region}" }] }; -var bk = { [cD]: [{ [cE]: true, [j]: z, [cF]: A, [cI]: ["*"] }, { [cE]: true, [j]: "sigv4", [cF]: A, [cG]: "{bucketArn#region}" }] }; -var bl = { [cw]: F, [cx]: [ad] }; -var bm = { [cA]: "https://s3-fips.dualstack.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aG, [cH]: {} }; -var bn = { [cA]: "https://s3-fips.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aG, [cH]: {} }; -var bo = { [cA]: "https://s3.dualstack.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aG, [cH]: {} }; -var bp = { [cA]: Q, [cB]: aG, [cH]: {} }; -var bq = { [cA]: "https://s3.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aG, [cH]: {} }; -var br = { [cy]: "UseObjectLambdaEndpoint" }; -var bs = { [cD]: [{ [cE]: true, [j]: "sigv4", [cF]: J, [cG]: "{Region}" }] }; -var bt = { [cA]: "https://s3-fips.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var bu = { [cA]: "https://s3-fips.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var bv = { [cA]: "https://s3.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var bw = { [cA]: t, [cB]: aG, [cH]: {} }; -var bx = { [cA]: "https://s3.{Region}.{partitionResult#dnsSuffix}", [cB]: aG, [cH]: {} }; -var by = [{ [cy]: "Region" }]; -var bz = [{ [cy]: "Endpoint" }]; -var bA = [ad]; -var bB = [W]; -var bC = [Z, ag]; -var bD = [{ [cw]: d, [cx]: [{ [cy]: "DisableS3ExpressSessionAuth" }] }, { [cw]: e, [cx]: [{ [cy]: "DisableS3ExpressSessionAuth" }, true] }]; -var bE = [aj]; -var bF = [am]; -var bG = [aa]; -var bH = [X, Y]; -var bI = [X, ar]; -var bJ = [as, Y]; -var bK = [as, ar]; -var bL = [{ [cw]: k, [cx]: [ad, 6, 14, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 14, 16, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bM = [{ [cv]: [X, Y], [n]: { [cA]: "https://{Bucket}.s3express-fips-{s3expressAvailabilityZoneId}.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: {} }, [ct]: n }, { [cv]: bI, [n]: { [cA]: "https://{Bucket}.s3express-fips-{s3expressAvailabilityZoneId}.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: {} }, [ct]: n }, { [cv]: bJ, [n]: { [cA]: "https://{Bucket}.s3express-{s3expressAvailabilityZoneId}.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: {} }, [ct]: n }, { [cv]: bK, [n]: { [cA]: "https://{Bucket}.s3express-{s3expressAvailabilityZoneId}.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: {} }, [ct]: n }]; -var bN = [{ [cw]: k, [cx]: [ad, 6, 15, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 15, 17, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bO = [{ [cw]: k, [cx]: [ad, 6, 19, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 19, 21, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bP = [{ [cw]: k, [cx]: [ad, 6, 20, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 20, 22, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bQ = [{ [cw]: k, [cx]: [ad, 6, 26, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 26, 28, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bR = [{ [cv]: [X, Y], [n]: { [cA]: "https://{Bucket}.s3express-fips-{s3expressAvailabilityZoneId}.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4-s3express", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }, { [cv]: bI, [n]: { [cA]: "https://{Bucket}.s3express-fips-{s3expressAvailabilityZoneId}.{Region}.{partitionResult#dnsSuffix}", [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4-s3express", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }, { [cv]: bJ, [n]: { [cA]: "https://{Bucket}.s3express-{s3expressAvailabilityZoneId}.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4-s3express", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }, { [cv]: bK, [n]: { [cA]: "https://{Bucket}.s3express-{s3expressAvailabilityZoneId}.{Region}.{partitionResult#dnsSuffix}", [cB]: { [cC]: "S3Express", [cD]: [{ [cE]: true, [j]: "sigv4-s3express", [cF]: "s3express", [cG]: "{Region}" }] }, [cH]: {} }, [ct]: n }]; -var bS = [ad, 0, 7, true]; -var bT = [{ [cw]: k, [cx]: [ad, 7, 15, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 15, 17, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bU = [{ [cw]: k, [cx]: [ad, 7, 16, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 16, 18, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bV = [{ [cw]: k, [cx]: [ad, 7, 20, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 20, 22, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bW = [{ [cw]: k, [cx]: [ad, 7, 21, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 21, 23, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bX = [{ [cw]: k, [cx]: [ad, 7, 27, true], [cz]: "s3expressAvailabilityZoneId" }, { [cw]: k, [cx]: [ad, 27, 29, true], [cz]: "s3expressAvailabilityZoneDelim" }, { [cw]: h, [cx]: [{ [cy]: "s3expressAvailabilityZoneDelim" }, "--"] }]; -var bY = [ac]; -var bZ = [{ [cw]: y, [cx]: [{ [cy]: x }, false] }]; -var ca = [{ [cw]: h, [cx]: [{ [cy]: v }, "beta"] }]; -var cb = ["*"]; -var cc = [{ [cw]: y, [cx]: [{ [cy]: "Region" }, false] }]; -var cd = [{ [cw]: h, [cx]: [{ [cy]: "Region" }, "us-east-1"] }]; -var ce = [{ [cw]: h, [cx]: [aT, K] }]; -var cf = [{ [cw]: i, [cx]: [aS, "resourceId[1]"], [cz]: L }, { [cw]: r, [cx]: [{ [cw]: h, [cx]: [aV, I] }] }]; -var cg = [aS, "resourceId[1]"]; -var ch = [Y]; -var ci = [{ [cw]: r, [cx]: [{ [cw]: h, [cx]: [{ [cw]: i, [cx]: [aS, "region"] }, I] }] }]; -var cj = [{ [cw]: r, [cx]: [{ [cw]: d, [cx]: [{ [cw]: i, [cx]: [aS, "resourceId[2]"] }] }] }]; -var ck = [aS, "resourceId[2]"]; -var cl = [{ [cw]: g, [cx]: [{ [cw]: i, [cx]: [aS, "region"] }], [cz]: "bucketPartition" }]; -var cm = [{ [cw]: h, [cx]: [ba, { [cw]: i, [cx]: [{ [cy]: "partitionResult" }, j] }] }]; -var cn = [{ [cw]: y, [cx]: [{ [cw]: i, [cx]: [aS, "region"] }, true] }]; -var co = [{ [cw]: y, [cx]: [bb, false] }]; -var cp = [{ [cw]: y, [cx]: [aV, false] }]; -var cq = [X]; -var cr = [{ [cw]: y, [cx]: [{ [cy]: "Region" }, true] }]; -var _data = { version: "1.0", parameters: { Bucket: T, Region: T, UseFIPS: U, UseDualStack: U, Endpoint: T, ForcePathStyle: U, Accelerate: U, UseGlobalEndpoint: U, UseObjectLambdaEndpoint: V, Key: T, Prefix: T, CopySource: T, DisableAccessPoints: V, DisableMultiRegionAccessPoints: U, UseArnRegion: V, UseS3ExpressControlEndpoint: V, DisableS3ExpressSessionAuth: V }, [cu]: [{ [cv]: [{ [cw]: d, [cx]: by }], [cu]: [{ [cv]: [W, X], error: "Accelerate cannot be used with FIPS", [ct]: f }, { [cv]: [Y, Z], error: "Cannot set dual-stack in combination with a custom endpoint.", [ct]: f }, { [cv]: [Z, X], error: "A custom endpoint cannot be combined with FIPS", [ct]: f }, { [cv]: [Z, W], error: "A custom endpoint cannot be combined with S3 Accelerate", [ct]: f }, { [cv]: [X, aa, ab], error: "Partition does not support FIPS", [ct]: f }, { [cv]: [ac, { [cw]: k, [cx]: [ad, 0, a, c], [cz]: l }, { [cw]: h, [cx]: [{ [cy]: l }, "--x-s3"] }], [cu]: [ae, af, { [cv]: [ao, ap], [cu]: [{ [cv]: bG, [cu]: [{ [cv]: [aj, aq], [cu]: [{ [cv]: bH, endpoint: { [cA]: "https://s3express-control-fips.dualstack.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bI, endpoint: { [cA]: "https://s3express-control-fips.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bJ, endpoint: { [cA]: "https://s3express-control.dualstack.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bK, endpoint: { [cA]: "https://s3express-control.{Region}.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: ak, [cH]: al }, [ct]: n }], [ct]: o }], [ct]: o }], [ct]: o }, { [cv]: bF, [cu]: [{ [cv]: bG, [cu]: [{ [cv]: bD, [cu]: [{ [cv]: bL, [cu]: bM, [ct]: o }, { [cv]: bN, [cu]: bM, [ct]: o }, { [cv]: bO, [cu]: bM, [ct]: o }, { [cv]: bP, [cu]: bM, [ct]: o }, { [cv]: bQ, [cu]: bM, [ct]: o }, at], [ct]: o }, { [cv]: bL, [cu]: bR, [ct]: o }, { [cv]: bN, [cu]: bR, [ct]: o }, { [cv]: bO, [cu]: bR, [ct]: o }, { [cv]: bP, [cu]: bR, [ct]: o }, { [cv]: bQ, [cu]: bR, [ct]: o }, at], [ct]: o }], [ct]: o }, an], [ct]: o }, { [cv]: [ac, { [cw]: k, [cx]: bS, [cz]: s }, { [cw]: h, [cx]: [{ [cy]: s }, "--xa-s3"] }], [cu]: [ae, af, { [cv]: bF, [cu]: [{ [cv]: bG, [cu]: [{ [cv]: bD, [cu]: [{ [cv]: bT, [cu]: bM, [ct]: o }, { [cv]: bU, [cu]: bM, [ct]: o }, { [cv]: bV, [cu]: bM, [ct]: o }, { [cv]: bW, [cu]: bM, [ct]: o }, { [cv]: bX, [cu]: bM, [ct]: o }, at], [ct]: o }, { [cv]: bT, [cu]: bR, [ct]: o }, { [cv]: bU, [cu]: bR, [ct]: o }, { [cv]: bV, [cu]: bR, [ct]: o }, { [cv]: bW, [cu]: bR, [ct]: o }, { [cv]: bX, [cu]: bR, [ct]: o }, at], [ct]: o }], [ct]: o }, an], [ct]: o }, { [cv]: [au, ao, ap], [cu]: [{ [cv]: bG, [cu]: [{ [cv]: bC, endpoint: { [cA]: t, [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bH, endpoint: { [cA]: "https://s3express-control-fips.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bI, endpoint: { [cA]: "https://s3express-control-fips.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bJ, endpoint: { [cA]: "https://s3express-control.dualstack.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: al }, [ct]: n }, { [cv]: bK, endpoint: { [cA]: "https://s3express-control.{Region}.{partitionResult#dnsSuffix}", [cB]: ak, [cH]: al }, [ct]: n }], [ct]: o }], [ct]: o }, { [cv]: [ac, { [cw]: k, [cx]: [ad, 49, 50, c], [cz]: u }, { [cw]: k, [cx]: [ad, 8, 12, c], [cz]: v }, { [cw]: k, [cx]: bS, [cz]: w }, { [cw]: k, [cx]: [ad, 32, 49, c], [cz]: x }, { [cw]: g, [cx]: by, [cz]: "regionPartition" }, { [cw]: h, [cx]: [{ [cy]: w }, "--op-s3"] }], [cu]: [{ [cv]: bZ, [cu]: [{ [cv]: bF, [cu]: [{ [cv]: [{ [cw]: h, [cx]: [av, "e"] }], [cu]: [{ [cv]: ca, [cu]: [aw, { [cv]: bC, endpoint: { [cA]: "https://{Bucket}.ec2.{url#authority}", [cB]: ax, [cH]: al }, [ct]: n }], [ct]: o }, { endpoint: { [cA]: "https://{Bucket}.ec2.s3-outposts.{Region}.{regionPartition#dnsSuffix}", [cB]: ax, [cH]: al }, [ct]: n }], [ct]: o }, { [cv]: [{ [cw]: h, [cx]: [av, "o"] }], [cu]: [{ [cv]: ca, [cu]: [aw, { [cv]: bC, endpoint: { [cA]: "https://{Bucket}.op-{outpostId}.{url#authority}", [cB]: ax, [cH]: al }, [ct]: n }], [ct]: o }, { endpoint: { [cA]: "https://{Bucket}.op-{outpostId}.s3-outposts.{Region}.{regionPartition#dnsSuffix}", [cB]: ax, [cH]: al }, [ct]: n }], [ct]: o }, { error: 'Unrecognized hardware type: "Expected hardware type o or e but got {hardwareType}"', [ct]: f }], [ct]: o }, { error: "Invalid Outposts Bucket alias - it must be a valid bucket name.", [ct]: f }], [ct]: o }, { error: "Invalid ARN: The outpost Id must only contain a-z, A-Z, 0-9 and `-`.", [ct]: f }], [ct]: o }, { [cv]: bY, [cu]: [{ [cv]: [Z, { [cw]: r, [cx]: [{ [cw]: d, [cx]: [{ [cw]: m, [cx]: bz }] }] }], error: "Custom endpoint `{Endpoint}` was not a valid URI", [ct]: f }, { [cv]: [ay, am], [cu]: [{ [cv]: bG, [cu]: [{ [cv]: cc, [cu]: [{ [cv]: [W, ab], error: "S3 Accelerate cannot be used in this region", [ct]: f }, { [cv]: [Y, X, aA, aq, aB], endpoint: { [cA]: "https://{Bucket}.s3-fips.dualstack.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [Y, X, aA, aq, aD, aE], [cu]: [{ endpoint: aF, [ct]: n }], [ct]: o }, { [cv]: [Y, X, aA, aq, aD, aH], endpoint: aF, [ct]: n }, { [cv]: [ar, X, aA, aq, aB], endpoint: { [cA]: "https://{Bucket}.s3-fips.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, X, aA, aq, aD, aE], [cu]: [{ endpoint: aI, [ct]: n }], [ct]: o }, { [cv]: [ar, X, aA, aq, aD, aH], endpoint: aI, [ct]: n }, { [cv]: [Y, as, W, aq, aB], endpoint: { [cA]: "https://{Bucket}.s3-accelerate.dualstack.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [Y, as, W, aq, aD, aE], [cu]: [{ endpoint: aJ, [ct]: n }], [ct]: o }, { [cv]: [Y, as, W, aq, aD, aH], endpoint: aJ, [ct]: n }, { [cv]: [Y, as, aA, aq, aB], endpoint: { [cA]: "https://{Bucket}.s3.dualstack.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [Y, as, aA, aq, aD, aE], [cu]: [{ endpoint: aK, [ct]: n }], [ct]: o }, { [cv]: [Y, as, aA, aq, aD, aH], endpoint: aK, [ct]: n }, { [cv]: [ar, as, aA, Z, ag, ah, aB], endpoint: { [cA]: C, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, as, aA, Z, ag, aL, aB], endpoint: { [cA]: q, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, as, aA, Z, ag, ah, aD, aE], [cu]: [{ [cv]: cd, endpoint: aM, [ct]: n }, { endpoint: aM, [ct]: n }], [ct]: o }, { [cv]: [ar, as, aA, Z, ag, aL, aD, aE], [cu]: [{ [cv]: cd, endpoint: aN, [ct]: n }, aO], [ct]: o }, { [cv]: [ar, as, aA, Z, ag, ah, aD, aH], endpoint: aM, [ct]: n }, { [cv]: [ar, as, aA, Z, ag, aL, aD, aH], endpoint: aN, [ct]: n }, { [cv]: [ar, as, W, aq, aB], endpoint: { [cA]: D, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, as, W, aq, aD, aE], [cu]: [{ [cv]: cd, endpoint: aP, [ct]: n }, { endpoint: aP, [ct]: n }], [ct]: o }, { [cv]: [ar, as, W, aq, aD, aH], endpoint: aP, [ct]: n }, { [cv]: [ar, as, aA, aq, aB], endpoint: { [cA]: E, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, as, aA, aq, aD, aE], [cu]: [{ [cv]: cd, endpoint: { [cA]: E, [cB]: aG, [cH]: al }, [ct]: n }, { endpoint: aQ, [ct]: n }], [ct]: o }, { [cv]: [ar, as, aA, aq, aD, aH], endpoint: aQ, [ct]: n }], [ct]: o }, aR], [ct]: o }], [ct]: o }, { [cv]: [Z, ag, { [cw]: h, [cx]: [{ [cw]: i, [cx]: [ai, "scheme"] }, "http"] }, { [cw]: p, [cx]: [ad, c] }, ay, as, ar, aA], [cu]: [{ [cv]: bG, [cu]: [{ [cv]: cc, [cu]: [aO], [ct]: o }, aR], [ct]: o }], [ct]: o }, { [cv]: [ay, { [cw]: F, [cx]: bA, [cz]: G }], [cu]: [{ [cv]: [{ [cw]: i, [cx]: [aS, "resourceId[0]"], [cz]: H }, { [cw]: r, [cx]: [{ [cw]: h, [cx]: [aT, I] }] }], [cu]: [{ [cv]: [{ [cw]: h, [cx]: [aU, J] }], [cu]: [{ [cv]: ce, [cu]: [{ [cv]: cf, [cu]: [aW, aX, { [cv]: ci, [cu]: [aY, { [cv]: cj, [cu]: [aZ, { [cv]: cl, [cu]: [{ [cv]: bG, [cu]: [{ [cv]: cm, [cu]: [{ [cv]: cn, [cu]: [{ [cv]: [{ [cw]: h, [cx]: [bb, I] }], error: "Invalid ARN: Missing account id", [ct]: f }, { [cv]: co, [cu]: [{ [cv]: cp, [cu]: [{ [cv]: bC, endpoint: { [cA]: M, [cB]: bc, [cH]: al }, [ct]: n }, { [cv]: cq, endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.s3-object-lambda-fips.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bc, [cH]: al }, [ct]: n }, { endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.s3-object-lambda.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bc, [cH]: al }, [ct]: n }], [ct]: o }, bd], [ct]: o }, be], [ct]: o }, bf], [ct]: o }, bg], [ct]: o }], [ct]: o }], [ct]: o }, bh], [ct]: o }, { error: "Invalid ARN: bucket ARN is missing a region", [ct]: f }], [ct]: o }, bi], [ct]: o }, { error: "Invalid ARN: Object Lambda ARNs only support `accesspoint` arn types, but found: `{arnType}`", [ct]: f }], [ct]: o }, { [cv]: ce, [cu]: [{ [cv]: cf, [cu]: [{ [cv]: ci, [cu]: [{ [cv]: ce, [cu]: [{ [cv]: ci, [cu]: [aY, { [cv]: cj, [cu]: [aZ, { [cv]: cl, [cu]: [{ [cv]: bG, [cu]: [{ [cv]: [{ [cw]: h, [cx]: [ba, "{partitionResult#name}"] }], [cu]: [{ [cv]: cn, [cu]: [{ [cv]: [{ [cw]: h, [cx]: [aU, B] }], [cu]: [{ [cv]: co, [cu]: [{ [cv]: cp, [cu]: [{ [cv]: bB, error: "Access Points do not support S3 Accelerate", [ct]: f }, { [cv]: bH, endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.s3-accesspoint-fips.dualstack.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bj, [cH]: al }, [ct]: n }, { [cv]: bI, endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.s3-accesspoint-fips.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bj, [cH]: al }, [ct]: n }, { [cv]: bJ, endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.s3-accesspoint.dualstack.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bj, [cH]: al }, [ct]: n }, { [cv]: [as, ar, Z, ag], endpoint: { [cA]: M, [cB]: bj, [cH]: al }, [ct]: n }, { [cv]: bK, endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.s3-accesspoint.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bj, [cH]: al }, [ct]: n }], [ct]: o }, bd], [ct]: o }, be], [ct]: o }, { error: "Invalid ARN: The ARN was not for the S3 service, found: {bucketArn#service}", [ct]: f }], [ct]: o }, bf], [ct]: o }, bg], [ct]: o }], [ct]: o }], [ct]: o }, bh], [ct]: o }], [ct]: o }], [ct]: o }, { [cv]: [{ [cw]: y, [cx]: [aV, c] }], [cu]: [{ [cv]: ch, error: "S3 MRAP does not support dual-stack", [ct]: f }, { [cv]: cq, error: "S3 MRAP does not support FIPS", [ct]: f }, { [cv]: bB, error: "S3 MRAP does not support S3 Accelerate", [ct]: f }, { [cv]: [{ [cw]: e, [cx]: [{ [cy]: "DisableMultiRegionAccessPoints" }, c] }], error: "Invalid configuration: Multi-Region Access Point ARNs are disabled.", [ct]: f }, { [cv]: [{ [cw]: g, [cx]: by, [cz]: N }], [cu]: [{ [cv]: [{ [cw]: h, [cx]: [{ [cw]: i, [cx]: [{ [cy]: N }, j] }, { [cw]: i, [cx]: [aS, "partition"] }] }], [cu]: [{ endpoint: { [cA]: "https://{accessPointName}.accesspoint.s3-global.{mrapPartition#dnsSuffix}", [cB]: { [cD]: [{ [cE]: c, name: z, [cF]: B, [cI]: cb }] }, [cH]: al }, [ct]: n }], [ct]: o }, { error: "Client was configured for partition `{mrapPartition#name}` but bucket referred to partition `{bucketArn#partition}`", [ct]: f }], [ct]: o }], [ct]: o }, { error: "Invalid Access Point Name", [ct]: f }], [ct]: o }, bi], [ct]: o }, { [cv]: [{ [cw]: h, [cx]: [aU, A] }], [cu]: [{ [cv]: ch, error: "S3 Outposts does not support Dual-stack", [ct]: f }, { [cv]: cq, error: "S3 Outposts does not support FIPS", [ct]: f }, { [cv]: bB, error: "S3 Outposts does not support S3 Accelerate", [ct]: f }, { [cv]: [{ [cw]: d, [cx]: [{ [cw]: i, [cx]: [aS, "resourceId[4]"] }] }], error: "Invalid Arn: Outpost Access Point ARN contains sub resources", [ct]: f }, { [cv]: [{ [cw]: i, [cx]: cg, [cz]: x }], [cu]: [{ [cv]: bZ, [cu]: [aZ, { [cv]: cl, [cu]: [{ [cv]: bG, [cu]: [{ [cv]: cm, [cu]: [{ [cv]: cn, [cu]: [{ [cv]: co, [cu]: [{ [cv]: [{ [cw]: i, [cx]: ck, [cz]: O }], [cu]: [{ [cv]: [{ [cw]: i, [cx]: [aS, "resourceId[3]"], [cz]: L }], [cu]: [{ [cv]: [{ [cw]: h, [cx]: [{ [cy]: O }, K] }], [cu]: [{ [cv]: bC, endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.{outpostId}.{url#authority}", [cB]: bk, [cH]: al }, [ct]: n }, { endpoint: { [cA]: "https://{accessPointName}-{bucketArn#accountId}.{outpostId}.s3-outposts.{bucketArn#region}.{bucketPartition#dnsSuffix}", [cB]: bk, [cH]: al }, [ct]: n }], [ct]: o }, { error: "Expected an outpost type `accesspoint`, found {outpostType}", [ct]: f }], [ct]: o }, { error: "Invalid ARN: expected an access point name", [ct]: f }], [ct]: o }, { error: "Invalid ARN: Expected a 4-component resource", [ct]: f }], [ct]: o }, be], [ct]: o }, bf], [ct]: o }, bg], [ct]: o }], [ct]: o }], [ct]: o }, { error: "Invalid ARN: The outpost Id may only contain a-z, A-Z, 0-9 and `-`. Found: `{outpostId}`", [ct]: f }], [ct]: o }, { error: "Invalid ARN: The Outpost Id was not set", [ct]: f }], [ct]: o }, { error: "Invalid ARN: Unrecognized format: {Bucket} (type: {arnType})", [ct]: f }], [ct]: o }, { error: "Invalid ARN: No ARN type specified", [ct]: f }], [ct]: o }, { [cv]: [{ [cw]: k, [cx]: [ad, 0, 4, b], [cz]: P }, { [cw]: h, [cx]: [{ [cy]: P }, "arn:"] }, { [cw]: r, [cx]: [{ [cw]: d, [cx]: [bl] }] }], error: "Invalid ARN: `{Bucket}` was not a valid ARN", [ct]: f }, { [cv]: [{ [cw]: e, [cx]: [az, c] }, bl], error: "Path-style addressing cannot be used with ARN buckets", [ct]: f }, { [cv]: bE, [cu]: [{ [cv]: bG, [cu]: [{ [cv]: [aA], [cu]: [{ [cv]: [Y, aq, X, aB], endpoint: { [cA]: "https://s3-fips.dualstack.us-east-1.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [Y, aq, X, aD, aE], [cu]: [{ endpoint: bm, [ct]: n }], [ct]: o }, { [cv]: [Y, aq, X, aD, aH], endpoint: bm, [ct]: n }, { [cv]: [ar, aq, X, aB], endpoint: { [cA]: "https://s3-fips.us-east-1.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, aq, X, aD, aE], [cu]: [{ endpoint: bn, [ct]: n }], [ct]: o }, { [cv]: [ar, aq, X, aD, aH], endpoint: bn, [ct]: n }, { [cv]: [Y, aq, as, aB], endpoint: { [cA]: "https://s3.dualstack.us-east-1.{partitionResult#dnsSuffix}/{uri_encoded_bucket}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [Y, aq, as, aD, aE], [cu]: [{ endpoint: bo, [ct]: n }], [ct]: o }, { [cv]: [Y, aq, as, aD, aH], endpoint: bo, [ct]: n }, { [cv]: [ar, Z, ag, as, aB], endpoint: { [cA]: Q, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, Z, ag, as, aD, aE], [cu]: [{ [cv]: cd, endpoint: bp, [ct]: n }, { endpoint: bp, [ct]: n }], [ct]: o }, { [cv]: [ar, Z, ag, as, aD, aH], endpoint: bp, [ct]: n }, { [cv]: [ar, aq, as, aB], endpoint: { [cA]: R, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [ar, aq, as, aD, aE], [cu]: [{ [cv]: cd, endpoint: { [cA]: R, [cB]: aG, [cH]: al }, [ct]: n }, { endpoint: bq, [ct]: n }], [ct]: o }, { [cv]: [ar, aq, as, aD, aH], endpoint: bq, [ct]: n }], [ct]: o }, { error: "Path-style addressing cannot be used with S3 Accelerate", [ct]: f }], [ct]: o }], [ct]: o }], [ct]: o }, { [cv]: [{ [cw]: d, [cx]: [br] }, { [cw]: e, [cx]: [br, c] }], [cu]: [{ [cv]: bG, [cu]: [{ [cv]: cr, [cu]: [aW, aX, { [cv]: bC, endpoint: { [cA]: t, [cB]: bs, [cH]: al }, [ct]: n }, { [cv]: cq, endpoint: { [cA]: "https://s3-object-lambda-fips.{Region}.{partitionResult#dnsSuffix}", [cB]: bs, [cH]: al }, [ct]: n }, { endpoint: { [cA]: "https://s3-object-lambda.{Region}.{partitionResult#dnsSuffix}", [cB]: bs, [cH]: al }, [ct]: n }], [ct]: o }, aR], [ct]: o }], [ct]: o }, { [cv]: [au], [cu]: [{ [cv]: bG, [cu]: [{ [cv]: cr, [cu]: [{ [cv]: [X, Y, aq, aB], endpoint: { [cA]: "https://s3-fips.dualstack.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [X, Y, aq, aD, aE], [cu]: [{ endpoint: bt, [ct]: n }], [ct]: o }, { [cv]: [X, Y, aq, aD, aH], endpoint: bt, [ct]: n }, { [cv]: [X, ar, aq, aB], endpoint: { [cA]: "https://s3-fips.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [X, ar, aq, aD, aE], [cu]: [{ endpoint: bu, [ct]: n }], [ct]: o }, { [cv]: [X, ar, aq, aD, aH], endpoint: bu, [ct]: n }, { [cv]: [as, Y, aq, aB], endpoint: { [cA]: "https://s3.dualstack.us-east-1.{partitionResult#dnsSuffix}", [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [as, Y, aq, aD, aE], [cu]: [{ endpoint: bv, [ct]: n }], [ct]: o }, { [cv]: [as, Y, aq, aD, aH], endpoint: bv, [ct]: n }, { [cv]: [as, ar, Z, ag, aB], endpoint: { [cA]: t, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [as, ar, Z, ag, aD, aE], [cu]: [{ [cv]: cd, endpoint: bw, [ct]: n }, { endpoint: bw, [ct]: n }], [ct]: o }, { [cv]: [as, ar, Z, ag, aD, aH], endpoint: bw, [ct]: n }, { [cv]: [as, ar, aq, aB], endpoint: { [cA]: S, [cB]: aC, [cH]: al }, [ct]: n }, { [cv]: [as, ar, aq, aD, aE], [cu]: [{ [cv]: cd, endpoint: { [cA]: S, [cB]: aG, [cH]: al }, [ct]: n }, { endpoint: bx, [ct]: n }], [ct]: o }, { [cv]: [as, ar, aq, aD, aH], endpoint: bx, [ct]: n }], [ct]: o }, aR], [ct]: o }], [ct]: o }], [ct]: o }, { error: "A region must be set when sending requests to S3.", [ct]: f }] }; -var ruleSet = _data; - -// ../node_modules/@aws-sdk/client-s3/dist-es/endpoint/endpointResolver.js -var cache = new EndpointCache({ - size: 50, - params: [ - "Accelerate", - "Bucket", - "DisableAccessPoints", - "DisableMultiRegionAccessPoints", - "DisableS3ExpressSessionAuth", - "Endpoint", - "ForcePathStyle", - "Region", - "UseArnRegion", - "UseDualStack", - "UseFIPS", - "UseGlobalEndpoint", - "UseObjectLambdaEndpoint", - "UseS3ExpressControlEndpoint" - ] +// ../node_modules/token-types/lib/index.js +var require_lib = __commonJS({ + "../node_modules/token-types/lib/index.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.AnsiStringType = exports2.StringType = exports2.BufferType = exports2.Uint8ArrayType = exports2.IgnoreType = exports2.Float80_LE = exports2.Float80_BE = exports2.Float64_LE = exports2.Float64_BE = exports2.Float32_LE = exports2.Float32_BE = exports2.Float16_LE = exports2.Float16_BE = exports2.INT64_BE = exports2.UINT64_BE = exports2.INT64_LE = exports2.UINT64_LE = exports2.INT32_LE = exports2.INT32_BE = exports2.INT24_BE = exports2.INT24_LE = exports2.INT16_LE = exports2.INT16_BE = exports2.INT8 = exports2.UINT32_BE = exports2.UINT32_LE = exports2.UINT24_BE = exports2.UINT24_LE = exports2.UINT16_BE = exports2.UINT16_LE = exports2.UINT8 = void 0; + var ieee754 = require_ieee754(); + function dv(array) { + return new DataView(array.buffer, array.byteOffset); + } + exports2.UINT8 = { + len: 1, + get(array, offset) { + return dv(array).getUint8(offset); + }, + put(array, offset, value) { + dv(array).setUint8(offset, value); + return offset + 1; + } + }; + exports2.UINT16_LE = { + len: 2, + get(array, offset) { + return dv(array).getUint16(offset, true); + }, + put(array, offset, value) { + dv(array).setUint16(offset, value, true); + return offset + 2; + } + }; + exports2.UINT16_BE = { + len: 2, + get(array, offset) { + return dv(array).getUint16(offset); + }, + put(array, offset, value) { + dv(array).setUint16(offset, value); + return offset + 2; + } + }; + exports2.UINT24_LE = { + len: 3, + get(array, offset) { + const dataView = dv(array); + return dataView.getUint8(offset) + (dataView.getUint16(offset + 1, true) << 8); + }, + put(array, offset, value) { + const dataView = dv(array); + dataView.setUint8(offset, value & 255); + dataView.setUint16(offset + 1, value >> 8, true); + return offset + 3; + } + }; + exports2.UINT24_BE = { + len: 3, + get(array, offset) { + const dataView = dv(array); + return (dataView.getUint16(offset) << 8) + dataView.getUint8(offset + 2); + }, + put(array, offset, value) { + const dataView = dv(array); + dataView.setUint16(offset, value >> 8); + dataView.setUint8(offset + 2, value & 255); + return offset + 3; + } + }; + exports2.UINT32_LE = { + len: 4, + get(array, offset) { + return dv(array).getUint32(offset, true); + }, + put(array, offset, value) { + dv(array).setUint32(offset, value, true); + return offset + 4; + } + }; + exports2.UINT32_BE = { + len: 4, + get(array, offset) { + return dv(array).getUint32(offset); + }, + put(array, offset, value) { + dv(array).setUint32(offset, value); + return offset + 4; + } + }; + exports2.INT8 = { + len: 1, + get(array, offset) { + return dv(array).getInt8(offset); + }, + put(array, offset, value) { + dv(array).setInt8(offset, value); + return offset + 1; + } + }; + exports2.INT16_BE = { + len: 2, + get(array, offset) { + return dv(array).getInt16(offset); + }, + put(array, offset, value) { + dv(array).setInt16(offset, value); + return offset + 2; + } + }; + exports2.INT16_LE = { + len: 2, + get(array, offset) { + return dv(array).getInt16(offset, true); + }, + put(array, offset, value) { + dv(array).setInt16(offset, value, true); + return offset + 2; + } + }; + exports2.INT24_LE = { + len: 3, + get(array, offset) { + const unsigned = exports2.UINT24_LE.get(array, offset); + return unsigned > 8388607 ? unsigned - 16777216 : unsigned; + }, + put(array, offset, value) { + const dataView = dv(array); + dataView.setUint8(offset, value & 255); + dataView.setUint16(offset + 1, value >> 8, true); + return offset + 3; + } + }; + exports2.INT24_BE = { + len: 3, + get(array, offset) { + const unsigned = exports2.UINT24_BE.get(array, offset); + return unsigned > 8388607 ? unsigned - 16777216 : unsigned; + }, + put(array, offset, value) { + const dataView = dv(array); + dataView.setUint16(offset, value >> 8); + dataView.setUint8(offset + 2, value & 255); + return offset + 3; + } + }; + exports2.INT32_BE = { + len: 4, + get(array, offset) { + return dv(array).getInt32(offset); + }, + put(array, offset, value) { + dv(array).setInt32(offset, value); + return offset + 4; + } + }; + exports2.INT32_LE = { + len: 4, + get(array, offset) { + return dv(array).getInt32(offset, true); + }, + put(array, offset, value) { + dv(array).setInt32(offset, value, true); + return offset + 4; + } + }; + exports2.UINT64_LE = { + len: 8, + get(array, offset) { + return dv(array).getBigUint64(offset, true); + }, + put(array, offset, value) { + dv(array).setBigUint64(offset, value, true); + return offset + 8; + } + }; + exports2.INT64_LE = { + len: 8, + get(array, offset) { + return dv(array).getBigInt64(offset, true); + }, + put(array, offset, value) { + dv(array).setBigInt64(offset, value, true); + return offset + 8; + } + }; + exports2.UINT64_BE = { + len: 8, + get(array, offset) { + return dv(array).getBigUint64(offset); + }, + put(array, offset, value) { + dv(array).setBigUint64(offset, value); + return offset + 8; + } + }; + exports2.INT64_BE = { + len: 8, + get(array, offset) { + return dv(array).getBigInt64(offset); + }, + put(array, offset, value) { + dv(array).setBigInt64(offset, value); + return offset + 8; + } + }; + exports2.Float16_BE = { + len: 2, + get(dataView, offset) { + return ieee754.read(dataView, offset, false, 10, this.len); + }, + put(dataView, offset, value) { + ieee754.write(dataView, value, offset, false, 10, this.len); + return offset + this.len; + } + }; + exports2.Float16_LE = { + len: 2, + get(array, offset) { + return ieee754.read(array, offset, true, 10, this.len); + }, + put(array, offset, value) { + ieee754.write(array, value, offset, true, 10, this.len); + return offset + this.len; + } + }; + exports2.Float32_BE = { + len: 4, + get(array, offset) { + return dv(array).getFloat32(offset); + }, + put(array, offset, value) { + dv(array).setFloat32(offset, value); + return offset + 4; + } + }; + exports2.Float32_LE = { + len: 4, + get(array, offset) { + return dv(array).getFloat32(offset, true); + }, + put(array, offset, value) { + dv(array).setFloat32(offset, value, true); + return offset + 4; + } + }; + exports2.Float64_BE = { + len: 8, + get(array, offset) { + return dv(array).getFloat64(offset); + }, + put(array, offset, value) { + dv(array).setFloat64(offset, value); + return offset + 8; + } + }; + exports2.Float64_LE = { + len: 8, + get(array, offset) { + return dv(array).getFloat64(offset, true); + }, + put(array, offset, value) { + dv(array).setFloat64(offset, value, true); + return offset + 8; + } + }; + exports2.Float80_BE = { + len: 10, + get(array, offset) { + return ieee754.read(array, offset, false, 63, this.len); + }, + put(array, offset, value) { + ieee754.write(array, value, offset, false, 63, this.len); + return offset + this.len; + } + }; + exports2.Float80_LE = { + len: 10, + get(array, offset) { + return ieee754.read(array, offset, true, 63, this.len); + }, + put(array, offset, value) { + ieee754.write(array, value, offset, true, 63, this.len); + return offset + this.len; + } + }; + var IgnoreType = class { + /** + * @param len number of bytes to ignore + */ + constructor(len) { + this.len = len; + } + // ToDo: don't read, but skip data + get(array, off) { + } + }; + exports2.IgnoreType = IgnoreType; + var Uint8ArrayType = class { + constructor(len) { + this.len = len; + } + get(array, offset) { + return array.subarray(offset, offset + this.len); + } + }; + exports2.Uint8ArrayType = Uint8ArrayType; + var BufferType = class { + constructor(len) { + this.len = len; + } + get(uint8Array, off) { + return Buffer.from(uint8Array.subarray(off, off + this.len)); + } + }; + exports2.BufferType = BufferType; + var StringType = class { + constructor(len, encoding) { + this.len = len; + this.encoding = encoding; + } + get(uint8Array, offset) { + return Buffer.from(uint8Array).toString(this.encoding, offset, offset + this.len); + } + }; + exports2.StringType = StringType; + var AnsiStringType = class _AnsiStringType { + constructor(len) { + this.len = len; + } + static decode(buffer, offset, until) { + let str = ""; + for (let i6 = offset; i6 < until; ++i6) { + str += _AnsiStringType.codePointToString(_AnsiStringType.singleByteDecoder(buffer[i6])); + } + return str; + } + static inRange(a6, min, max) { + return min <= a6 && a6 <= max; + } + static codePointToString(cp2) { + if (cp2 <= 65535) { + return String.fromCharCode(cp2); + } else { + cp2 -= 65536; + return String.fromCharCode((cp2 >> 10) + 55296, (cp2 & 1023) + 56320); + } + } + static singleByteDecoder(bite) { + if (_AnsiStringType.inRange(bite, 0, 127)) { + return bite; + } + const codePoint = _AnsiStringType.windows1252[bite - 128]; + if (codePoint === null) { + throw Error("invaliding encoding"); + } + return codePoint; + } + get(buffer, offset = 0) { + return _AnsiStringType.decode(buffer, offset, offset + this.len); + } + }; + exports2.AnsiStringType = AnsiStringType; + AnsiStringType.windows1252 = [ + 8364, + 129, + 8218, + 402, + 8222, + 8230, + 8224, + 8225, + 710, + 8240, + 352, + 8249, + 338, + 141, + 381, + 143, + 144, + 8216, + 8217, + 8220, + 8221, + 8226, + 8211, + 8212, + 732, + 8482, + 353, + 8250, + 339, + 157, + 382, + 376, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 174, + 175, + 176, + 177, + 178, + 179, + 180, + 181, + 182, + 183, + 184, + 185, + 186, + 187, + 188, + 189, + 190, + 191, + 192, + 193, + 194, + 195, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 210, + 211, + 212, + 213, + 214, + 215, + 216, + 217, + 218, + 219, + 220, + 221, + 222, + 223, + 224, + 225, + 226, + 227, + 228, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 249, + 250, + 251, + 252, + 253, + 254, + 255 + ]; + } }); -var defaultEndpointResolver = (endpointParams, context3 = {}) => { - return cache.get(endpointParams, () => resolveEndpoint(ruleSet, { - endpointParams, - logger: context3.logger - })); -}; -customEndpointFunctions.aws = awsEndpointFunctions; -// ../node_modules/@aws-sdk/client-s3/dist-es/auth/httpAuthSchemeProvider.js -var createEndpointRuleSetHttpAuthSchemeParametersProvider = (defaultHttpAuthSchemeParametersProvider) => async (config, context3, input) => { - if (!input) { - throw new Error("Could not find `input` for `defaultEndpointRuleSetHttpAuthSchemeParametersProvider`"); +// ../node_modules/peek-readable/lib/EndOfFileStream.js +var require_EndOfFileStream = __commonJS({ + "../node_modules/peek-readable/lib/EndOfFileStream.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.EndOfStreamError = exports2.defaultMessages = void 0; + exports2.defaultMessages = "End-Of-Stream"; + var EndOfStreamError = class extends Error { + constructor() { + super(exports2.defaultMessages); + } + }; + exports2.EndOfStreamError = EndOfStreamError; } - const defaultParameters = await defaultHttpAuthSchemeParametersProvider(config, context3, input); - const instructionsFn = getSmithyContext(context3)?.commandInstance?.constructor?.getEndpointParameterInstructions; - if (!instructionsFn) { - throw new Error(`getEndpointParameterInstructions() is not defined on '${context3.commandName}'`); +}); + +// ../node_modules/peek-readable/lib/Deferred.js +var require_Deferred = __commonJS({ + "../node_modules/peek-readable/lib/Deferred.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.Deferred = void 0; + var Deferred = class { + constructor() { + this.resolve = () => null; + this.reject = () => null; + this.promise = new Promise((resolve3, reject2) => { + this.reject = reject2; + this.resolve = resolve3; + }); + } + }; + exports2.Deferred = Deferred; } - const endpointParameters = await resolveParams(input, { getEndpointParameterInstructions: instructionsFn }, config); - return Object.assign(defaultParameters, endpointParameters); -}; -var _defaultS3HttpAuthSchemeParametersProvider = async (config, context3, input) => { - return { - operation: getSmithyContext(context3).operation, - region: await normalizeProvider(config.region)() || (() => { - throw new Error("expected `region` to be configured for `aws.auth#sigv4`"); - })() - }; -}; -var defaultS3HttpAuthSchemeParametersProvider = createEndpointRuleSetHttpAuthSchemeParametersProvider(_defaultS3HttpAuthSchemeParametersProvider); -function createAwsAuthSigv4HttpAuthOption(authParameters) { - return { - schemeId: "aws.auth#sigv4", - signingProperties: { - name: "s3", - region: authParameters.region - }, - propertiesExtractor: (config, context3) => ({ - signingProperties: { - config, - context: context3 +}); + +// ../node_modules/peek-readable/lib/StreamReader.js +var require_StreamReader = __commonJS({ + "../node_modules/peek-readable/lib/StreamReader.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.StreamReader = exports2.EndOfStreamError = void 0; + var EndOfFileStream_1 = require_EndOfFileStream(); + var Deferred_1 = require_Deferred(); + var EndOfFileStream_2 = require_EndOfFileStream(); + Object.defineProperty(exports2, "EndOfStreamError", { enumerable: true, get: function() { + return EndOfFileStream_2.EndOfStreamError; + } }); + var maxStreamReadSize = 1 * 1024 * 1024; + var StreamReader = class { + constructor(s6) { + this.s = s6; + this.deferred = null; + this.endOfStream = false; + this.peekQueue = []; + if (!s6.read || !s6.once) { + throw new Error("Expected an instance of stream.Readable"); + } + this.s.once("end", () => this.reject(new EndOfFileStream_1.EndOfStreamError())); + this.s.once("error", (err) => this.reject(err)); + this.s.once("close", () => this.reject(new Error("Stream closed"))); } - }) - }; -} -function createAwsAuthSigv4aHttpAuthOption(authParameters) { - return { - schemeId: "aws.auth#sigv4a", - signingProperties: { - name: "s3", - region: authParameters.region - }, - propertiesExtractor: (config, context3) => ({ - signingProperties: { - config, - context: context3 + /** + * Read ahead (peek) from stream. Subsequent read or peeks will return the same data + * @param uint8Array - Uint8Array (or Buffer) to store data read from stream in + * @param offset - Offset target + * @param length - Number of bytes to read + * @returns Number of bytes peeked + */ + async peek(uint8Array, offset, length) { + const bytesRead = await this.read(uint8Array, offset, length); + this.peekQueue.push(uint8Array.subarray(offset, offset + bytesRead)); + return bytesRead; } - }) - }; -} -var createEndpointRuleSetHttpAuthSchemeProvider = (defaultEndpointResolver6, defaultHttpAuthSchemeResolver, createHttpAuthOptionFunctions) => { - const endpointRuleSetHttpAuthSchemeProvider = (authParameters) => { - const endpoint2 = defaultEndpointResolver6(authParameters); - const authSchemes = endpoint2.properties?.authSchemes; - if (!authSchemes) { - return defaultHttpAuthSchemeResolver(authParameters); - } - const options = []; - for (const scheme of authSchemes) { - const { name: resolvedName, properties = {}, ...rest } = scheme; - const name = resolvedName.toLowerCase(); - if (resolvedName !== name) { - console.warn(`HttpAuthScheme has been normalized with lowercasing: '${resolvedName}' to '${name}'`); + /** + * Read chunk from stream + * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in + * @param offset - Offset target + * @param length - Number of bytes to read + * @returns Number of bytes read + */ + async read(buffer, offset, length) { + if (length === 0) { + return 0; + } + if (this.peekQueue.length === 0 && this.endOfStream) { + throw new EndOfFileStream_1.EndOfStreamError(); + } + let remaining = length; + let bytesRead = 0; + while (this.peekQueue.length > 0 && remaining > 0) { + const peekData = this.peekQueue.pop(); + if (!peekData) + throw new Error("peekData should be defined"); + const lenCopy = Math.min(peekData.length, remaining); + buffer.set(peekData.subarray(0, lenCopy), offset + bytesRead); + bytesRead += lenCopy; + remaining -= lenCopy; + if (lenCopy < peekData.length) { + this.peekQueue.push(peekData.subarray(lenCopy)); + } + } + while (remaining > 0 && !this.endOfStream) { + const reqLen = Math.min(remaining, maxStreamReadSize); + const chunkLen = await this.readFromStream(buffer, offset + bytesRead, reqLen); + bytesRead += chunkLen; + if (chunkLen < reqLen) + break; + remaining -= chunkLen; + } + return bytesRead; } - let schemeId; - if (name === "sigv4a") { - schemeId = "aws.auth#sigv4a"; - const sigv4Present = authSchemes.find((s6) => { - const name2 = s6.name.toLowerCase(); - return name2 !== "sigv4a" && name2.startsWith("sigv4"); - }); - if (SignatureV4MultiRegion.sigv4aDependency() === "none" && sigv4Present) { - continue; + /** + * Read chunk from stream + * @param buffer Target Uint8Array (or Buffer) to store data read from stream in + * @param offset Offset target + * @param length Number of bytes to read + * @returns Number of bytes read + */ + async readFromStream(buffer, offset, length) { + const readBuffer = this.s.read(length); + if (readBuffer) { + buffer.set(readBuffer, offset); + return readBuffer.length; + } else { + const request4 = { + buffer, + offset, + length, + deferred: new Deferred_1.Deferred() + }; + this.deferred = request4.deferred; + this.s.once("readable", () => { + this.readDeferred(request4); + }); + return request4.deferred.promise; } - } else if (name.startsWith("sigv4")) { - schemeId = "aws.auth#sigv4"; - } else { - throw new Error(`Unknown HttpAuthScheme found in '@smithy.rules#endpointRuleSet': '${name}'`); } - const createOption = createHttpAuthOptionFunctions[schemeId]; - if (!createOption) { - throw new Error(`Could not find HttpAuthOption create function for '${schemeId}'`); + /** + * Process deferred read request + * @param request Deferred read request + */ + readDeferred(request4) { + const readBuffer = this.s.read(request4.length); + if (readBuffer) { + request4.buffer.set(readBuffer, request4.offset); + request4.deferred.resolve(readBuffer.length); + this.deferred = null; + } else { + this.s.once("readable", () => { + this.readDeferred(request4); + }); + } } - const option = createOption(authParameters); - option.schemeId = schemeId; - option.signingProperties = { ...option.signingProperties || {}, ...rest, ...properties }; - options.push(option); - } - return options; - }; - return endpointRuleSetHttpAuthSchemeProvider; -}; -var _defaultS3HttpAuthSchemeProvider = (authParameters) => { - const options = []; - switch (authParameters.operation) { - default: { - options.push(createAwsAuthSigv4HttpAuthOption(authParameters)); - options.push(createAwsAuthSigv4aHttpAuthOption(authParameters)); - } + reject(err) { + this.endOfStream = true; + if (this.deferred) { + this.deferred.reject(err); + this.deferred = null; + } + } + }; + exports2.StreamReader = StreamReader; } - return options; -}; -var defaultS3HttpAuthSchemeProvider = createEndpointRuleSetHttpAuthSchemeProvider(defaultEndpointResolver, _defaultS3HttpAuthSchemeProvider, { - "aws.auth#sigv4": createAwsAuthSigv4HttpAuthOption, - "aws.auth#sigv4a": createAwsAuthSigv4aHttpAuthOption }); -var resolveHttpAuthSchemeConfig = (config) => { - const config_0 = resolveAwsSdkSigV4Config(config); - const config_1 = resolveAwsSdkSigV4AConfig(config_0); - return Object.assign(config_1, { - authSchemePreference: normalizeProvider(config.authSchemePreference ?? []) - }); -}; - -// ../node_modules/@aws-sdk/client-s3/dist-es/commands/CreateSessionCommand.js -init_dist_es36(); -init_dist_es20(); - -// ../node_modules/@aws-sdk/client-s3/dist-es/endpoint/EndpointParameters.js -var resolveClientEndpointParameters = (options) => { - return Object.assign(options, { - useFipsEndpoint: options.useFipsEndpoint ?? false, - useDualstackEndpoint: options.useDualstackEndpoint ?? false, - forcePathStyle: options.forcePathStyle ?? false, - useAccelerateEndpoint: options.useAccelerateEndpoint ?? false, - useGlobalEndpoint: options.useGlobalEndpoint ?? false, - disableMultiregionAccessPoints: options.disableMultiregionAccessPoints ?? false, - defaultSigningName: "s3", - clientContextParams: options.clientContextParams ?? {} - }); -}; -var commonParams = { - ForcePathStyle: { type: "clientContextParams", name: "forcePathStyle" }, - UseArnRegion: { type: "clientContextParams", name: "useArnRegion" }, - DisableMultiRegionAccessPoints: { type: "clientContextParams", name: "disableMultiregionAccessPoints" }, - Accelerate: { type: "clientContextParams", name: "useAccelerateEndpoint" }, - DisableS3ExpressSessionAuth: { type: "clientContextParams", name: "disableS3ExpressSessionAuth" }, - UseGlobalEndpoint: { type: "builtInParams", name: "useGlobalEndpoint" }, - UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, - Endpoint: { type: "builtInParams", name: "endpoint" }, - Region: { type: "builtInParams", name: "region" }, - UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" } -}; -// ../node_modules/@aws-sdk/client-s3/dist-es/schemas/schemas_0.js -init_schema2(); - -// ../node_modules/@aws-sdk/client-s3/dist-es/models/S3ServiceException.js -init_dist_es20(); -var S3ServiceException = class _S3ServiceException extends ServiceException { - constructor(options) { - super(options); - Object.setPrototypeOf(this, _S3ServiceException.prototype); +// ../node_modules/peek-readable/lib/index.js +var require_lib2 = __commonJS({ + "../node_modules/peek-readable/lib/index.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.StreamReader = exports2.EndOfStreamError = void 0; + var EndOfFileStream_1 = require_EndOfFileStream(); + Object.defineProperty(exports2, "EndOfStreamError", { enumerable: true, get: function() { + return EndOfFileStream_1.EndOfStreamError; + } }); + var StreamReader_1 = require_StreamReader(); + Object.defineProperty(exports2, "StreamReader", { enumerable: true, get: function() { + return StreamReader_1.StreamReader; + } }); } -}; +}); -// ../node_modules/@aws-sdk/client-s3/dist-es/models/errors.js -var NoSuchUpload = class _NoSuchUpload extends S3ServiceException { - name = "NoSuchUpload"; - $fault = "client"; - constructor(opts) { - super({ - name: "NoSuchUpload", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _NoSuchUpload.prototype); +// ../node_modules/strtok3/lib/AbstractTokenizer.js +var require_AbstractTokenizer = __commonJS({ + "../node_modules/strtok3/lib/AbstractTokenizer.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.AbstractTokenizer = void 0; + var peek_readable_1 = require_lib2(); + var AbstractTokenizer = class { + constructor(fileInfo) { + this.position = 0; + this.numBuffer = new Uint8Array(8); + this.fileInfo = fileInfo ? fileInfo : {}; + } + /** + * Read a token from the tokenizer-stream + * @param token - The token to read + * @param position - If provided, the desired position in the tokenizer-stream + * @returns Promise with token data + */ + async readToken(token, position = this.position) { + const uint8Array = Buffer.alloc(token.len); + const len = await this.readBuffer(uint8Array, { position }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(uint8Array, 0); + } + /** + * Peek a token from the tokenizer-stream. + * @param token - Token to peek from the tokenizer-stream. + * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position. + * @returns Promise with token data + */ + async peekToken(token, position = this.position) { + const uint8Array = Buffer.alloc(token.len); + const len = await this.peekBuffer(uint8Array, { position }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(uint8Array, 0); + } + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + async readNumber(token) { + const len = await this.readBuffer(this.numBuffer, { length: token.len }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(this.numBuffer, 0); + } + /** + * Read a numeric token from the stream + * @param token - Numeric token + * @returns Promise with number + */ + async peekNumber(token) { + const len = await this.peekBuffer(this.numBuffer, { length: token.len }); + if (len < token.len) + throw new peek_readable_1.EndOfStreamError(); + return token.get(this.numBuffer, 0); + } + /** + * Ignore number of bytes, advances the pointer in under tokenizer-stream. + * @param length - Number of bytes to ignore + * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available + */ + async ignore(length) { + if (this.fileInfo.size !== void 0) { + const bytesLeft = this.fileInfo.size - this.position; + if (length > bytesLeft) { + this.position += bytesLeft; + return bytesLeft; + } + } + this.position += length; + return length; + } + async close() { + } + normalizeOptions(uint8Array, options) { + if (options && options.position !== void 0 && options.position < this.position) { + throw new Error("`options.position` must be equal or greater than `tokenizer.position`"); + } + if (options) { + return { + mayBeLess: options.mayBeLess === true, + offset: options.offset ? options.offset : 0, + length: options.length ? options.length : uint8Array.length - (options.offset ? options.offset : 0), + position: options.position ? options.position : this.position + }; + } + return { + mayBeLess: false, + offset: 0, + length: uint8Array.length, + position: this.position + }; + } + }; + exports2.AbstractTokenizer = AbstractTokenizer; } -}; -var ObjectNotInActiveTierError = class _ObjectNotInActiveTierError extends S3ServiceException { - name = "ObjectNotInActiveTierError"; - $fault = "client"; - constructor(opts) { - super({ - name: "ObjectNotInActiveTierError", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _ObjectNotInActiveTierError.prototype); - } -}; -var BucketAlreadyExists = class _BucketAlreadyExists extends S3ServiceException { - name = "BucketAlreadyExists"; - $fault = "client"; - constructor(opts) { - super({ - name: "BucketAlreadyExists", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _BucketAlreadyExists.prototype); - } -}; -var BucketAlreadyOwnedByYou = class _BucketAlreadyOwnedByYou extends S3ServiceException { - name = "BucketAlreadyOwnedByYou"; - $fault = "client"; - constructor(opts) { - super({ - name: "BucketAlreadyOwnedByYou", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _BucketAlreadyOwnedByYou.prototype); - } -}; -var NoSuchBucket = class _NoSuchBucket extends S3ServiceException { - name = "NoSuchBucket"; - $fault = "client"; - constructor(opts) { - super({ - name: "NoSuchBucket", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _NoSuchBucket.prototype); - } -}; -var InvalidObjectState = class _InvalidObjectState extends S3ServiceException { - name = "InvalidObjectState"; - $fault = "client"; - StorageClass; - AccessTier; - constructor(opts) { - super({ - name: "InvalidObjectState", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _InvalidObjectState.prototype); - this.StorageClass = opts.StorageClass; - this.AccessTier = opts.AccessTier; - } -}; -var NoSuchKey = class _NoSuchKey extends S3ServiceException { - name = "NoSuchKey"; - $fault = "client"; - constructor(opts) { - super({ - name: "NoSuchKey", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _NoSuchKey.prototype); - } -}; -var NotFound = class _NotFound extends S3ServiceException { - name = "NotFound"; - $fault = "client"; - constructor(opts) { - super({ - name: "NotFound", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _NotFound.prototype); - } -}; -var EncryptionTypeMismatch = class _EncryptionTypeMismatch extends S3ServiceException { - name = "EncryptionTypeMismatch"; - $fault = "client"; - constructor(opts) { - super({ - name: "EncryptionTypeMismatch", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _EncryptionTypeMismatch.prototype); - } -}; -var InvalidRequest = class _InvalidRequest extends S3ServiceException { - name = "InvalidRequest"; - $fault = "client"; - constructor(opts) { - super({ - name: "InvalidRequest", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _InvalidRequest.prototype); +}); + +// ../node_modules/strtok3/lib/ReadStreamTokenizer.js +var require_ReadStreamTokenizer = __commonJS({ + "../node_modules/strtok3/lib/ReadStreamTokenizer.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.ReadStreamTokenizer = void 0; + var AbstractTokenizer_1 = require_AbstractTokenizer(); + var peek_readable_1 = require_lib2(); + var maxBufferSize = 256e3; + var ReadStreamTokenizer = class extends AbstractTokenizer_1.AbstractTokenizer { + constructor(stream3, fileInfo) { + super(fileInfo); + this.streamReader = new peek_readable_1.StreamReader(stream3); + } + /** + * Get file information, an HTTP-client may implement this doing a HEAD request + * @return Promise with file information + */ + async getFileInfo() { + return this.fileInfo; + } + /** + * Read buffer from tokenizer + * @param uint8Array - Target Uint8Array to fill with data read from the tokenizer-stream + * @param options - Read behaviour options + * @returns Promise with number of bytes read + */ + async readBuffer(uint8Array, options) { + const normOptions = this.normalizeOptions(uint8Array, options); + const skipBytes = normOptions.position - this.position; + if (skipBytes > 0) { + await this.ignore(skipBytes); + return this.readBuffer(uint8Array, options); + } else if (skipBytes < 0) { + throw new Error("`options.position` must be equal or greater than `tokenizer.position`"); + } + if (normOptions.length === 0) { + return 0; + } + const bytesRead = await this.streamReader.read(uint8Array, normOptions.offset, normOptions.length); + this.position += bytesRead; + if ((!options || !options.mayBeLess) && bytesRead < normOptions.length) { + throw new peek_readable_1.EndOfStreamError(); + } + return bytesRead; + } + /** + * Peek (read ahead) buffer from tokenizer + * @param uint8Array - Uint8Array (or Buffer) to write data to + * @param options - Read behaviour options + * @returns Promise with number of bytes peeked + */ + async peekBuffer(uint8Array, options) { + const normOptions = this.normalizeOptions(uint8Array, options); + let bytesRead = 0; + if (normOptions.position) { + const skipBytes = normOptions.position - this.position; + if (skipBytes > 0) { + const skipBuffer = new Uint8Array(normOptions.length + skipBytes); + bytesRead = await this.peekBuffer(skipBuffer, { mayBeLess: normOptions.mayBeLess }); + uint8Array.set(skipBuffer.subarray(skipBytes), normOptions.offset); + return bytesRead - skipBytes; + } else if (skipBytes < 0) { + throw new Error("Cannot peek from a negative offset in a stream"); + } + } + if (normOptions.length > 0) { + try { + bytesRead = await this.streamReader.peek(uint8Array, normOptions.offset, normOptions.length); + } catch (err) { + if (options && options.mayBeLess && err instanceof peek_readable_1.EndOfStreamError) { + return 0; + } + throw err; + } + if (!normOptions.mayBeLess && bytesRead < normOptions.length) { + throw new peek_readable_1.EndOfStreamError(); + } + } + return bytesRead; + } + async ignore(length) { + const bufSize = Math.min(maxBufferSize, length); + const buf = new Uint8Array(bufSize); + let totBytesRead = 0; + while (totBytesRead < length) { + const remaining = length - totBytesRead; + const bytesRead = await this.readBuffer(buf, { length: Math.min(bufSize, remaining) }); + if (bytesRead < 0) { + return bytesRead; + } + totBytesRead += bytesRead; + } + return totBytesRead; + } + }; + exports2.ReadStreamTokenizer = ReadStreamTokenizer; } -}; -var InvalidWriteOffset = class _InvalidWriteOffset extends S3ServiceException { - name = "InvalidWriteOffset"; - $fault = "client"; - constructor(opts) { - super({ - name: "InvalidWriteOffset", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _InvalidWriteOffset.prototype); +}); + +// ../node_modules/strtok3/lib/BufferTokenizer.js +var require_BufferTokenizer = __commonJS({ + "../node_modules/strtok3/lib/BufferTokenizer.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.BufferTokenizer = void 0; + var peek_readable_1 = require_lib2(); + var AbstractTokenizer_1 = require_AbstractTokenizer(); + var BufferTokenizer = class extends AbstractTokenizer_1.AbstractTokenizer { + /** + * Construct BufferTokenizer + * @param uint8Array - Uint8Array to tokenize + * @param fileInfo - Pass additional file information to the tokenizer + */ + constructor(uint8Array, fileInfo) { + super(fileInfo); + this.uint8Array = uint8Array; + this.fileInfo.size = this.fileInfo.size ? this.fileInfo.size : uint8Array.length; + } + /** + * Read buffer from tokenizer + * @param uint8Array - Uint8Array to tokenize + * @param options - Read behaviour options + * @returns {Promise} + */ + async readBuffer(uint8Array, options) { + if (options && options.position) { + if (options.position < this.position) { + throw new Error("`options.position` must be equal or greater than `tokenizer.position`"); + } + this.position = options.position; + } + const bytesRead = await this.peekBuffer(uint8Array, options); + this.position += bytesRead; + return bytesRead; + } + /** + * Peek (read ahead) buffer from tokenizer + * @param uint8Array + * @param options - Read behaviour options + * @returns {Promise} + */ + async peekBuffer(uint8Array, options) { + const normOptions = this.normalizeOptions(uint8Array, options); + const bytes2read = Math.min(this.uint8Array.length - normOptions.position, normOptions.length); + if (!normOptions.mayBeLess && bytes2read < normOptions.length) { + throw new peek_readable_1.EndOfStreamError(); + } else { + uint8Array.set(this.uint8Array.subarray(normOptions.position, normOptions.position + bytes2read), normOptions.offset); + return bytes2read; + } + } + async close() { + } + }; + exports2.BufferTokenizer = BufferTokenizer; } -}; -var TooManyParts = class _TooManyParts extends S3ServiceException { - name = "TooManyParts"; - $fault = "client"; - constructor(opts) { - super({ - name: "TooManyParts", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _TooManyParts.prototype); +}); + +// ../node_modules/strtok3/lib/core.js +var require_core = __commonJS({ + "../node_modules/strtok3/lib/core.js"(exports2) { + "use strict"; + Object.defineProperty(exports2, "__esModule", { value: true }); + exports2.fromBuffer = exports2.fromStream = exports2.EndOfStreamError = void 0; + var ReadStreamTokenizer_1 = require_ReadStreamTokenizer(); + var BufferTokenizer_1 = require_BufferTokenizer(); + var peek_readable_1 = require_lib2(); + Object.defineProperty(exports2, "EndOfStreamError", { enumerable: true, get: function() { + return peek_readable_1.EndOfStreamError; + } }); + function fromStream2(stream3, fileInfo) { + fileInfo = fileInfo ? fileInfo : {}; + return new ReadStreamTokenizer_1.ReadStreamTokenizer(stream3, fileInfo); + } + exports2.fromStream = fromStream2; + function fromBuffer2(uint8Array, fileInfo) { + return new BufferTokenizer_1.BufferTokenizer(uint8Array, fileInfo); + } + exports2.fromBuffer = fromBuffer2; } -}; -var IdempotencyParameterMismatch = class _IdempotencyParameterMismatch extends S3ServiceException { - name = "IdempotencyParameterMismatch"; - $fault = "client"; - constructor(opts) { - super({ - name: "IdempotencyParameterMismatch", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _IdempotencyParameterMismatch.prototype); +}); + +// ../node_modules/file-type/util.js +var require_util10 = __commonJS({ + "../node_modules/file-type/util.js"(exports2) { + "use strict"; + exports2.stringToBytes = (string) => [...string].map((character) => character.charCodeAt(0)); + exports2.tarHeaderChecksumMatches = (buffer, offset = 0) => { + const readSum = parseInt(buffer.toString("utf8", 148, 154).replace(/\0.*$/, "").trim(), 8); + if (isNaN(readSum)) { + return false; + } + let sum = 8 * 32; + for (let i6 = offset; i6 < offset + 148; i6++) { + sum += buffer[i6]; + } + for (let i6 = offset + 156; i6 < offset + 512; i6++) { + sum += buffer[i6]; + } + return readSum === sum; + }; + exports2.uint32SyncSafeToken = { + get: (buffer, offset) => { + return buffer[offset + 3] & 127 | buffer[offset + 2] << 7 | buffer[offset + 1] << 14 | buffer[offset] << 21; + }, + len: 4 + }; } -}; -var ObjectAlreadyInActiveTierError = class _ObjectAlreadyInActiveTierError extends S3ServiceException { - name = "ObjectAlreadyInActiveTierError"; - $fault = "client"; - constructor(opts) { - super({ - name: "ObjectAlreadyInActiveTierError", - $fault: "client", - ...opts - }); - Object.setPrototypeOf(this, _ObjectAlreadyInActiveTierError.prototype); +}); + +// ../node_modules/file-type/supported.js +var require_supported = __commonJS({ + "../node_modules/file-type/supported.js"(exports2, module2) { + "use strict"; + module2.exports = { + extensions: [ + "jpg", + "png", + "apng", + "gif", + "webp", + "flif", + "xcf", + "cr2", + "cr3", + "orf", + "arw", + "dng", + "nef", + "rw2", + "raf", + "tif", + "bmp", + "icns", + "jxr", + "psd", + "indd", + "zip", + "tar", + "rar", + "gz", + "bz2", + "7z", + "dmg", + "mp4", + "mid", + "mkv", + "webm", + "mov", + "avi", + "mpg", + "mp2", + "mp3", + "m4a", + "oga", + "ogg", + "ogv", + "opus", + "flac", + "wav", + "spx", + "amr", + "pdf", + "epub", + "exe", + "swf", + "rtf", + "wasm", + "woff", + "woff2", + "eot", + "ttf", + "otf", + "ico", + "flv", + "ps", + "xz", + "sqlite", + "nes", + "crx", + "xpi", + "cab", + "deb", + "ar", + "rpm", + "Z", + "lz", + "cfb", + "mxf", + "mts", + "blend", + "bpg", + "docx", + "pptx", + "xlsx", + "3gp", + "3g2", + "jp2", + "jpm", + "jpx", + "mj2", + "aif", + "qcp", + "odt", + "ods", + "odp", + "xml", + "mobi", + "heic", + "cur", + "ktx", + "ape", + "wv", + "dcm", + "ics", + "glb", + "pcap", + "dsf", + "lnk", + "alias", + "voc", + "ac3", + "m4v", + "m4p", + "m4b", + "f4v", + "f4p", + "f4b", + "f4a", + "mie", + "asf", + "ogm", + "ogx", + "mpc", + "arrow", + "shp", + "aac", + "mp1", + "it", + "s3m", + "xm", + "ai", + "skp", + "avif", + "eps", + "lzh", + "pgp", + "asar", + "stl", + "chm", + "3mf", + "zst", + "jxl", + "vcf" + ], + mimeTypes: [ + "image/jpeg", + "image/png", + "image/gif", + "image/webp", + "image/flif", + "image/x-xcf", + "image/x-canon-cr2", + "image/x-canon-cr3", + "image/tiff", + "image/bmp", + "image/vnd.ms-photo", + "image/vnd.adobe.photoshop", + "application/x-indesign", + "application/epub+zip", + "application/x-xpinstall", + "application/vnd.oasis.opendocument.text", + "application/vnd.oasis.opendocument.spreadsheet", + "application/vnd.oasis.opendocument.presentation", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/zip", + "application/x-tar", + "application/x-rar-compressed", + "application/gzip", + "application/x-bzip2", + "application/x-7z-compressed", + "application/x-apple-diskimage", + "application/x-apache-arrow", + "video/mp4", + "audio/midi", + "video/x-matroska", + "video/webm", + "video/quicktime", + "video/vnd.avi", + "audio/vnd.wave", + "audio/qcelp", + "audio/x-ms-asf", + "video/x-ms-asf", + "application/vnd.ms-asf", + "video/mpeg", + "video/3gpp", + "audio/mpeg", + "audio/mp4", + // RFC 4337 + "audio/opus", + "video/ogg", + "audio/ogg", + "application/ogg", + "audio/x-flac", + "audio/ape", + "audio/wavpack", + "audio/amr", + "application/pdf", + "application/x-msdownload", + "application/x-shockwave-flash", + "application/rtf", + "application/wasm", + "font/woff", + "font/woff2", + "application/vnd.ms-fontobject", + "font/ttf", + "font/otf", + "image/x-icon", + "video/x-flv", + "application/postscript", + "application/eps", + "application/x-xz", + "application/x-sqlite3", + "application/x-nintendo-nes-rom", + "application/x-google-chrome-extension", + "application/vnd.ms-cab-compressed", + "application/x-deb", + "application/x-unix-archive", + "application/x-rpm", + "application/x-compress", + "application/x-lzip", + "application/x-cfb", + "application/x-mie", + "application/mxf", + "video/mp2t", + "application/x-blender", + "image/bpg", + "image/jp2", + "image/jpx", + "image/jpm", + "image/mj2", + "audio/aiff", + "application/xml", + "application/x-mobipocket-ebook", + "image/heif", + "image/heif-sequence", + "image/heic", + "image/heic-sequence", + "image/icns", + "image/ktx", + "application/dicom", + "audio/x-musepack", + "text/calendar", + "text/vcard", + "model/gltf-binary", + "application/vnd.tcpdump.pcap", + "audio/x-dsf", + // Non-standard + "application/x.ms.shortcut", + // Invented by us + "application/x.apple.alias", + // Invented by us + "audio/x-voc", + "audio/vnd.dolby.dd-raw", + "audio/x-m4a", + "image/apng", + "image/x-olympus-orf", + "image/x-sony-arw", + "image/x-adobe-dng", + "image/x-nikon-nef", + "image/x-panasonic-rw2", + "image/x-fujifilm-raf", + "video/x-m4v", + "video/3gpp2", + "application/x-esri-shape", + "audio/aac", + "audio/x-it", + "audio/x-s3m", + "audio/x-xm", + "video/MP1S", + "video/MP2P", + "application/vnd.sketchup.skp", + "image/avif", + "application/x-lzh-compressed", + "application/pgp-encrypted", + "application/x-asar", + "model/stl", + "application/vnd.ms-htmlhelp", + "model/3mf", + "image/jxl", + "application/zstd" + ] + }; } -}; +}); -// ../node_modules/@aws-sdk/client-s3/dist-es/schemas/schemas_0.js -var _A = "Account"; -var _AAO = "AnalyticsAndOperator"; -var _AC = "AccelerateConfiguration"; -var _ACL = "AccessControlList"; -var _ACL_ = "ACL"; -var _ACLn = "AnalyticsConfigurationList"; -var _ACP = "AccessControlPolicy"; -var _ACT = "AccessControlTranslation"; -var _ACn = "AnalyticsConfiguration"; -var _AD = "AbortDate"; -var _AED = "AnalyticsExportDestination"; -var _AF = "AnalyticsFilter"; -var _AH = "AllowedHeaders"; -var _AHl = "AllowedHeader"; -var _AI = "AccountId"; -var _AIMU = "AbortIncompleteMultipartUpload"; -var _AKI = "AccessKeyId"; -var _AM = "AllowedMethods"; -var _AMU = "AbortMultipartUpload"; -var _AMUO = "AbortMultipartUploadOutput"; -var _AMUR = "AbortMultipartUploadRequest"; -var _AMl = "AllowedMethod"; -var _AO = "AllowedOrigins"; -var _AOl = "AllowedOrigin"; -var _APA = "AccessPointAlias"; -var _APAc = "AccessPointArn"; -var _AQRD = "AllowQuotedRecordDelimiter"; -var _AR = "AcceptRanges"; -var _ARI = "AbortRuleId"; -var _AS = "AbacStatus"; -var _ASBD = "AnalyticsS3BucketDestination"; -var _ASSEBD = "ApplyServerSideEncryptionByDefault"; -var _ASr = "ArchiveStatus"; -var _AT = "AccessTier"; -var _An = "And"; -var _B = "Bucket"; -var _BA = "BucketArn"; -var _BAE = "BucketAlreadyExists"; -var _BAI = "BucketAccountId"; -var _BAOBY = "BucketAlreadyOwnedByYou"; -var _BET = "BlockedEncryptionTypes"; -var _BGR = "BypassGovernanceRetention"; -var _BI = "BucketInfo"; -var _BKE = "BucketKeyEnabled"; -var _BLC = "BucketLifecycleConfiguration"; -var _BLN = "BucketLocationName"; -var _BLS = "BucketLoggingStatus"; -var _BLT = "BucketLocationType"; -var _BN = "BucketName"; -var _BP = "BytesProcessed"; -var _BPA = "BlockPublicAcls"; -var _BPP = "BlockPublicPolicy"; -var _BR = "BucketRegion"; -var _BRy = "BytesReturned"; -var _BS = "BytesScanned"; -var _Bo = "Body"; -var _Bu = "Buckets"; -var _C = "Checksum"; -var _CA = "ChecksumAlgorithm"; -var _CACL = "CannedACL"; -var _CB = "CreateBucket"; -var _CBC = "CreateBucketConfiguration"; -var _CBMC = "CreateBucketMetadataConfiguration"; -var _CBMCR = "CreateBucketMetadataConfigurationRequest"; -var _CBMTC = "CreateBucketMetadataTableConfiguration"; -var _CBMTCR = "CreateBucketMetadataTableConfigurationRequest"; -var _CBO = "CreateBucketOutput"; -var _CBR = "CreateBucketRequest"; -var _CC = "CacheControl"; -var _CCRC = "ChecksumCRC32"; -var _CCRCC = "ChecksumCRC32C"; -var _CCRCNVME = "ChecksumCRC64NVME"; -var _CC_ = "Cache-Control"; -var _CD = "CreationDate"; -var _CD_ = "Content-Disposition"; -var _CDo = "ContentDisposition"; -var _CE = "ContinuationEvent"; -var _CE_ = "Content-Encoding"; -var _CEo = "ContentEncoding"; -var _CF = "CloudFunction"; -var _CFC = "CloudFunctionConfiguration"; -var _CL = "ContentLanguage"; -var _CL_ = "Content-Language"; -var _CL__ = "Content-Length"; -var _CLo = "ContentLength"; -var _CM = "Content-MD5"; -var _CMD = "ContentMD5"; -var _CMU = "CompletedMultipartUpload"; -var _CMUO = "CompleteMultipartUploadOutput"; -var _CMUOr = "CreateMultipartUploadOutput"; -var _CMUR = "CompleteMultipartUploadResult"; -var _CMURo = "CompleteMultipartUploadRequest"; -var _CMURr = "CreateMultipartUploadRequest"; -var _CMUo = "CompleteMultipartUpload"; -var _CMUr = "CreateMultipartUpload"; -var _CMh = "ChecksumMode"; -var _CO = "CopyObject"; -var _COO = "CopyObjectOutput"; -var _COR = "CopyObjectResult"; -var _CORSC = "CORSConfiguration"; -var _CORSR = "CORSRules"; -var _CORSRu = "CORSRule"; -var _CORo = "CopyObjectRequest"; -var _CP = "CommonPrefix"; -var _CPL = "CommonPrefixList"; -var _CPLo = "CompletedPartList"; -var _CPR = "CopyPartResult"; -var _CPo = "CompletedPart"; -var _CPom = "CommonPrefixes"; -var _CR = "ContentRange"; -var _CRSBA = "ConfirmRemoveSelfBucketAccess"; -var _CR_ = "Content-Range"; -var _CS = "CopySource"; -var _CSHA = "ChecksumSHA1"; -var _CSHAh = "ChecksumSHA256"; -var _CSIM = "CopySourceIfMatch"; -var _CSIMS = "CopySourceIfModifiedSince"; -var _CSINM = "CopySourceIfNoneMatch"; -var _CSIUS = "CopySourceIfUnmodifiedSince"; -var _CSO = "CreateSessionOutput"; -var _CSR = "CreateSessionResult"; -var _CSRo = "CopySourceRange"; -var _CSRr = "CreateSessionRequest"; -var _CSSSECA = "CopySourceSSECustomerAlgorithm"; -var _CSSSECK = "CopySourceSSECustomerKey"; -var _CSSSECKMD = "CopySourceSSECustomerKeyMD5"; -var _CSV = "CSV"; -var _CSVI = "CopySourceVersionId"; -var _CSVIn = "CSVInput"; -var _CSVO = "CSVOutput"; -var _CSo = "ConfigurationState"; -var _CSr = "CreateSession"; -var _CT = "ChecksumType"; -var _CT_ = "Content-Type"; -var _CTl = "ClientToken"; -var _CTo = "ContentType"; -var _CTom = "CompressionType"; -var _CTon = "ContinuationToken"; -var _Co = "Condition"; -var _Cod = "Code"; -var _Com = "Comments"; -var _Con = "Contents"; -var _Cont = "Cont"; -var _Cr = "Credentials"; -var _D = "Days"; -var _DAI = "DaysAfterInitiation"; -var _DB = "DeleteBucket"; -var _DBAC = "DeleteBucketAnalyticsConfiguration"; -var _DBACR = "DeleteBucketAnalyticsConfigurationRequest"; -var _DBC = "DeleteBucketCors"; -var _DBCR = "DeleteBucketCorsRequest"; -var _DBE = "DeleteBucketEncryption"; -var _DBER = "DeleteBucketEncryptionRequest"; -var _DBIC = "DeleteBucketInventoryConfiguration"; -var _DBICR = "DeleteBucketInventoryConfigurationRequest"; -var _DBITC = "DeleteBucketIntelligentTieringConfiguration"; -var _DBITCR = "DeleteBucketIntelligentTieringConfigurationRequest"; -var _DBL = "DeleteBucketLifecycle"; -var _DBLR = "DeleteBucketLifecycleRequest"; -var _DBMC = "DeleteBucketMetadataConfiguration"; -var _DBMCR = "DeleteBucketMetadataConfigurationRequest"; -var _DBMCRe = "DeleteBucketMetricsConfigurationRequest"; -var _DBMCe = "DeleteBucketMetricsConfiguration"; -var _DBMTC = "DeleteBucketMetadataTableConfiguration"; -var _DBMTCR = "DeleteBucketMetadataTableConfigurationRequest"; -var _DBOC = "DeleteBucketOwnershipControls"; -var _DBOCR = "DeleteBucketOwnershipControlsRequest"; -var _DBP = "DeleteBucketPolicy"; -var _DBPR = "DeleteBucketPolicyRequest"; -var _DBR = "DeleteBucketRequest"; -var _DBRR = "DeleteBucketReplicationRequest"; -var _DBRe = "DeleteBucketReplication"; -var _DBT = "DeleteBucketTagging"; -var _DBTR = "DeleteBucketTaggingRequest"; -var _DBW = "DeleteBucketWebsite"; -var _DBWR = "DeleteBucketWebsiteRequest"; -var _DE = "DataExport"; -var _DIM = "DestinationIfMatch"; -var _DIMS = "DestinationIfModifiedSince"; -var _DINM = "DestinationIfNoneMatch"; -var _DIUS = "DestinationIfUnmodifiedSince"; -var _DM = "DeleteMarker"; -var _DME = "DeleteMarkerEntry"; -var _DMR = "DeleteMarkerReplication"; -var _DMVI = "DeleteMarkerVersionId"; -var _DMe = "DeleteMarkers"; -var _DN = "DisplayName"; -var _DO = "DeletedObject"; -var _DOO = "DeleteObjectOutput"; -var _DOOe = "DeleteObjectsOutput"; -var _DOR = "DeleteObjectRequest"; -var _DORe = "DeleteObjectsRequest"; -var _DOT = "DeleteObjectTagging"; -var _DOTO = "DeleteObjectTaggingOutput"; -var _DOTR = "DeleteObjectTaggingRequest"; -var _DOe = "DeletedObjects"; -var _DOel = "DeleteObject"; -var _DOele = "DeleteObjects"; -var _DPAB = "DeletePublicAccessBlock"; -var _DPABR = "DeletePublicAccessBlockRequest"; -var _DR = "DataRedundancy"; -var _DRe = "DefaultRetention"; -var _DRel = "DeleteResult"; -var _DRes = "DestinationResult"; -var _Da = "Date"; -var _De = "Delete"; -var _Del = "Deleted"; -var _Deli = "Delimiter"; -var _Des = "Destination"; -var _Desc = "Description"; -var _Det = "Details"; -var _E = "Expiration"; -var _EA = "EmailAddress"; -var _EBC = "EventBridgeConfiguration"; -var _EBO = "ExpectedBucketOwner"; -var _EC = "EncryptionConfiguration"; -var _ECr = "ErrorCode"; -var _ED = "ErrorDetails"; -var _EDr = "ErrorDocument"; -var _EE = "EndEvent"; -var _EH = "ExposeHeaders"; -var _EHx = "ExposeHeader"; -var _EM = "ErrorMessage"; -var _EODM = "ExpiredObjectDeleteMarker"; -var _EOR = "ExistingObjectReplication"; -var _ES = "ExpiresString"; -var _ESBO = "ExpectedSourceBucketOwner"; -var _ET = "EncryptionType"; -var _ETL = "EncryptionTypeList"; -var _ETM = "EncryptionTypeMismatch"; -var _ETa = "ETag"; -var _ETn = "EncodingType"; -var _ETv = "EventThreshold"; -var _ETx = "ExpressionType"; -var _En = "Encryption"; -var _Ena = "Enabled"; -var _End = "End"; -var _Er = "Errors"; -var _Err = "Error"; -var _Ev = "Events"; -var _Eve = "Event"; -var _Ex = "Expires"; -var _Exp = "Expression"; -var _F = "Filter"; -var _FD = "FieldDelimiter"; -var _FHI = "FileHeaderInfo"; -var _FO = "FetchOwner"; -var _FR = "FilterRule"; -var _FRL = "FilterRuleList"; -var _FRi = "FilterRules"; -var _Fi = "Field"; -var _Fo = "Format"; -var _Fr = "Frequency"; -var _G = "Grants"; -var _GBA = "GetBucketAbac"; -var _GBAC = "GetBucketAccelerateConfiguration"; -var _GBACO = "GetBucketAccelerateConfigurationOutput"; -var _GBACOe = "GetBucketAnalyticsConfigurationOutput"; -var _GBACR = "GetBucketAccelerateConfigurationRequest"; -var _GBACRe = "GetBucketAnalyticsConfigurationRequest"; -var _GBACe = "GetBucketAnalyticsConfiguration"; -var _GBAO = "GetBucketAbacOutput"; -var _GBAOe = "GetBucketAclOutput"; -var _GBAR = "GetBucketAbacRequest"; -var _GBARe = "GetBucketAclRequest"; -var _GBAe = "GetBucketAcl"; -var _GBC = "GetBucketCors"; -var _GBCO = "GetBucketCorsOutput"; -var _GBCR = "GetBucketCorsRequest"; -var _GBE = "GetBucketEncryption"; -var _GBEO = "GetBucketEncryptionOutput"; -var _GBER = "GetBucketEncryptionRequest"; -var _GBIC = "GetBucketInventoryConfiguration"; -var _GBICO = "GetBucketInventoryConfigurationOutput"; -var _GBICR = "GetBucketInventoryConfigurationRequest"; -var _GBITC = "GetBucketIntelligentTieringConfiguration"; -var _GBITCO = "GetBucketIntelligentTieringConfigurationOutput"; -var _GBITCR = "GetBucketIntelligentTieringConfigurationRequest"; -var _GBL = "GetBucketLocation"; -var _GBLC = "GetBucketLifecycleConfiguration"; -var _GBLCO = "GetBucketLifecycleConfigurationOutput"; -var _GBLCR = "GetBucketLifecycleConfigurationRequest"; -var _GBLO = "GetBucketLocationOutput"; -var _GBLOe = "GetBucketLoggingOutput"; -var _GBLR = "GetBucketLocationRequest"; -var _GBLRe = "GetBucketLoggingRequest"; -var _GBLe = "GetBucketLogging"; -var _GBMC = "GetBucketMetadataConfiguration"; -var _GBMCO = "GetBucketMetadataConfigurationOutput"; -var _GBMCOe = "GetBucketMetricsConfigurationOutput"; -var _GBMCR = "GetBucketMetadataConfigurationResult"; -var _GBMCRe = "GetBucketMetadataConfigurationRequest"; -var _GBMCRet = "GetBucketMetricsConfigurationRequest"; +// ../node_modules/file-type/core.js +var require_core2 = __commonJS({ + "../node_modules/file-type/core.js"(exports, module) { + "use strict"; + var Token = require_lib(); + var strtok3 = require_core(); + var { + stringToBytes, + tarHeaderChecksumMatches, + uint32SyncSafeToken + } = require_util10(); + var supported = require_supported(); + var minimumBytes = 4100; + async function fromStream(stream3) { + const tokenizer = await strtok3.fromStream(stream3); + try { + return await fromTokenizer(tokenizer); + } finally { + await tokenizer.close(); + } + } + async function fromBuffer(input) { + if (!(input instanceof Uint8Array || input instanceof ArrayBuffer || Buffer.isBuffer(input))) { + throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof input}\``); + } + const buffer = input instanceof Buffer ? input : Buffer.from(input); + if (!(buffer && buffer.length > 1)) { + return; + } + const tokenizer = strtok3.fromBuffer(buffer); + return fromTokenizer(tokenizer); + } + function _check(buffer, headers, options) { + options = { + offset: 0, + ...options + }; + for (const [index, header] of headers.entries()) { + if (options.mask) { + if (header !== (options.mask[index] & buffer[index + options.offset])) { + return false; + } + } else if (header !== buffer[index + options.offset]) { + return false; + } + } + return true; + } + async function fromTokenizer(tokenizer) { + try { + return _fromTokenizer(tokenizer); + } catch (error2) { + if (!(error2 instanceof strtok3.EndOfStreamError)) { + throw error2; + } + } + } + async function _fromTokenizer(tokenizer) { + let buffer = Buffer.alloc(minimumBytes); + const bytesRead = 12; + const check = (header, options) => _check(buffer, header, options); + const checkString = (header, options) => check(stringToBytes(header), options); + if (!tokenizer.fileInfo.size) { + tokenizer.fileInfo.size = Number.MAX_SAFE_INTEGER; + } + await tokenizer.peekBuffer(buffer, { length: bytesRead, mayBeLess: true }); + if (check([66, 77])) { + return { + ext: "bmp", + mime: "image/bmp" + }; + } + if (check([11, 119])) { + return { + ext: "ac3", + mime: "audio/vnd.dolby.dd-raw" + }; + } + if (check([120, 1])) { + return { + ext: "dmg", + mime: "application/x-apple-diskimage" + }; + } + if (check([77, 90])) { + return { + ext: "exe", + mime: "application/x-msdownload" + }; + } + if (check([37, 33])) { + await tokenizer.peekBuffer(buffer, { length: 24, mayBeLess: true }); + if (checkString("PS-Adobe-", { offset: 2 }) && checkString(" EPSF-", { offset: 14 })) { + return { + ext: "eps", + mime: "application/eps" + }; + } + return { + ext: "ps", + mime: "application/postscript" + }; + } + if (check([31, 160]) || check([31, 157])) { + return { + ext: "Z", + mime: "application/x-compress" + }; + } + if (check([255, 216, 255])) { + return { + ext: "jpg", + mime: "image/jpeg" + }; + } + if (check([73, 73, 188])) { + return { + ext: "jxr", + mime: "image/vnd.ms-photo" + }; + } + if (check([31, 139, 8])) { + return { + ext: "gz", + mime: "application/gzip" + }; + } + if (check([66, 90, 104])) { + return { + ext: "bz2", + mime: "application/x-bzip2" + }; + } + if (checkString("ID3")) { + await tokenizer.ignore(6); + const id3HeaderLen = await tokenizer.readToken(uint32SyncSafeToken); + if (tokenizer.position + id3HeaderLen > tokenizer.fileInfo.size) { + return { + ext: "mp3", + mime: "audio/mpeg" + }; + } + await tokenizer.ignore(id3HeaderLen); + return fromTokenizer(tokenizer); + } + if (checkString("MP+")) { + return { + ext: "mpc", + mime: "audio/x-musepack" + }; + } + if ((buffer[0] === 67 || buffer[0] === 70) && check([87, 83], { offset: 1 })) { + return { + ext: "swf", + mime: "application/x-shockwave-flash" + }; + } + if (check([71, 73, 70])) { + return { + ext: "gif", + mime: "image/gif" + }; + } + if (checkString("FLIF")) { + return { + ext: "flif", + mime: "image/flif" + }; + } + if (checkString("8BPS")) { + return { + ext: "psd", + mime: "image/vnd.adobe.photoshop" + }; + } + if (checkString("WEBP", { offset: 8 })) { + return { + ext: "webp", + mime: "image/webp" + }; + } + if (checkString("MPCK")) { + return { + ext: "mpc", + mime: "audio/x-musepack" + }; + } + if (checkString("FORM")) { + return { + ext: "aif", + mime: "audio/aiff" + }; + } + if (checkString("icns", { offset: 0 })) { + return { + ext: "icns", + mime: "image/icns" + }; + } + if (check([80, 75, 3, 4])) { + try { + while (tokenizer.position + 30 < tokenizer.fileInfo.size) { + await tokenizer.readBuffer(buffer, { length: 30 }); + const zipHeader = { + compressedSize: buffer.readUInt32LE(18), + uncompressedSize: buffer.readUInt32LE(22), + filenameLength: buffer.readUInt16LE(26), + extraFieldLength: buffer.readUInt16LE(28) + }; + zipHeader.filename = await tokenizer.readToken(new Token.StringType(zipHeader.filenameLength, "utf-8")); + await tokenizer.ignore(zipHeader.extraFieldLength); + if (zipHeader.filename === "META-INF/mozilla.rsa") { + return { + ext: "xpi", + mime: "application/x-xpinstall" + }; + } + if (zipHeader.filename.endsWith(".rels") || zipHeader.filename.endsWith(".xml")) { + const type = zipHeader.filename.split("/")[0]; + switch (type) { + case "_rels": + break; + case "word": + return { + ext: "docx", + mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + }; + case "ppt": + return { + ext: "pptx", + mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation" + }; + case "xl": + return { + ext: "xlsx", + mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + }; + default: + break; + } + } + if (zipHeader.filename.startsWith("xl/")) { + return { + ext: "xlsx", + mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + }; + } + if (zipHeader.filename.startsWith("3D/") && zipHeader.filename.endsWith(".model")) { + return { + ext: "3mf", + mime: "model/3mf" + }; + } + if (zipHeader.filename === "mimetype" && zipHeader.compressedSize === zipHeader.uncompressedSize) { + const mimeType = await tokenizer.readToken(new Token.StringType(zipHeader.compressedSize, "utf-8")); + switch (mimeType) { + case "application/epub+zip": + return { + ext: "epub", + mime: "application/epub+zip" + }; + case "application/vnd.oasis.opendocument.text": + return { + ext: "odt", + mime: "application/vnd.oasis.opendocument.text" + }; + case "application/vnd.oasis.opendocument.spreadsheet": + return { + ext: "ods", + mime: "application/vnd.oasis.opendocument.spreadsheet" + }; + case "application/vnd.oasis.opendocument.presentation": + return { + ext: "odp", + mime: "application/vnd.oasis.opendocument.presentation" + }; + default: + } + } + if (zipHeader.compressedSize === 0) { + let nextHeaderIndex = -1; + while (nextHeaderIndex < 0 && tokenizer.position < tokenizer.fileInfo.size) { + await tokenizer.peekBuffer(buffer, { mayBeLess: true }); + nextHeaderIndex = buffer.indexOf("504B0304", 0, "hex"); + await tokenizer.ignore(nextHeaderIndex >= 0 ? nextHeaderIndex : buffer.length); + } + } else { + await tokenizer.ignore(zipHeader.compressedSize); + } + } + } catch (error2) { + if (!(error2 instanceof strtok3.EndOfStreamError)) { + throw error2; + } + } + return { + ext: "zip", + mime: "application/zip" + }; + } + if (checkString("OggS")) { + await tokenizer.ignore(28); + const type = Buffer.alloc(8); + await tokenizer.readBuffer(type); + if (_check(type, [79, 112, 117, 115, 72, 101, 97, 100])) { + return { + ext: "opus", + mime: "audio/opus" + }; + } + if (_check(type, [128, 116, 104, 101, 111, 114, 97])) { + return { + ext: "ogv", + mime: "video/ogg" + }; + } + if (_check(type, [1, 118, 105, 100, 101, 111, 0])) { + return { + ext: "ogm", + mime: "video/ogg" + }; + } + if (_check(type, [127, 70, 76, 65, 67])) { + return { + ext: "oga", + mime: "audio/ogg" + }; + } + if (_check(type, [83, 112, 101, 101, 120, 32, 32])) { + return { + ext: "spx", + mime: "audio/ogg" + }; + } + if (_check(type, [1, 118, 111, 114, 98, 105, 115])) { + return { + ext: "ogg", + mime: "audio/ogg" + }; + } + return { + ext: "ogx", + mime: "application/ogg" + }; + } + if (check([80, 75]) && (buffer[2] === 3 || buffer[2] === 5 || buffer[2] === 7) && (buffer[3] === 4 || buffer[3] === 6 || buffer[3] === 8)) { + return { + ext: "zip", + mime: "application/zip" + }; + } + if (checkString("ftyp", { offset: 4 }) && (buffer[8] & 96) !== 0) { + const brandMajor = buffer.toString("binary", 8, 12).replace("\0", " ").trim(); + switch (brandMajor) { + case "avif": + return { ext: "avif", mime: "image/avif" }; + case "mif1": + return { ext: "heic", mime: "image/heif" }; + case "msf1": + return { ext: "heic", mime: "image/heif-sequence" }; + case "heic": + case "heix": + return { ext: "heic", mime: "image/heic" }; + case "hevc": + case "hevx": + return { ext: "heic", mime: "image/heic-sequence" }; + case "qt": + return { ext: "mov", mime: "video/quicktime" }; + case "M4V": + case "M4VH": + case "M4VP": + return { ext: "m4v", mime: "video/x-m4v" }; + case "M4P": + return { ext: "m4p", mime: "video/mp4" }; + case "M4B": + return { ext: "m4b", mime: "audio/mp4" }; + case "M4A": + return { ext: "m4a", mime: "audio/x-m4a" }; + case "F4V": + return { ext: "f4v", mime: "video/mp4" }; + case "F4P": + return { ext: "f4p", mime: "video/mp4" }; + case "F4A": + return { ext: "f4a", mime: "audio/mp4" }; + case "F4B": + return { ext: "f4b", mime: "audio/mp4" }; + case "crx": + return { ext: "cr3", mime: "image/x-canon-cr3" }; + default: + if (brandMajor.startsWith("3g")) { + if (brandMajor.startsWith("3g2")) { + return { ext: "3g2", mime: "video/3gpp2" }; + } + return { ext: "3gp", mime: "video/3gpp" }; + } + return { ext: "mp4", mime: "video/mp4" }; + } + } + if (checkString("MThd")) { + return { + ext: "mid", + mime: "audio/midi" + }; + } + if (checkString("wOFF") && (check([0, 1, 0, 0], { offset: 4 }) || checkString("OTTO", { offset: 4 }))) { + return { + ext: "woff", + mime: "font/woff" + }; + } + if (checkString("wOF2") && (check([0, 1, 0, 0], { offset: 4 }) || checkString("OTTO", { offset: 4 }))) { + return { + ext: "woff2", + mime: "font/woff2" + }; + } + if (check([212, 195, 178, 161]) || check([161, 178, 195, 212])) { + return { + ext: "pcap", + mime: "application/vnd.tcpdump.pcap" + }; + } + if (checkString("DSD ")) { + return { + ext: "dsf", + mime: "audio/x-dsf" + // Non-standard + }; + } + if (checkString("LZIP")) { + return { + ext: "lz", + mime: "application/x-lzip" + }; + } + if (checkString("fLaC")) { + return { + ext: "flac", + mime: "audio/x-flac" + }; + } + if (check([66, 80, 71, 251])) { + return { + ext: "bpg", + mime: "image/bpg" + }; + } + if (checkString("wvpk")) { + return { + ext: "wv", + mime: "audio/wavpack" + }; + } + if (checkString("%PDF")) { + await tokenizer.ignore(1350); + const maxBufferSize = 10 * 1024 * 1024; + const buffer2 = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size)); + await tokenizer.readBuffer(buffer2, { mayBeLess: true }); + if (buffer2.includes(Buffer.from("AIPrivateData"))) { + return { + ext: "ai", + mime: "application/postscript" + }; + } + return { + ext: "pdf", + mime: "application/pdf" + }; + } + if (check([0, 97, 115, 109])) { + return { + ext: "wasm", + mime: "application/wasm" + }; + } + if (check([73, 73, 42, 0])) { + if (checkString("CR", { offset: 8 })) { + return { + ext: "cr2", + mime: "image/x-canon-cr2" + }; + } + if (check([28, 0, 254, 0], { offset: 8 }) || check([31, 0, 11, 0], { offset: 8 })) { + return { + ext: "nef", + mime: "image/x-nikon-nef" + }; + } + if (check([8, 0, 0, 0], { offset: 4 }) && (check([45, 0, 254, 0], { offset: 8 }) || check([39, 0, 254, 0], { offset: 8 }))) { + return { + ext: "dng", + mime: "image/x-adobe-dng" + }; + } + buffer = Buffer.alloc(24); + await tokenizer.peekBuffer(buffer); + if ((check([16, 251, 134, 1], { offset: 4 }) || check([8, 0, 0, 0], { offset: 4 })) && // This pattern differentiates ARW from other TIFF-ish file types: + check([0, 254, 0, 4, 0, 1, 0, 0, 0, 1, 0, 0, 0, 3, 1], { offset: 9 })) { + return { + ext: "arw", + mime: "image/x-sony-arw" + }; + } + return { + ext: "tif", + mime: "image/tiff" + }; + } + if (check([77, 77, 0, 42])) { + return { + ext: "tif", + mime: "image/tiff" + }; + } + if (checkString("MAC ")) { + return { + ext: "ape", + mime: "audio/ape" + }; + } + if (check([26, 69, 223, 163])) { + async function readField() { + const msb = await tokenizer.peekNumber(Token.UINT8); + let mask = 128; + let ic2 = 0; + while ((msb & mask) === 0 && mask !== 0) { + ++ic2; + mask >>= 1; + } + const id = Buffer.alloc(ic2 + 1); + await tokenizer.readBuffer(id); + return id; + } + async function readElement() { + const id = await readField(); + const lenField = await readField(); + lenField[0] ^= 128 >> lenField.length - 1; + const nrLen = Math.min(6, lenField.length); + return { + id: id.readUIntBE(0, id.length), + len: lenField.readUIntBE(lenField.length - nrLen, nrLen) + }; + } + async function readChildren(level, children2) { + while (children2 > 0) { + const e6 = await readElement(); + if (e6.id === 17026) { + return tokenizer.readToken(new Token.StringType(e6.len, "utf-8")); + } + await tokenizer.ignore(e6.len); + --children2; + } + } + const re = await readElement(); + const docType = await readChildren(1, re.len); + switch (docType) { + case "webm": + return { + ext: "webm", + mime: "video/webm" + }; + case "matroska": + return { + ext: "mkv", + mime: "video/x-matroska" + }; + default: + return; + } + } + if (check([82, 73, 70, 70])) { + if (check([65, 86, 73], { offset: 8 })) { + return { + ext: "avi", + mime: "video/vnd.avi" + }; + } + if (check([87, 65, 86, 69], { offset: 8 })) { + return { + ext: "wav", + mime: "audio/vnd.wave" + }; + } + if (check([81, 76, 67, 77], { offset: 8 })) { + return { + ext: "qcp", + mime: "audio/qcelp" + }; + } + } + if (checkString("SQLi")) { + return { + ext: "sqlite", + mime: "application/x-sqlite3" + }; + } + if (check([78, 69, 83, 26])) { + return { + ext: "nes", + mime: "application/x-nintendo-nes-rom" + }; + } + if (checkString("Cr24")) { + return { + ext: "crx", + mime: "application/x-google-chrome-extension" + }; + } + if (checkString("MSCF") || checkString("ISc(")) { + return { + ext: "cab", + mime: "application/vnd.ms-cab-compressed" + }; + } + if (check([237, 171, 238, 219])) { + return { + ext: "rpm", + mime: "application/x-rpm" + }; + } + if (check([197, 208, 211, 198])) { + return { + ext: "eps", + mime: "application/eps" + }; + } + if (check([40, 181, 47, 253])) { + return { + ext: "zst", + mime: "application/zstd" + }; + } + if (check([79, 84, 84, 79, 0])) { + return { + ext: "otf", + mime: "font/otf" + }; + } + if (checkString("#!AMR")) { + return { + ext: "amr", + mime: "audio/amr" + }; + } + if (checkString("{\\rtf")) { + return { + ext: "rtf", + mime: "application/rtf" + }; + } + if (check([70, 76, 86, 1])) { + return { + ext: "flv", + mime: "video/x-flv" + }; + } + if (checkString("IMPM")) { + return { + ext: "it", + mime: "audio/x-it" + }; + } + if (checkString("-lh0-", { offset: 2 }) || checkString("-lh1-", { offset: 2 }) || checkString("-lh2-", { offset: 2 }) || checkString("-lh3-", { offset: 2 }) || checkString("-lh4-", { offset: 2 }) || checkString("-lh5-", { offset: 2 }) || checkString("-lh6-", { offset: 2 }) || checkString("-lh7-", { offset: 2 }) || checkString("-lzs-", { offset: 2 }) || checkString("-lz4-", { offset: 2 }) || checkString("-lz5-", { offset: 2 }) || checkString("-lhd-", { offset: 2 })) { + return { + ext: "lzh", + mime: "application/x-lzh-compressed" + }; + } + if (check([0, 0, 1, 186])) { + if (check([33], { offset: 4, mask: [241] })) { + return { + ext: "mpg", + // May also be .ps, .mpeg + mime: "video/MP1S" + }; + } + if (check([68], { offset: 4, mask: [196] })) { + return { + ext: "mpg", + // May also be .mpg, .m2p, .vob or .sub + mime: "video/MP2P" + }; + } + } + if (checkString("ITSF")) { + return { + ext: "chm", + mime: "application/vnd.ms-htmlhelp" + }; + } + if (check([253, 55, 122, 88, 90, 0])) { + return { + ext: "xz", + mime: "application/x-xz" + }; + } + if (checkString("")) { + await tokenizer.ignore(8); + const str = await tokenizer.readToken(new Token.StringType(13, "ascii")); + if (str === "debian-binary") { + return { + ext: "deb", + mime: "application/x-deb" + }; + } + return { + ext: "ar", + mime: "application/x-unix-archive" + }; + } + if (check([137, 80, 78, 71, 13, 10, 26, 10])) { + await tokenizer.ignore(8); + async function readChunkHeader() { + return { + length: await tokenizer.readToken(Token.INT32_BE), + type: await tokenizer.readToken(new Token.StringType(4, "binary")) + }; + } + do { + const chunk = await readChunkHeader(); + if (chunk.length < 0) { + return; + } + switch (chunk.type) { + case "IDAT": + return { + ext: "png", + mime: "image/png" + }; + case "acTL": + return { + ext: "apng", + mime: "image/apng" + }; + default: + await tokenizer.ignore(chunk.length + 4); + } + } while (tokenizer.position + 8 < tokenizer.fileInfo.size); + return { + ext: "png", + mime: "image/png" + }; + } + if (check([65, 82, 82, 79, 87, 49, 0, 0])) { + return { + ext: "arrow", + mime: "application/x-apache-arrow" + }; + } + if (check([103, 108, 84, 70, 2, 0, 0, 0])) { + return { + ext: "glb", + mime: "model/gltf-binary" + }; + } + if (check([102, 114, 101, 101], { offset: 4 }) || // `free` + check([109, 100, 97, 116], { offset: 4 }) || // `mdat` MJPEG + check([109, 111, 111, 118], { offset: 4 }) || // `moov` + check([119, 105, 100, 101], { offset: 4 })) { + return { + ext: "mov", + mime: "video/quicktime" + }; + } + if (check([73, 73, 82, 79, 8, 0, 0, 0, 24])) { + return { + ext: "orf", + mime: "image/x-olympus-orf" + }; + } + if (checkString("gimp xcf ")) { + return { + ext: "xcf", + mime: "image/x-xcf" + }; + } + if (check([73, 73, 85, 0, 24, 0, 0, 0, 136, 231, 116, 216])) { + return { + ext: "rw2", + mime: "image/x-panasonic-rw2" + }; + } + if (check([48, 38, 178, 117, 142, 102, 207, 17, 166, 217])) { + async function readHeader() { + const guid = Buffer.alloc(16); + await tokenizer.readBuffer(guid); + return { + id: guid, + size: Number(await tokenizer.readToken(Token.UINT64_LE)) + }; + } + await tokenizer.ignore(30); + while (tokenizer.position + 24 < tokenizer.fileInfo.size) { + const header = await readHeader(); + let payload = header.size - 24; + if (_check(header.id, [145, 7, 220, 183, 183, 169, 207, 17, 142, 230, 0, 192, 12, 32, 83, 101])) { + const typeId = Buffer.alloc(16); + payload -= await tokenizer.readBuffer(typeId); + if (_check(typeId, [64, 158, 105, 248, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) { + return { + ext: "asf", + mime: "audio/x-ms-asf" + }; + } + if (_check(typeId, [192, 239, 25, 188, 77, 91, 207, 17, 168, 253, 0, 128, 95, 92, 68, 43])) { + return { + ext: "asf", + mime: "video/x-ms-asf" + }; + } + break; + } + await tokenizer.ignore(payload); + } + return { + ext: "asf", + mime: "application/vnd.ms-asf" + }; + } + if (check([171, 75, 84, 88, 32, 49, 49, 187, 13, 10, 26, 10])) { + return { + ext: "ktx", + mime: "image/ktx" + }; + } + if ((check([126, 16, 4]) || check([126, 24, 4])) && check([48, 77, 73, 69], { offset: 4 })) { + return { + ext: "mie", + mime: "application/x-mie" + }; + } + if (check([39, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], { offset: 2 })) { + return { + ext: "shp", + mime: "application/x-esri-shape" + }; + } + if (check([0, 0, 0, 12, 106, 80, 32, 32, 13, 10, 135, 10])) { + await tokenizer.ignore(20); + const type = await tokenizer.readToken(new Token.StringType(4, "ascii")); + switch (type) { + case "jp2 ": + return { + ext: "jp2", + mime: "image/jp2" + }; + case "jpx ": + return { + ext: "jpx", + mime: "image/jpx" + }; + case "jpm ": + return { + ext: "jpm", + mime: "image/jpm" + }; + case "mjp2": + return { + ext: "mj2", + mime: "image/mj2" + }; + default: + return; + } + } + if (check([255, 10]) || check([0, 0, 0, 12, 74, 88, 76, 32, 13, 10, 135, 10])) { + return { + ext: "jxl", + mime: "image/jxl" + }; + } + if (check([0, 0, 1, 186]) || check([0, 0, 1, 179])) { + return { + ext: "mpg", + mime: "video/mpeg" + }; + } + if (check([0, 1, 0, 0, 0])) { + return { + ext: "ttf", + mime: "font/ttf" + }; + } + if (check([0, 0, 1, 0])) { + return { + ext: "ico", + mime: "image/x-icon" + }; + } + if (check([0, 0, 2, 0])) { + return { + ext: "cur", + mime: "image/x-icon" + }; + } + if (check([208, 207, 17, 224, 161, 177, 26, 225])) { + return { + ext: "cfb", + mime: "application/x-cfb" + }; + } + await tokenizer.peekBuffer(buffer, { length: Math.min(256, tokenizer.fileInfo.size), mayBeLess: true }); + if (checkString("BEGIN:")) { + if (checkString("VCARD", { offset: 6 })) { + return { + ext: "vcf", + mime: "text/vcard" + }; + } + if (checkString("VCALENDAR", { offset: 6 })) { + return { + ext: "ics", + mime: "text/calendar" + }; + } + } + if (checkString("FUJIFILMCCD-RAW")) { + return { + ext: "raf", + mime: "image/x-fujifilm-raf" + }; + } + if (checkString("Extended Module:")) { + return { + ext: "xm", + mime: "audio/x-xm" + }; + } + if (checkString("Creative Voice File")) { + return { + ext: "voc", + mime: "audio/x-voc" + }; + } + if (check([4, 0, 0, 0]) && buffer.length >= 16) { + const jsonSize = buffer.readUInt32LE(12); + if (jsonSize > 12 && buffer.length >= jsonSize + 16) { + try { + const header = buffer.slice(16, jsonSize + 16).toString(); + const json = JSON.parse(header); + if (json.files) { + return { + ext: "asar", + mime: "application/x-asar" + }; + } + } catch (_) { + } + } + } + if (check([6, 14, 43, 52, 2, 5, 1, 1, 13, 1, 2, 1, 1, 2])) { + return { + ext: "mxf", + mime: "application/mxf" + }; + } + if (checkString("SCRM", { offset: 44 })) { + return { + ext: "s3m", + mime: "audio/x-s3m" + }; + } + if (check([71], { offset: 4 }) && (check([71], { offset: 192 }) || check([71], { offset: 196 }))) { + return { + ext: "mts", + mime: "video/mp2t" + }; + } + if (check([66, 79, 79, 75, 77, 79, 66, 73], { offset: 60 })) { + return { + ext: "mobi", + mime: "application/x-mobipocket-ebook" + }; + } + if (check([68, 73, 67, 77], { offset: 128 })) { + return { + ext: "dcm", + mime: "application/dicom" + }; + } + if (check([76, 0, 0, 0, 1, 20, 2, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70])) { + return { + ext: "lnk", + mime: "application/x.ms.shortcut" + // Invented by us + }; + } + if (check([98, 111, 111, 107, 0, 0, 0, 0, 109, 97, 114, 107, 0, 0, 0, 0])) { + return { + ext: "alias", + mime: "application/x.apple.alias" + // Invented by us + }; + } + if (check([76, 80], { offset: 34 }) && (check([0, 0, 1], { offset: 8 }) || check([1, 0, 2], { offset: 8 }) || check([2, 0, 2], { offset: 8 }))) { + return { + ext: "eot", + mime: "application/vnd.ms-fontobject" + }; + } + if (check([6, 6, 237, 245, 216, 29, 70, 229, 189, 49, 239, 231, 254, 116, 183, 29])) { + return { + ext: "indd", + mime: "application/x-indesign" + }; + } + await tokenizer.peekBuffer(buffer, { length: Math.min(512, tokenizer.fileInfo.size), mayBeLess: true }); + if (tarHeaderChecksumMatches(buffer)) { + return { + ext: "tar", + mime: "application/x-tar" + }; + } + if (check([255, 254, 255, 14, 83, 0, 107, 0, 101, 0, 116, 0, 99, 0, 104, 0, 85, 0, 112, 0, 32, 0, 77, 0, 111, 0, 100, 0, 101, 0, 108, 0])) { + return { + ext: "skp", + mime: "application/vnd.sketchup.skp" + }; + } + if (checkString("-----BEGIN PGP MESSAGE-----")) { + return { + ext: "pgp", + mime: "application/pgp-encrypted" + }; + } + if (buffer.length >= 2 && check([255, 224], { offset: 0, mask: [255, 224] })) { + if (check([16], { offset: 1, mask: [22] })) { + if (check([8], { offset: 1, mask: [8] })) { + return { + ext: "aac", + mime: "audio/aac" + }; + } + return { + ext: "aac", + mime: "audio/aac" + }; + } + if (check([2], { offset: 1, mask: [6] })) { + return { + ext: "mp3", + mime: "audio/mpeg" + }; + } + if (check([4], { offset: 1, mask: [6] })) { + return { + ext: "mp2", + mime: "audio/mpeg" + }; + } + if (check([6], { offset: 1, mask: [6] })) { + return { + ext: "mp1", + mime: "audio/mpeg" + }; + } + } + } + var stream = (readableStream) => new Promise((resolve, reject) => { + const stream = eval("require")("stream"); + readableStream.on("error", reject); + readableStream.once("readable", async () => { + const pass = new stream.PassThrough(); + let outputStream; + if (stream.pipeline) { + outputStream = stream.pipeline(readableStream, pass, () => { + }); + } else { + outputStream = readableStream.pipe(pass); + } + const chunk = readableStream.read(minimumBytes) || readableStream.read() || Buffer.alloc(0); + try { + const fileType3 = await fromBuffer(chunk); + pass.fileType = fileType3; + } catch (error2) { + reject(error2); + } + resolve(outputStream); + }); + }); + var fileType = { + fromStream, + fromTokenizer, + fromBuffer, + stream + }; + Object.defineProperty(fileType, "extensions", { + get() { + return new Set(supported.extensions); + } + }); + Object.defineProperty(fileType, "mimeTypes", { + get() { + return new Set(supported.mimeTypes); + } + }); + module.exports = fileType; + } +}); + +// ../node_modules/mime/Mime.js +var require_Mime = __commonJS({ + "../node_modules/mime/Mime.js"(exports2, module2) { + "use strict"; + function Mime() { + this._types = /* @__PURE__ */ Object.create(null); + this._extensions = /* @__PURE__ */ Object.create(null); + for (let i6 = 0; i6 < arguments.length; i6++) { + this.define(arguments[i6]); + } + this.define = this.define.bind(this); + this.getType = this.getType.bind(this); + this.getExtension = this.getExtension.bind(this); + } + Mime.prototype.define = function(typeMap, force) { + for (let type in typeMap) { + let extensions = typeMap[type].map(function(t12) { + return t12.toLowerCase(); + }); + type = type.toLowerCase(); + for (let i6 = 0; i6 < extensions.length; i6++) { + const ext2 = extensions[i6]; + if (ext2[0] === "*") { + continue; + } + if (!force && ext2 in this._types) { + throw new Error( + 'Attempt to change mapping for "' + ext2 + '" extension from "' + this._types[ext2] + '" to "' + type + '". Pass `force=true` to allow this, otherwise remove "' + ext2 + '" from the list of extensions for "' + type + '".' + ); + } + this._types[ext2] = type; + } + if (force || !this._extensions[type]) { + const ext2 = extensions[0]; + this._extensions[type] = ext2[0] !== "*" ? ext2 : ext2.substr(1); + } + } + }; + Mime.prototype.getType = function(path7) { + path7 = String(path7); + let last = path7.replace(/^.*[/\\]/, "").toLowerCase(); + let ext2 = last.replace(/^.*\./, "").toLowerCase(); + let hasPath = last.length < path7.length; + let hasDot = ext2.length < last.length - 1; + return (hasDot || !hasPath) && this._types[ext2] || null; + }; + Mime.prototype.getExtension = function(type) { + type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; + return type && this._extensions[type.toLowerCase()] || null; + }; + module2.exports = Mime; + } +}); + +// ../node_modules/mime/types/standard.js +var require_standard = __commonJS({ + "../node_modules/mime/types/standard.js"(exports2, module2) { + "use strict"; + module2.exports = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] }; + } +}); + +// ../node_modules/mime/lite.js +var require_lite = __commonJS({ + "../node_modules/mime/lite.js"(exports2, module2) { + "use strict"; + var Mime = require_Mime(); + module2.exports = new Mime(require_standard()); + } +}); + +// ../node_modules/exif-parser/lib/jpeg.js +var require_jpeg = __commonJS({ + "../node_modules/exif-parser/lib/jpeg.js"(exports2, module2) { + "use strict"; + module2.exports = { + parseSections: function(stream3, iterator2) { + var len, markerType; + stream3.setBigEndian(true); + while (stream3.remainingLength() > 0 && markerType !== 218) { + if (stream3.nextUInt8() !== 255) { + throw new Error("Invalid JPEG section offset"); + } + markerType = stream3.nextUInt8(); + if (markerType >= 208 && markerType <= 217 || markerType === 218) { + len = 0; + } else { + len = stream3.nextUInt16() - 2; + } + iterator2(markerType, stream3.branch(0, len)); + stream3.skip(len); + } + }, + //stream should be located after SOF section size and in big endian mode, like passed to parseSections iterator + getSizeFromSOFSection: function(stream3) { + stream3.skip(1); + return { + height: stream3.nextUInt16(), + width: stream3.nextUInt16() + }; + }, + getSectionName: function(markerType) { + var name, index; + switch (markerType) { + case 216: + name = "SOI"; + break; + case 196: + name = "DHT"; + break; + case 219: + name = "DQT"; + break; + case 221: + name = "DRI"; + break; + case 218: + name = "SOS"; + break; + case 254: + name = "COM"; + break; + case 217: + name = "EOI"; + break; + default: + if (markerType >= 224 && markerType <= 239) { + name = "APP"; + index = markerType - 224; + } else if (markerType >= 192 && markerType <= 207 && markerType !== 196 && markerType !== 200 && markerType !== 204) { + name = "SOF"; + index = markerType - 192; + } else if (markerType >= 208 && markerType <= 215) { + name = "RST"; + index = markerType - 208; + } + break; + } + var nameStruct = { + name + }; + if (typeof index === "number") { + nameStruct.index = index; + } + return nameStruct; + } + }; + } +}); + +// ../node_modules/exif-parser/lib/exif.js +var require_exif = __commonJS({ + "../node_modules/exif-parser/lib/exif.js"(exports2, module2) { + "use strict"; + function readExifValue(format2, stream3) { + switch (format2) { + case 1: + return stream3.nextUInt8(); + case 3: + return stream3.nextUInt16(); + case 4: + return stream3.nextUInt32(); + case 5: + return [stream3.nextUInt32(), stream3.nextUInt32()]; + case 6: + return stream3.nextInt8(); + case 8: + return stream3.nextUInt16(); + case 9: + return stream3.nextUInt32(); + case 10: + return [stream3.nextInt32(), stream3.nextInt32()]; + case 11: + return stream3.nextFloat(); + case 12: + return stream3.nextDouble(); + default: + throw new Error("Invalid format while decoding: " + format2); + } + } + function getBytesPerComponent(format2) { + switch (format2) { + case 1: + case 2: + case 6: + case 7: + return 1; + case 3: + case 8: + return 2; + case 4: + case 9: + case 11: + return 4; + case 5: + case 10: + case 12: + return 8; + default: + return 0; + } + } + function readExifTag(tiffMarker, stream3) { + var tagType = stream3.nextUInt16(), format2 = stream3.nextUInt16(), bytesPerComponent = getBytesPerComponent(format2), components = stream3.nextUInt32(), valueBytes = bytesPerComponent * components, values, value, c7; + if (valueBytes > 4) { + stream3 = tiffMarker.openWithOffset(stream3.nextUInt32()); + } + if (format2 === 2) { + values = stream3.nextString(components); + var lastNull = values.indexOf("\0"); + if (lastNull !== -1) { + values = values.substr(0, lastNull); + } + } else if (format2 === 7) { + values = stream3.nextBuffer(components); + } else if (format2 !== 0) { + values = []; + for (c7 = 0; c7 < components; ++c7) { + values.push(readExifValue(format2, stream3)); + } + } + if (valueBytes < 4) { + stream3.skip(4 - valueBytes); + } + return [tagType, values, format2]; + } + function readIFDSection(tiffMarker, stream3, iterator2) { + var numberOfEntries = stream3.nextUInt16(), tag, i6; + for (i6 = 0; i6 < numberOfEntries; ++i6) { + tag = readExifTag(tiffMarker, stream3); + iterator2(tag[0], tag[1], tag[2]); + } + } + function readHeader(stream3) { + var exifHeader = stream3.nextString(6); + if (exifHeader !== "Exif\0\0") { + throw new Error("Invalid EXIF header"); + } + var tiffMarker = stream3.mark(); + var tiffHeader = stream3.nextUInt16(); + if (tiffHeader === 18761) { + stream3.setBigEndian(false); + } else if (tiffHeader === 19789) { + stream3.setBigEndian(true); + } else { + throw new Error("Invalid TIFF header"); + } + if (stream3.nextUInt16() !== 42) { + throw new Error("Invalid TIFF data"); + } + return tiffMarker; + } + module2.exports = { + IFD0: 1, + IFD1: 2, + GPSIFD: 3, + SubIFD: 4, + InteropIFD: 5, + parseTags: function(stream3, iterator2) { + var tiffMarker; + try { + tiffMarker = readHeader(stream3); + } catch (e6) { + return false; + } + var subIfdOffset, gpsOffset, interopOffset; + var ifd0Stream = tiffMarker.openWithOffset(stream3.nextUInt32()), IFD0 = this.IFD0; + readIFDSection(tiffMarker, ifd0Stream, function(tagType, value, format2) { + switch (tagType) { + case 34853: + gpsOffset = value[0]; + break; + case 34665: + subIfdOffset = value[0]; + break; + default: + iterator2(IFD0, tagType, value, format2); + break; + } + }); + var ifd1Offset = ifd0Stream.nextUInt32(); + if (ifd1Offset !== 0) { + var ifd1Stream = tiffMarker.openWithOffset(ifd1Offset); + readIFDSection(tiffMarker, ifd1Stream, iterator2.bind(null, this.IFD1)); + } + if (gpsOffset) { + var gpsStream = tiffMarker.openWithOffset(gpsOffset); + readIFDSection(tiffMarker, gpsStream, iterator2.bind(null, this.GPSIFD)); + } + if (subIfdOffset) { + var subIfdStream = tiffMarker.openWithOffset(subIfdOffset), InteropIFD = this.InteropIFD; + readIFDSection(tiffMarker, subIfdStream, function(tagType, value, format2) { + if (tagType === 40965) { + interopOffset = value[0]; + } else { + iterator2(InteropIFD, tagType, value, format2); + } + }); + } + if (interopOffset) { + var interopStream = tiffMarker.openWithOffset(interopOffset); + readIFDSection(tiffMarker, interopStream, iterator2.bind(null, this.InteropIFD)); + } + return true; + } + }; + } +}); + +// ../node_modules/exif-parser/lib/date.js +var require_date = __commonJS({ + "../node_modules/exif-parser/lib/date.js"(exports2, module2) { + "use strict"; + function parseNumber2(s6) { + return parseInt(s6, 10); + } + var hours = 3600; + var minutes = 60; + function parseDateTimeParts(dateParts, timeParts) { + dateParts = dateParts.map(parseNumber2); + timeParts = timeParts.map(parseNumber2); + var year2 = dateParts[0]; + var month = dateParts[1] - 1; + var day = dateParts[2]; + var hours2 = timeParts[0]; + var minutes2 = timeParts[1]; + var seconds = timeParts[2]; + var date2 = Date.UTC(year2, month, day, hours2, minutes2, seconds, 0); + var timestamp = date2 / 1e3; + return timestamp; + } + function parseDateWithTimezoneFormat(dateTimeStr) { + var dateParts = dateTimeStr.substr(0, 10).split("-"); + var timeParts = dateTimeStr.substr(11, 8).split(":"); + var timezoneStr = dateTimeStr.substr(19, 6); + var timezoneParts = timezoneStr.split(":").map(parseNumber2); + var timezoneOffset = timezoneParts[0] * hours + timezoneParts[1] * minutes; + var timestamp = parseDateTimeParts(dateParts, timeParts); + timestamp -= timezoneOffset; + if (typeof timestamp === "number" && !isNaN(timestamp)) { + return timestamp; + } + } + function parseDateWithSpecFormat(dateTimeStr) { + var parts = dateTimeStr.split(" "), dateParts = parts[0].split(":"), timeParts = parts[1].split(":"); + var timestamp = parseDateTimeParts(dateParts, timeParts); + if (typeof timestamp === "number" && !isNaN(timestamp)) { + return timestamp; + } + } + function parseExifDate(dateTimeStr) { + var isSpecFormat = dateTimeStr.length === 19 && dateTimeStr.charAt(4) === ":"; + var isTimezoneFormat = dateTimeStr.length === 25 && dateTimeStr.charAt(10) === "T"; + var timestamp; + if (isTimezoneFormat) { + return parseDateWithTimezoneFormat(dateTimeStr); + } else if (isSpecFormat) { + return parseDateWithSpecFormat(dateTimeStr); + } + } + module2.exports = { + parseDateWithSpecFormat, + parseDateWithTimezoneFormat, + parseExifDate + }; + } +}); + +// ../node_modules/exif-parser/lib/simplify.js +var require_simplify = __commonJS({ + "../node_modules/exif-parser/lib/simplify.js"(exports2, module2) { + "use strict"; + var exif = require_exif(); + var date2 = require_date(); + var degreeTags = [ + { + section: exif.GPSIFD, + type: 2, + name: "GPSLatitude", + refType: 1, + refName: "GPSLatitudeRef", + posVal: "N" + }, + { + section: exif.GPSIFD, + type: 4, + name: "GPSLongitude", + refType: 3, + refName: "GPSLongitudeRef", + posVal: "E" + } + ]; + var dateTags = [ + { + section: exif.SubIFD, + type: 306, + name: "ModifyDate" + }, + { + section: exif.SubIFD, + type: 36867, + name: "DateTimeOriginal" + }, + { + section: exif.SubIFD, + type: 36868, + name: "CreateDate" + }, + { + section: exif.SubIFD, + type: 306, + name: "ModifyDate" + } + ]; + module2.exports = { + castDegreeValues: function(getTagValue, setTagValue) { + degreeTags.forEach(function(t12) { + var degreeVal = getTagValue(t12); + if (degreeVal) { + var degreeRef = getTagValue({ section: t12.section, type: t12.refType, name: t12.refName }); + var degreeNumRef = degreeRef === t12.posVal ? 1 : -1; + var degree = (degreeVal[0] + degreeVal[1] / 60 + degreeVal[2] / 3600) * degreeNumRef; + setTagValue(t12, degree); + } + }); + }, + castDateValues: function(getTagValue, setTagValue) { + dateTags.forEach(function(t12) { + var dateStrVal = getTagValue(t12); + if (dateStrVal) { + var timestamp = date2.parseExifDate(dateStrVal); + if (typeof timestamp !== "undefined") { + setTagValue(t12, timestamp); + } + } + }); + }, + simplifyValue: function(values, format2) { + if (Array.isArray(values)) { + values = values.map(function(value) { + if (format2 === 10 || format2 === 5) { + return value[0] / value[1]; + } + return value; + }); + if (values.length === 1) { + values = values[0]; + } + } + return values; + } + }; + } +}); + +// ../node_modules/exif-parser/lib/exif-tags.js +var require_exif_tags = __commonJS({ + "../node_modules/exif-parser/lib/exif-tags.js"(exports2, module2) { + "use strict"; + module2.exports = { + exif: { + 1: "InteropIndex", + 2: "InteropVersion", + 11: "ProcessingSoftware", + 254: "SubfileType", + 255: "OldSubfileType", + 256: "ImageWidth", + 257: "ImageHeight", + 258: "BitsPerSample", + 259: "Compression", + 262: "PhotometricInterpretation", + 263: "Thresholding", + 264: "CellWidth", + 265: "CellLength", + 266: "FillOrder", + 269: "DocumentName", + 270: "ImageDescription", + 271: "Make", + 272: "Model", + 273: "StripOffsets", + 274: "Orientation", + 277: "SamplesPerPixel", + 278: "RowsPerStrip", + 279: "StripByteCounts", + 280: "MinSampleValue", + 281: "MaxSampleValue", + 282: "XResolution", + 283: "YResolution", + 284: "PlanarConfiguration", + 285: "PageName", + 286: "XPosition", + 287: "YPosition", + 288: "FreeOffsets", + 289: "FreeByteCounts", + 290: "GrayResponseUnit", + 291: "GrayResponseCurve", + 292: "T4Options", + 293: "T6Options", + 296: "ResolutionUnit", + 297: "PageNumber", + 300: "ColorResponseUnit", + 301: "TransferFunction", + 305: "Software", + 306: "ModifyDate", + 315: "Artist", + 316: "HostComputer", + 317: "Predictor", + 318: "WhitePoint", + 319: "PrimaryChromaticities", + 320: "ColorMap", + 321: "HalftoneHints", + 322: "TileWidth", + 323: "TileLength", + 324: "TileOffsets", + 325: "TileByteCounts", + 326: "BadFaxLines", + 327: "CleanFaxData", + 328: "ConsecutiveBadFaxLines", + 330: "SubIFD", + 332: "InkSet", + 333: "InkNames", + 334: "NumberofInks", + 336: "DotRange", + 337: "TargetPrinter", + 338: "ExtraSamples", + 339: "SampleFormat", + 340: "SMinSampleValue", + 341: "SMaxSampleValue", + 342: "TransferRange", + 343: "ClipPath", + 344: "XClipPathUnits", + 345: "YClipPathUnits", + 346: "Indexed", + 347: "JPEGTables", + 351: "OPIProxy", + 400: "GlobalParametersIFD", + 401: "ProfileType", + 402: "FaxProfile", + 403: "CodingMethods", + 404: "VersionYear", + 405: "ModeNumber", + 433: "Decode", + 434: "DefaultImageColor", + 435: "T82Options", + 437: "JPEGTables", + 512: "JPEGProc", + 513: "ThumbnailOffset", + 514: "ThumbnailLength", + 515: "JPEGRestartInterval", + 517: "JPEGLosslessPredictors", + 518: "JPEGPointTransforms", + 519: "JPEGQTables", + 520: "JPEGDCTables", + 521: "JPEGACTables", + 529: "YCbCrCoefficients", + 530: "YCbCrSubSampling", + 531: "YCbCrPositioning", + 532: "ReferenceBlackWhite", + 559: "StripRowCounts", + 700: "ApplicationNotes", + 999: "USPTOMiscellaneous", + 4096: "RelatedImageFileFormat", + 4097: "RelatedImageWidth", + 4098: "RelatedImageHeight", + 18246: "Rating", + 18247: "XP_DIP_XML", + 18248: "StitchInfo", + 18249: "RatingPercent", + 32781: "ImageID", + 32931: "WangTag1", + 32932: "WangAnnotation", + 32933: "WangTag3", + 32934: "WangTag4", + 32995: "Matteing", + 32996: "DataType", + 32997: "ImageDepth", + 32998: "TileDepth", + 33405: "Model2", + 33421: "CFARepeatPatternDim", + 33422: "CFAPattern2", + 33423: "BatteryLevel", + 33424: "KodakIFD", + 33432: "Copyright", + 33434: "ExposureTime", + 33437: "FNumber", + 33445: "MDFileTag", + 33446: "MDScalePixel", + 33447: "MDColorTable", + 33448: "MDLabName", + 33449: "MDSampleInfo", + 33450: "MDPrepDate", + 33451: "MDPrepTime", + 33452: "MDFileUnits", + 33550: "PixelScale", + 33589: "AdventScale", + 33590: "AdventRevision", + 33628: "UIC1Tag", + 33629: "UIC2Tag", + 33630: "UIC3Tag", + 33631: "UIC4Tag", + 33723: "IPTC-NAA", + 33918: "IntergraphPacketData", + 33919: "IntergraphFlagRegisters", + 33920: "IntergraphMatrix", + 33921: "INGRReserved", + 33922: "ModelTiePoint", + 34016: "Site", + 34017: "ColorSequence", + 34018: "IT8Header", + 34019: "RasterPadding", + 34020: "BitsPerRunLength", + 34021: "BitsPerExtendedRunLength", + 34022: "ColorTable", + 34023: "ImageColorIndicator", + 34024: "BackgroundColorIndicator", + 34025: "ImageColorValue", + 34026: "BackgroundColorValue", + 34027: "PixelIntensityRange", + 34028: "TransparencyIndicator", + 34029: "ColorCharacterization", + 34030: "HCUsage", + 34031: "TrapIndicator", + 34032: "CMYKEquivalent", + 34118: "SEMInfo", + 34152: "AFCP_IPTC", + 34232: "PixelMagicJBIGOptions", + 34264: "ModelTransform", + 34306: "WB_GRGBLevels", + 34310: "LeafData", + 34377: "PhotoshopSettings", + 34665: "ExifOffset", + 34675: "ICC_Profile", + 34687: "TIFF_FXExtensions", + 34688: "MultiProfiles", + 34689: "SharedData", + 34690: "T88Options", + 34732: "ImageLayer", + 34735: "GeoTiffDirectory", + 34736: "GeoTiffDoubleParams", + 34737: "GeoTiffAsciiParams", + 34850: "ExposureProgram", + 34852: "SpectralSensitivity", + 34853: "GPSInfo", + 34855: "ISO", + 34856: "Opto-ElectricConvFactor", + 34857: "Interlace", + 34858: "TimeZoneOffset", + 34859: "SelfTimerMode", + 34864: "SensitivityType", + 34865: "StandardOutputSensitivity", + 34866: "RecommendedExposureIndex", + 34867: "ISOSpeed", + 34868: "ISOSpeedLatitudeyyy", + 34869: "ISOSpeedLatitudezzz", + 34908: "FaxRecvParams", + 34909: "FaxSubAddress", + 34910: "FaxRecvTime", + 34954: "LeafSubIFD", + 36864: "ExifVersion", + 36867: "DateTimeOriginal", + 36868: "CreateDate", + 37121: "ComponentsConfiguration", + 37122: "CompressedBitsPerPixel", + 37377: "ShutterSpeedValue", + 37378: "ApertureValue", + 37379: "BrightnessValue", + 37380: "ExposureCompensation", + 37381: "MaxApertureValue", + 37382: "SubjectDistance", + 37383: "MeteringMode", + 37384: "LightSource", + 37385: "Flash", + 37386: "FocalLength", + 37387: "FlashEnergy", + 37388: "SpatialFrequencyResponse", + 37389: "Noise", + 37390: "FocalPlaneXResolution", + 37391: "FocalPlaneYResolution", + 37392: "FocalPlaneResolutionUnit", + 37393: "ImageNumber", + 37394: "SecurityClassification", + 37395: "ImageHistory", + 37396: "SubjectArea", + 37397: "ExposureIndex", + 37398: "TIFF-EPStandardID", + 37399: "SensingMethod", + 37434: "CIP3DataFile", + 37435: "CIP3Sheet", + 37436: "CIP3Side", + 37439: "StoNits", + 37500: "MakerNote", + 37510: "UserComment", + 37520: "SubSecTime", + 37521: "SubSecTimeOriginal", + 37522: "SubSecTimeDigitized", + 37679: "MSDocumentText", + 37680: "MSPropertySetStorage", + 37681: "MSDocumentTextPosition", + 37724: "ImageSourceData", + 40091: "XPTitle", + 40092: "XPComment", + 40093: "XPAuthor", + 40094: "XPKeywords", + 40095: "XPSubject", + 40960: "FlashpixVersion", + 40961: "ColorSpace", + 40962: "ExifImageWidth", + 40963: "ExifImageHeight", + 40964: "RelatedSoundFile", + 40965: "InteropOffset", + 41483: "FlashEnergy", + 41484: "SpatialFrequencyResponse", + 41485: "Noise", + 41486: "FocalPlaneXResolution", + 41487: "FocalPlaneYResolution", + 41488: "FocalPlaneResolutionUnit", + 41489: "ImageNumber", + 41490: "SecurityClassification", + 41491: "ImageHistory", + 41492: "SubjectLocation", + 41493: "ExposureIndex", + 41494: "TIFF-EPStandardID", + 41495: "SensingMethod", + 41728: "FileSource", + 41729: "SceneType", + 41730: "CFAPattern", + 41985: "CustomRendered", + 41986: "ExposureMode", + 41987: "WhiteBalance", + 41988: "DigitalZoomRatio", + 41989: "FocalLengthIn35mmFormat", + 41990: "SceneCaptureType", + 41991: "GainControl", + 41992: "Contrast", + 41993: "Saturation", + 41994: "Sharpness", + 41995: "DeviceSettingDescription", + 41996: "SubjectDistanceRange", + 42016: "ImageUniqueID", + 42032: "OwnerName", + 42033: "SerialNumber", + 42034: "LensInfo", + 42035: "LensMake", + 42036: "LensModel", + 42037: "LensSerialNumber", + 42112: "GDALMetadata", + 42113: "GDALNoData", + 42240: "Gamma", + 44992: "ExpandSoftware", + 44993: "ExpandLens", + 44994: "ExpandFilm", + 44995: "ExpandFilterLens", + 44996: "ExpandScanner", + 44997: "ExpandFlashLamp", + 48129: "PixelFormat", + 48130: "Transformation", + 48131: "Uncompressed", + 48132: "ImageType", + 48256: "ImageWidth", + 48257: "ImageHeight", + 48258: "WidthResolution", + 48259: "HeightResolution", + 48320: "ImageOffset", + 48321: "ImageByteCount", + 48322: "AlphaOffset", + 48323: "AlphaByteCount", + 48324: "ImageDataDiscard", + 48325: "AlphaDataDiscard", + 50215: "OceScanjobDesc", + 50216: "OceApplicationSelector", + 50217: "OceIDNumber", + 50218: "OceImageLogic", + 50255: "Annotations", + 50341: "PrintIM", + 50560: "USPTOOriginalContentType", + 50706: "DNGVersion", + 50707: "DNGBackwardVersion", + 50708: "UniqueCameraModel", + 50709: "LocalizedCameraModel", + 50710: "CFAPlaneColor", + 50711: "CFALayout", + 50712: "LinearizationTable", + 50713: "BlackLevelRepeatDim", + 50714: "BlackLevel", + 50715: "BlackLevelDeltaH", + 50716: "BlackLevelDeltaV", + 50717: "WhiteLevel", + 50718: "DefaultScale", + 50719: "DefaultCropOrigin", + 50720: "DefaultCropSize", + 50721: "ColorMatrix1", + 50722: "ColorMatrix2", + 50723: "CameraCalibration1", + 50724: "CameraCalibration2", + 50725: "ReductionMatrix1", + 50726: "ReductionMatrix2", + 50727: "AnalogBalance", + 50728: "AsShotNeutral", + 50729: "AsShotWhiteXY", + 50730: "BaselineExposure", + 50731: "BaselineNoise", + 50732: "BaselineSharpness", + 50733: "BayerGreenSplit", + 50734: "LinearResponseLimit", + 50735: "CameraSerialNumber", + 50736: "DNGLensInfo", + 50737: "ChromaBlurRadius", + 50738: "AntiAliasStrength", + 50739: "ShadowScale", + 50740: "DNGPrivateData", + 50741: "MakerNoteSafety", + 50752: "RawImageSegmentation", + 50778: "CalibrationIlluminant1", + 50779: "CalibrationIlluminant2", + 50780: "BestQualityScale", + 50781: "RawDataUniqueID", + 50784: "AliasLayerMetadata", + 50827: "OriginalRawFileName", + 50828: "OriginalRawFileData", + 50829: "ActiveArea", + 50830: "MaskedAreas", + 50831: "AsShotICCProfile", + 50832: "AsShotPreProfileMatrix", + 50833: "CurrentICCProfile", + 50834: "CurrentPreProfileMatrix", + 50879: "ColorimetricReference", + 50898: "PanasonicTitle", + 50899: "PanasonicTitle2", + 50931: "CameraCalibrationSig", + 50932: "ProfileCalibrationSig", + 50933: "ProfileIFD", + 50934: "AsShotProfileName", + 50935: "NoiseReductionApplied", + 50936: "ProfileName", + 50937: "ProfileHueSatMapDims", + 50938: "ProfileHueSatMapData1", + 50939: "ProfileHueSatMapData2", + 50940: "ProfileToneCurve", + 50941: "ProfileEmbedPolicy", + 50942: "ProfileCopyright", + 50964: "ForwardMatrix1", + 50965: "ForwardMatrix2", + 50966: "PreviewApplicationName", + 50967: "PreviewApplicationVersion", + 50968: "PreviewSettingsName", + 50969: "PreviewSettingsDigest", + 50970: "PreviewColorSpace", + 50971: "PreviewDateTime", + 50972: "RawImageDigest", + 50973: "OriginalRawFileDigest", + 50974: "SubTileBlockSize", + 50975: "RowInterleaveFactor", + 50981: "ProfileLookTableDims", + 50982: "ProfileLookTableData", + 51008: "OpcodeList1", + 51009: "OpcodeList2", + 51022: "OpcodeList3", + 51041: "NoiseProfile", + 51043: "TimeCodes", + 51044: "FrameRate", + 51058: "TStop", + 51081: "ReelName", + 51089: "OriginalDefaultFinalSize", + 51090: "OriginalBestQualitySize", + 51091: "OriginalDefaultCropSize", + 51105: "CameraLabel", + 51107: "ProfileHueSatMapEncoding", + 51108: "ProfileLookTableEncoding", + 51109: "BaselineExposureOffset", + 51110: "DefaultBlackRender", + 51111: "NewRawImageDigest", + 51112: "RawToPreviewGain", + 51125: "DefaultUserCrop", + 59932: "Padding", + 59933: "OffsetSchema", + 65e3: "OwnerName", + 65001: "SerialNumber", + 65002: "Lens", + 65024: "KDC_IFD", + 65100: "RawFile", + 65101: "Converter", + 65102: "WhiteBalance", + 65105: "Exposure", + 65106: "Shadows", + 65107: "Brightness", + 65108: "Contrast", + 65109: "Saturation", + 65110: "Sharpness", + 65111: "Smoothness", + 65112: "MoireFilter" + }, + gps: { + 0: "GPSVersionID", + 1: "GPSLatitudeRef", + 2: "GPSLatitude", + 3: "GPSLongitudeRef", + 4: "GPSLongitude", + 5: "GPSAltitudeRef", + 6: "GPSAltitude", + 7: "GPSTimeStamp", + 8: "GPSSatellites", + 9: "GPSStatus", + 10: "GPSMeasureMode", + 11: "GPSDOP", + 12: "GPSSpeedRef", + 13: "GPSSpeed", + 14: "GPSTrackRef", + 15: "GPSTrack", + 16: "GPSImgDirectionRef", + 17: "GPSImgDirection", + 18: "GPSMapDatum", + 19: "GPSDestLatitudeRef", + 20: "GPSDestLatitude", + 21: "GPSDestLongitudeRef", + 22: "GPSDestLongitude", + 23: "GPSDestBearingRef", + 24: "GPSDestBearing", + 25: "GPSDestDistanceRef", + 26: "GPSDestDistance", + 27: "GPSProcessingMethod", + 28: "GPSAreaInformation", + 29: "GPSDateStamp", + 30: "GPSDifferential", + 31: "GPSHPositioningError" + } + }; + } +}); + +// ../node_modules/exif-parser/lib/parser.js +var require_parser2 = __commonJS({ + "../node_modules/exif-parser/lib/parser.js"(exports2, module2) { + "use strict"; + var jpeg2 = require_jpeg(); + var exif = require_exif(); + var simplify = require_simplify(); + function ExifResult(startMarker, tags, imageSize, thumbnailOffset, thumbnailLength, thumbnailType, app1Offset) { + this.startMarker = startMarker; + this.tags = tags; + this.imageSize = imageSize; + this.thumbnailOffset = thumbnailOffset; + this.thumbnailLength = thumbnailLength; + this.thumbnailType = thumbnailType; + this.app1Offset = app1Offset; + } + ExifResult.prototype = { + hasThumbnail: function(mime2) { + if (!this.thumbnailOffset || !this.thumbnailLength) { + return false; + } + if (typeof mime2 !== "string") { + return true; + } + if (mime2.toLowerCase().trim() === "image/jpeg") { + return this.thumbnailType === 6; + } + if (mime2.toLowerCase().trim() === "image/tiff") { + return this.thumbnailType === 1; + } + return false; + }, + getThumbnailOffset: function() { + return this.app1Offset + 6 + this.thumbnailOffset; + }, + getThumbnailLength: function() { + return this.thumbnailLength; + }, + getThumbnailBuffer: function() { + return this._getThumbnailStream().nextBuffer(this.thumbnailLength); + }, + _getThumbnailStream: function() { + return this.startMarker.openWithOffset(this.getThumbnailOffset()); + }, + getImageSize: function() { + return this.imageSize; + }, + getThumbnailSize: function() { + var stream3 = this._getThumbnailStream(), size; + jpeg2.parseSections(stream3, function(sectionType, sectionStream) { + if (jpeg2.getSectionName(sectionType).name === "SOF") { + size = jpeg2.getSizeFromSOFSection(sectionStream); + } + }); + return size; + } + }; + function Parser(stream3) { + this.stream = stream3; + this.flags = { + readBinaryTags: false, + resolveTagNames: true, + simplifyValues: true, + imageSize: true, + hidePointers: true, + returnTags: true + }; + } + Parser.prototype = { + enableBinaryFields: function(enable) { + this.flags.readBinaryTags = !!enable; + return this; + }, + enablePointers: function(enable) { + this.flags.hidePointers = !enable; + return this; + }, + enableTagNames: function(enable) { + this.flags.resolveTagNames = !!enable; + return this; + }, + enableImageSize: function(enable) { + this.flags.imageSize = !!enable; + return this; + }, + enableReturnTags: function(enable) { + this.flags.returnTags = !!enable; + return this; + }, + enableSimpleValues: function(enable) { + this.flags.simplifyValues = !!enable; + return this; + }, + parse: function() { + var start = this.stream.mark(), stream3 = start.openWithOffset(0), flags = this.flags, tags, imageSize, thumbnailOffset, thumbnailLength, thumbnailType, app1Offset, tagNames, getTagValue, setTagValue; + if (flags.resolveTagNames) { + tagNames = require_exif_tags(); + } + if (flags.resolveTagNames) { + tags = {}; + getTagValue = function(t12) { + return tags[t12.name]; + }; + setTagValue = function(t12, value) { + tags[t12.name] = value; + }; + } else { + tags = []; + getTagValue = function(t12) { + var i6; + for (i6 = 0; i6 < tags.length; ++i6) { + if (tags[i6].type === t12.type && tags[i6].section === t12.section) { + return tags.value; + } + } + }; + setTagValue = function(t12, value) { + var i6; + for (i6 = 0; i6 < tags.length; ++i6) { + if (tags[i6].type === t12.type && tags[i6].section === t12.section) { + tags.value = value; + return; + } + } + }; + } + jpeg2.parseSections(stream3, function(sectionType, sectionStream) { + var validExifHeaders, sectionOffset = sectionStream.offsetFrom(start); + if (sectionType === 225) { + validExifHeaders = exif.parseTags(sectionStream, function(ifdSection, tagType, value, format2) { + if (!flags.readBinaryTags && format2 === 7) { + return; + } + if (tagType === 513) { + thumbnailOffset = value[0]; + if (flags.hidePointers) { + return; + } + } else if (tagType === 514) { + thumbnailLength = value[0]; + if (flags.hidePointers) { + return; + } + } else if (tagType === 259) { + thumbnailType = value[0]; + if (flags.hidePointers) { + return; + } + } + if (!flags.returnTags) { + return; + } + if (flags.simplifyValues) { + value = simplify.simplifyValue(value, format2); + } + if (flags.resolveTagNames) { + var sectionTagNames = ifdSection === exif.GPSIFD ? tagNames.gps : tagNames.exif; + var name = sectionTagNames[tagType]; + if (!name) { + name = tagNames.exif[tagType]; + } + if (!tags.hasOwnProperty(name)) { + tags[name] = value; + } + } else { + tags.push({ + section: ifdSection, + type: tagType, + value + }); + } + }); + if (validExifHeaders) { + app1Offset = sectionOffset; + } + } else if (flags.imageSize && jpeg2.getSectionName(sectionType).name === "SOF") { + imageSize = jpeg2.getSizeFromSOFSection(sectionStream); + } + }); + if (flags.simplifyValues) { + simplify.castDegreeValues(getTagValue, setTagValue); + simplify.castDateValues(getTagValue, setTagValue); + } + return new ExifResult(start, tags, imageSize, thumbnailOffset, thumbnailLength, thumbnailType, app1Offset); + } + }; + module2.exports = Parser; + } +}); + +// ../node_modules/exif-parser/lib/dom-bufferstream.js +var require_dom_bufferstream = __commonJS({ + "../node_modules/exif-parser/lib/dom-bufferstream.js"(exports2, module2) { + "use strict"; + function DOMBufferStream(arrayBuffer, offset, length, bigEndian, global2, parentOffset) { + this.global = global2; + offset = offset || 0; + length = length || arrayBuffer.byteLength - offset; + this.arrayBuffer = arrayBuffer.slice(offset, offset + length); + this.view = new global2.DataView(this.arrayBuffer, 0, this.arrayBuffer.byteLength); + this.setBigEndian(bigEndian); + this.offset = 0; + this.parentOffset = (parentOffset || 0) + offset; + } + DOMBufferStream.prototype = { + setBigEndian: function(bigEndian) { + this.littleEndian = !bigEndian; + }, + nextUInt8: function() { + var value = this.view.getUint8(this.offset); + this.offset += 1; + return value; + }, + nextInt8: function() { + var value = this.view.getInt8(this.offset); + this.offset += 1; + return value; + }, + nextUInt16: function() { + var value = this.view.getUint16(this.offset, this.littleEndian); + this.offset += 2; + return value; + }, + nextUInt32: function() { + var value = this.view.getUint32(this.offset, this.littleEndian); + this.offset += 4; + return value; + }, + nextInt16: function() { + var value = this.view.getInt16(this.offset, this.littleEndian); + this.offset += 2; + return value; + }, + nextInt32: function() { + var value = this.view.getInt32(this.offset, this.littleEndian); + this.offset += 4; + return value; + }, + nextFloat: function() { + var value = this.view.getFloat32(this.offset, this.littleEndian); + this.offset += 4; + return value; + }, + nextDouble: function() { + var value = this.view.getFloat64(this.offset, this.littleEndian); + this.offset += 8; + return value; + }, + nextBuffer: function(length) { + var value = this.arrayBuffer.slice(this.offset, this.offset + length); + this.offset += length; + return value; + }, + remainingLength: function() { + return this.arrayBuffer.byteLength - this.offset; + }, + nextString: function(length) { + var value = this.arrayBuffer.slice(this.offset, this.offset + length); + value = String.fromCharCode.apply(null, new this.global.Uint8Array(value)); + this.offset += length; + return value; + }, + mark: function() { + var self2 = this; + return { + openWithOffset: function(offset) { + offset = (offset || 0) + this.offset; + return new DOMBufferStream(self2.arrayBuffer, offset, self2.arrayBuffer.byteLength - offset, !self2.littleEndian, self2.global, self2.parentOffset); + }, + offset: this.offset, + getParentOffset: function() { + return self2.parentOffset; + } + }; + }, + offsetFrom: function(marker) { + return this.parentOffset + this.offset - (marker.offset + marker.getParentOffset()); + }, + skip: function(amount) { + this.offset += amount; + }, + branch: function(offset, length) { + length = typeof length === "number" ? length : this.arrayBuffer.byteLength - (this.offset + offset); + return new DOMBufferStream(this.arrayBuffer, this.offset + offset, length, !this.littleEndian, this.global, this.parentOffset); + } + }; + module2.exports = DOMBufferStream; + } +}); + +// ../node_modules/exif-parser/lib/bufferstream.js +var require_bufferstream = __commonJS({ + "../node_modules/exif-parser/lib/bufferstream.js"(exports2, module2) { + "use strict"; + function BufferStream(buffer, offset, length, bigEndian) { + this.buffer = buffer; + this.offset = offset || 0; + length = typeof length === "number" ? length : buffer.length; + this.endPosition = this.offset + length; + this.setBigEndian(bigEndian); + } + BufferStream.prototype = { + setBigEndian: function(bigEndian) { + this.bigEndian = !!bigEndian; + }, + nextUInt8: function() { + var value = this.buffer.readUInt8(this.offset); + this.offset += 1; + return value; + }, + nextInt8: function() { + var value = this.buffer.readInt8(this.offset); + this.offset += 1; + return value; + }, + nextUInt16: function() { + var value = this.bigEndian ? this.buffer.readUInt16BE(this.offset) : this.buffer.readUInt16LE(this.offset); + this.offset += 2; + return value; + }, + nextUInt32: function() { + var value = this.bigEndian ? this.buffer.readUInt32BE(this.offset) : this.buffer.readUInt32LE(this.offset); + this.offset += 4; + return value; + }, + nextInt16: function() { + var value = this.bigEndian ? this.buffer.readInt16BE(this.offset) : this.buffer.readInt16LE(this.offset); + this.offset += 2; + return value; + }, + nextInt32: function() { + var value = this.bigEndian ? this.buffer.readInt32BE(this.offset) : this.buffer.readInt32LE(this.offset); + this.offset += 4; + return value; + }, + nextFloat: function() { + var value = this.bigEndian ? this.buffer.readFloatBE(this.offset) : this.buffer.readFloatLE(this.offset); + this.offset += 4; + return value; + }, + nextDouble: function() { + var value = this.bigEndian ? this.buffer.readDoubleBE(this.offset) : this.buffer.readDoubleLE(this.offset); + this.offset += 8; + return value; + }, + nextBuffer: function(length) { + var value = this.buffer.slice(this.offset, this.offset + length); + this.offset += length; + return value; + }, + remainingLength: function() { + return this.endPosition - this.offset; + }, + nextString: function(length) { + var value = this.buffer.toString("utf8", this.offset, this.offset + length); + this.offset += length; + return value; + }, + mark: function() { + var self2 = this; + return { + openWithOffset: function(offset) { + offset = (offset || 0) + this.offset; + return new BufferStream(self2.buffer, offset, self2.endPosition - offset, self2.bigEndian); + }, + offset: this.offset + }; + }, + offsetFrom: function(marker) { + return this.offset - marker.offset; + }, + skip: function(amount) { + this.offset += amount; + }, + branch: function(offset, length) { + length = typeof length === "number" ? length : this.endPosition - (this.offset + offset); + return new BufferStream(this.buffer, this.offset + offset, length, this.bigEndian); + } + }; + module2.exports = BufferStream; + } +}); + +// ../node_modules/exif-parser/index.js +var require_exif_parser = __commonJS({ + "../node_modules/exif-parser/index.js"(exports2, module2) { + "use strict"; + var Parser = require_parser2(); + function getGlobal() { + return (1, eval)("this"); + } + module2.exports = { + create: function(buffer, global2) { + global2 = global2 || getGlobal(); + if (buffer instanceof global2.ArrayBuffer) { + var DOMBufferStream = require_dom_bufferstream(); + return new Parser(new DOMBufferStream(buffer, 0, buffer.byteLength, true, global2)); + } else { + var NodeBufferStream = require_bufferstream(); + return new Parser(new NodeBufferStream(buffer, 0, buffer.length, true)); + } + } + }; + } +}); + +// ../node_modules/any-base/src/converter.js +var require_converter = __commonJS({ + "../node_modules/any-base/src/converter.js"(exports2, module2) { + "use strict"; + function Converter(srcAlphabet, dstAlphabet) { + if (!srcAlphabet || !dstAlphabet || !srcAlphabet.length || !dstAlphabet.length) { + throw new Error("Bad alphabet"); + } + this.srcAlphabet = srcAlphabet; + this.dstAlphabet = dstAlphabet; + } + Converter.prototype.convert = function(number) { + var i6, divide, newlen, numberMap = {}, fromBase = this.srcAlphabet.length, toBase = this.dstAlphabet.length, length = number.length, result = typeof number === "string" ? "" : []; + if (!this.isValid(number)) { + throw new Error('Number "' + number + '" contains of non-alphabetic digits (' + this.srcAlphabet + ")"); + } + if (this.srcAlphabet === this.dstAlphabet) { + return number; + } + for (i6 = 0; i6 < length; i6++) { + numberMap[i6] = this.srcAlphabet.indexOf(number[i6]); + } + do { + divide = 0; + newlen = 0; + for (i6 = 0; i6 < length; i6++) { + divide = divide * fromBase + numberMap[i6]; + if (divide >= toBase) { + numberMap[newlen++] = parseInt(divide / toBase, 10); + divide = divide % toBase; + } else if (newlen > 0) { + numberMap[newlen++] = 0; + } + } + length = newlen; + result = this.dstAlphabet.slice(divide, divide + 1).concat(result); + } while (newlen !== 0); + return result; + }; + Converter.prototype.isValid = function(number) { + var i6 = 0; + for (; i6 < number.length; ++i6) { + if (this.srcAlphabet.indexOf(number[i6]) === -1) { + return false; + } + } + return true; + }; + module2.exports = Converter; + } +}); + +// ../node_modules/any-base/index.js +var require_any_base = __commonJS({ + "../node_modules/any-base/index.js"(exports2, module2) { + "use strict"; + var Converter = require_converter(); + function anyBase2(srcAlphabet, dstAlphabet) { + var converter = new Converter(srcAlphabet, dstAlphabet); + return function(number) { + return converter.convert(number); + }; + } + anyBase2.BIN = "01"; + anyBase2.OCT = "01234567"; + anyBase2.DEC = "0123456789"; + anyBase2.HEX = "0123456789abcdef"; + module2.exports = anyBase2; + } +}); + +// ../node_modules/parse-bmfont-ascii/index.js +var require_parse_bmfont_ascii = __commonJS({ + "../node_modules/parse-bmfont-ascii/index.js"(exports2, module2) { + "use strict"; + module2.exports = function parseBMFontAscii(data) { + if (!data) + throw new Error("no data provided"); + data = data.toString().trim(); + var output = { + pages: [], + chars: [], + kernings: [] + }; + var lines = data.split(/\r\n?|\n/g); + if (lines.length === 0) + throw new Error("no data in BMFont file"); + for (var i6 = 0; i6 < lines.length; i6++) { + var lineData = splitLine(lines[i6], i6); + if (!lineData) + continue; + if (lineData.key === "page") { + if (typeof lineData.data.id !== "number") + throw new Error("malformed file at line " + i6 + " -- needs page id=N"); + if (typeof lineData.data.file !== "string") + throw new Error("malformed file at line " + i6 + ' -- needs page file="path"'); + output.pages[lineData.data.id] = lineData.data.file; + } else if (lineData.key === "chars" || lineData.key === "kernings") { + } else if (lineData.key === "char") { + output.chars.push(lineData.data); + } else if (lineData.key === "kerning") { + output.kernings.push(lineData.data); + } else { + output[lineData.key] = lineData.data; + } + } + return output; + }; + function splitLine(line, idx) { + line = line.replace(/\t+/g, " ").trim(); + if (!line) + return null; + var space = line.indexOf(" "); + if (space === -1) + throw new Error("no named row at line " + idx); + var key = line.substring(0, space); + line = line.substring(space + 1); + line = line.replace(/letter=[\'\"]\S+[\'\"]/gi, ""); + line = line.split("="); + line = line.map(function(str) { + return str.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g); + }); + var data = []; + for (var i6 = 0; i6 < line.length; i6++) { + var dt = line[i6]; + if (i6 === 0) { + data.push({ + key: dt[0], + data: "" + }); + } else if (i6 === line.length - 1) { + data[data.length - 1].data = parseData(dt[0]); + } else { + data[data.length - 1].data = parseData(dt[0]); + data.push({ + key: dt[1], + data: "" + }); + } + } + var out = { + key, + data: {} + }; + data.forEach(function(v7) { + out.data[v7.key] = v7.data; + }); + return out; + } + function parseData(data) { + if (!data || data.length === 0) + return ""; + if (data.indexOf('"') === 0 || data.indexOf("'") === 0) + return data.substring(1, data.length - 1); + if (data.indexOf(",") !== -1) + return parseIntList(data); + return parseInt(data, 10); + } + function parseIntList(data) { + return data.split(",").map(function(val) { + return parseInt(val, 10); + }); + } + } +}); + +// ../node_modules/xml2js/lib/defaults.js +var require_defaults = __commonJS({ + "../node_modules/xml2js/lib/defaults.js"(exports2) { + "use strict"; + (function() { + exports2.defaults = { + "0.1": { + explicitCharkey: false, + trim: true, + normalize: true, + normalizeTags: false, + attrkey: "@", + charkey: "#", + explicitArray: false, + ignoreAttrs: false, + mergeAttrs: false, + explicitRoot: false, + validator: null, + xmlns: false, + explicitChildren: false, + childkey: "@@", + charsAsChildren: false, + includeWhiteChars: false, + async: false, + strict: true, + attrNameProcessors: null, + attrValueProcessors: null, + tagNameProcessors: null, + valueProcessors: null, + emptyTag: "" + }, + "0.2": { + explicitCharkey: false, + trim: false, + normalize: false, + normalizeTags: false, + attrkey: "$", + charkey: "_", + explicitArray: true, + ignoreAttrs: false, + mergeAttrs: false, + explicitRoot: true, + validator: null, + xmlns: false, + explicitChildren: false, + preserveChildrenOrder: false, + childkey: "$$", + charsAsChildren: false, + includeWhiteChars: false, + async: false, + strict: true, + attrNameProcessors: null, + attrValueProcessors: null, + tagNameProcessors: null, + valueProcessors: null, + rootName: "root", + xmldec: { + "version": "1.0", + "encoding": "UTF-8", + "standalone": true + }, + doctype: null, + renderOpts: { + "pretty": true, + "indent": " ", + "newline": "\n" + }, + headless: false, + chunkSize: 1e4, + emptyTag: "", + cdata: false + } + }; + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/Utility.js +var require_Utility = __commonJS({ + "../node_modules/xmlbuilder/lib/Utility.js"(exports2, module2) { + "use strict"; + (function() { + var assign, getValue, isArray, isEmpty, isFunction2, isObject2, isPlainObject4, slice = [].slice, hasProp = {}.hasOwnProperty; + assign = function() { + var i6, key, len, source, sources, target; + target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; + if (isFunction2(Object.assign)) { + Object.assign.apply(null, arguments); + } else { + for (i6 = 0, len = sources.length; i6 < len; i6++) { + source = sources[i6]; + if (source != null) { + for (key in source) { + if (!hasProp.call(source, key)) continue; + target[key] = source[key]; + } + } + } + } + return target; + }; + isFunction2 = function(val) { + return !!val && Object.prototype.toString.call(val) === "[object Function]"; + }; + isObject2 = function(val) { + var ref; + return !!val && ((ref = typeof val) === "function" || ref === "object"); + }; + isArray = function(val) { + if (isFunction2(Array.isArray)) { + return Array.isArray(val); + } else { + return Object.prototype.toString.call(val) === "[object Array]"; + } + }; + isEmpty = function(val) { + var key; + if (isArray(val)) { + return !val.length; + } else { + for (key in val) { + if (!hasProp.call(val, key)) continue; + return false; + } + return true; + } + }; + isPlainObject4 = function(val) { + var ctor, proto; + return isObject2(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object); + }; + getValue = function(obj2) { + if (isFunction2(obj2.valueOf)) { + return obj2.valueOf(); + } else { + return obj2; + } + }; + module2.exports.assign = assign; + module2.exports.isFunction = isFunction2; + module2.exports.isObject = isObject2; + module2.exports.isArray = isArray; + module2.exports.isEmpty = isEmpty; + module2.exports.isPlainObject = isPlainObject4; + module2.exports.getValue = getValue; + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDOMImplementation.js +var require_XMLDOMImplementation = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDOMImplementation.js"(exports2, module2) { + "use strict"; + (function() { + var XMLDOMImplementation; + module2.exports = XMLDOMImplementation = (function() { + function XMLDOMImplementation2() { + } + XMLDOMImplementation2.prototype.hasFeature = function(feature, version) { + return true; + }; + XMLDOMImplementation2.prototype.createDocumentType = function(qualifiedName, publicId, systemId) { + throw new Error("This DOM method is not implemented."); + }; + XMLDOMImplementation2.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) { + throw new Error("This DOM method is not implemented."); + }; + XMLDOMImplementation2.prototype.createHTMLDocument = function(title) { + throw new Error("This DOM method is not implemented."); + }; + XMLDOMImplementation2.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented."); + }; + return XMLDOMImplementation2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDOMErrorHandler.js +var require_XMLDOMErrorHandler = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDOMErrorHandler.js"(exports2, module2) { + "use strict"; + (function() { + var XMLDOMErrorHandler; + module2.exports = XMLDOMErrorHandler = (function() { + function XMLDOMErrorHandler2() { + } + XMLDOMErrorHandler2.prototype.handleError = function(error2) { + throw new Error(error2); + }; + return XMLDOMErrorHandler2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDOMStringList.js +var require_XMLDOMStringList = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDOMStringList.js"(exports2, module2) { + "use strict"; + (function() { + var XMLDOMStringList; + module2.exports = XMLDOMStringList = (function() { + function XMLDOMStringList2(arr) { + this.arr = arr || []; + } + Object.defineProperty(XMLDOMStringList2.prototype, "length", { + get: function() { + return this.arr.length; + } + }); + XMLDOMStringList2.prototype.item = function(index) { + return this.arr[index] || null; + }; + XMLDOMStringList2.prototype.contains = function(str) { + return this.arr.indexOf(str) !== -1; + }; + return XMLDOMStringList2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDOMConfiguration.js +var require_XMLDOMConfiguration = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDOMConfiguration.js"(exports2, module2) { + "use strict"; + (function() { + var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; + XMLDOMErrorHandler = require_XMLDOMErrorHandler(); + XMLDOMStringList = require_XMLDOMStringList(); + module2.exports = XMLDOMConfiguration = (function() { + function XMLDOMConfiguration2() { + var clonedSelf; + this.defaultParams = { + "canonical-form": false, + "cdata-sections": false, + "comments": false, + "datatype-normalization": false, + "element-content-whitespace": true, + "entities": true, + "error-handler": new XMLDOMErrorHandler(), + "infoset": true, + "validate-if-schema": false, + "namespaces": true, + "namespace-declarations": true, + "normalize-characters": false, + "schema-location": "", + "schema-type": "", + "split-cdata-sections": true, + "validate": false, + "well-formed": true + }; + this.params = clonedSelf = Object.create(this.defaultParams); + } + Object.defineProperty(XMLDOMConfiguration2.prototype, "parameterNames", { + get: function() { + return new XMLDOMStringList(Object.keys(this.defaultParams)); + } + }); + XMLDOMConfiguration2.prototype.getParameter = function(name) { + if (this.params.hasOwnProperty(name)) { + return this.params[name]; + } else { + return null; + } + }; + XMLDOMConfiguration2.prototype.canSetParameter = function(name, value) { + return true; + }; + XMLDOMConfiguration2.prototype.setParameter = function(name, value) { + if (value != null) { + return this.params[name] = value; + } else { + return delete this.params[name]; + } + }; + return XMLDOMConfiguration2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/NodeType.js +var require_NodeType = __commonJS({ + "../node_modules/xmlbuilder/lib/NodeType.js"(exports2, module2) { + "use strict"; + (function() { + module2.exports = { + Element: 1, + Attribute: 2, + Text: 3, + CData: 4, + EntityReference: 5, + EntityDeclaration: 6, + ProcessingInstruction: 7, + Comment: 8, + Document: 9, + DocType: 10, + DocumentFragment: 11, + NotationDeclaration: 12, + Declaration: 201, + Raw: 202, + AttributeDeclaration: 203, + ElementDeclaration: 204, + Dummy: 205 + }; + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLAttribute.js +var require_XMLAttribute = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLAttribute.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLAttribute, XMLNode; + NodeType = require_NodeType(); + XMLNode = require_XMLNode(); + module2.exports = XMLAttribute = (function() { + function XMLAttribute2(parent, name, value) { + this.parent = parent; + if (this.parent) { + this.options = this.parent.options; + this.stringify = this.parent.stringify; + } + if (name == null) { + throw new Error("Missing attribute name. " + this.debugInfo(name)); + } + this.name = this.stringify.name(name); + this.value = this.stringify.attValue(value); + this.type = NodeType.Attribute; + this.isId = false; + this.schemaTypeInfo = null; + } + Object.defineProperty(XMLAttribute2.prototype, "nodeType", { + get: function() { + return this.type; + } + }); + Object.defineProperty(XMLAttribute2.prototype, "ownerElement", { + get: function() { + return this.parent; + } + }); + Object.defineProperty(XMLAttribute2.prototype, "textContent", { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ""; + } + }); + Object.defineProperty(XMLAttribute2.prototype, "namespaceURI", { + get: function() { + return ""; + } + }); + Object.defineProperty(XMLAttribute2.prototype, "prefix", { + get: function() { + return ""; + } + }); + Object.defineProperty(XMLAttribute2.prototype, "localName", { + get: function() { + return this.name; + } + }); + Object.defineProperty(XMLAttribute2.prototype, "specified", { + get: function() { + return true; + } + }); + XMLAttribute2.prototype.clone = function() { + return Object.create(this); + }; + XMLAttribute2.prototype.toString = function(options) { + return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); + }; + XMLAttribute2.prototype.debugInfo = function(name) { + name = name || this.name; + if (name == null) { + return "parent: <" + this.parent.name + ">"; + } else { + return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; + } + }; + XMLAttribute2.prototype.isEqualNode = function(node) { + if (node.namespaceURI !== this.namespaceURI) { + return false; + } + if (node.prefix !== this.prefix) { + return false; + } + if (node.localName !== this.localName) { + return false; + } + if (node.value !== this.value) { + return false; + } + return true; + }; + return XMLAttribute2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLNamedNodeMap.js +var require_XMLNamedNodeMap = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLNamedNodeMap.js"(exports2, module2) { + "use strict"; + (function() { + var XMLNamedNodeMap; + module2.exports = XMLNamedNodeMap = (function() { + function XMLNamedNodeMap2(nodes) { + this.nodes = nodes; + } + Object.defineProperty(XMLNamedNodeMap2.prototype, "length", { + get: function() { + return Object.keys(this.nodes).length || 0; + } + }); + XMLNamedNodeMap2.prototype.clone = function() { + return this.nodes = null; + }; + XMLNamedNodeMap2.prototype.getNamedItem = function(name) { + return this.nodes[name]; + }; + XMLNamedNodeMap2.prototype.setNamedItem = function(node) { + var oldNode; + oldNode = this.nodes[node.nodeName]; + this.nodes[node.nodeName] = node; + return oldNode || null; + }; + XMLNamedNodeMap2.prototype.removeNamedItem = function(name) { + var oldNode; + oldNode = this.nodes[name]; + delete this.nodes[name]; + return oldNode || null; + }; + XMLNamedNodeMap2.prototype.item = function(index) { + return this.nodes[Object.keys(this.nodes)[index]] || null; + }; + XMLNamedNodeMap2.prototype.getNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); + }; + XMLNamedNodeMap2.prototype.setNamedItemNS = function(node) { + throw new Error("This DOM method is not implemented."); + }; + XMLNamedNodeMap2.prototype.removeNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); + }; + return XMLNamedNodeMap2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLElement.js +var require_XMLElement = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLElement.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction2, isObject2, ref, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + ref = require_Utility(), isObject2 = ref.isObject, isFunction2 = ref.isFunction, getValue = ref.getValue; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + XMLAttribute = require_XMLAttribute(); + XMLNamedNodeMap = require_XMLNamedNodeMap(); + module2.exports = XMLElement = (function(superClass) { + extend(XMLElement2, superClass); + function XMLElement2(parent, name, attributes) { + var child2, j6, len, ref1; + XMLElement2.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing element name. " + this.debugInfo()); + } + this.name = this.stringify.name(name); + this.type = NodeType.Element; + this.attribs = {}; + this.schemaTypeInfo = null; + if (attributes != null) { + this.attribute(attributes); + } + if (parent.type === NodeType.Document) { + this.isRoot = true; + this.documentObject = parent; + parent.rootObject = this; + if (parent.children) { + ref1 = parent.children; + for (j6 = 0, len = ref1.length; j6 < len; j6++) { + child2 = ref1[j6]; + if (child2.type === NodeType.DocType) { + child2.name = this.name; + break; + } + } + } + } + } + Object.defineProperty(XMLElement2.prototype, "tagName", { + get: function() { + return this.name; + } + }); + Object.defineProperty(XMLElement2.prototype, "namespaceURI", { + get: function() { + return ""; + } + }); + Object.defineProperty(XMLElement2.prototype, "prefix", { + get: function() { + return ""; + } + }); + Object.defineProperty(XMLElement2.prototype, "localName", { + get: function() { + return this.name; + } + }); + Object.defineProperty(XMLElement2.prototype, "id", { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + Object.defineProperty(XMLElement2.prototype, "className", { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + Object.defineProperty(XMLElement2.prototype, "classList", { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + Object.defineProperty(XMLElement2.prototype, "attributes", { + get: function() { + if (!this.attributeMap || !this.attributeMap.nodes) { + this.attributeMap = new XMLNamedNodeMap(this.attribs); + } + return this.attributeMap; + } + }); + XMLElement2.prototype.clone = function() { + var att, attName, clonedSelf, ref1; + clonedSelf = Object.create(this); + if (clonedSelf.isRoot) { + clonedSelf.documentObject = null; + } + clonedSelf.attribs = {}; + ref1 = this.attribs; + for (attName in ref1) { + if (!hasProp.call(ref1, attName)) continue; + att = ref1[attName]; + clonedSelf.attribs[attName] = att.clone(); + } + clonedSelf.children = []; + this.children.forEach(function(child2) { + var clonedChild; + clonedChild = child2.clone(); + clonedChild.parent = clonedSelf; + return clonedSelf.children.push(clonedChild); + }); + return clonedSelf; + }; + XMLElement2.prototype.attribute = function(name, value) { + var attName, attValue; + if (name != null) { + name = getValue(name); + } + if (isObject2(name)) { + for (attName in name) { + if (!hasProp.call(name, attName)) continue; + attValue = name[attName]; + this.attribute(attName, attValue); + } + } else { + if (isFunction2(value)) { + value = value.apply(); + } + if (this.options.keepNullAttributes && value == null) { + this.attribs[name] = new XMLAttribute(this, name, ""); + } else if (value != null) { + this.attribs[name] = new XMLAttribute(this, name, value); + } + } + return this; + }; + XMLElement2.prototype.removeAttribute = function(name) { + var attName, j6, len; + if (name == null) { + throw new Error("Missing attribute name. " + this.debugInfo()); + } + name = getValue(name); + if (Array.isArray(name)) { + for (j6 = 0, len = name.length; j6 < len; j6++) { + attName = name[j6]; + delete this.attribs[attName]; + } + } else { + delete this.attribs[name]; + } + return this; + }; + XMLElement2.prototype.toString = function(options) { + return this.options.writer.element(this, this.options.writer.filterOptions(options)); + }; + XMLElement2.prototype.att = function(name, value) { + return this.attribute(name, value); + }; + XMLElement2.prototype.a = function(name, value) { + return this.attribute(name, value); + }; + XMLElement2.prototype.getAttribute = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].value; + } else { + return null; + } + }; + XMLElement2.prototype.setAttribute = function(name, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getAttributeNode = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name]; + } else { + return null; + } + }; + XMLElement2.prototype.setAttributeNode = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.removeAttributeNode = function(oldAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getElementsByTagName = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.removeAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getAttributeNodeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.setAttributeNodeNS = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.hasAttribute = function(name) { + return this.attribs.hasOwnProperty(name); + }; + XMLElement2.prototype.hasAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.setIdAttribute = function(name, isId) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].isId; + } else { + return isId; + } + }; + XMLElement2.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.setIdAttributeNode = function(idAttr, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLElement2.prototype.isEqualNode = function(node) { + var i6, j6, ref1; + if (!XMLElement2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.namespaceURI !== this.namespaceURI) { + return false; + } + if (node.prefix !== this.prefix) { + return false; + } + if (node.localName !== this.localName) { + return false; + } + if (node.attribs.length !== this.attribs.length) { + return false; + } + for (i6 = j6 = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j6 <= ref1 : j6 >= ref1; i6 = 0 <= ref1 ? ++j6 : --j6) { + if (!this.attribs[i6].isEqualNode(node.attribs[i6])) { + return false; + } + } + return true; + }; + return XMLElement2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLCharacterData.js +var require_XMLCharacterData = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLCharacterData.js"(exports2, module2) { + "use strict"; + (function() { + var XMLCharacterData, XMLNode, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + XMLNode = require_XMLNode(); + module2.exports = XMLCharacterData = (function(superClass) { + extend(XMLCharacterData2, superClass); + function XMLCharacterData2(parent) { + XMLCharacterData2.__super__.constructor.call(this, parent); + this.value = ""; + } + Object.defineProperty(XMLCharacterData2.prototype, "data", { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ""; + } + }); + Object.defineProperty(XMLCharacterData2.prototype, "length", { + get: function() { + return this.value.length; + } + }); + Object.defineProperty(XMLCharacterData2.prototype, "textContent", { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ""; + } + }); + XMLCharacterData2.prototype.clone = function() { + return Object.create(this); + }; + XMLCharacterData2.prototype.substringData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLCharacterData2.prototype.appendData = function(arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLCharacterData2.prototype.insertData = function(offset, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLCharacterData2.prototype.deleteData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLCharacterData2.prototype.replaceData = function(offset, count, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLCharacterData2.prototype.isEqualNode = function(node) { + if (!XMLCharacterData2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.data !== this.data) { + return false; + } + return true; + }; + return XMLCharacterData2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLCData.js +var require_XMLCData = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLCData.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLCData, XMLCharacterData, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + NodeType = require_NodeType(); + XMLCharacterData = require_XMLCharacterData(); + module2.exports = XMLCData = (function(superClass) { + extend(XMLCData2, superClass); + function XMLCData2(parent, text) { + XMLCData2.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing CDATA text. " + this.debugInfo()); + } + this.name = "#cdata-section"; + this.type = NodeType.CData; + this.value = this.stringify.cdata(text); + } + XMLCData2.prototype.clone = function() { + return Object.create(this); + }; + XMLCData2.prototype.toString = function(options) { + return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); + }; + return XMLCData2; + })(XMLCharacterData); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLComment.js +var require_XMLComment = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLComment.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLCharacterData, XMLComment, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + NodeType = require_NodeType(); + XMLCharacterData = require_XMLCharacterData(); + module2.exports = XMLComment = (function(superClass) { + extend(XMLComment2, superClass); + function XMLComment2(parent, text) { + XMLComment2.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing comment text. " + this.debugInfo()); + } + this.name = "#comment"; + this.type = NodeType.Comment; + this.value = this.stringify.comment(text); + } + XMLComment2.prototype.clone = function() { + return Object.create(this); + }; + XMLComment2.prototype.toString = function(options) { + return this.options.writer.comment(this, this.options.writer.filterOptions(options)); + }; + return XMLComment2; + })(XMLCharacterData); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDeclaration.js +var require_XMLDeclaration = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDeclaration.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDeclaration, XMLNode, isObject2, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + isObject2 = require_Utility().isObject; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + module2.exports = XMLDeclaration = (function(superClass) { + extend(XMLDeclaration2, superClass); + function XMLDeclaration2(parent, version, encoding, standalone) { + var ref; + XMLDeclaration2.__super__.constructor.call(this, parent); + if (isObject2(version)) { + ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone; + } + if (!version) { + version = "1.0"; + } + this.type = NodeType.Declaration; + this.version = this.stringify.xmlVersion(version); + if (encoding != null) { + this.encoding = this.stringify.xmlEncoding(encoding); + } + if (standalone != null) { + this.standalone = this.stringify.xmlStandalone(standalone); + } + } + XMLDeclaration2.prototype.toString = function(options) { + return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); + }; + return XMLDeclaration2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDTDAttList.js +var require_XMLDTDAttList = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDTDAttList.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDTDAttList, XMLNode, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + module2.exports = XMLDTDAttList = (function(superClass) { + extend(XMLDTDAttList2, superClass); + function XMLDTDAttList2(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { + XMLDTDAttList2.__super__.constructor.call(this, parent); + if (elementName == null) { + throw new Error("Missing DTD element name. " + this.debugInfo()); + } + if (attributeName == null) { + throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName)); + } + if (!attributeType) { + throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName)); + } + if (!defaultValueType) { + throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName)); + } + if (defaultValueType.indexOf("#") !== 0) { + defaultValueType = "#" + defaultValueType; + } + if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) { + throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName)); + } + if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) { + throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName)); + } + this.elementName = this.stringify.name(elementName); + this.type = NodeType.AttributeDeclaration; + this.attributeName = this.stringify.name(attributeName); + this.attributeType = this.stringify.dtdAttType(attributeType); + if (defaultValue) { + this.defaultValue = this.stringify.dtdAttDefault(defaultValue); + } + this.defaultValueType = defaultValueType; + } + XMLDTDAttList2.prototype.toString = function(options) { + return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); + }; + return XMLDTDAttList2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDTDEntity.js +var require_XMLDTDEntity = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDTDEntity.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDTDEntity, XMLNode, isObject2, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + isObject2 = require_Utility().isObject; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + module2.exports = XMLDTDEntity = (function(superClass) { + extend(XMLDTDEntity2, superClass); + function XMLDTDEntity2(parent, pe, name, value) { + XMLDTDEntity2.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing DTD entity name. " + this.debugInfo(name)); + } + if (value == null) { + throw new Error("Missing DTD entity value. " + this.debugInfo(name)); + } + this.pe = !!pe; + this.name = this.stringify.name(name); + this.type = NodeType.EntityDeclaration; + if (!isObject2(value)) { + this.value = this.stringify.dtdEntityValue(value); + this.internal = true; + } else { + if (!value.pubID && !value.sysID) { + throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name)); + } + if (value.pubID && !value.sysID) { + throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name)); + } + this.internal = false; + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); + } + if (value.sysID != null) { + this.sysID = this.stringify.dtdSysID(value.sysID); + } + if (value.nData != null) { + this.nData = this.stringify.dtdNData(value.nData); + } + if (this.pe && this.nData) { + throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name)); + } + } + } + Object.defineProperty(XMLDTDEntity2.prototype, "publicId", { + get: function() { + return this.pubID; + } + }); + Object.defineProperty(XMLDTDEntity2.prototype, "systemId", { + get: function() { + return this.sysID; + } + }); + Object.defineProperty(XMLDTDEntity2.prototype, "notationName", { + get: function() { + return this.nData || null; + } + }); + Object.defineProperty(XMLDTDEntity2.prototype, "inputEncoding", { + get: function() { + return null; + } + }); + Object.defineProperty(XMLDTDEntity2.prototype, "xmlEncoding", { + get: function() { + return null; + } + }); + Object.defineProperty(XMLDTDEntity2.prototype, "xmlVersion", { + get: function() { + return null; + } + }); + XMLDTDEntity2.prototype.toString = function(options) { + return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); + }; + return XMLDTDEntity2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDTDElement.js +var require_XMLDTDElement = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDTDElement.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDTDElement, XMLNode, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + module2.exports = XMLDTDElement = (function(superClass) { + extend(XMLDTDElement2, superClass); + function XMLDTDElement2(parent, name, value) { + XMLDTDElement2.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing DTD element name. " + this.debugInfo()); + } + if (!value) { + value = "(#PCDATA)"; + } + if (Array.isArray(value)) { + value = "(" + value.join(",") + ")"; + } + this.name = this.stringify.name(name); + this.type = NodeType.ElementDeclaration; + this.value = this.stringify.dtdElementValue(value); + } + XMLDTDElement2.prototype.toString = function(options) { + return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options)); + }; + return XMLDTDElement2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDTDNotation.js +var require_XMLDTDNotation = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDTDNotation.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDTDNotation, XMLNode, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + module2.exports = XMLDTDNotation = (function(superClass) { + extend(XMLDTDNotation2, superClass); + function XMLDTDNotation2(parent, name, value) { + XMLDTDNotation2.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing DTD notation name. " + this.debugInfo(name)); + } + if (!value.pubID && !value.sysID) { + throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name)); + } + this.name = this.stringify.name(name); + this.type = NodeType.NotationDeclaration; + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); + } + if (value.sysID != null) { + this.sysID = this.stringify.dtdSysID(value.sysID); + } + } + Object.defineProperty(XMLDTDNotation2.prototype, "publicId", { + get: function() { + return this.pubID; + } + }); + Object.defineProperty(XMLDTDNotation2.prototype, "systemId", { + get: function() { + return this.sysID; + } + }); + XMLDTDNotation2.prototype.toString = function(options) { + return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); + }; + return XMLDTDNotation2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDocType.js +var require_XMLDocType = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDocType.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject2, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + isObject2 = require_Utility().isObject; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + XMLDTDAttList = require_XMLDTDAttList(); + XMLDTDEntity = require_XMLDTDEntity(); + XMLDTDElement = require_XMLDTDElement(); + XMLDTDNotation = require_XMLDTDNotation(); + XMLNamedNodeMap = require_XMLNamedNodeMap(); + module2.exports = XMLDocType = (function(superClass) { + extend(XMLDocType2, superClass); + function XMLDocType2(parent, pubID, sysID) { + var child2, i6, len, ref, ref1, ref2; + XMLDocType2.__super__.constructor.call(this, parent); + this.type = NodeType.DocType; + if (parent.children) { + ref = parent.children; + for (i6 = 0, len = ref.length; i6 < len; i6++) { + child2 = ref[i6]; + if (child2.type === NodeType.Element) { + this.name = child2.name; + break; + } + } + } + this.documentObject = parent; + if (isObject2(pubID)) { + ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID; + } + if (sysID == null) { + ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1]; + } + if (pubID != null) { + this.pubID = this.stringify.dtdPubID(pubID); + } + if (sysID != null) { + this.sysID = this.stringify.dtdSysID(sysID); + } + } + Object.defineProperty(XMLDocType2.prototype, "entities", { + get: function() { + var child2, i6, len, nodes, ref; + nodes = {}; + ref = this.children; + for (i6 = 0, len = ref.length; i6 < len; i6++) { + child2 = ref[i6]; + if (child2.type === NodeType.EntityDeclaration && !child2.pe) { + nodes[child2.name] = child2; + } + } + return new XMLNamedNodeMap(nodes); + } + }); + Object.defineProperty(XMLDocType2.prototype, "notations", { + get: function() { + var child2, i6, len, nodes, ref; + nodes = {}; + ref = this.children; + for (i6 = 0, len = ref.length; i6 < len; i6++) { + child2 = ref[i6]; + if (child2.type === NodeType.NotationDeclaration) { + nodes[child2.name] = child2; + } + } + return new XMLNamedNodeMap(nodes); + } + }); + Object.defineProperty(XMLDocType2.prototype, "publicId", { + get: function() { + return this.pubID; + } + }); + Object.defineProperty(XMLDocType2.prototype, "systemId", { + get: function() { + return this.sysID; + } + }); + Object.defineProperty(XMLDocType2.prototype, "internalSubset", { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + XMLDocType2.prototype.element = function(name, value) { + var child2; + child2 = new XMLDTDElement(this, name, value); + this.children.push(child2); + return this; + }; + XMLDocType2.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + var child2; + child2 = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); + this.children.push(child2); + return this; + }; + XMLDocType2.prototype.entity = function(name, value) { + var child2; + child2 = new XMLDTDEntity(this, false, name, value); + this.children.push(child2); + return this; + }; + XMLDocType2.prototype.pEntity = function(name, value) { + var child2; + child2 = new XMLDTDEntity(this, true, name, value); + this.children.push(child2); + return this; + }; + XMLDocType2.prototype.notation = function(name, value) { + var child2; + child2 = new XMLDTDNotation(this, name, value); + this.children.push(child2); + return this; + }; + XMLDocType2.prototype.toString = function(options) { + return this.options.writer.docType(this, this.options.writer.filterOptions(options)); + }; + XMLDocType2.prototype.ele = function(name, value) { + return this.element(name, value); + }; + XMLDocType2.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); + }; + XMLDocType2.prototype.ent = function(name, value) { + return this.entity(name, value); + }; + XMLDocType2.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; + XMLDocType2.prototype.not = function(name, value) { + return this.notation(name, value); + }; + XMLDocType2.prototype.up = function() { + return this.root() || this.documentObject; + }; + XMLDocType2.prototype.isEqualNode = function(node) { + if (!XMLDocType2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.name !== this.name) { + return false; + } + if (node.publicId !== this.publicId) { + return false; + } + if (node.systemId !== this.systemId) { + return false; + } + return true; + }; + return XMLDocType2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLRaw.js +var require_XMLRaw = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLRaw.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLNode, XMLRaw, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + NodeType = require_NodeType(); + XMLNode = require_XMLNode(); + module2.exports = XMLRaw = (function(superClass) { + extend(XMLRaw2, superClass); + function XMLRaw2(parent, text) { + XMLRaw2.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing raw text. " + this.debugInfo()); + } + this.type = NodeType.Raw; + this.value = this.stringify.raw(text); + } + XMLRaw2.prototype.clone = function() { + return Object.create(this); + }; + XMLRaw2.prototype.toString = function(options) { + return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + }; + return XMLRaw2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLText.js +var require_XMLText = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLText.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLCharacterData, XMLText, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + NodeType = require_NodeType(); + XMLCharacterData = require_XMLCharacterData(); + module2.exports = XMLText = (function(superClass) { + extend(XMLText2, superClass); + function XMLText2(parent, text) { + XMLText2.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing element text. " + this.debugInfo()); + } + this.name = "#text"; + this.type = NodeType.Text; + this.value = this.stringify.text(text); + } + Object.defineProperty(XMLText2.prototype, "isElementContentWhitespace", { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + Object.defineProperty(XMLText2.prototype, "wholeText", { + get: function() { + var next, prev, str; + str = ""; + prev = this.previousSibling; + while (prev) { + str = prev.data + str; + prev = prev.previousSibling; + } + str += this.data; + next = this.nextSibling; + while (next) { + str = str + next.data; + next = next.nextSibling; + } + return str; + } + }); + XMLText2.prototype.clone = function() { + return Object.create(this); + }; + XMLText2.prototype.toString = function(options) { + return this.options.writer.text(this, this.options.writer.filterOptions(options)); + }; + XMLText2.prototype.splitText = function(offset) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLText2.prototype.replaceWholeText = function(content) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + return XMLText2; + })(XMLCharacterData); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLProcessingInstruction.js +var require_XMLProcessingInstruction = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLProcessingInstruction.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLCharacterData, XMLProcessingInstruction, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + NodeType = require_NodeType(); + XMLCharacterData = require_XMLCharacterData(); + module2.exports = XMLProcessingInstruction = (function(superClass) { + extend(XMLProcessingInstruction2, superClass); + function XMLProcessingInstruction2(parent, target, value) { + XMLProcessingInstruction2.__super__.constructor.call(this, parent); + if (target == null) { + throw new Error("Missing instruction target. " + this.debugInfo()); + } + this.type = NodeType.ProcessingInstruction; + this.target = this.stringify.insTarget(target); + this.name = this.target; + if (value) { + this.value = this.stringify.insValue(value); + } + } + XMLProcessingInstruction2.prototype.clone = function() { + return Object.create(this); + }; + XMLProcessingInstruction2.prototype.toString = function(options) { + return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); + }; + XMLProcessingInstruction2.prototype.isEqualNode = function(node) { + if (!XMLProcessingInstruction2.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.target !== this.target) { + return false; + } + return true; + }; + return XMLProcessingInstruction2; + })(XMLCharacterData); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDummy.js +var require_XMLDummy = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDummy.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDummy, XMLNode, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + module2.exports = XMLDummy = (function(superClass) { + extend(XMLDummy2, superClass); + function XMLDummy2(parent) { + XMLDummy2.__super__.constructor.call(this, parent); + this.type = NodeType.Dummy; + } + XMLDummy2.prototype.clone = function() { + return Object.create(this); + }; + XMLDummy2.prototype.toString = function(options) { + return ""; + }; + return XMLDummy2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLNodeList.js +var require_XMLNodeList = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLNodeList.js"(exports2, module2) { + "use strict"; + (function() { + var XMLNodeList; + module2.exports = XMLNodeList = (function() { + function XMLNodeList2(nodes) { + this.nodes = nodes; + } + Object.defineProperty(XMLNodeList2.prototype, "length", { + get: function() { + return this.nodes.length || 0; + } + }); + XMLNodeList2.prototype.clone = function() { + return this.nodes = null; + }; + XMLNodeList2.prototype.item = function(index) { + return this.nodes[index] || null; + }; + return XMLNodeList2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/DocumentPosition.js +var require_DocumentPosition = __commonJS({ + "../node_modules/xmlbuilder/lib/DocumentPosition.js"(exports2, module2) { + "use strict"; + (function() { + module2.exports = { + Disconnected: 1, + Preceding: 2, + Following: 4, + Contains: 8, + ContainedBy: 16, + ImplementationSpecific: 32 + }; + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLNode.js +var require_XMLNode = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLNode.js"(exports2, module2) { + "use strict"; + (function() { + var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction2, isObject2, ref1, hasProp = {}.hasOwnProperty; + ref1 = require_Utility(), isObject2 = ref1.isObject, isFunction2 = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue; + XMLElement = null; + XMLCData = null; + XMLComment = null; + XMLDeclaration = null; + XMLDocType = null; + XMLRaw = null; + XMLText = null; + XMLProcessingInstruction = null; + XMLDummy = null; + NodeType = null; + XMLNodeList = null; + XMLNamedNodeMap = null; + DocumentPosition = null; + module2.exports = XMLNode = (function() { + function XMLNode2(parent1) { + this.parent = parent1; + if (this.parent) { + this.options = this.parent.options; + this.stringify = this.parent.stringify; + } + this.value = null; + this.children = []; + this.baseURI = null; + if (!XMLElement) { + XMLElement = require_XMLElement(); + XMLCData = require_XMLCData(); + XMLComment = require_XMLComment(); + XMLDeclaration = require_XMLDeclaration(); + XMLDocType = require_XMLDocType(); + XMLRaw = require_XMLRaw(); + XMLText = require_XMLText(); + XMLProcessingInstruction = require_XMLProcessingInstruction(); + XMLDummy = require_XMLDummy(); + NodeType = require_NodeType(); + XMLNodeList = require_XMLNodeList(); + XMLNamedNodeMap = require_XMLNamedNodeMap(); + DocumentPosition = require_DocumentPosition(); + } + } + Object.defineProperty(XMLNode2.prototype, "nodeName", { + get: function() { + return this.name; + } + }); + Object.defineProperty(XMLNode2.prototype, "nodeType", { + get: function() { + return this.type; + } + }); + Object.defineProperty(XMLNode2.prototype, "nodeValue", { + get: function() { + return this.value; + } + }); + Object.defineProperty(XMLNode2.prototype, "parentNode", { + get: function() { + return this.parent; + } + }); + Object.defineProperty(XMLNode2.prototype, "childNodes", { + get: function() { + if (!this.childNodeList || !this.childNodeList.nodes) { + this.childNodeList = new XMLNodeList(this.children); + } + return this.childNodeList; + } + }); + Object.defineProperty(XMLNode2.prototype, "firstChild", { + get: function() { + return this.children[0] || null; + } + }); + Object.defineProperty(XMLNode2.prototype, "lastChild", { + get: function() { + return this.children[this.children.length - 1] || null; + } + }); + Object.defineProperty(XMLNode2.prototype, "previousSibling", { + get: function() { + var i6; + i6 = this.parent.children.indexOf(this); + return this.parent.children[i6 - 1] || null; + } + }); + Object.defineProperty(XMLNode2.prototype, "nextSibling", { + get: function() { + var i6; + i6 = this.parent.children.indexOf(this); + return this.parent.children[i6 + 1] || null; + } + }); + Object.defineProperty(XMLNode2.prototype, "ownerDocument", { + get: function() { + return this.document() || null; + } + }); + Object.defineProperty(XMLNode2.prototype, "textContent", { + get: function() { + var child2, j6, len, ref2, str; + if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) { + str = ""; + ref2 = this.children; + for (j6 = 0, len = ref2.length; j6 < len; j6++) { + child2 = ref2[j6]; + if (child2.textContent) { + str += child2.textContent; + } + } + return str; + } else { + return null; + } + }, + set: function(value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + XMLNode2.prototype.setParent = function(parent) { + var child2, j6, len, ref2, results; + this.parent = parent; + if (parent) { + this.options = parent.options; + this.stringify = parent.stringify; + } + ref2 = this.children; + results = []; + for (j6 = 0, len = ref2.length; j6 < len; j6++) { + child2 = ref2[j6]; + results.push(child2.setParent(this)); + } + return results; + }; + XMLNode2.prototype.element = function(name, attributes, text) { + var childNode, item, j6, k6, key, lastChild, len, len1, ref2, ref3, val; + lastChild = null; + if (attributes === null && text == null) { + ref2 = [{}, null], attributes = ref2[0], text = ref2[1]; + } + if (attributes == null) { + attributes = {}; + } + attributes = getValue(attributes); + if (!isObject2(attributes)) { + ref3 = [attributes, text], text = ref3[0], attributes = ref3[1]; + } + if (name != null) { + name = getValue(name); + } + if (Array.isArray(name)) { + for (j6 = 0, len = name.length; j6 < len; j6++) { + item = name[j6]; + lastChild = this.element(item); + } + } else if (isFunction2(name)) { + lastChild = this.element(name.apply()); + } else if (isObject2(name)) { + for (key in name) { + if (!hasProp.call(name, key)) continue; + val = name[key]; + if (isFunction2(val)) { + val = val.apply(); + } + if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { + lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); + } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) { + lastChild = this.dummy(); + } else if (isObject2(val) && isEmpty(val)) { + lastChild = this.element(key); + } else if (!this.options.keepNullNodes && val == null) { + lastChild = this.dummy(); + } else if (!this.options.separateArrayItems && Array.isArray(val)) { + for (k6 = 0, len1 = val.length; k6 < len1; k6++) { + item = val[k6]; + childNode = {}; + childNode[key] = item; + lastChild = this.element(childNode); + } + } else if (isObject2(val)) { + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) { + lastChild = this.element(val); + } else { + lastChild = this.element(key); + lastChild.element(val); + } + } else { + lastChild = this.element(key, val); + } + } + } else if (!this.options.keepNullNodes && text === null) { + lastChild = this.dummy(); + } else { + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) { + lastChild = this.text(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) { + lastChild = this.cdata(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) { + lastChild = this.comment(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { + lastChild = this.raw(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) { + lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text); + } else { + lastChild = this.node(name, attributes, text); + } + } + if (lastChild == null) { + throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo()); + } + return lastChild; + }; + XMLNode2.prototype.insertBefore = function(name, attributes, text) { + var child2, i6, newChild, refChild, removed; + if (name != null ? name.type : void 0) { + newChild = name; + refChild = attributes; + newChild.setParent(this); + if (refChild) { + i6 = children.indexOf(refChild); + removed = children.splice(i6); + children.push(newChild); + Array.prototype.push.apply(children, removed); + } else { + children.push(newChild); + } + return newChild; + } else { + if (this.isRoot) { + throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); + } + i6 = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i6); + child2 = this.parent.element(name, attributes, text); + Array.prototype.push.apply(this.parent.children, removed); + return child2; + } + }; + XMLNode2.prototype.insertAfter = function(name, attributes, text) { + var child2, i6, removed; + if (this.isRoot) { + throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); + } + i6 = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i6 + 1); + child2 = this.parent.element(name, attributes, text); + Array.prototype.push.apply(this.parent.children, removed); + return child2; + }; + XMLNode2.prototype.remove = function() { + var i6, ref2; + if (this.isRoot) { + throw new Error("Cannot remove the root element. " + this.debugInfo()); + } + i6 = this.parent.children.indexOf(this); + [].splice.apply(this.parent.children, [i6, i6 - i6 + 1].concat(ref2 = [])), ref2; + return this.parent; + }; + XMLNode2.prototype.node = function(name, attributes, text) { + var child2, ref2; + if (name != null) { + name = getValue(name); + } + attributes || (attributes = {}); + attributes = getValue(attributes); + if (!isObject2(attributes)) { + ref2 = [attributes, text], text = ref2[0], attributes = ref2[1]; + } + child2 = new XMLElement(this, name, attributes); + if (text != null) { + child2.text(text); + } + this.children.push(child2); + return child2; + }; + XMLNode2.prototype.text = function(value) { + var child2; + if (isObject2(value)) { + this.element(value); + } + child2 = new XMLText(this, value); + this.children.push(child2); + return this; + }; + XMLNode2.prototype.cdata = function(value) { + var child2; + child2 = new XMLCData(this, value); + this.children.push(child2); + return this; + }; + XMLNode2.prototype.comment = function(value) { + var child2; + child2 = new XMLComment(this, value); + this.children.push(child2); + return this; + }; + XMLNode2.prototype.commentBefore = function(value) { + var child2, i6, removed; + i6 = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i6); + child2 = this.parent.comment(value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + XMLNode2.prototype.commentAfter = function(value) { + var child2, i6, removed; + i6 = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i6 + 1); + child2 = this.parent.comment(value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + XMLNode2.prototype.raw = function(value) { + var child2; + child2 = new XMLRaw(this, value); + this.children.push(child2); + return this; + }; + XMLNode2.prototype.dummy = function() { + var child2; + child2 = new XMLDummy(this); + return child2; + }; + XMLNode2.prototype.instruction = function(target, value) { + var insTarget, insValue, instruction, j6, len; + if (target != null) { + target = getValue(target); + } + if (value != null) { + value = getValue(value); + } + if (Array.isArray(target)) { + for (j6 = 0, len = target.length; j6 < len; j6++) { + insTarget = target[j6]; + this.instruction(insTarget); + } + } else if (isObject2(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); + } + } else { + if (isFunction2(value)) { + value = value.apply(); + } + instruction = new XMLProcessingInstruction(this, target, value); + this.children.push(instruction); + } + return this; + }; + XMLNode2.prototype.instructionBefore = function(target, value) { + var child2, i6, removed; + i6 = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i6); + child2 = this.parent.instruction(target, value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + XMLNode2.prototype.instructionAfter = function(target, value) { + var child2, i6, removed; + i6 = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i6 + 1); + child2 = this.parent.instruction(target, value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + XMLNode2.prototype.declaration = function(version, encoding, standalone) { + var doc, xmldec; + doc = this.document(); + xmldec = new XMLDeclaration(doc, version, encoding, standalone); + if (doc.children.length === 0) { + doc.children.unshift(xmldec); + } else if (doc.children[0].type === NodeType.Declaration) { + doc.children[0] = xmldec; + } else { + doc.children.unshift(xmldec); + } + return doc.root() || doc; + }; + XMLNode2.prototype.dtd = function(pubID, sysID) { + var child2, doc, doctype, i6, j6, k6, len, len1, ref2, ref3; + doc = this.document(); + doctype = new XMLDocType(doc, pubID, sysID); + ref2 = doc.children; + for (i6 = j6 = 0, len = ref2.length; j6 < len; i6 = ++j6) { + child2 = ref2[i6]; + if (child2.type === NodeType.DocType) { + doc.children[i6] = doctype; + return doctype; + } + } + ref3 = doc.children; + for (i6 = k6 = 0, len1 = ref3.length; k6 < len1; i6 = ++k6) { + child2 = ref3[i6]; + if (child2.isRoot) { + doc.children.splice(i6, 0, doctype); + return doctype; + } + } + doc.children.push(doctype); + return doctype; + }; + XMLNode2.prototype.up = function() { + if (this.isRoot) { + throw new Error("The root node has no parent. Use doc() if you need to get the document object."); + } + return this.parent; + }; + XMLNode2.prototype.root = function() { + var node; + node = this; + while (node) { + if (node.type === NodeType.Document) { + return node.rootObject; + } else if (node.isRoot) { + return node; + } else { + node = node.parent; + } + } + }; + XMLNode2.prototype.document = function() { + var node; + node = this; + while (node) { + if (node.type === NodeType.Document) { + return node; + } else { + node = node.parent; + } + } + }; + XMLNode2.prototype.end = function(options) { + return this.document().end(options); + }; + XMLNode2.prototype.prev = function() { + var i6; + i6 = this.parent.children.indexOf(this); + if (i6 < 1) { + throw new Error("Already at the first node. " + this.debugInfo()); + } + return this.parent.children[i6 - 1]; + }; + XMLNode2.prototype.next = function() { + var i6; + i6 = this.parent.children.indexOf(this); + if (i6 === -1 || i6 === this.parent.children.length - 1) { + throw new Error("Already at the last node. " + this.debugInfo()); + } + return this.parent.children[i6 + 1]; + }; + XMLNode2.prototype.importDocument = function(doc) { + var clonedRoot; + clonedRoot = doc.root().clone(); + clonedRoot.parent = this; + clonedRoot.isRoot = false; + this.children.push(clonedRoot); + return this; + }; + XMLNode2.prototype.debugInfo = function(name) { + var ref2, ref3; + name = name || this.name; + if (name == null && !((ref2 = this.parent) != null ? ref2.name : void 0)) { + return ""; + } else if (name == null) { + return "parent: <" + this.parent.name + ">"; + } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) { + return "node: <" + name + ">"; + } else { + return "node: <" + name + ">, parent: <" + this.parent.name + ">"; + } + }; + XMLNode2.prototype.ele = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + XMLNode2.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + XMLNode2.prototype.txt = function(value) { + return this.text(value); + }; + XMLNode2.prototype.dat = function(value) { + return this.cdata(value); + }; + XMLNode2.prototype.com = function(value) { + return this.comment(value); + }; + XMLNode2.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + XMLNode2.prototype.doc = function() { + return this.document(); + }; + XMLNode2.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + XMLNode2.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + XMLNode2.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + XMLNode2.prototype.t = function(value) { + return this.text(value); + }; + XMLNode2.prototype.d = function(value) { + return this.cdata(value); + }; + XMLNode2.prototype.c = function(value) { + return this.comment(value); + }; + XMLNode2.prototype.r = function(value) { + return this.raw(value); + }; + XMLNode2.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + XMLNode2.prototype.u = function() { + return this.up(); + }; + XMLNode2.prototype.importXMLBuilder = function(doc) { + return this.importDocument(doc); + }; + XMLNode2.prototype.replaceChild = function(newChild, oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.removeChild = function(oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.appendChild = function(newChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.hasChildNodes = function() { + return this.children.length !== 0; + }; + XMLNode2.prototype.cloneNode = function(deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.normalize = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.isSupported = function(feature, version) { + return true; + }; + XMLNode2.prototype.hasAttributes = function() { + return this.attribs.length !== 0; + }; + XMLNode2.prototype.compareDocumentPosition = function(other) { + var ref, res; + ref = this; + if (ref === other) { + return 0; + } else if (this.document() !== other.document()) { + res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific; + if (Math.random() < 0.5) { + res |= DocumentPosition.Preceding; + } else { + res |= DocumentPosition.Following; + } + return res; + } else if (ref.isAncestor(other)) { + return DocumentPosition.Contains | DocumentPosition.Preceding; + } else if (ref.isDescendant(other)) { + return DocumentPosition.Contains | DocumentPosition.Following; + } else if (ref.isPreceding(other)) { + return DocumentPosition.Preceding; + } else { + return DocumentPosition.Following; + } + }; + XMLNode2.prototype.isSameNode = function(other) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.lookupPrefix = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.isDefaultNamespace = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.lookupNamespaceURI = function(prefix) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.isEqualNode = function(node) { + var i6, j6, ref2; + if (node.nodeType !== this.nodeType) { + return false; + } + if (node.children.length !== this.children.length) { + return false; + } + for (i6 = j6 = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j6 <= ref2 : j6 >= ref2; i6 = 0 <= ref2 ? ++j6 : --j6) { + if (!this.children[i6].isEqualNode(node.children[i6])) { + return false; + } + } + return true; + }; + XMLNode2.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.setUserData = function(key, data, handler2) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.getUserData = function(key) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLNode2.prototype.contains = function(other) { + if (!other) { + return false; + } + return other === this || this.isDescendant(other); + }; + XMLNode2.prototype.isDescendant = function(node) { + var child2, isDescendantChild, j6, len, ref2; + ref2 = this.children; + for (j6 = 0, len = ref2.length; j6 < len; j6++) { + child2 = ref2[j6]; + if (node === child2) { + return true; + } + isDescendantChild = child2.isDescendant(node); + if (isDescendantChild) { + return true; + } + } + return false; + }; + XMLNode2.prototype.isAncestor = function(node) { + return node.isDescendant(this); + }; + XMLNode2.prototype.isPreceding = function(node) { + var nodePos, thisPos; + nodePos = this.treePosition(node); + thisPos = this.treePosition(this); + if (nodePos === -1 || thisPos === -1) { + return false; + } else { + return nodePos < thisPos; + } + }; + XMLNode2.prototype.isFollowing = function(node) { + var nodePos, thisPos; + nodePos = this.treePosition(node); + thisPos = this.treePosition(this); + if (nodePos === -1 || thisPos === -1) { + return false; + } else { + return nodePos > thisPos; + } + }; + XMLNode2.prototype.treePosition = function(node) { + var found, pos; + pos = 0; + found = false; + this.foreachTreeNode(this.document(), function(childNode) { + pos++; + if (!found && childNode === node) { + return found = true; + } + }); + if (found) { + return pos; + } else { + return -1; + } + }; + XMLNode2.prototype.foreachTreeNode = function(node, func) { + var child2, j6, len, ref2, res; + node || (node = this.document()); + ref2 = node.children; + for (j6 = 0, len = ref2.length; j6 < len; j6++) { + child2 = ref2[j6]; + if (res = func(child2)) { + return res; + } else { + res = this.foreachTreeNode(child2, func); + if (res) { + return res; + } + } + } + }; + return XMLNode2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLStringifier.js +var require_XMLStringifier = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLStringifier.js"(exports2, module2) { + "use strict"; + (function() { + var XMLStringifier, bind2 = function(fn, me) { + return function() { + return fn.apply(me, arguments); + }; + }, hasProp = {}.hasOwnProperty; + module2.exports = XMLStringifier = (function() { + function XMLStringifier2(options) { + this.assertLegalName = bind2(this.assertLegalName, this); + this.assertLegalChar = bind2(this.assertLegalChar, this); + var key, ref, value; + options || (options = {}); + this.options = options; + if (!this.options.version) { + this.options.version = "1.0"; + } + ref = options.stringify || {}; + for (key in ref) { + if (!hasProp.call(ref, key)) continue; + value = ref[key]; + this[key] = value; + } + } + XMLStringifier2.prototype.name = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalName("" + val || ""); + }; + XMLStringifier2.prototype.text = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.textEscape("" + val || "")); + }; + XMLStringifier2.prototype.cdata = function(val) { + if (this.options.noValidation) { + return val; + } + val = "" + val || ""; + val = val.replace("]]>", "]]]]>"); + return this.assertLegalChar(val); + }; + XMLStringifier2.prototype.comment = function(val) { + if (this.options.noValidation) { + return val; + } + val = "" + val || ""; + if (val.match(/--/)) { + throw new Error("Comment text cannot contain double-hypen: " + val); + } + return this.assertLegalChar(val); + }; + XMLStringifier2.prototype.raw = function(val) { + if (this.options.noValidation) { + return val; + } + return "" + val || ""; + }; + XMLStringifier2.prototype.attValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.attEscape(val = "" + val || "")); + }; + XMLStringifier2.prototype.insTarget = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.insValue = function(val) { + if (this.options.noValidation) { + return val; + } + val = "" + val || ""; + if (val.match(/\?>/)) { + throw new Error("Invalid processing instruction value: " + val); + } + return this.assertLegalChar(val); + }; + XMLStringifier2.prototype.xmlVersion = function(val) { + if (this.options.noValidation) { + return val; + } + val = "" + val || ""; + if (!val.match(/1\.[0-9]+/)) { + throw new Error("Invalid version number: " + val); + } + return val; + }; + XMLStringifier2.prototype.xmlEncoding = function(val) { + if (this.options.noValidation) { + return val; + } + val = "" + val || ""; + if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) { + throw new Error("Invalid encoding: " + val); + } + return this.assertLegalChar(val); + }; + XMLStringifier2.prototype.xmlStandalone = function(val) { + if (this.options.noValidation) { + return val; + } + if (val) { + return "yes"; + } else { + return "no"; + } + }; + XMLStringifier2.prototype.dtdPubID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.dtdSysID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.dtdElementValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.dtdAttType = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.dtdAttDefault = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.dtdEntityValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.dtdNData = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar("" + val || ""); + }; + XMLStringifier2.prototype.convertAttKey = "@"; + XMLStringifier2.prototype.convertPIKey = "?"; + XMLStringifier2.prototype.convertTextKey = "#text"; + XMLStringifier2.prototype.convertCDataKey = "#cdata"; + XMLStringifier2.prototype.convertCommentKey = "#comment"; + XMLStringifier2.prototype.convertRawKey = "#raw"; + XMLStringifier2.prototype.assertLegalChar = function(str) { + var regex, res; + if (this.options.noValidation) { + return str; + } + regex = ""; + if (this.options.version === "1.0") { + regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; + if (res = str.match(regex)) { + throw new Error("Invalid character in string: " + str + " at index " + res.index); + } + } else if (this.options.version === "1.1") { + regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; + if (res = str.match(regex)) { + throw new Error("Invalid character in string: " + str + " at index " + res.index); + } + } + return str; + }; + XMLStringifier2.prototype.assertLegalName = function(str) { + var regex; + if (this.options.noValidation) { + return str; + } + this.assertLegalChar(str); + regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/; + if (!str.match(regex)) { + throw new Error("Invalid character in name"); + } + return str; + }; + XMLStringifier2.prototype.textEscape = function(str) { + var ampregex; + if (this.options.noValidation) { + return str; + } + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; + return str.replace(ampregex, "&").replace(//g, ">").replace(/\r/g, " "); + }; + XMLStringifier2.prototype.attEscape = function(str) { + var ampregex; + if (this.options.noValidation) { + return str; + } + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; + return str.replace(ampregex, "&").replace(/ 0) { + return new Array(indentLevel).join(options.indent); + } + } + return ""; + }; + XMLWriterBase2.prototype.endline = function(node, options, level) { + if (!options.pretty || options.suppressPrettyCount) { + return ""; + } else { + return options.newline; + } + }; + XMLWriterBase2.prototype.attribute = function(att, options, level) { + var r6; + this.openAttribute(att, options, level); + r6 = " " + att.name + '="' + att.value + '"'; + this.closeAttribute(att, options, level); + return r6; + }; + XMLWriterBase2.prototype.cdata = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + "" + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.comment = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + "" + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.declaration = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + ""; + r6 += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.docType = function(node, options, level) { + var child2, i6, len, r6, ref; + level || (level = 0); + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level); + r6 += " 0) { + r6 += " ["; + r6 += this.endline(node, options, level); + options.state = WriterState.InsideTag; + ref = node.children; + for (i6 = 0, len = ref.length; i6 < len; i6++) { + child2 = ref[i6]; + r6 += this.writeChildNode(child2, options, level + 1); + } + options.state = WriterState.CloseTag; + r6 += "]"; + } + options.state = WriterState.CloseTag; + r6 += options.spaceBeforeSlash + ">"; + r6 += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.element = function(node, options, level) { + var att, child2, childNodeCount, firstChildNode, i6, j6, len, len1, name, prettySuppressed, r6, ref, ref1, ref2; + level || (level = 0); + prettySuppressed = false; + r6 = ""; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 += this.indent(node, options, level) + "<" + node.name; + ref = node.attribs; + for (name in ref) { + if (!hasProp.call(ref, name)) continue; + att = ref[name]; + r6 += this.attribute(att, options, level); + } + childNodeCount = node.children.length; + firstChildNode = childNodeCount === 0 ? null : node.children[0]; + if (childNodeCount === 0 || node.children.every(function(e6) { + return (e6.type === NodeType.Text || e6.type === NodeType.Raw) && e6.value === ""; + })) { + if (options.allowEmpty) { + r6 += ">"; + options.state = WriterState.CloseTag; + r6 += "" + this.endline(node, options, level); + } else { + options.state = WriterState.CloseTag; + r6 += options.spaceBeforeSlash + "/>" + this.endline(node, options, level); + } + } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) { + r6 += ">"; + options.state = WriterState.InsideTag; + options.suppressPrettyCount++; + prettySuppressed = true; + r6 += this.writeChildNode(firstChildNode, options, level + 1); + options.suppressPrettyCount--; + prettySuppressed = false; + options.state = WriterState.CloseTag; + r6 += "" + this.endline(node, options, level); + } else { + if (options.dontPrettyTextNodes) { + ref1 = node.children; + for (i6 = 0, len = ref1.length; i6 < len; i6++) { + child2 = ref1[i6]; + if ((child2.type === NodeType.Text || child2.type === NodeType.Raw) && child2.value != null) { + options.suppressPrettyCount++; + prettySuppressed = true; + break; + } + } + } + r6 += ">" + this.endline(node, options, level); + options.state = WriterState.InsideTag; + ref2 = node.children; + for (j6 = 0, len1 = ref2.length; j6 < len1; j6++) { + child2 = ref2[j6]; + r6 += this.writeChildNode(child2, options, level + 1); + } + options.state = WriterState.CloseTag; + r6 += this.indent(node, options, level) + ""; + if (prettySuppressed) { + options.suppressPrettyCount--; + } + r6 += this.endline(node, options, level); + options.state = WriterState.None; + } + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.writeChildNode = function(node, options, level) { + switch (node.type) { + case NodeType.CData: + return this.cdata(node, options, level); + case NodeType.Comment: + return this.comment(node, options, level); + case NodeType.Element: + return this.element(node, options, level); + case NodeType.Raw: + return this.raw(node, options, level); + case NodeType.Text: + return this.text(node, options, level); + case NodeType.ProcessingInstruction: + return this.processingInstruction(node, options, level); + case NodeType.Dummy: + return ""; + case NodeType.Declaration: + return this.declaration(node, options, level); + case NodeType.DocType: + return this.docType(node, options, level); + case NodeType.AttributeDeclaration: + return this.dtdAttList(node, options, level); + case NodeType.ElementDeclaration: + return this.dtdElement(node, options, level); + case NodeType.EntityDeclaration: + return this.dtdEntity(node, options, level); + case NodeType.NotationDeclaration: + return this.dtdNotation(node, options, level); + default: + throw new Error("Unknown XML node type: " + node.constructor.name); + } + }; + XMLWriterBase2.prototype.processingInstruction = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + ""; + r6 += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.raw = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level); + options.state = WriterState.InsideTag; + r6 += node.value; + options.state = WriterState.CloseTag; + r6 += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.text = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level); + options.state = WriterState.InsideTag; + r6 += node.value; + options.state = WriterState.CloseTag; + r6 += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.dtdAttList = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + "" + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.dtdElement = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + "" + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.dtdEntity = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + "" + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.dtdNotation = function(node, options, level) { + var r6; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r6 = this.indent(node, options, level) + "" + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r6; + }; + XMLWriterBase2.prototype.openNode = function(node, options, level) { + }; + XMLWriterBase2.prototype.closeNode = function(node, options, level) { + }; + XMLWriterBase2.prototype.openAttribute = function(att, options, level) { + }; + XMLWriterBase2.prototype.closeAttribute = function(att, options, level) { + }; + return XMLWriterBase2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLStringWriter.js +var require_XMLStringWriter = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLStringWriter.js"(exports2, module2) { + "use strict"; + (function() { + var XMLStringWriter, XMLWriterBase, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + XMLWriterBase = require_XMLWriterBase(); + module2.exports = XMLStringWriter = (function(superClass) { + extend(XMLStringWriter2, superClass); + function XMLStringWriter2(options) { + XMLStringWriter2.__super__.constructor.call(this, options); + } + XMLStringWriter2.prototype.document = function(doc, options) { + var child2, i6, len, r6, ref; + options = this.filterOptions(options); + r6 = ""; + ref = doc.children; + for (i6 = 0, len = ref.length; i6 < len; i6++) { + child2 = ref[i6]; + r6 += this.writeChildNode(child2, options, 0); + } + if (options.pretty && r6.slice(-options.newline.length) === options.newline) { + r6 = r6.slice(0, -options.newline.length); + } + return r6; + }; + return XMLStringWriter2; + })(XMLWriterBase); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDocument.js +var require_XMLDocument = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDocument.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject4, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + isPlainObject4 = require_Utility().isPlainObject; + XMLDOMImplementation = require_XMLDOMImplementation(); + XMLDOMConfiguration = require_XMLDOMConfiguration(); + XMLNode = require_XMLNode(); + NodeType = require_NodeType(); + XMLStringifier = require_XMLStringifier(); + XMLStringWriter = require_XMLStringWriter(); + module2.exports = XMLDocument = (function(superClass) { + extend(XMLDocument2, superClass); + function XMLDocument2(options) { + XMLDocument2.__super__.constructor.call(this, null); + this.name = "#document"; + this.type = NodeType.Document; + this.documentURI = null; + this.domConfig = new XMLDOMConfiguration(); + options || (options = {}); + if (!options.writer) { + options.writer = new XMLStringWriter(); + } + this.options = options; + this.stringify = new XMLStringifier(options); + } + Object.defineProperty(XMLDocument2.prototype, "implementation", { + value: new XMLDOMImplementation() + }); + Object.defineProperty(XMLDocument2.prototype, "doctype", { + get: function() { + var child2, i6, len, ref; + ref = this.children; + for (i6 = 0, len = ref.length; i6 < len; i6++) { + child2 = ref[i6]; + if (child2.type === NodeType.DocType) { + return child2; + } + } + return null; + } + }); + Object.defineProperty(XMLDocument2.prototype, "documentElement", { + get: function() { + return this.rootObject || null; + } + }); + Object.defineProperty(XMLDocument2.prototype, "inputEncoding", { + get: function() { + return null; + } + }); + Object.defineProperty(XMLDocument2.prototype, "strictErrorChecking", { + get: function() { + return false; + } + }); + Object.defineProperty(XMLDocument2.prototype, "xmlEncoding", { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].encoding; + } else { + return null; + } + } + }); + Object.defineProperty(XMLDocument2.prototype, "xmlStandalone", { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].standalone === "yes"; + } else { + return false; + } + } + }); + Object.defineProperty(XMLDocument2.prototype, "xmlVersion", { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].version; + } else { + return "1.0"; + } + } + }); + Object.defineProperty(XMLDocument2.prototype, "URL", { + get: function() { + return this.documentURI; + } + }); + Object.defineProperty(XMLDocument2.prototype, "origin", { + get: function() { + return null; + } + }); + Object.defineProperty(XMLDocument2.prototype, "compatMode", { + get: function() { + return null; + } + }); + Object.defineProperty(XMLDocument2.prototype, "characterSet", { + get: function() { + return null; + } + }); + Object.defineProperty(XMLDocument2.prototype, "contentType", { + get: function() { + return null; + } + }); + XMLDocument2.prototype.end = function(writer) { + var writerOptions; + writerOptions = {}; + if (!writer) { + writer = this.options.writer; + } else if (isPlainObject4(writer)) { + writerOptions = writer; + writer = this.options.writer; + } + return writer.document(this, writer.filterOptions(writerOptions)); + }; + XMLDocument2.prototype.toString = function(options) { + return this.options.writer.document(this, this.options.writer.filterOptions(options)); + }; + XMLDocument2.prototype.createElement = function(tagName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createDocumentFragment = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createTextNode = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createComment = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createCDATASection = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createProcessingInstruction = function(target, data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createAttribute = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createEntityReference = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.importNode = function(importedNode, deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createElementNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.getElementById = function(elementId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.adoptNode = function(source) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.normalizeDocument = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.renameNode = function(node, namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createEvent = function(eventInterface) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createRange = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createNodeIterator = function(root, whatToShow, filter2) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + XMLDocument2.prototype.createTreeWalker = function(root, whatToShow, filter2) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + return XMLDocument2; + })(XMLNode); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLDocumentCB.js +var require_XMLDocumentCB = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLDocumentCB.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction2, isObject2, isPlainObject4, ref, hasProp = {}.hasOwnProperty; + ref = require_Utility(), isObject2 = ref.isObject, isFunction2 = ref.isFunction, isPlainObject4 = ref.isPlainObject, getValue = ref.getValue; + NodeType = require_NodeType(); + XMLDocument = require_XMLDocument(); + XMLElement = require_XMLElement(); + XMLCData = require_XMLCData(); + XMLComment = require_XMLComment(); + XMLRaw = require_XMLRaw(); + XMLText = require_XMLText(); + XMLProcessingInstruction = require_XMLProcessingInstruction(); + XMLDeclaration = require_XMLDeclaration(); + XMLDocType = require_XMLDocType(); + XMLDTDAttList = require_XMLDTDAttList(); + XMLDTDEntity = require_XMLDTDEntity(); + XMLDTDElement = require_XMLDTDElement(); + XMLDTDNotation = require_XMLDTDNotation(); + XMLAttribute = require_XMLAttribute(); + XMLStringifier = require_XMLStringifier(); + XMLStringWriter = require_XMLStringWriter(); + WriterState = require_WriterState(); + module2.exports = XMLDocumentCB = (function() { + function XMLDocumentCB2(options, onData, onEnd) { + var writerOptions; + this.name = "?xml"; + this.type = NodeType.Document; + options || (options = {}); + writerOptions = {}; + if (!options.writer) { + options.writer = new XMLStringWriter(); + } else if (isPlainObject4(options.writer)) { + writerOptions = options.writer; + options.writer = new XMLStringWriter(); + } + this.options = options; + this.writer = options.writer; + this.writerOptions = this.writer.filterOptions(writerOptions); + this.stringify = new XMLStringifier(options); + this.onDataCallback = onData || function() { + }; + this.onEndCallback = onEnd || function() { + }; + this.currentNode = null; + this.currentLevel = -1; + this.openTags = {}; + this.documentStarted = false; + this.documentCompleted = false; + this.root = null; + } + XMLDocumentCB2.prototype.createChildNode = function(node) { + var att, attName, attributes, child2, i6, len, ref1, ref2; + switch (node.type) { + case NodeType.CData: + this.cdata(node.value); + break; + case NodeType.Comment: + this.comment(node.value); + break; + case NodeType.Element: + attributes = {}; + ref1 = node.attribs; + for (attName in ref1) { + if (!hasProp.call(ref1, attName)) continue; + att = ref1[attName]; + attributes[attName] = att.value; + } + this.node(node.name, attributes); + break; + case NodeType.Dummy: + this.dummy(); + break; + case NodeType.Raw: + this.raw(node.value); + break; + case NodeType.Text: + this.text(node.value); + break; + case NodeType.ProcessingInstruction: + this.instruction(node.target, node.value); + break; + default: + throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name); + } + ref2 = node.children; + for (i6 = 0, len = ref2.length; i6 < len; i6++) { + child2 = ref2[i6]; + this.createChildNode(child2); + if (child2.type === NodeType.Element) { + this.up(); + } + } + return this; + }; + XMLDocumentCB2.prototype.dummy = function() { + return this; + }; + XMLDocumentCB2.prototype.node = function(name, attributes, text) { + var ref1; + if (name == null) { + throw new Error("Missing node name."); + } + if (this.root && this.currentLevel === -1) { + throw new Error("Document can only have one root node. " + this.debugInfo(name)); + } + this.openCurrent(); + name = getValue(name); + if (attributes == null) { + attributes = {}; + } + attributes = getValue(attributes); + if (!isObject2(attributes)) { + ref1 = [attributes, text], text = ref1[0], attributes = ref1[1]; + } + this.currentNode = new XMLElement(this, name, attributes); + this.currentNode.children = false; + this.currentLevel++; + this.openTags[this.currentLevel] = this.currentNode; + if (text != null) { + this.text(text); + } + return this; + }; + XMLDocumentCB2.prototype.element = function(name, attributes, text) { + var child2, i6, len, oldValidationFlag, ref1, root; + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + this.dtdElement.apply(this, arguments); + } else { + if (Array.isArray(name) || isObject2(name) || isFunction2(name)) { + oldValidationFlag = this.options.noValidation; + this.options.noValidation = true; + root = new XMLDocument(this.options).element("TEMP_ROOT"); + root.element(name); + this.options.noValidation = oldValidationFlag; + ref1 = root.children; + for (i6 = 0, len = ref1.length; i6 < len; i6++) { + child2 = ref1[i6]; + this.createChildNode(child2); + if (child2.type === NodeType.Element) { + this.up(); + } + } + } else { + this.node(name, attributes, text); + } + } + return this; + }; + XMLDocumentCB2.prototype.attribute = function(name, value) { + var attName, attValue; + if (!this.currentNode || this.currentNode.children) { + throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name)); + } + if (name != null) { + name = getValue(name); + } + if (isObject2(name)) { + for (attName in name) { + if (!hasProp.call(name, attName)) continue; + attValue = name[attName]; + this.attribute(attName, attValue); + } + } else { + if (isFunction2(value)) { + value = value.apply(); + } + if (this.options.keepNullAttributes && value == null) { + this.currentNode.attribs[name] = new XMLAttribute(this, name, ""); + } else if (value != null) { + this.currentNode.attribs[name] = new XMLAttribute(this, name, value); + } + } + return this; + }; + XMLDocumentCB2.prototype.text = function(value) { + var node; + this.openCurrent(); + node = new XMLText(this, value); + this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.cdata = function(value) { + var node; + this.openCurrent(); + node = new XMLCData(this, value); + this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.comment = function(value) { + var node; + this.openCurrent(); + node = new XMLComment(this, value); + this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.raw = function(value) { + var node; + this.openCurrent(); + node = new XMLRaw(this, value); + this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.instruction = function(target, value) { + var i6, insTarget, insValue, len, node; + this.openCurrent(); + if (target != null) { + target = getValue(target); + } + if (value != null) { + value = getValue(value); + } + if (Array.isArray(target)) { + for (i6 = 0, len = target.length; i6 < len; i6++) { + insTarget = target[i6]; + this.instruction(insTarget); + } + } else if (isObject2(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); + } + } else { + if (isFunction2(value)) { + value = value.apply(); + } + node = new XMLProcessingInstruction(this, target, value); + this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + } + return this; + }; + XMLDocumentCB2.prototype.declaration = function(version, encoding, standalone) { + var node; + this.openCurrent(); + if (this.documentStarted) { + throw new Error("declaration() must be the first node."); + } + node = new XMLDeclaration(this, version, encoding, standalone); + this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.doctype = function(root, pubID, sysID) { + this.openCurrent(); + if (root == null) { + throw new Error("Missing root node name."); + } + if (this.root) { + throw new Error("dtd() must come before the root node."); + } + this.currentNode = new XMLDocType(this, pubID, sysID); + this.currentNode.rootNodeName = root; + this.currentNode.children = false; + this.currentLevel++; + this.openTags[this.currentLevel] = this.currentNode; + return this; + }; + XMLDocumentCB2.prototype.dtdElement = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDElement(this, name, value); + this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + var node; + this.openCurrent(); + node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); + this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.entity = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDEntity(this, false, name, value); + this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.pEntity = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDEntity(this, true, name, value); + this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.notation = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDNotation(this, name, value); + this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + XMLDocumentCB2.prototype.up = function() { + if (this.currentLevel < 0) { + throw new Error("The document node has no parent."); + } + if (this.currentNode) { + if (this.currentNode.children) { + this.closeNode(this.currentNode); + } else { + this.openNode(this.currentNode); + } + this.currentNode = null; + } else { + this.closeNode(this.openTags[this.currentLevel]); + } + delete this.openTags[this.currentLevel]; + this.currentLevel--; + return this; + }; + XMLDocumentCB2.prototype.end = function() { + while (this.currentLevel >= 0) { + this.up(); + } + return this.onEnd(); + }; + XMLDocumentCB2.prototype.openCurrent = function() { + if (this.currentNode) { + this.currentNode.children = true; + return this.openNode(this.currentNode); + } + }; + XMLDocumentCB2.prototype.openNode = function(node) { + var att, chunk, name, ref1; + if (!node.isOpen) { + if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) { + this.root = node; + } + chunk = ""; + if (node.type === NodeType.Element) { + this.writerOptions.state = WriterState.OpenTag; + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "<" + node.name; + ref1 = node.attribs; + for (name in ref1) { + if (!hasProp.call(ref1, name)) continue; + att = ref1[name]; + chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel); + } + chunk += (node.children ? ">" : "/>") + this.writer.endline(node, this.writerOptions, this.currentLevel); + this.writerOptions.state = WriterState.InsideTag; + } else { + this.writerOptions.state = WriterState.OpenTag; + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ""; + } + chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); + } + this.onData(chunk, this.currentLevel); + return node.isOpen = true; + } + }; + XMLDocumentCB2.prototype.closeNode = function(node) { + var chunk; + if (!node.isClosed) { + chunk = ""; + this.writerOptions.state = WriterState.CloseTag; + if (node.type === NodeType.Element) { + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "" + this.writer.endline(node, this.writerOptions, this.currentLevel); + } else { + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + "]>" + this.writer.endline(node, this.writerOptions, this.currentLevel); + } + this.writerOptions.state = WriterState.None; + this.onData(chunk, this.currentLevel); + return node.isClosed = true; + } + }; + XMLDocumentCB2.prototype.onData = function(chunk, level) { + this.documentStarted = true; + return this.onDataCallback(chunk, level + 1); + }; + XMLDocumentCB2.prototype.onEnd = function() { + this.documentCompleted = true; + return this.onEndCallback(); + }; + XMLDocumentCB2.prototype.debugInfo = function(name) { + if (name == null) { + return ""; + } else { + return "node: <" + name + ">"; + } + }; + XMLDocumentCB2.prototype.ele = function() { + return this.element.apply(this, arguments); + }; + XMLDocumentCB2.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + XMLDocumentCB2.prototype.txt = function(value) { + return this.text(value); + }; + XMLDocumentCB2.prototype.dat = function(value) { + return this.cdata(value); + }; + XMLDocumentCB2.prototype.com = function(value) { + return this.comment(value); + }; + XMLDocumentCB2.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + XMLDocumentCB2.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + XMLDocumentCB2.prototype.dtd = function(root, pubID, sysID) { + return this.doctype(root, pubID, sysID); + }; + XMLDocumentCB2.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + XMLDocumentCB2.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + XMLDocumentCB2.prototype.t = function(value) { + return this.text(value); + }; + XMLDocumentCB2.prototype.d = function(value) { + return this.cdata(value); + }; + XMLDocumentCB2.prototype.c = function(value) { + return this.comment(value); + }; + XMLDocumentCB2.prototype.r = function(value) { + return this.raw(value); + }; + XMLDocumentCB2.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + XMLDocumentCB2.prototype.att = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; + XMLDocumentCB2.prototype.a = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; + XMLDocumentCB2.prototype.ent = function(name, value) { + return this.entity(name, value); + }; + XMLDocumentCB2.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; + XMLDocumentCB2.prototype.not = function(name, value) { + return this.notation(name, value); + }; + return XMLDocumentCB2; + })(); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/XMLStreamWriter.js +var require_XMLStreamWriter = __commonJS({ + "../node_modules/xmlbuilder/lib/XMLStreamWriter.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, WriterState, XMLStreamWriter, XMLWriterBase, extend = function(child2, parent) { + for (var key in parent) { + if (hasProp.call(parent, key)) child2[key] = parent[key]; + } + function ctor() { + this.constructor = child2; + } + ctor.prototype = parent.prototype; + child2.prototype = new ctor(); + child2.__super__ = parent.prototype; + return child2; + }, hasProp = {}.hasOwnProperty; + NodeType = require_NodeType(); + XMLWriterBase = require_XMLWriterBase(); + WriterState = require_WriterState(); + module2.exports = XMLStreamWriter = (function(superClass) { + extend(XMLStreamWriter2, superClass); + function XMLStreamWriter2(stream3, options) { + this.stream = stream3; + XMLStreamWriter2.__super__.constructor.call(this, options); + } + XMLStreamWriter2.prototype.endline = function(node, options, level) { + if (node.isLastRootNode && options.state === WriterState.CloseTag) { + return ""; + } else { + return XMLStreamWriter2.__super__.endline.call(this, node, options, level); + } + }; + XMLStreamWriter2.prototype.document = function(doc, options) { + var child2, i6, j6, k6, len, len1, ref, ref1, results; + ref = doc.children; + for (i6 = j6 = 0, len = ref.length; j6 < len; i6 = ++j6) { + child2 = ref[i6]; + child2.isLastRootNode = i6 === doc.children.length - 1; + } + options = this.filterOptions(options); + ref1 = doc.children; + results = []; + for (k6 = 0, len1 = ref1.length; k6 < len1; k6++) { + child2 = ref1[k6]; + results.push(this.writeChildNode(child2, options, 0)); + } + return results; + }; + XMLStreamWriter2.prototype.attribute = function(att, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.attribute.call(this, att, options, level)); + }; + XMLStreamWriter2.prototype.cdata = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.cdata.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.comment = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.comment.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.declaration = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.declaration.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.docType = function(node, options, level) { + var child2, j6, len, ref; + level || (level = 0); + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + this.stream.write(this.indent(node, options, level)); + this.stream.write(" 0) { + this.stream.write(" ["); + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.InsideTag; + ref = node.children; + for (j6 = 0, len = ref.length; j6 < len; j6++) { + child2 = ref[j6]; + this.writeChildNode(child2, options, level + 1); + } + options.state = WriterState.CloseTag; + this.stream.write("]"); + } + options.state = WriterState.CloseTag; + this.stream.write(options.spaceBeforeSlash + ">"); + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.None; + return this.closeNode(node, options, level); + }; + XMLStreamWriter2.prototype.element = function(node, options, level) { + var att, child2, childNodeCount, firstChildNode, j6, len, name, prettySuppressed, ref, ref1; + level || (level = 0); + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + this.stream.write(this.indent(node, options, level) + "<" + node.name); + ref = node.attribs; + for (name in ref) { + if (!hasProp.call(ref, name)) continue; + att = ref[name]; + this.attribute(att, options, level); + } + childNodeCount = node.children.length; + firstChildNode = childNodeCount === 0 ? null : node.children[0]; + if (childNodeCount === 0 || node.children.every(function(e6) { + return (e6.type === NodeType.Text || e6.type === NodeType.Raw) && e6.value === ""; + })) { + if (options.allowEmpty) { + this.stream.write(">"); + options.state = WriterState.CloseTag; + this.stream.write(""); + } else { + options.state = WriterState.CloseTag; + this.stream.write(options.spaceBeforeSlash + "/>"); + } + } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && firstChildNode.value != null) { + this.stream.write(">"); + options.state = WriterState.InsideTag; + options.suppressPrettyCount++; + prettySuppressed = true; + this.writeChildNode(firstChildNode, options, level + 1); + options.suppressPrettyCount--; + prettySuppressed = false; + options.state = WriterState.CloseTag; + this.stream.write(""); + } else { + this.stream.write(">" + this.endline(node, options, level)); + options.state = WriterState.InsideTag; + ref1 = node.children; + for (j6 = 0, len = ref1.length; j6 < len; j6++) { + child2 = ref1[j6]; + this.writeChildNode(child2, options, level + 1); + } + options.state = WriterState.CloseTag; + this.stream.write(this.indent(node, options, level) + ""); + } + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.None; + return this.closeNode(node, options, level); + }; + XMLStreamWriter2.prototype.processingInstruction = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.processingInstruction.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.raw = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.raw.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.text = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.text.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.dtdAttList = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.dtdAttList.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.dtdElement = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.dtdElement.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.dtdEntity = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.dtdEntity.call(this, node, options, level)); + }; + XMLStreamWriter2.prototype.dtdNotation = function(node, options, level) { + return this.stream.write(XMLStreamWriter2.__super__.dtdNotation.call(this, node, options, level)); + }; + return XMLStreamWriter2; + })(XMLWriterBase); + }).call(exports2); + } +}); + +// ../node_modules/xmlbuilder/lib/index.js +var require_lib3 = __commonJS({ + "../node_modules/xmlbuilder/lib/index.js"(exports2, module2) { + "use strict"; + (function() { + var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction2, ref; + ref = require_Utility(), assign = ref.assign, isFunction2 = ref.isFunction; + XMLDOMImplementation = require_XMLDOMImplementation(); + XMLDocument = require_XMLDocument(); + XMLDocumentCB = require_XMLDocumentCB(); + XMLStringWriter = require_XMLStringWriter(); + XMLStreamWriter = require_XMLStreamWriter(); + NodeType = require_NodeType(); + WriterState = require_WriterState(); + module2.exports.create = function(name, xmldec, doctype, options) { + var doc, root; + if (name == null) { + throw new Error("Root element needs a name."); + } + options = assign({}, xmldec, doctype, options); + doc = new XMLDocument(options); + root = doc.element(name); + if (!options.headless) { + doc.declaration(options); + if (options.pubID != null || options.sysID != null) { + doc.dtd(options); + } + } + return root; + }; + module2.exports.begin = function(options, onData, onEnd) { + var ref1; + if (isFunction2(options)) { + ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1]; + options = {}; + } + if (onData) { + return new XMLDocumentCB(options, onData, onEnd); + } else { + return new XMLDocument(options); + } + }; + module2.exports.stringWriter = function(options) { + return new XMLStringWriter(options); + }; + module2.exports.streamWriter = function(stream3, options) { + return new XMLStreamWriter(stream3, options); + }; + module2.exports.implementation = new XMLDOMImplementation(); + module2.exports.nodeType = NodeType; + module2.exports.writerState = WriterState; + }).call(exports2); + } +}); + +// ../node_modules/xml2js/lib/builder.js +var require_builder = __commonJS({ + "../node_modules/xml2js/lib/builder.js"(exports2) { + "use strict"; + (function() { + "use strict"; + var builder, defaults3, escapeCDATA, requiresCDATA, wrapCDATA, hasProp = {}.hasOwnProperty; + builder = require_lib3(); + defaults3 = require_defaults().defaults; + requiresCDATA = function(entry) { + return typeof entry === "string" && (entry.indexOf("&") >= 0 || entry.indexOf(">") >= 0 || entry.indexOf("<") >= 0); + }; + wrapCDATA = function(entry) { + return ""; + }; + escapeCDATA = function(entry) { + return entry.replace("]]>", "]]]]>"); + }; + exports2.Builder = (function() { + function Builder(opts) { + var key, ref, value; + this.options = {}; + ref = defaults3["0.2"]; + for (key in ref) { + if (!hasProp.call(ref, key)) continue; + value = ref[key]; + this.options[key] = value; + } + for (key in opts) { + if (!hasProp.call(opts, key)) continue; + value = opts[key]; + this.options[key] = value; + } + } + Builder.prototype.buildObject = function(rootObj) { + var attrkey, charkey, render, rootElement, rootName; + attrkey = this.options.attrkey; + charkey = this.options.charkey; + if (Object.keys(rootObj).length === 1 && this.options.rootName === defaults3["0.2"].rootName) { + rootName = Object.keys(rootObj)[0]; + rootObj = rootObj[rootName]; + } else { + rootName = this.options.rootName; + } + render = /* @__PURE__ */ (function(_this) { + return function(element, obj2) { + var attr, child2, entry, index, key, value; + if (typeof obj2 !== "object") { + if (_this.options.cdata && requiresCDATA(obj2)) { + element.raw(wrapCDATA(obj2)); + } else { + element.txt(obj2); + } + } else if (Array.isArray(obj2)) { + for (index in obj2) { + if (!hasProp.call(obj2, index)) continue; + child2 = obj2[index]; + for (key in child2) { + entry = child2[key]; + element = render(element.ele(key), entry).up(); + } + } + } else { + for (key in obj2) { + if (!hasProp.call(obj2, key)) continue; + child2 = obj2[key]; + if (key === attrkey) { + if (typeof child2 === "object") { + for (attr in child2) { + value = child2[attr]; + element = element.att(attr, value); + } + } + } else if (key === charkey) { + if (_this.options.cdata && requiresCDATA(child2)) { + element = element.raw(wrapCDATA(child2)); + } else { + element = element.txt(child2); + } + } else if (Array.isArray(child2)) { + for (index in child2) { + if (!hasProp.call(child2, index)) continue; + entry = child2[index]; + if (typeof entry === "string") { + if (_this.options.cdata && requiresCDATA(entry)) { + element = element.ele(key).raw(wrapCDATA(entry)).up(); + } else { + element = element.ele(key, entry).up(); + } + } else { + element = render(element.ele(key), entry).up(); + } + } + } else if (typeof child2 === "object") { + element = render(element.ele(key), child2).up(); + } else { + if (typeof child2 === "string" && _this.options.cdata && requiresCDATA(child2)) { + element = element.ele(key).raw(wrapCDATA(child2)).up(); + } else { + if (child2 == null) { + child2 = ""; + } + element = element.ele(key, child2.toString()).up(); + } + } + } + } + return element; + }; + })(this); + rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, { + headless: this.options.headless, + allowSurrogateChars: this.options.allowSurrogateChars + }); + return render(rootElement, rootObj).end(this.options.renderOpts); + }; + return Builder; + })(); + }).call(exports2); + } +}); + +// ../node_modules/sax/lib/sax.js +var require_sax = __commonJS({ + "../node_modules/sax/lib/sax.js"(exports2) { + "use strict"; + (function(sax) { + sax.parser = function(strict, opt) { + return new SAXParser(strict, opt); + }; + sax.SAXParser = SAXParser; + sax.SAXStream = SAXStream; + sax.createStream = createStream; + sax.MAX_BUFFER_LENGTH = 64 * 1024; + var buffers = [ + "comment", + "sgmlDecl", + "textNode", + "tagName", + "doctype", + "procInstName", + "procInstBody", + "entity", + "attribName", + "attribValue", + "cdata", + "script" + ]; + sax.EVENTS = [ + "text", + "processinginstruction", + "sgmldeclaration", + "doctype", + "comment", + "opentagstart", + "attribute", + "opentag", + "closetag", + "opencdata", + "cdata", + "closecdata", + "error", + "end", + "ready", + "script", + "opennamespace", + "closenamespace" + ]; + function SAXParser(strict, opt) { + if (!(this instanceof SAXParser)) { + return new SAXParser(strict, opt); + } + var parser2 = this; + clearBuffers(parser2); + parser2.q = parser2.c = ""; + parser2.bufferCheckPosition = sax.MAX_BUFFER_LENGTH; + parser2.opt = opt || {}; + parser2.opt.lowercase = parser2.opt.lowercase || parser2.opt.lowercasetags; + parser2.looseCase = parser2.opt.lowercase ? "toLowerCase" : "toUpperCase"; + parser2.tags = []; + parser2.closed = parser2.closedRoot = parser2.sawRoot = false; + parser2.tag = parser2.error = null; + parser2.strict = !!strict; + parser2.noscript = !!(strict || parser2.opt.noscript); + parser2.state = S2.BEGIN; + parser2.strictEntities = parser2.opt.strictEntities; + parser2.ENTITIES = parser2.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES); + parser2.attribList = []; + if (parser2.opt.xmlns) { + parser2.ns = Object.create(rootNS); + } + if (parser2.opt.unquotedAttributeValues === void 0) { + parser2.opt.unquotedAttributeValues = !strict; + } + parser2.trackPosition = parser2.opt.position !== false; + if (parser2.trackPosition) { + parser2.position = parser2.line = parser2.column = 0; + } + emit(parser2, "onready"); + } + if (!Object.create) { + Object.create = function(o6) { + function F3() { + } + F3.prototype = o6; + var newf = new F3(); + return newf; + }; + } + if (!Object.keys) { + Object.keys = function(o6) { + var a6 = []; + for (var i6 in o6) if (o6.hasOwnProperty(i6)) a6.push(i6); + return a6; + }; + } + function checkBufferLength(parser2) { + var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10); + var maxActual = 0; + for (var i6 = 0, l6 = buffers.length; i6 < l6; i6++) { + var len = parser2[buffers[i6]].length; + if (len > maxAllowed) { + switch (buffers[i6]) { + case "textNode": + closeText(parser2); + break; + case "cdata": + emitNode(parser2, "oncdata", parser2.cdata); + parser2.cdata = ""; + break; + case "script": + emitNode(parser2, "onscript", parser2.script); + parser2.script = ""; + break; + default: + error2(parser2, "Max buffer length exceeded: " + buffers[i6]); + } + } + maxActual = Math.max(maxActual, len); + } + var m6 = sax.MAX_BUFFER_LENGTH - maxActual; + parser2.bufferCheckPosition = m6 + parser2.position; + } + function clearBuffers(parser2) { + for (var i6 = 0, l6 = buffers.length; i6 < l6; i6++) { + parser2[buffers[i6]] = ""; + } + } + function flushBuffers(parser2) { + closeText(parser2); + if (parser2.cdata !== "") { + emitNode(parser2, "oncdata", parser2.cdata); + parser2.cdata = ""; + } + if (parser2.script !== "") { + emitNode(parser2, "onscript", parser2.script); + parser2.script = ""; + } + } + SAXParser.prototype = { + end: function() { + end(this); + }, + write, + resume: function() { + this.error = null; + return this; + }, + close: function() { + return this.write(null); + }, + flush: function() { + flushBuffers(this); + } + }; + var Stream2; + try { + Stream2 = require("stream").Stream; + } catch (ex) { + Stream2 = function() { + }; + } + if (!Stream2) Stream2 = function() { + }; + var streamWraps = sax.EVENTS.filter(function(ev) { + return ev !== "error" && ev !== "end"; + }); + function createStream(strict, opt) { + return new SAXStream(strict, opt); + } + function SAXStream(strict, opt) { + if (!(this instanceof SAXStream)) { + return new SAXStream(strict, opt); + } + Stream2.apply(this); + this._parser = new SAXParser(strict, opt); + this.writable = true; + this.readable = true; + var me = this; + this._parser.onend = function() { + me.emit("end"); + }; + this._parser.onerror = function(er) { + me.emit("error", er); + me._parser.error = null; + }; + this._decoder = null; + streamWraps.forEach(function(ev) { + Object.defineProperty(me, "on" + ev, { + get: function() { + return me._parser["on" + ev]; + }, + set: function(h6) { + if (!h6) { + me.removeAllListeners(ev); + me._parser["on" + ev] = h6; + return h6; + } + me.on(ev, h6); + }, + enumerable: true, + configurable: false + }); + }); + } + SAXStream.prototype = Object.create(Stream2.prototype, { + constructor: { + value: SAXStream + } + }); + SAXStream.prototype.write = function(data) { + if (typeof Buffer === "function" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(data)) { + if (!this._decoder) { + var SD = require("string_decoder").StringDecoder; + this._decoder = new SD("utf8"); + } + data = this._decoder.write(data); + } + this._parser.write(data.toString()); + this.emit("data", data); + return true; + }; + SAXStream.prototype.end = function(chunk) { + if (chunk && chunk.length) { + this.write(chunk); + } + this._parser.end(); + return true; + }; + SAXStream.prototype.on = function(ev, handler2) { + var me = this; + if (!me._parser["on" + ev] && streamWraps.indexOf(ev) !== -1) { + me._parser["on" + ev] = function() { + var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments); + args.splice(0, 0, ev); + me.emit.apply(me, args); + }; + } + return Stream2.prototype.on.call(me, ev, handler2); + }; + var CDATA = "[CDATA["; + var DOCTYPE = "DOCTYPE"; + var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"; + var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"; + var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }; + var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; + var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/; + var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; + var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/; + function isWhitespace(c7) { + return c7 === " " || c7 === "\n" || c7 === "\r" || c7 === " "; + } + function isQuote(c7) { + return c7 === '"' || c7 === "'"; + } + function isAttribEnd(c7) { + return c7 === ">" || isWhitespace(c7); + } + function isMatch(regex, c7) { + return regex.test(c7); + } + function notMatch(regex, c7) { + return !isMatch(regex, c7); + } + var S2 = 0; + sax.STATE = { + BEGIN: S2++, + // leading byte order mark or whitespace + BEGIN_WHITESPACE: S2++, + // leading whitespace + TEXT: S2++, + // general stuff + TEXT_ENTITY: S2++, + // & and such. + OPEN_WAKA: S2++, + // < + SGML_DECL: S2++, + // + SCRIPT: S2++, + //