react-vnc
Version:
A React Component to connect to a websockified VNC client using noVNC.
1,285 lines • 483 kB
JavaScript
import { jsx as En } from "react/jsx-runtime";
import { forwardRef as Xn, useRef as mt, useState as Fn, useImperativeHandle as Cn, useEffect as An } from "react";
function Rn(P) {
return P && P.__esModule && Object.prototype.hasOwnProperty.call(P, "default") ? P.default : P;
}
var Mt = {}, wt = {}, vr;
function dn() {
if (vr) return wt;
vr = 1, Object.defineProperty(wt, "__esModule", {
value: !0
}), wt.toSigned32bit = h, wt.toUnsigned32bit = P;
function P(Y) {
return Y >>> 0;
}
function h(Y) {
return Y | 0;
}
return wt;
}
var Je = {}, yr;
function ht() {
if (yr) return Je;
yr = 1, Object.defineProperty(Je, "__esModule", {
value: !0
}), Je.Warn = Je.Info = Je.Error = Je.Debug = void 0, Je.getLogging = Y, Je.initLogging = h;
var P = "warn";
Je.Debug = function() {
}, Je.Info = function() {
}, Je.Warn = function() {
}, Je.Error = function() {
};
function h(A) {
if (typeof A > "u" ? A = P : P = A, Je.Debug = Je.Info = Je.Warn = Je.Error = function() {
}, typeof window.console < "u")
switch (A) {
case "debug":
Je.Debug = console.debug.bind(window.console);
case "info":
Je.Info = console.info.bind(window.console);
case "warn":
Je.Warn = console.warn.bind(window.console);
case "error":
Je.Error = console.error.bind(window.console);
case "none":
break;
default:
throw new window.Error("invalid logging type '" + A + "'");
}
}
function Y() {
return P;
}
return h(), Je;
}
var kt = {}, xr;
function _n() {
if (xr) return kt;
xr = 1, Object.defineProperty(kt, "__esModule", {
value: !0
}), kt.decodeUTF8 = P, kt.encodeUTF8 = h;
function P(Y) {
var A = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
try {
return decodeURIComponent(escape(Y));
} catch (K) {
if (K instanceof URIError && A)
return Y;
throw K;
}
}
function h(Y) {
return unescape(encodeURIComponent(Y));
}
return kt;
}
var Ve = {}, gr;
function Ct() {
if (gr) return Ve;
gr = 1;
function P(S) {
"@babel/helpers - typeof";
return P = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(X) {
return typeof X;
} : function(X) {
return X && typeof Symbol == "function" && X.constructor === Symbol && X !== Symbol.prototype ? "symbol" : typeof X;
}, P(S);
}
Object.defineProperty(Ve, "__esModule", {
value: !0
}), Ve.hasScrollbarGutter = Ve.dragThreshold = void 0, Ve.isAndroid = r, Ve.isBlink = g, Ve.isChrome = i, Ve.isChromeOS = n, Ve.isChromium = c, Ve.isEdge = v, Ve.isFirefox = a, Ve.isGecko = b, Ve.isIOS = f, Ve.isMac = s, Ve.isOpera = x, Ve.isSafari = l, Ve.isTouchDevice = void 0, Ve.isWebKit = y, Ve.isWindows = p, Ve.supportsCursorURIs = void 0;
var h = A(ht());
function Y(S) {
if (typeof WeakMap != "function") return null;
var X = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap();
return (Y = function(B) {
return B ? F : X;
})(S);
}
function A(S, X) {
if (S && S.__esModule) return S;
if (S === null || P(S) != "object" && typeof S != "function") return { default: S };
var F = Y(X);
if (F && F.has(S)) return F.get(S);
var T = { __proto__: null }, B = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var D in S) if (D !== "default" && {}.hasOwnProperty.call(S, D)) {
var N = B ? Object.getOwnPropertyDescriptor(S, D) : null;
N && (N.get || N.set) ? Object.defineProperty(T, D, N) : T[D] = S[D];
}
return T.default = S, F && F.set(S, T), T;
}
Ve.isTouchDevice = "ontouchstart" in document.documentElement || // requried for Chrome debugger
document.ontouchstart !== void 0 || // required for MS Surface
navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0, window.addEventListener("touchstart", function S() {
Ve.isTouchDevice = !0, window.removeEventListener("touchstart", S, !1);
}, !1), Ve.dragThreshold = 10 * (window.devicePixelRatio || 1);
var K = !1;
try {
var Q = document.createElement("canvas");
Q.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default', Q.style.cursor.indexOf("url") === 0 ? (h.Info("Data URI scheme cursor supported"), K = !0) : h.Warn("Data URI scheme cursor not supported");
} catch (S) {
h.Error("Data URI scheme cursor test exception: " + S);
}
Ve.supportsCursorURIs = K;
var L = !0;
try {
var C = document.createElement("div");
C.style.visibility = "hidden", C.style.overflow = "scroll", document.body.appendChild(C);
var u = document.createElement("div");
C.appendChild(u);
var _ = C.offsetWidth - u.offsetWidth;
C.parentNode.removeChild(C), L = _ != 0;
} catch (S) {
h.Error("Scrollbar test exception: " + S);
}
Ve.hasScrollbarGutter = L;
function s() {
return !!/mac/i.exec(navigator.platform);
}
function p() {
return !!/win/i.exec(navigator.platform);
}
function f() {
return !!/ipad/i.exec(navigator.platform) || !!/iphone/i.exec(navigator.platform) || !!/ipod/i.exec(navigator.platform);
}
function r() {
return !!navigator.userAgent.match("Android ");
}
function n() {
return !!navigator.userAgent.match(" CrOS ");
}
function l() {
return !!navigator.userAgent.match("Safari/...") && !navigator.userAgent.match("Chrome/...") && !navigator.userAgent.match("Chromium/...") && !navigator.userAgent.match("Epiphany/...");
}
function a() {
return !!navigator.userAgent.match("Firefox/...") && !navigator.userAgent.match("Seamonkey/...");
}
function i() {
return !!navigator.userAgent.match("Chrome/...") && !navigator.userAgent.match("Chromium/...") && !navigator.userAgent.match("Edg/...") && !navigator.userAgent.match("OPR/...");
}
function c() {
return !!navigator.userAgent.match("Chromium/...");
}
function x() {
return !!navigator.userAgent.match("OPR/...");
}
function v() {
return !!navigator.userAgent.match("Edg/...");
}
function b() {
return !!navigator.userAgent.match("Gecko/...");
}
function y() {
return !!navigator.userAgent.match("AppleWebKit/...") && !navigator.userAgent.match("Chrome/...");
}
function g() {
return !!navigator.userAgent.match("Chrome/...");
}
return Ve;
}
var Xt = {}, br;
function Tn() {
if (br) return Xt;
br = 1, Object.defineProperty(Xt, "__esModule", {
value: !0
}), Xt.clientToElement = P;
function P(h, Y, A) {
var K = A.getBoundingClientRect(), Q = {
x: 0,
y: 0
};
return h < K.left ? Q.x = 0 : h >= K.right ? Q.x = K.width - 1 : Q.x = h - K.left, Y < K.top ? Q.y = 0 : Y >= K.bottom ? Q.y = K.height - 1 : Q.y = Y - K.top, Q;
}
return Xt;
}
var pt = {}, mr;
function pn() {
if (mr) return pt;
mr = 1, Object.defineProperty(pt, "__esModule", {
value: !0
}), pt.getPointerEvent = P, pt.releaseCapture = u, pt.setCapture = C, pt.stopEvent = h;
function P(_) {
return _.changedTouches ? _.changedTouches[0] : _.touches ? _.touches[0] : _;
}
function h(_) {
_.stopPropagation(), _.preventDefault();
}
var Y = !1, A = null;
document.captureElement = null;
function K(_) {
if (!Y) {
var s = new _.constructor(_.type, _);
Y = !0, document.captureElement ? document.captureElement.dispatchEvent(s) : A.dispatchEvent(s), Y = !1, _.stopPropagation(), s.defaultPrevented && _.preventDefault(), _.type === "mouseup" && u();
}
}
function Q() {
var _ = document.getElementById("noVNC_mouse_capture_elem");
_.style.cursor = window.getComputedStyle(document.captureElement).cursor;
}
var L = new MutationObserver(Q);
function C(_) {
if (_.setCapture)
_.setCapture(), document.captureElement = _;
else {
u();
var s = document.getElementById("noVNC_mouse_capture_elem");
s === null && (s = document.createElement("div"), s.id = "noVNC_mouse_capture_elem", s.style.position = "fixed", s.style.top = "0px", s.style.left = "0px", s.style.width = "100%", s.style.height = "100%", s.style.zIndex = 1e4, s.style.display = "none", document.body.appendChild(s), s.addEventListener("contextmenu", K), s.addEventListener("mousemove", K), s.addEventListener("mouseup", K)), document.captureElement = _, L.observe(_, {
attributes: !0
}), Q(), s.style.display = "", window.addEventListener("mousemove", K), window.addEventListener("mouseup", K);
}
}
function u() {
if (document.releaseCapture)
document.releaseCapture(), document.captureElement = null;
else {
if (!document.captureElement)
return;
A = document.captureElement, document.captureElement = null, L.disconnect();
var _ = document.getElementById("noVNC_mouse_capture_elem");
_.style.display = "none", window.removeEventListener("mousemove", K), window.removeEventListener("mouseup", K);
}
}
return pt;
}
var Dt = {}, wr;
function vn() {
return wr || (wr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = void 0;
function h(C) {
"@babel/helpers - typeof";
return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(u) {
return typeof u;
} : function(u) {
return u && typeof Symbol == "function" && u.constructor === Symbol && u !== Symbol.prototype ? "symbol" : typeof u;
}, h(C);
}
function Y(C, u) {
if (!(C instanceof u)) throw new TypeError("Cannot call a class as a function");
}
function A(C, u) {
for (var _ = 0; _ < u.length; _++) {
var s = u[_];
s.enumerable = s.enumerable || !1, s.configurable = !0, "value" in s && (s.writable = !0), Object.defineProperty(C, Q(s.key), s);
}
}
function K(C, u, _) {
return u && A(C.prototype, u), Object.defineProperty(C, "prototype", { writable: !1 }), C;
}
function Q(C) {
var u = L(C, "string");
return h(u) == "symbol" ? u : u + "";
}
function L(C, u) {
if (h(C) != "object" || !C) return C;
var _ = C[Symbol.toPrimitive];
if (_ !== void 0) {
var s = _.call(C, u);
if (h(s) != "object") return s;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(C);
}
P.default = /* @__PURE__ */ function() {
function C() {
Y(this, C), this._listeners = /* @__PURE__ */ new Map();
}
return K(C, [{
key: "addEventListener",
value: function(_, s) {
this._listeners.has(_) || this._listeners.set(_, /* @__PURE__ */ new Set()), this._listeners.get(_).add(s);
}
}, {
key: "removeEventListener",
value: function(_, s) {
this._listeners.has(_) && this._listeners.get(_).delete(s);
}
}, {
key: "dispatchEvent",
value: function(_) {
var s = this;
return this._listeners.has(_.type) ? (this._listeners.get(_.type).forEach(function(p) {
return p.call(s, _);
}), !_.defaultPrevented) : !0;
}
}]);
}();
}(Dt)), Dt;
}
var Ot = {}, Bt = {}, kr;
function yn() {
return kr || (kr = 1, function(P) {
function h(Q) {
"@babel/helpers - typeof";
return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(L) {
return typeof L;
} : function(L) {
return L && typeof Symbol == "function" && L.constructor === Symbol && L !== Symbol.prototype ? "symbol" : typeof L;
}, h(Q);
}
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = void 0;
var Y = K(ht());
function A(Q) {
if (typeof WeakMap != "function") return null;
var L = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap();
return (A = function(_) {
return _ ? C : L;
})(Q);
}
function K(Q, L) {
if (Q && Q.__esModule) return Q;
if (Q === null || h(Q) != "object" && typeof Q != "function") return { default: Q };
var C = A(L);
if (C && C.has(Q)) return C.get(Q);
var u = { __proto__: null }, _ = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var s in Q) if (s !== "default" && {}.hasOwnProperty.call(Q, s)) {
var p = _ ? Object.getOwnPropertyDescriptor(Q, s) : null;
p && (p.get || p.set) ? Object.defineProperty(u, s, p) : u[s] = Q[s];
}
return u.default = Q, C && C.set(Q, u), u;
}
P.default = {
/* Convert data (an array of integers) to a Base64 string. */
toBase64Table: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),
base64Pad: "=",
encode: function(L) {
for (var C = "", u = L.length, _ = u % 3, s = 0; s < u - 2; s += 3)
C += this.toBase64Table[L[s] >> 2], C += this.toBase64Table[((L[s] & 3) << 4) + (L[s + 1] >> 4)], C += this.toBase64Table[((L[s + 1] & 15) << 2) + (L[s + 2] >> 6)], C += this.toBase64Table[L[s + 2] & 63];
var p = u - _;
return _ === 2 ? (C += this.toBase64Table[L[p] >> 2], C += this.toBase64Table[((L[p] & 3) << 4) + (L[p + 1] >> 4)], C += this.toBase64Table[(L[p + 1] & 15) << 2], C += this.toBase64Table[64]) : _ === 1 && (C += this.toBase64Table[L[p] >> 2], C += this.toBase64Table[(L[p] & 3) << 4], C += this.toBase64Table[64], C += this.toBase64Table[64]), C;
},
/* Convert Base64 data to a string */
/* eslint-disable comma-spacing */
toBinaryTable: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1],
/* eslint-enable comma-spacing */
decode: function(L) {
var C = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, u = L.indexOf("=") - C;
u < 0 && (u = L.length - C);
for (var _ = (u >> 2) * 3 + Math.floor(u % 4 / 1.5), s = new Array(_), p = 0, f = 0, r = 0, n = C; n < L.length; n++) {
var l = this.toBinaryTable[L.charCodeAt(n) & 127], a = L.charAt(n) === this.base64Pad;
if (l === -1) {
Y.Error("Illegal character code " + L.charCodeAt(n) + " at position " + n);
continue;
}
f = f << 6 | l, p += 6, p >= 8 && (p -= 8, a || (s[r++] = f >> p & 255), f &= (1 << p) - 1);
}
if (p) {
var i = new Error("Corrupted base64 string");
throw i.name = "Base64-Error", i;
}
return s;
}
};
}(Bt)), Bt;
}
var Sr;
function Pn() {
return Sr || (Sr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = void 0;
var h = L(ht()), Y = K(yn()), A = dn();
function K(r) {
return r && r.__esModule ? r : { default: r };
}
function Q(r) {
if (typeof WeakMap != "function") return null;
var n = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
return (Q = function(i) {
return i ? l : n;
})(r);
}
function L(r, n) {
if (r && r.__esModule) return r;
if (r === null || C(r) != "object" && typeof r != "function") return { default: r };
var l = Q(n);
if (l && l.has(r)) return l.get(r);
var a = { __proto__: null }, i = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var c in r) if (c !== "default" && {}.hasOwnProperty.call(r, c)) {
var x = i ? Object.getOwnPropertyDescriptor(r, c) : null;
x && (x.get || x.set) ? Object.defineProperty(a, c, x) : a[c] = r[c];
}
return a.default = r, l && l.set(r, a), a;
}
function C(r) {
"@babel/helpers - typeof";
return C = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
return typeof n;
} : function(n) {
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
}, C(r);
}
function u(r, n) {
if (!(r instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function _(r, n) {
for (var l = 0; l < n.length; l++) {
var a = n[l];
a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(r, p(a.key), a);
}
}
function s(r, n, l) {
return n && _(r.prototype, n), Object.defineProperty(r, "prototype", { writable: !1 }), r;
}
function p(r) {
var n = f(r, "string");
return C(n) == "symbol" ? n : n + "";
}
function f(r, n) {
if (C(r) != "object" || !r) return r;
var l = r[Symbol.toPrimitive];
if (l !== void 0) {
var a = l.call(r, n);
if (C(a) != "object") return a;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(r);
}
P.default = /* @__PURE__ */ function() {
function r(n) {
if (u(this, r), this._drawCtx = null, this._renderQ = [], this._flushPromise = null, this._fbWidth = 0, this._fbHeight = 0, this._prevDrawStyle = "", h.Debug(">> Display.constructor"), this._target = n, !this._target)
throw new Error("Target must be set");
if (typeof this._target == "string")
throw new Error("target must be a DOM element");
if (!this._target.getContext)
throw new Error("no getContext method");
this._targetCtx = this._target.getContext("2d"), this._viewportLoc = {
x: 0,
y: 0,
w: this._target.width,
h: this._target.height
}, this._backbuffer = document.createElement("canvas"), this._drawCtx = this._backbuffer.getContext("2d"), this._damageBounds = {
left: 0,
top: 0,
right: this._backbuffer.width,
bottom: this._backbuffer.height
}, h.Debug("User Agent: " + navigator.userAgent), h.Debug("<< Display.constructor"), this._scale = 1, this._clipViewport = !1;
}
return s(r, [{
key: "scale",
get: function() {
return this._scale;
},
set: function(l) {
this._rescale(l);
}
}, {
key: "clipViewport",
get: function() {
return this._clipViewport;
},
set: function(l) {
this._clipViewport = l;
var a = this._viewportLoc;
this.viewportChangeSize(a.w, a.h), this.viewportChangePos(0, 0);
}
}, {
key: "width",
get: function() {
return this._fbWidth;
}
}, {
key: "height",
get: function() {
return this._fbHeight;
}
// ===== PUBLIC METHODS =====
}, {
key: "viewportChangePos",
value: function(l, a) {
var i = this._viewportLoc;
l = Math.floor(l), a = Math.floor(a), this._clipViewport || (l = -i.w, a = -i.h);
var c = i.x + i.w - 1, x = i.y + i.h - 1;
l < 0 && i.x + l < 0 && (l = -i.x), c + l >= this._fbWidth && (l -= c + l - this._fbWidth + 1), i.y + a < 0 && (a = -i.y), x + a >= this._fbHeight && (a -= x + a - this._fbHeight + 1), !(l === 0 && a === 0) && (h.Debug("viewportChange deltaX: " + l + ", deltaY: " + a), i.x += l, i.y += a, this._damage(i.x, i.y, i.w, i.h), this.flip());
}
}, {
key: "viewportChangeSize",
value: function(l, a) {
(!this._clipViewport || typeof l > "u" || typeof a > "u") && (h.Debug("Setting viewport to full display region"), l = this._fbWidth, a = this._fbHeight), l = Math.floor(l), a = Math.floor(a), l > this._fbWidth && (l = this._fbWidth), a > this._fbHeight && (a = this._fbHeight);
var i = this._viewportLoc;
if (i.w !== l || i.h !== a) {
i.w = l, i.h = a;
var c = this._target;
c.width = l, c.height = a, this.viewportChangePos(0, 0), this._damage(i.x, i.y, i.w, i.h), this.flip(), this._rescale(this._scale);
}
}
}, {
key: "absX",
value: function(l) {
return this._scale === 0 ? 0 : (0, A.toSigned32bit)(l / this._scale + this._viewportLoc.x);
}
}, {
key: "absY",
value: function(l) {
return this._scale === 0 ? 0 : (0, A.toSigned32bit)(l / this._scale + this._viewportLoc.y);
}
}, {
key: "resize",
value: function(l, a) {
this._prevDrawStyle = "", this._fbWidth = l, this._fbHeight = a;
var i = this._backbuffer;
if (i.width !== l || i.height !== a) {
var c = null;
i.width > 0 && i.height > 0 && (c = this._drawCtx.getImageData(0, 0, i.width, i.height)), i.width !== l && (i.width = l), i.height !== a && (i.height = a), c && this._drawCtx.putImageData(c, 0, 0);
}
var x = this._viewportLoc;
this.viewportChangeSize(x.w, x.h), this.viewportChangePos(0, 0);
}
}, {
key: "getImageData",
value: function() {
return this._drawCtx.getImageData(0, 0, this.width, this.height);
}
}, {
key: "toDataURL",
value: function(l, a) {
return this._backbuffer.toDataURL(l, a);
}
}, {
key: "toBlob",
value: function(l, a, i) {
return this._backbuffer.toBlob(l, a, i);
}
// Track what parts of the visible canvas that need updating
}, {
key: "_damage",
value: function(l, a, i, c) {
l < this._damageBounds.left && (this._damageBounds.left = l), a < this._damageBounds.top && (this._damageBounds.top = a), l + i > this._damageBounds.right && (this._damageBounds.right = l + i), a + c > this._damageBounds.bottom && (this._damageBounds.bottom = a + c);
}
// Update the visible canvas with the contents of the
// rendering canvas
}, {
key: "flip",
value: function(l) {
if (this._renderQ.length !== 0 && !l)
this._renderQPush({
type: "flip"
});
else {
var a = this._damageBounds.left, i = this._damageBounds.top, c = this._damageBounds.right - a, x = this._damageBounds.bottom - i, v = a - this._viewportLoc.x, b = i - this._viewportLoc.y;
v < 0 && (c += v, a -= v, v = 0), b < 0 && (x += b, i -= b, b = 0), v + c > this._viewportLoc.w && (c = this._viewportLoc.w - v), b + x > this._viewportLoc.h && (x = this._viewportLoc.h - b), c > 0 && x > 0 && this._targetCtx.drawImage(this._backbuffer, a, i, c, x, v, b, c, x), this._damageBounds.left = this._damageBounds.top = 65535, this._damageBounds.right = this._damageBounds.bottom = 0;
}
}
}, {
key: "pending",
value: function() {
return this._renderQ.length > 0;
}
}, {
key: "flush",
value: function() {
var l = this;
return this._renderQ.length === 0 ? Promise.resolve() : (this._flushPromise === null && (this._flushPromise = new Promise(function(a) {
l._flushResolve = a;
})), this._flushPromise);
}
}, {
key: "fillRect",
value: function(l, a, i, c, x, v) {
this._renderQ.length !== 0 && !v ? this._renderQPush({
type: "fill",
x: l,
y: a,
width: i,
height: c,
color: x
}) : (this._setFillColor(x), this._drawCtx.fillRect(l, a, i, c), this._damage(l, a, i, c));
}
}, {
key: "copyImage",
value: function(l, a, i, c, x, v, b) {
this._renderQ.length !== 0 && !b ? this._renderQPush({
type: "copy",
oldX: l,
oldY: a,
x: i,
y: c,
width: x,
height: v
}) : (this._drawCtx.mozImageSmoothingEnabled = !1, this._drawCtx.webkitImageSmoothingEnabled = !1, this._drawCtx.msImageSmoothingEnabled = !1, this._drawCtx.imageSmoothingEnabled = !1, this._drawCtx.drawImage(this._backbuffer, l, a, x, v, i, c, x, v), this._damage(i, c, x, v));
}
}, {
key: "imageRect",
value: function(l, a, i, c, x, v) {
if (!(i === 0 || c === 0)) {
var b = new Image();
b.src = "data: " + x + ";base64," + Y.default.encode(v), this._renderQPush({
type: "img",
img: b,
x: l,
y: a,
width: i,
height: c
});
}
}
}, {
key: "blitImage",
value: function(l, a, i, c, x, v, b) {
if (this._renderQ.length !== 0 && !b) {
var y = new Uint8Array(i * c * 4);
y.set(new Uint8Array(x.buffer, 0, y.length)), this._renderQPush({
type: "blit",
data: y,
x: l,
y: a,
width: i,
height: c
});
} else {
var g = new Uint8ClampedArray(x.buffer, x.byteOffset + v, i * c * 4), S = new ImageData(g, i, c);
this._drawCtx.putImageData(S, l, a), this._damage(l, a, i, c);
}
}
}, {
key: "drawImage",
value: function(l, a, i) {
this._drawCtx.drawImage(l, a, i), this._damage(a, i, l.width, l.height);
}
}, {
key: "autoscale",
value: function(l, a) {
var i;
if (l === 0 || a === 0)
i = 0;
else {
var c = this._viewportLoc, x = l / a, v = c.w / c.h;
v >= x ? i = l / c.w : i = a / c.h;
}
this._rescale(i);
}
// ===== PRIVATE METHODS =====
}, {
key: "_rescale",
value: function(l) {
this._scale = l;
var a = this._viewportLoc, i = l * a.w + "px", c = l * a.h + "px";
(this._target.style.width !== i || this._target.style.height !== c) && (this._target.style.width = i, this._target.style.height = c);
}
}, {
key: "_setFillColor",
value: function(l) {
var a = "rgb(" + l[0] + "," + l[1] + "," + l[2] + ")";
a !== this._prevDrawStyle && (this._drawCtx.fillStyle = a, this._prevDrawStyle = a);
}
}, {
key: "_renderQPush",
value: function(l) {
this._renderQ.push(l), this._renderQ.length === 1 && this._scanRenderQ();
}
}, {
key: "_resumeRenderQ",
value: function() {
this.removeEventListener("load", this._noVNCDisplay._resumeRenderQ), this._noVNCDisplay._scanRenderQ();
}
}, {
key: "_scanRenderQ",
value: function() {
for (var l = !0; l && this._renderQ.length > 0; ) {
var a = this._renderQ[0];
switch (a.type) {
case "flip":
this.flip(!0);
break;
case "copy":
this.copyImage(a.oldX, a.oldY, a.x, a.y, a.width, a.height, !0);
break;
case "fill":
this.fillRect(a.x, a.y, a.width, a.height, a.color, !0);
break;
case "blit":
this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, !0);
break;
case "img":
if (a.img.complete) {
if (a.img.width !== a.width || a.img.height !== a.height) {
h.Error("Decoded image has incorrect dimensions. Got " + a.img.width + "x" + a.img.height + ". Expected " + a.width + "x" + a.height + ".");
return;
}
this.drawImage(a.img, a.x, a.y);
} else
a.img._noVNCDisplay = this, a.img.addEventListener("load", this._resumeRenderQ), l = !1;
break;
}
l && this._renderQ.shift();
}
this._renderQ.length === 0 && this._flushPromise !== null && (this._flushResolve(), this._flushPromise = null, this._flushResolve = null);
}
}]);
}();
}(Ot)), Ot;
}
var Qt = {}, ze = {}, ut = {}, Kr;
function At() {
if (Kr) return ut;
Kr = 1, Object.defineProperty(ut, "__esModule", {
value: !0
}), ut.Buf8 = ut.Buf32 = ut.Buf16 = void 0, ut.arraySet = h, ut.flattenChunks = Y, ut.shrinkBuf = P;
function P(A, K) {
return A.length === K ? A : A.subarray ? A.subarray(0, K) : (A.length = K, A);
}
function h(A, K, Q, L, C) {
if (K.subarray && A.subarray) {
A.set(K.subarray(Q, Q + L), C);
return;
}
for (var u = 0; u < L; u++)
A[C + u] = K[Q + u];
}
function Y(A) {
var K, Q, L, C, u, _;
for (L = 0, K = 0, Q = A.length; K < Q; K++)
L += A[K].length;
for (_ = new Uint8Array(L), C = 0, K = 0, Q = A.length; K < Q; K++)
u = A[K], _.set(u, C), C += u.length;
return _;
}
return ut.Buf8 = Uint8Array, ut.Buf16 = Uint16Array, ut.Buf32 = Int32Array, ut;
}
var It = {}, Er;
function xn() {
return Er || (Er = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = h;
function h(Y, A, K, Q) {
for (var L = Y & 65535 | 0, C = Y >>> 16 & 65535 | 0, u = 0; K !== 0; ) {
u = K > 2e3 ? 2e3 : K, K -= u;
do
L = L + A[Q++] | 0, C = C + L | 0;
while (--u);
L %= 65521, C %= 65521;
}
return L | C << 16 | 0;
}
}(It)), It;
}
var Ut = {}, Xr;
function gn() {
return Xr || (Xr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = h;
function h() {
for (var Y, A = [], K = 0; K < 256; K++) {
Y = K;
for (var Q = 0; Q < 8; Q++)
Y = Y & 1 ? 3988292384 ^ Y >>> 1 : Y >>> 1;
A[K] = Y;
}
return A;
}
h();
}(Ut)), Ut;
}
var Nt = {}, Fr;
function Ln() {
return Fr || (Fr = 1, function(P) {
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = A;
var h = 30, Y = 12;
function A(K, Q) {
var L, C, u, _, s, p, f, r, n, l, a, i, c, x, v, b, y, g, S, X, F, T, B, D, N;
L = K.state, C = K.next_in, D = K.input, u = C + (K.avail_in - 5), _ = K.next_out, N = K.output, s = _ - (Q - K.avail_out), p = _ + (K.avail_out - 257), f = L.dmax, r = L.wsize, n = L.whave, l = L.wnext, a = L.window, i = L.hold, c = L.bits, x = L.lencode, v = L.distcode, b = (1 << L.lenbits) - 1, y = (1 << L.distbits) - 1;
e: do {
c < 15 && (i += D[C++] << c, c += 8, i += D[C++] << c, c += 8), g = x[i & b];
t: for (; ; ) {
if (S = g >>> 24, i >>>= S, c -= S, S = g >>> 16 & 255, S === 0)
N[_++] = g & 65535;
else if (S & 16) {
X = g & 65535, S &= 15, S && (c < S && (i += D[C++] << c, c += 8), X += i & (1 << S) - 1, i >>>= S, c -= S), c < 15 && (i += D[C++] << c, c += 8, i += D[C++] << c, c += 8), g = v[i & y];
r: for (; ; ) {
if (S = g >>> 24, i >>>= S, c -= S, S = g >>> 16 & 255, S & 16) {
if (F = g & 65535, S &= 15, c < S && (i += D[C++] << c, c += 8, c < S && (i += D[C++] << c, c += 8)), F += i & (1 << S) - 1, F > f) {
K.msg = "invalid distance too far back", L.mode = h;
break e;
}
if (i >>>= S, c -= S, S = _ - s, F > S) {
if (S = F - S, S > n && L.sane) {
K.msg = "invalid distance too far back", L.mode = h;
break e;
}
if (T = 0, B = a, l === 0) {
if (T += r - S, S < X) {
X -= S;
do
N[_++] = a[T++];
while (--S);
T = _ - F, B = N;
}
} else if (l < S) {
if (T += r + l - S, S -= l, S < X) {
X -= S;
do
N[_++] = a[T++];
while (--S);
if (T = 0, l < X) {
S = l, X -= S;
do
N[_++] = a[T++];
while (--S);
T = _ - F, B = N;
}
}
} else if (T += l - S, S < X) {
X -= S;
do
N[_++] = a[T++];
while (--S);
T = _ - F, B = N;
}
for (; X > 2; )
N[_++] = B[T++], N[_++] = B[T++], N[_++] = B[T++], X -= 3;
X && (N[_++] = B[T++], X > 1 && (N[_++] = B[T++]));
} else {
T = _ - F;
do
N[_++] = N[T++], N[_++] = N[T++], N[_++] = N[T++], X -= 3;
while (X > 2);
X && (N[_++] = N[T++], X > 1 && (N[_++] = N[T++]));
}
} else if ((S & 64) === 0) {
g = v[(g & 65535) + (i & (1 << S) - 1)];
continue r;
} else {
K.msg = "invalid distance code", L.mode = h;
break e;
}
break;
}
} else if ((S & 64) === 0) {
g = x[(g & 65535) + (i & (1 << S) - 1)];
continue t;
} else if (S & 32) {
L.mode = Y;
break e;
} else {
K.msg = "invalid literal/length code", L.mode = h;
break e;
}
break;
}
} while (C < u && _ < p);
X = c >> 3, C -= X, c -= X << 3, i &= (1 << c) - 1, K.next_in = C, K.next_out = _, K.avail_in = C < u ? 5 + (u - C) : 5 - (C - u), K.avail_out = _ < p ? 257 + (p - _) : 257 - (_ - p), L.hold = i, L.bits = c;
}
}(Nt)), Nt;
}
var jt = {}, Cr;
function Mn() {
return Cr || (Cr = 1, function(P) {
function h(a) {
"@babel/helpers - typeof";
return h = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
return typeof i;
} : function(i) {
return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
}, h(a);
}
Object.defineProperty(P, "__esModule", {
value: !0
}), P.default = l;
var Y = K(At());
function A(a) {
if (typeof WeakMap != "function") return null;
var i = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap();
return (A = function(v) {
return v ? c : i;
})(a);
}
function K(a, i) {
if (a && a.__esModule) return a;
if (a === null || h(a) != "object" && typeof a != "function") return { default: a };
var c = A(i);
if (c && c.has(a)) return c.get(a);
var x = { __proto__: null }, v = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var b in a) if (b !== "default" && {}.hasOwnProperty.call(a, b)) {
var y = v ? Object.getOwnPropertyDescriptor(a, b) : null;
y && (y.get || y.set) ? Object.defineProperty(x, b, y) : x[b] = a[b];
}
return x.default = a, c && c.set(a, x), x;
}
var Q = 15, L = 852, C = 592, u = 0, _ = 1, s = 2, p = [
/* 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
], f = [
/* 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
], r = [
/* 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
], n = [
/* 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
];
function l(a, i, c, x, v, b, y, g) {
var S = g.bits, X = 0, F = 0, T = 0, B = 0, D = 0, N = 0, te = 0, _e = 0, ge = 0, ve = 0, Fe, Ae, le, ke, Re, De = null, J = 0, $, re = new Y.Buf16(Q + 1), G = new Y.Buf16(Q + 1), O = null, I = 0, se, ue, j;
for (X = 0; X <= Q; X++)
re[X] = 0;
for (F = 0; F < x; F++)
re[i[c + F]]++;
for (D = S, B = Q; B >= 1 && re[B] === 0; B--)
;
if (D > B && (D = B), B === 0)
return v[b++] = 1 << 24 | 64 << 16 | 0, v[b++] = 1 << 24 | 64 << 16 | 0, g.bits = 1, 0;
for (T = 1; T < B && re[T] === 0; T++)
;
for (D < T && (D = T), _e = 1, X = 1; X <= Q; X++)
if (_e <<= 1, _e -= re[X], _e < 0)
return -1;
if (_e > 0 && (a === u || B !== 1))
return -1;
for (G[1] = 0, X = 1; X < Q; X++)
G[X + 1] = G[X] + re[X];
for (F = 0; F < x; F++)
i[c + F] !== 0 && (y[G[i[c + F]]++] = F);
if (a === u ? (De = O = y, $ = 19) : a === _ ? (De = p, J -= 257, O = f, I -= 257, $ = 256) : (De = r, O = n, $ = -1), ve = 0, F = 0, X = T, Re = b, N = D, te = 0, le = -1, ge = 1 << D, ke = ge - 1, a === _ && ge > L || a === s && ge > C)
return 1;
for (; ; ) {
se = X - te, y[F] < $ ? (ue = 0, j = y[F]) : y[F] > $ ? (ue = O[I + y[F]], j = De[J + y[F]]) : (ue = 96, j = 0), Fe = 1 << X - te, Ae = 1 << N, T = Ae;
do
Ae -= Fe, v[Re + (ve >> te) + Ae] = se << 24 | ue << 16 | j | 0;
while (Ae !== 0);
for (Fe = 1 << X - 1; ve & Fe; )
Fe >>= 1;
if (Fe !== 0 ? (ve &= Fe - 1, ve += Fe) : ve = 0, F++, --re[X] === 0) {
if (X === B)
break;
X = i[c + y[F]];
}
if (X > D && (ve & ke) !== le) {
for (te === 0 && (te = D), Re += T, N = X - te, _e = 1 << N; N + te < B && (_e -= re[N + te], !(_e <= 0)); )
N++, _e <<= 1;
if (ge += 1 << N, a === _ && ge > L || a === s && ge > C)
return 1;
le = ve & ke, v[le] = D << 24 | N << 16 | Re - b | 0;
}
}
return ve !== 0 && (v[Re + ve] = X - te << 24 | 64 << 16 | 0), g.bits = D, 0;
}
}(jt)), jt;
}
var Ar;
function Dn() {
if (Ar) return ze;
Ar = 1;
function P(R) {
"@babel/helpers - typeof";
return P = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(Z) {
return typeof Z;
} : function(Z) {
return Z && typeof Symbol == "function" && Z.constructor === Symbol && Z !== Symbol.prototype ? "symbol" : typeof Z;
}, P(R);
}
Object.defineProperty(ze, "__esModule", {
value: !0
}), ze.Z_TREES = ze.Z_STREAM_ERROR = ze.Z_STREAM_END = ze.Z_OK = ze.Z_NEED_DICT = ze.Z_MEM_ERROR = ze.Z_FINISH = ze.Z_DEFLATED = ze.Z_DATA_ERROR = ze.Z_BUF_ERROR = ze.Z_BLOCK = void 0, ze.inflate = oe, ze.inflateEnd = fe, ze.inflateGetHeader = ye, ze.inflateInfo = void 0, ze.inflateInit = Ze, ze.inflateInit2 = We, ze.inflateReset = He, ze.inflateReset2 = xe, ze.inflateResetKeep = je, ze.inflateSetDictionary = Ce;
var h = u(At()), Y = L(xn()), A = L(gn()), K = L(Ln()), Q = L(Mn());
function L(R) {
return R && R.__esModule ? R : { default: R };
}
function C(R) {
if (typeof WeakMap != "function") return null;
var Z = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap();
return (C = function(Ee) {
return Ee ? w : Z;
})(R);
}
function u(R, Z) {
if (R && R.__esModule) return R;
if (R === null || P(R) != "object" && typeof R != "function") return { default: R };
var w = C(Z);
if (w && w.has(R)) return w.get(R);
var de = { __proto__: null }, Ee = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var e in R) if (e !== "default" && {}.hasOwnProperty.call(R, e)) {
var k = Ee ? Object.getOwnPropertyDescriptor(R, e) : null;
k && (k.get || k.set) ? Object.defineProperty(de, e, k) : de[e] = R[e];
}
return de.default = R, w && w.set(R, de), de;
}
var _ = 0, s = 1, p = 2, f = ze.Z_FINISH = 4, r = ze.Z_BLOCK = 5, n = ze.Z_TREES = 6, l = ze.Z_OK = 0, a = ze.Z_STREAM_END = 1, i = ze.Z_NEED_DICT = 2, c = ze.Z_STREAM_ERROR = -2, x = ze.Z_DATA_ERROR = -3, v = ze.Z_MEM_ERROR = -4, b = ze.Z_BUF_ERROR = -5, y = ze.Z_DEFLATED = 8, g = 1, S = 2, X = 3, F = 4, T = 5, B = 6, D = 7, N = 8, te = 9, _e = 10, ge = 11, ve = 12, Fe = 13, Ae = 14, le = 15, ke = 16, Re = 17, De = 18, J = 19, $ = 20, re = 21, G = 22, O = 23, I = 24, se = 25, ue = 26, j = 27, W = 28, ee = 29, ne = 30, be = 31, V = 32, q = 852, ie = 592, ce = 15, he = ce;
function H(R) {
return (R >>> 24 & 255) + (R >>> 8 & 65280) + ((R & 65280) << 8) + ((R & 255) << 24);
}
function we() {
this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new h.Buf16(320), this.work = new h.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
}
function je(R) {
var Z;
return !R || !R.state ? c : (Z = R.state, R.total_in = R.total_out = Z.total = 0, R.msg = "", Z.wrap && (R.adler = Z.wrap & 1), Z.mode = g, Z.last = 0, Z.havedict = 0, Z.dmax = 32768, Z.head = null, Z.hold = 0, Z.bits = 0, Z.lencode = Z.lendyn = new h.Buf32(q), Z.distcode = Z.distdyn = new h.Buf32(ie), Z.sane = 1, Z.back = -1, l);
}
function He(R) {
var Z;
return !R || !R.state ? c : (Z = R.state, Z.wsize = 0, Z.whave = 0, Z.wnext = 0, je(R));
}
function xe(R, Z) {
var w, de;
return !R || !R.state || (de = R.state, Z < 0 ? (w = 0, Z = -Z) : (w = (Z >> 4) + 1, Z < 48 && (Z &= 15)), Z && (Z < 8 || Z > 15)) ? c : (de.window !== null && de.wbits !== Z && (de.window = null), de.wrap = w, de.wbits = Z, He(R));
}
function We(R, Z) {
var w, de;
return R ? (de = new we(), R.state = de, de.window = null, w = xe(R, Z), w !== l && (R.state = null), w) : c;
}
function Ze(R) {
return We(R, he);
}
var at = !0, lt, tt;
function ot(R) {
if (at) {
var Z;
for (lt = new h.Buf32(512), tt = new h.Buf32(32), Z = 0; Z < 144; )
R.lens[Z++] = 8;
for (; Z < 256; )
R.lens[Z++] = 9;
for (; Z < 280; )
R.lens[Z++] = 7;
for (; Z < 288; )
R.lens[Z++] = 8;
for ((0, Q.default)(s, R.lens, 0, 288, lt, 0, R.work, {
bits: 9
}), Z = 0; Z < 32; )
R.lens[Z++] = 5;
(0, Q.default)(p, R.lens, 0, 32, tt, 0, R.work, {
bits: 5
}), at = !1;
}
R.lencode = lt, R.lenbits = 9, R.distcode = tt, R.distbits = 5;
}
function E(R, Z, w, de) {
var Ee, e = R.state;
return e.window === null && (e.wsize = 1 << e.wbits, e.wnext = 0, e.whave = 0, e.window = new h.Buf8(e.wsize)), de >= e.wsize ? (h.arraySet(e.window, Z, w - e.wsize, e.wsize, 0), e.wnext = 0, e.whave = e.wsize) : (Ee = e.wsize - e.wnext, Ee > de && (Ee = de), h.arraySet(e.window, Z, w - de, Ee, e.wnext), de -= Ee, de ? (h.arraySet(e.window, Z, w - de, de, 0), e.wnext = de, e.whave = e.wsize) : (e.wnext += Ee, e.wnext === e.wsize && (e.wnext = 0), e.whave < e.wsize && (e.whave += Ee))), 0;
}
function oe(R, Z) {
var w, de, Ee, e, k, m, t, d, o, M, U, z, ae, Le, Pe = 0, Xe, Te, Be, Ke, Ie, Ye, qe, Ne, Ge = new h.Buf8(4), et, rt, st = (
/* permutation of code lengths */
[16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]
);
if (!R || !R.state || !R.output || !R.input && R.avail_in !== 0)
return c;
w = R.state, w.mode === ve && (w.mode = Fe), k = R.next_out, Ee = R.output, t = R.avail_out, e = R.next_in, de = R.input, m = R.avail_in, d = w.hold, o = w.bits, M = m, U = t, Ne = l;
e:
for (; ; )
switch (w.mode) {
case g:
if (w.wrap === 0) {
w.mode = Fe;
break;
}
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += de[e++] << o, o += 8;
}
if (w.wrap & 2 && d === 35615) {
w.check = 0, Ge[0] = d & 255, Ge[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, Ge, 2, 0), d = 0, o = 0, w.mode = S;
break;
}
if (w.flags = 0, w.head && (w.head.done = !1), !(w.wrap & 1) || /* check if zlib header allowed */
(((d & 255) << 8) + (d >> 8)) % 31) {
R.msg = "incorrect header check", w.mode = ne;
break;
}
if ((d & 15) !== y) {
R.msg = "unknown compression method", w.mode = ne;
break;
}
if (d >>>= 4, o -= 4, qe = (d & 15) + 8, w.wbits === 0)
w.wbits = qe;
else if (qe > w.wbits) {
R.msg = "invalid window size", w.mode = ne;
break;
}
w.dmax = 1 << qe, R.adler = w.check = 1, w.mode = d & 512 ? _e : ve, d = 0, o = 0;
break;
case S:
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += de[e++] << o, o += 8;
}
if (w.flags = d, (w.flags & 255) !== y) {
R.msg = "unknown compression method", w.mode = ne;
break;
}
if (w.flags & 57344) {
R.msg = "unknown header flags set", w.mode = ne;
break;
}
w.head && (w.head.text = d >> 8 & 1), w.flags & 512 && (Ge[0] = d & 255, Ge[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, Ge, 2, 0)), d = 0, o = 0, w.mode = X;
/* falls through */
case X:
for (; o < 32; ) {
if (m === 0)
break e;
m--, d += de[e++] << o, o += 8;
}
w.head && (w.head.time = d), w.flags & 512 && (Ge[0] = d & 255, Ge[1] = d >>> 8 & 255, Ge[2] = d >>> 16 & 255, Ge[3] = d >>> 24 & 255, w.check = (0, A.default)(w.check, Ge, 4, 0)), d = 0, o = 0, w.mode = F;
/* falls through */
case F:
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += de[e++] << o, o += 8;
}
w.head && (w.head.xflags = d & 255, w.head.os = d >> 8), w.flags & 512 && (Ge[0] = d & 255, Ge[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, Ge, 2, 0)), d = 0, o = 0, w.mode = T;
/* falls through */
case T:
if (w.flags & 1024) {
for (; o < 16; ) {
if (m === 0)
break e;
m--, d += de[e++] << o, o += 8;
}
w.length = d, w.head && (w.head.extra_len = d), w.flags & 512 && (Ge[0] = d & 255, Ge[1] = d >>> 8 & 255, w.check = (0, A.default)(w.check, Ge, 2, 0)), d = 0, o = 0;
} else w.head && (w.head.extra = null);
w.mode = B;
/* falls through */
case B:
if (w.flags & 1024 && (z = w.length, z > m && (z = m), z && (w.head && (qe = w.head.extra_len - w.length, w.head.extra || (w.head.extra = new Array(w.head.extra_len)), h.arraySet(
w.head.extra,
de,
e,
// extra field is limited to 65536 bytes
// - no need for additional size check
z,
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
qe
)), w.flags & 512 && (w.check = (0, A.default)(w.check, de, z, e)), m -= z, e += z, w.length -= z), w.length))
break e;
w.length = 0, w.mode = D;
/* falls through */
case D:
if (w.flags & 2048) {
if (m === 0)
break e;
z = 0;
do
qe = de[e + z++], w.head && qe && w.length < 65536 && (w.head.name += String.fromCharCode(qe));
while (qe && z < m);
if (w.flags & 512 && (w.check = (0, A.default)(w.check, de, z, e)), m -= z, e += z, qe)
break