From 244ff94f8d26f8b770894d43d892887626996f03 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Sat, 25 Nov 2023 19:57:10 -0600 Subject: [PATCH] git being annoying --- Cargo.lock | 6 +- client/dist/index.html | 59 + client/dist/index.js | 30 + .../dist/modulepreload-polyfill-6303fcb0.js | 24 + client/dist/play.html | 51 + client/dist/play.js | 3493 +++++++++++++++++ 6 files changed, 3660 insertions(+), 3 deletions(-) create mode 100644 client/dist/index.html create mode 100644 client/dist/index.js create mode 100644 client/dist/modulepreload-polyfill-6303fcb0.js create mode 100644 client/dist/play.html create mode 100644 client/dist/play.js diff --git a/Cargo.lock b/Cargo.lock index 942bc6a541054229686aa8005c353df5e8a8de03..1ffe8fcff79f24156108e9c75378d7b1554c8fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,8 +379,8 @@ dependencies = [ [[package]] name = "bevy_twite" -version = "0.1.0" -source = "git+https://gitlab.com/ghostlyzsh/twite.git#f04df32d81c3b460fdd4d80930d19f537b860f1e" +version = "1.0.0" +source = "git+https://gitlab.com/ghostlyzsh/twite.git#37df5884b009eb55d2a0d49877559e397306a629" dependencies = [ "bevy", "crossbeam-channel", @@ -1167,7 +1167,7 @@ dependencies = [ [[package]] name = "twite" version = "0.1.0" -source = "git+https://gitlab.com/ghostlyzsh/twite.git#f04df32d81c3b460fdd4d80930d19f537b860f1e" +source = "git+https://gitlab.com/ghostlyzsh/twite.git#37df5884b009eb55d2a0d49877559e397306a629" dependencies = [ "base64", "rand", diff --git a/client/dist/index.html b/client/dist/index.html new file mode 100644 index 0000000000000000000000000000000000000000..4ac988c0e45814323cd96ca6cd0b7ea5a1810ee3 --- /dev/null +++ b/client/dist/index.html @@ -0,0 +1,59 @@ + + + + + + StarKingdoms + + + + + +

StarKingdoms

+
+ Join Game +
+ + +
+ + +
+ +
+ +
+ +
+

You are not logged in.

+ + Click here to log in or change accounts. +
+
+ + + + + + + diff --git a/client/dist/index.js b/client/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d565a3225853df3da3521cb1219dbc219991ad16 --- /dev/null +++ b/client/dist/index.js @@ -0,0 +1,30 @@ +import "./modulepreload-polyfill-6303fcb0.js"; +let s = "http://localhost:8080", r = []; +function i(e) { + return e.endsWith("/") ? e + "ping" : e + "/ping"; +} +function a(e) { + let t = new URL(e); + return t.protocol === "https:" ? "wss://" + t.host + "/ws" : "ws://" + t.host + "/ws"; +} +function u(e) { + fetch(i(e)).then((t) => { + t.json().then((o) => { + let l = document.createElement("option"); + l.value = a(e), l.text = `${o.description} - ${o.version.name} - ${o.players} online`, document.getElementById("server").appendChild(l); + }); + }); +} +fetch(`${s}/server-list`).then((e) => { + e.json().then((t) => { + r = t.servers; + for (let o = 0; o < r.length; o++) + u(r[o]); + }); +}); +let n = new URLSearchParams(window.location.search); +n.has("token") && n.has("user") && (window.localStorage.setItem("token", n.get("token")), window.localStorage.setItem("user", n.get("user"))); +window.localStorage.getItem("token") !== null && window.localStorage.getItem("user") !== null && (document.getElementById("logout").style.setProperty("display", "block"), document.getElementById("logout").addEventListener("click", () => { + window.localStorage.clear(), window.location.reload(); +}), document.getElementById("loginstatus").innerText = `Logged in! (you are ${window.localStorage.getItem("user")})`); +document.getElementById("login").href = `${s}/select-realm`; diff --git a/client/dist/modulepreload-polyfill-6303fcb0.js b/client/dist/modulepreload-polyfill-6303fcb0.js new file mode 100644 index 0000000000000000000000000000000000000000..f5ee899d644230d24e38a607d2d0277e4362fadf --- /dev/null +++ b/client/dist/modulepreload-polyfill-6303fcb0.js @@ -0,0 +1,24 @@ +(function() { + const t = document.createElement("link").relList; + if (t && t.supports && t.supports("modulepreload")) + return; + for (const e of document.querySelectorAll('link[rel="modulepreload"]')) + i(e); + new MutationObserver((e) => { + for (const r of e) + if (r.type === "childList") + for (const o of r.addedNodes) + o.tagName === "LINK" && o.rel === "modulepreload" && i(o); + }).observe(document, { childList: !0, subtree: !0 }); + function s(e) { + const r = {}; + return e.integrity && (r.integrity = e.integrity), e.referrerPolicy && (r.referrerPolicy = e.referrerPolicy), e.crossOrigin === "use-credentials" ? r.credentials = "include" : e.crossOrigin === "anonymous" ? r.credentials = "omit" : r.credentials = "same-origin", r; + } + function i(e) { + if (e.ep) + return; + e.ep = !0; + const r = s(e); + fetch(e.href, r); + } +})(); diff --git a/client/dist/play.html b/client/dist/play.html new file mode 100644 index 0000000000000000000000000000000000000000..f6ee7fd109363772a6c3f3c00f1a533b595e6cfe --- /dev/null +++ b/client/dist/play.html @@ -0,0 +1,51 @@ + + + + + + StarKingdoms + + + + + + + + +
+

Position: NaN, NaN

+

Velocity: NaN

+

Relative to Moon: NaN, NaN

+

Track Angle: NaN

+ +
+ + + + diff --git a/client/dist/play.js b/client/dist/play.js new file mode 100644 index 0000000000000000000000000000000000000000..044d1ff141f7aabee4bfd8151791a8f1f4e0f58f --- /dev/null +++ b/client/dist/play.js @@ -0,0 +1,3493 @@ +var Z = Object.defineProperty; +var F = (e, t, r) => t in e ? Z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r; +var G = (e, t, r) => (F(e, typeof t != "symbol" ? t + "" : t, r), r); +import "./modulepreload-polyfill-6303fcb0.js"; +let loglevel = 0; +const LEVEL_FATAL = 0, LEVEL_ERROR = 1, LEVEL_WARN = 2, LEVEL_INFO = 3, LEVEL_DEBUG = 4; +let timestampStart, deltaTimestamp, logger$2, loggerSetup = !1; +function logSetup() { + loggerSetup || (loggerSetup = !0, timestampStart = Date.now(), deltaTimestamp = Date.now(), logger$2 = new Logger("Logger.ts"), consoleLogLevel(LEVEL_INFO), logger$2.info("Logger setup complete")); +} +function log(e, t, r) { + const a = { + level: e, + module: t, + message: r, + timestamp: Date.now(), + deltaStart: Date.now() - timestampStart, + deltaLast: Date.now() - deltaTimestamp + }; + deltaTimestamp = Date.now(), consoleLogHandler(a); +} +function consoleLogHandler(e) { + if (e.level <= loglevel) { + let t = ""; + switch (e.level) { + case 0: + t = "color:red;font-weight:bold;"; + break; + case 1: + t = "color:red;"; + break; + case 2: + t = "color:yellow;"; + break; + case 3: + t = ""; + break; + case 4: + t = "color:gray;"; + break; + } + console.log(`%c${new Date(e.timestamp).toISOString()} ${(e.deltaStart / 1e3).toFixed(3)}Σ ${(e.deltaLast / 1e3).toFixed(3)}Δ +%c[${e.module}]%c ${e.message}`, "color:gray", "color:#8c188c", t); + } +} +function consoleLogLevel(e) { + loglevel = e; +} +class Logger { + constructor(t) { + G(this, "name"); + this.name = t; + } + fatal(t) { + log(LEVEL_FATAL, this.name, t); + } + error(t) { + log(LEVEL_ERROR, this.name, t); + } + warn(t) { + log(LEVEL_WARN, this.name, t); + } + info(t) { + log(LEVEL_INFO, this.name, t); + } + debug(t) { + log(LEVEL_DEBUG, this.name, t); + } +} +var __getOwnPropNames = Object.getOwnPropertyNames, __commonJS = (e, t) => function() { + return t || (0, e[__getOwnPropNames(e)[0]])((t = { exports: {} }).exports, t), t.exports; +}, require_aspromise = __commonJS({ + "node_modules/@protobufjs/aspromise/index.js"(e, t) { + t.exports = r; + function r(a, o) { + for (var n = new Array(arguments.length - 1), g = 0, s = 2, u = !0; s < arguments.length; ) + n[g++] = arguments[s++]; + return new Promise(function(f, d) { + n[g] = function(h) { + if (u) + if (u = !1, h) + d(h); + else { + for (var c = new Array(arguments.length - 1), p = 0; p < c.length; ) + c[p++] = arguments[p]; + f.apply(null, c); + } + }; + try { + a.apply(o || null, n); + } catch (m) { + u && (u = !1, d(m)); + } + }); + } + } +}), require_base64 = __commonJS({ + "node_modules/@protobufjs/base64/index.js"(e) { + var t = e; + t.length = function(s) { + var u = s.length; + if (!u) + return 0; + for (var l = 0; --u % 4 > 1 && s.charAt(u) === "="; ) + ++l; + return Math.ceil(s.length * 3) / 4 - l; + }; + var r = new Array(64), a = new Array(123); + for (o = 0; o < 64; ) + a[r[o] = o < 26 ? o + 65 : o < 52 ? o + 71 : o < 62 ? o - 4 : o - 59 | 43] = o++; + var o; + t.encode = function(s, u, l) { + for (var f = null, d = [], m = 0, h = 0, c; u < l; ) { + var p = s[u++]; + switch (h) { + case 0: + d[m++] = r[p >> 2], c = (p & 3) << 4, h = 1; + break; + case 1: + d[m++] = r[c | p >> 4], c = (p & 15) << 2, h = 2; + break; + case 2: + d[m++] = r[c | p >> 6], d[m++] = r[p & 63], h = 0; + break; + } + m > 8191 && ((f || (f = [])).push(String.fromCharCode.apply(String, d)), m = 0); + } + return h && (d[m++] = r[c], d[m++] = 61, h === 1 && (d[m++] = 61)), f ? (m && f.push(String.fromCharCode.apply(String, d.slice(0, m))), f.join("")) : String.fromCharCode.apply(String, d.slice(0, m)); + }; + var n = "invalid encoding"; + t.decode = function(s, u, l) { + for (var f = l, d = 0, m, h = 0; h < s.length; ) { + var c = s.charCodeAt(h++); + if (c === 61 && d > 1) + break; + if ((c = a[c]) === void 0) + throw Error(n); + switch (d) { + case 0: + m = c, d = 1; + break; + case 1: + u[l++] = m << 2 | (c & 48) >> 4, m = c, d = 2; + break; + case 2: + u[l++] = (m & 15) << 4 | (c & 60) >> 2, m = c, d = 3; + break; + case 3: + u[l++] = (m & 3) << 6 | c, d = 0; + break; + } + } + if (d === 1) + throw Error(n); + return l - f; + }, t.test = function(s) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s); + }; + } +}), require_eventemitter = __commonJS({ + "node_modules/@protobufjs/eventemitter/index.js"(e, t) { + t.exports = r; + function r() { + this._listeners = {}; + } + r.prototype.on = function(o, n, g) { + return (this._listeners[o] || (this._listeners[o] = [])).push({ + fn: n, + ctx: g || this + }), this; + }, r.prototype.off = function(o, n) { + if (o === void 0) + this._listeners = {}; + else if (n === void 0) + this._listeners[o] = []; + else + for (var g = this._listeners[o], s = 0; s < g.length; ) + g[s].fn === n ? g.splice(s, 1) : ++s; + return this; + }, r.prototype.emit = function(o) { + var n = this._listeners[o]; + if (n) { + for (var g = [], s = 1; s < arguments.length; ) + g.push(arguments[s++]); + for (s = 0; s < n.length; ) + n[s].fn.apply(n[s++].ctx, g); + } + return this; + }; + } +}), require_float = __commonJS({ + "node_modules/@protobufjs/float/index.js"(e, t) { + t.exports = r(r); + function r(s) { + return typeof Float32Array < "u" ? function() { + var u = new Float32Array([-0]), l = new Uint8Array(u.buffer), f = l[3] === 128; + function d(p, w, k) { + u[0] = p, w[k] = l[0], w[k + 1] = l[1], w[k + 2] = l[2], w[k + 3] = l[3]; + } + function m(p, w, k) { + u[0] = p, w[k] = l[3], w[k + 1] = l[2], w[k + 2] = l[1], w[k + 3] = l[0]; + } + s.writeFloatLE = f ? d : m, s.writeFloatBE = f ? m : d; + function h(p, w) { + return l[0] = p[w], l[1] = p[w + 1], l[2] = p[w + 2], l[3] = p[w + 3], u[0]; + } + function c(p, w) { + return l[3] = p[w], l[2] = p[w + 1], l[1] = p[w + 2], l[0] = p[w + 3], u[0]; + } + s.readFloatLE = f ? h : c, s.readFloatBE = f ? c : h; + }() : function() { + function u(f, d, m, h) { + var c = d < 0 ? 1 : 0; + if (c && (d = -d), d === 0) + f(1 / d > 0 ? ( + /* positive */ + 0 + ) : ( + /* negative 0 */ + 2147483648 + ), m, h); + else if (isNaN(d)) + f(2143289344, m, h); + else if (d > 34028234663852886e22) + f((c << 31 | 2139095040) >>> 0, m, h); + else if (d < 11754943508222875e-54) + f((c << 31 | Math.round(d / 1401298464324817e-60)) >>> 0, m, h); + else { + var p = Math.floor(Math.log(d) / Math.LN2), w = Math.round(d * Math.pow(2, -p) * 8388608) & 8388607; + f((c << 31 | p + 127 << 23 | w) >>> 0, m, h); + } + } + s.writeFloatLE = u.bind(null, a), s.writeFloatBE = u.bind(null, o); + function l(f, d, m) { + var h = f(d, m), c = (h >> 31) * 2 + 1, p = h >>> 23 & 255, w = h & 8388607; + return p === 255 ? w ? NaN : c * (1 / 0) : p === 0 ? c * 1401298464324817e-60 * w : c * Math.pow(2, p - 150) * (w + 8388608); + } + s.readFloatLE = l.bind(null, n), s.readFloatBE = l.bind(null, g); + }(), typeof Float64Array < "u" ? function() { + var u = new Float64Array([-0]), l = new Uint8Array(u.buffer), f = l[7] === 128; + function d(p, w, k) { + u[0] = p, w[k] = l[0], w[k + 1] = l[1], w[k + 2] = l[2], w[k + 3] = l[3], w[k + 4] = l[4], w[k + 5] = l[5], w[k + 6] = l[6], w[k + 7] = l[7]; + } + function m(p, w, k) { + u[0] = p, w[k] = l[7], w[k + 1] = l[6], w[k + 2] = l[5], w[k + 3] = l[4], w[k + 4] = l[3], w[k + 5] = l[2], w[k + 6] = l[1], w[k + 7] = l[0]; + } + s.writeDoubleLE = f ? d : m, s.writeDoubleBE = f ? m : d; + function h(p, w) { + return l[0] = p[w], l[1] = p[w + 1], l[2] = p[w + 2], l[3] = p[w + 3], l[4] = p[w + 4], l[5] = p[w + 5], l[6] = p[w + 6], l[7] = p[w + 7], u[0]; + } + function c(p, w) { + return l[7] = p[w], l[6] = p[w + 1], l[5] = p[w + 2], l[4] = p[w + 3], l[3] = p[w + 4], l[2] = p[w + 5], l[1] = p[w + 6], l[0] = p[w + 7], u[0]; + } + s.readDoubleLE = f ? h : c, s.readDoubleBE = f ? c : h; + }() : function() { + function u(f, d, m, h, c, p) { + var w = h < 0 ? 1 : 0; + if (w && (h = -h), h === 0) + f(0, c, p + d), f(1 / h > 0 ? ( + /* positive */ + 0 + ) : ( + /* negative 0 */ + 2147483648 + ), c, p + m); + else if (isNaN(h)) + f(0, c, p + d), f(2146959360, c, p + m); + else if (h > 17976931348623157e292) + f(0, c, p + d), f((w << 31 | 2146435072) >>> 0, c, p + m); + else { + var k; + if (h < 22250738585072014e-324) + k = h / 5e-324, f(k >>> 0, c, p + d), f((w << 31 | k / 4294967296) >>> 0, c, p + m); + else { + var N = Math.floor(Math.log(h) / Math.LN2); + N === 1024 && (N = 1023), k = h * Math.pow(2, -N), f(k * 4503599627370496 >>> 0, c, p + d), f((w << 31 | N + 1023 << 20 | k * 1048576 & 1048575) >>> 0, c, p + m); + } + } + } + s.writeDoubleLE = u.bind(null, a, 0, 4), s.writeDoubleBE = u.bind(null, o, 4, 0); + function l(f, d, m, h, c) { + var p = f(h, c + d), w = f(h, c + m), k = (w >> 31) * 2 + 1, N = w >>> 20 & 2047, y = 4294967296 * (w & 1048575) + p; + return N === 2047 ? y ? NaN : k * (1 / 0) : N === 0 ? k * 5e-324 * y : k * Math.pow(2, N - 1075) * (y + 4503599627370496); + } + s.readDoubleLE = l.bind(null, n, 0, 4), s.readDoubleBE = l.bind(null, g, 4, 0); + }(), s; + } + function a(s, u, l) { + u[l] = s & 255, u[l + 1] = s >>> 8 & 255, u[l + 2] = s >>> 16 & 255, u[l + 3] = s >>> 24; + } + function o(s, u, l) { + u[l] = s >>> 24, u[l + 1] = s >>> 16 & 255, u[l + 2] = s >>> 8 & 255, u[l + 3] = s & 255; + } + function n(s, u) { + return (s[u] | s[u + 1] << 8 | s[u + 2] << 16 | s[u + 3] << 24) >>> 0; + } + function g(s, u) { + return (s[u] << 24 | s[u + 1] << 16 | s[u + 2] << 8 | s[u + 3]) >>> 0; + } + } +}), require_inquire = __commonJS({ + "node_modules/@protobufjs/inquire/index.js"(exports, module) { + module.exports = inquire; + function inquire(moduleName) { + try { + var mod = eval("quire".replace(/^/, "re"))(moduleName); + if (mod && (mod.length || Object.keys(mod).length)) + return mod; + } catch (e) { + } + return null; + } + } +}), require_utf8 = __commonJS({ + "node_modules/@protobufjs/utf8/index.js"(e) { + var t = e; + t.length = function(a) { + for (var o = 0, n = 0, g = 0; g < a.length; ++g) + n = a.charCodeAt(g), n < 128 ? o += 1 : n < 2048 ? o += 2 : (n & 64512) === 55296 && (a.charCodeAt(g + 1) & 64512) === 56320 ? (++g, o += 4) : o += 3; + return o; + }, t.read = function(a, o, n) { + var g = n - o; + if (g < 1) + return ""; + for (var s = null, u = [], l = 0, f; o < n; ) + f = a[o++], f < 128 ? u[l++] = f : f > 191 && f < 224 ? u[l++] = (f & 31) << 6 | a[o++] & 63 : f > 239 && f < 365 ? (f = ((f & 7) << 18 | (a[o++] & 63) << 12 | (a[o++] & 63) << 6 | a[o++] & 63) - 65536, u[l++] = 55296 + (f >> 10), u[l++] = 56320 + (f & 1023)) : u[l++] = (f & 15) << 12 | (a[o++] & 63) << 6 | a[o++] & 63, l > 8191 && ((s || (s = [])).push(String.fromCharCode.apply(String, u)), l = 0); + return s ? (l && s.push(String.fromCharCode.apply(String, u.slice(0, l))), s.join("")) : String.fromCharCode.apply(String, u.slice(0, l)); + }, t.write = function(a, o, n) { + for (var g = n, s, u, l = 0; l < a.length; ++l) + s = a.charCodeAt(l), s < 128 ? o[n++] = s : s < 2048 ? (o[n++] = s >> 6 | 192, o[n++] = s & 63 | 128) : (s & 64512) === 55296 && ((u = a.charCodeAt(l + 1)) & 64512) === 56320 ? (s = 65536 + ((s & 1023) << 10) + (u & 1023), ++l, o[n++] = s >> 18 | 240, o[n++] = s >> 12 & 63 | 128, o[n++] = s >> 6 & 63 | 128, o[n++] = s & 63 | 128) : (o[n++] = s >> 12 | 224, o[n++] = s >> 6 & 63 | 128, o[n++] = s & 63 | 128); + return n - g; + }; + } +}), require_pool = __commonJS({ + "node_modules/@protobufjs/pool/index.js"(e, t) { + t.exports = r; + function r(a, o, n) { + var g = n || 8192, s = g >>> 1, u = null, l = g; + return function(d) { + if (d < 1 || d > s) + return a(d); + l + d > g && (u = a(g), l = 0); + var m = o.call(u, l, l += d); + return l & 7 && (l = (l | 7) + 1), m; + }; + } + } +}), require_longbits = __commonJS({ + "node_modules/protobufjs/src/util/longbits.js"(e, t) { + t.exports = a; + var r = require_minimal(); + function a(s, u) { + this.lo = s >>> 0, this.hi = u >>> 0; + } + var o = a.zero = new a(0, 0); + o.toNumber = function() { + return 0; + }, o.zzEncode = o.zzDecode = function() { + return this; + }, o.length = function() { + return 1; + }; + var n = a.zeroHash = "\0\0\0\0\0\0\0\0"; + a.fromNumber = function(u) { + if (u === 0) + return o; + var l = u < 0; + l && (u = -u); + var f = u >>> 0, d = (u - f) / 4294967296 >>> 0; + return l && (d = ~d >>> 0, f = ~f >>> 0, ++f > 4294967295 && (f = 0, ++d > 4294967295 && (d = 0))), new a(f, d); + }, a.from = function(u) { + if (typeof u == "number") + return a.fromNumber(u); + if (r.isString(u)) + if (r.Long) + u = r.Long.fromString(u); + else + return a.fromNumber(parseInt(u, 10)); + return u.low || u.high ? new a(u.low >>> 0, u.high >>> 0) : o; + }, a.prototype.toNumber = function(u) { + if (!u && this.hi >>> 31) { + var l = ~this.lo + 1 >>> 0, f = ~this.hi >>> 0; + return l || (f = f + 1 >>> 0), -(l + f * 4294967296); + } + return this.lo + this.hi * 4294967296; + }, a.prototype.toLong = function(u) { + return r.Long ? new r.Long(this.lo | 0, this.hi | 0, !!u) : { low: this.lo | 0, high: this.hi | 0, unsigned: !!u }; + }; + var g = String.prototype.charCodeAt; + a.fromHash = function(u) { + return u === n ? o : new a( + (g.call(u, 0) | g.call(u, 1) << 8 | g.call(u, 2) << 16 | g.call(u, 3) << 24) >>> 0, + (g.call(u, 4) | g.call(u, 5) << 8 | g.call(u, 6) << 16 | g.call(u, 7) << 24) >>> 0 + ); + }, a.prototype.toHash = function() { + return String.fromCharCode( + this.lo & 255, + this.lo >>> 8 & 255, + this.lo >>> 16 & 255, + this.lo >>> 24, + this.hi & 255, + this.hi >>> 8 & 255, + this.hi >>> 16 & 255, + this.hi >>> 24 + ); + }, a.prototype.zzEncode = function() { + var u = this.hi >> 31; + return this.hi = ((this.hi << 1 | this.lo >>> 31) ^ u) >>> 0, this.lo = (this.lo << 1 ^ u) >>> 0, this; + }, a.prototype.zzDecode = function() { + var u = -(this.lo & 1); + return this.lo = ((this.lo >>> 1 | this.hi << 31) ^ u) >>> 0, this.hi = (this.hi >>> 1 ^ u) >>> 0, this; + }, a.prototype.length = function() { + var u = this.lo, l = (this.lo >>> 28 | this.hi << 4) >>> 0, f = this.hi >>> 24; + return f === 0 ? l === 0 ? u < 16384 ? u < 128 ? 1 : 2 : u < 2097152 ? 3 : 4 : l < 16384 ? l < 128 ? 5 : 6 : l < 2097152 ? 7 : 8 : f < 128 ? 9 : 10; + }; + } +}), require_minimal = __commonJS({ + "node_modules/protobufjs/src/util/minimal.js"(e) { + var t = e; + t.asPromise = require_aspromise(), t.base64 = require_base64(), t.EventEmitter = require_eventemitter(), t.float = require_float(), t.inquire = require_inquire(), t.utf8 = require_utf8(), t.pool = require_pool(), t.LongBits = require_longbits(), t.isNode = !!(typeof global < "u" && global && global.process && global.process.versions && global.process.versions.node), t.global = t.isNode && global || typeof window < "u" && window || typeof self < "u" && self || e, t.emptyArray = Object.freeze ? Object.freeze([]) : ( + /* istanbul ignore next */ + [] + ), t.emptyObject = Object.freeze ? Object.freeze({}) : ( + /* istanbul ignore next */ + {} + ), t.isInteger = Number.isInteger || /* istanbul ignore next */ + function(n) { + return typeof n == "number" && isFinite(n) && Math.floor(n) === n; + }, t.isString = function(n) { + return typeof n == "string" || n instanceof String; + }, t.isObject = function(n) { + return n && typeof n == "object"; + }, t.isset = /** + * Checks if a property on a message is considered to be present. + * @param {Object} obj Plain object or message instance + * @param {string} prop Property name + * @returns {boolean} `true` if considered to be present, otherwise `false` + */ + t.isSet = function(n, g) { + var s = n[g]; + return s != null && n.hasOwnProperty(g) ? typeof s != "object" || (Array.isArray(s) ? s.length : Object.keys(s).length) > 0 : !1; + }, t.Buffer = function() { + try { + var o = t.inquire("buffer").Buffer; + return o.prototype.utf8Write ? o : ( + /* istanbul ignore next */ + null + ); + } catch { + return null; + } + }(), t._Buffer_from = null, t._Buffer_allocUnsafe = null, t.newBuffer = function(n) { + return typeof n == "number" ? t.Buffer ? t._Buffer_allocUnsafe(n) : new t.Array(n) : t.Buffer ? t._Buffer_from(n) : typeof Uint8Array > "u" ? n : new Uint8Array(n); + }, t.Array = typeof Uint8Array < "u" ? Uint8Array : Array, t.Long = /* istanbul ignore next */ + t.global.dcodeIO && /* istanbul ignore next */ + t.global.dcodeIO.Long || /* istanbul ignore next */ + t.global.Long || t.inquire("long"), t.key2Re = /^true|false|0|1$/, t.key32Re = /^-?(?:0|[1-9][0-9]*)$/, t.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/, t.longToHash = function(n) { + return n ? t.LongBits.from(n).toHash() : t.LongBits.zeroHash; + }, t.longFromHash = function(n, g) { + var s = t.LongBits.fromHash(n); + return t.Long ? t.Long.fromBits(s.lo, s.hi, g) : s.toNumber(!!g); + }; + function r(o, n, g) { + for (var s = Object.keys(n), u = 0; u < s.length; ++u) + (o[s[u]] === void 0 || !g) && (o[s[u]] = n[s[u]]); + return o; + } + t.merge = r, t.lcFirst = function(n) { + return n.charAt(0).toLowerCase() + n.substring(1); + }; + function a(o) { + function n(g, s) { + if (!(this instanceof n)) + return new n(g, s); + Object.defineProperty(this, "message", { get: function() { + return g; + } }), Error.captureStackTrace ? Error.captureStackTrace(this, n) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), s && r(this, s); + } + return (n.prototype = Object.create(Error.prototype)).constructor = n, Object.defineProperty(n.prototype, "name", { get: function() { + return o; + } }), n.prototype.toString = function() { + return this.name + ": " + this.message; + }, n; + } + t.newError = a, t.ProtocolError = a("ProtocolError"), t.oneOfGetter = function(n) { + for (var g = {}, s = 0; s < n.length; ++s) + g[n[s]] = 1; + return function() { + for (var u = Object.keys(this), l = u.length - 1; l > -1; --l) + if (g[u[l]] === 1 && this[u[l]] !== void 0 && this[u[l]] !== null) + return u[l]; + }; + }, t.oneOfSetter = function(n) { + return function(g) { + for (var s = 0; s < n.length; ++s) + n[s] !== g && delete this[n[s]]; + }; + }, t.toJSONOptions = { + longs: String, + enums: String, + bytes: String, + json: !0 + }, t._configure = function() { + var o = t.Buffer; + if (!o) { + t._Buffer_from = t._Buffer_allocUnsafe = null; + return; + } + t._Buffer_from = o.from !== Uint8Array.from && o.from || /* istanbul ignore next */ + function(g, s) { + return new o(g, s); + }, t._Buffer_allocUnsafe = o.allocUnsafe || /* istanbul ignore next */ + function(g) { + return new o(g); + }; + }; + } +}), require_writer = __commonJS({ + "node_modules/protobufjs/src/writer.js"(e, t) { + t.exports = f; + var r = require_minimal(), a, o = r.LongBits, n = r.base64, g = r.utf8; + function s(N, y, S) { + this.fn = N, this.len = y, this.next = void 0, this.val = S; + } + function u() { + } + function l(N) { + this.head = N.head, this.tail = N.tail, this.len = N.len, this.next = N.states; + } + function f() { + this.len = 0, this.head = new s(u, 0, 0), this.tail = this.head, this.states = null; + } + var d = function() { + return r.Buffer ? function() { + return (f.create = function() { + return new a(); + })(); + } : function() { + return new f(); + }; + }; + f.create = d(), f.alloc = function(y) { + return new r.Array(y); + }, r.Array !== Array && (f.alloc = r.pool(f.alloc, r.Array.prototype.subarray)), f.prototype._push = function(y, S, O) { + return this.tail = this.tail.next = new s(y, S, O), this.len += S, this; + }; + function m(N, y, S) { + y[S] = N & 255; + } + function h(N, y, S) { + for (; N > 127; ) + y[S++] = N & 127 | 128, N >>>= 7; + y[S] = N; + } + function c(N, y) { + this.len = N, this.next = void 0, this.val = y; + } + c.prototype = Object.create(s.prototype), c.prototype.fn = h, f.prototype.uint32 = function(y) { + return this.len += (this.tail = this.tail.next = new c( + (y = y >>> 0) < 128 ? 1 : y < 16384 ? 2 : y < 2097152 ? 3 : y < 268435456 ? 4 : 5, + y + )).len, this; + }, f.prototype.int32 = function(y) { + return y < 0 ? this._push(p, 10, o.fromNumber(y)) : this.uint32(y); + }, f.prototype.sint32 = function(y) { + return this.uint32((y << 1 ^ y >> 31) >>> 0); + }; + function p(N, y, S) { + for (; N.hi; ) + y[S++] = N.lo & 127 | 128, N.lo = (N.lo >>> 7 | N.hi << 25) >>> 0, N.hi >>>= 7; + for (; N.lo > 127; ) + y[S++] = N.lo & 127 | 128, N.lo = N.lo >>> 7; + y[S++] = N.lo; + } + f.prototype.uint64 = function(y) { + var S = o.from(y); + return this._push(p, S.length(), S); + }, f.prototype.int64 = f.prototype.uint64, f.prototype.sint64 = function(y) { + var S = o.from(y).zzEncode(); + return this._push(p, S.length(), S); + }, f.prototype.bool = function(y) { + return this._push(m, 1, y ? 1 : 0); + }; + function w(N, y, S) { + y[S] = N & 255, y[S + 1] = N >>> 8 & 255, y[S + 2] = N >>> 16 & 255, y[S + 3] = N >>> 24; + } + f.prototype.fixed32 = function(y) { + return this._push(w, 4, y >>> 0); + }, f.prototype.sfixed32 = f.prototype.fixed32, f.prototype.fixed64 = function(y) { + var S = o.from(y); + return this._push(w, 4, S.lo)._push(w, 4, S.hi); + }, f.prototype.sfixed64 = f.prototype.fixed64, f.prototype.float = function(y) { + return this._push(r.float.writeFloatLE, 4, y); + }, f.prototype.double = function(y) { + return this._push(r.float.writeDoubleLE, 8, y); + }; + var k = r.Array.prototype.set ? function(y, S, O) { + S.set(y, O); + } : function(y, S, O) { + for (var T = 0; T < y.length; ++T) + S[O + T] = y[T]; + }; + f.prototype.bytes = function(y) { + var S = y.length >>> 0; + if (!S) + return this._push(m, 1, 0); + if (r.isString(y)) { + var O = f.alloc(S = n.length(y)); + n.decode(y, O, 0), y = O; + } + return this.uint32(S)._push(k, S, y); + }, f.prototype.string = function(y) { + var S = g.length(y); + return S ? this.uint32(S)._push(g.write, S, y) : this._push(m, 1, 0); + }, f.prototype.fork = function() { + return this.states = new l(this), this.head = this.tail = new s(u, 0, 0), this.len = 0, this; + }, f.prototype.reset = function() { + return this.states ? (this.head = this.states.head, this.tail = this.states.tail, this.len = this.states.len, this.states = this.states.next) : (this.head = this.tail = new s(u, 0, 0), this.len = 0), this; + }, f.prototype.ldelim = function() { + var y = this.head, S = this.tail, O = this.len; + return this.reset().uint32(O), O && (this.tail.next = y.next, this.tail = S, this.len += O), this; + }, f.prototype.finish = function() { + for (var y = this.head.next, S = this.constructor.alloc(this.len), O = 0; y; ) + y.fn(y.val, S, O), O += y.len, y = y.next; + return S; + }, f._configure = function(N) { + a = N, f.create = d(), a._configure(); + }; + } +}), require_writer_buffer = __commonJS({ + "node_modules/protobufjs/src/writer_buffer.js"(e, t) { + t.exports = o; + var r = require_writer(); + (o.prototype = Object.create(r.prototype)).constructor = o; + var a = require_minimal(); + function o() { + r.call(this); + } + o._configure = function() { + o.alloc = a._Buffer_allocUnsafe, o.writeBytesBuffer = a.Buffer && a.Buffer.prototype instanceof Uint8Array && a.Buffer.prototype.set.name === "set" ? function(s, u, l) { + u.set(s, l); + } : function(s, u, l) { + if (s.copy) + s.copy(u, l, 0, s.length); + else + for (var f = 0; f < s.length; ) + u[l++] = s[f++]; + }; + }, o.prototype.bytes = function(s) { + a.isString(s) && (s = a._Buffer_from(s, "base64")); + var u = s.length >>> 0; + return this.uint32(u), u && this._push(o.writeBytesBuffer, u, s), this; + }; + function n(g, s, u) { + g.length < 40 ? a.utf8.write(g, s, u) : s.utf8Write ? s.utf8Write(g, u) : s.write(g, u); + } + o.prototype.string = function(s) { + var u = a.Buffer.byteLength(s); + return this.uint32(u), u && this._push(n, u, s), this; + }, o._configure(); + } +}), require_reader = __commonJS({ + "node_modules/protobufjs/src/reader.js"(e, t) { + t.exports = s; + var r = require_minimal(), a, o = r.LongBits, n = r.utf8; + function g(h, c) { + return RangeError("index out of range: " + h.pos + " + " + (c || 1) + " > " + h.len); + } + function s(h) { + this.buf = h, this.pos = 0, this.len = h.length; + } + var u = typeof Uint8Array < "u" ? function(c) { + if (c instanceof Uint8Array || Array.isArray(c)) + return new s(c); + throw Error("illegal buffer"); + } : function(c) { + if (Array.isArray(c)) + return new s(c); + throw Error("illegal buffer"); + }, l = function() { + return r.Buffer ? function(p) { + return (s.create = function(k) { + return r.Buffer.isBuffer(k) ? new a(k) : u(k); + })(p); + } : u; + }; + s.create = l(), s.prototype._slice = r.Array.prototype.subarray || /* istanbul ignore next */ + r.Array.prototype.slice, s.prototype.uint32 = function() { + var c = 4294967295; + return function() { + if (c = (this.buf[this.pos] & 127) >>> 0, this.buf[this.pos++] < 128 || (c = (c | (this.buf[this.pos] & 127) << 7) >>> 0, this.buf[this.pos++] < 128) || (c = (c | (this.buf[this.pos] & 127) << 14) >>> 0, this.buf[this.pos++] < 128) || (c = (c | (this.buf[this.pos] & 127) << 21) >>> 0, this.buf[this.pos++] < 128) || (c = (c | (this.buf[this.pos] & 15) << 28) >>> 0, this.buf[this.pos++] < 128)) + return c; + if ((this.pos += 5) > this.len) + throw this.pos = this.len, g(this, 10); + return c; + }; + }(), s.prototype.int32 = function() { + return this.uint32() | 0; + }, s.prototype.sint32 = function() { + var c = this.uint32(); + return c >>> 1 ^ -(c & 1) | 0; + }; + function f() { + var h = new o(0, 0), c = 0; + if (this.len - this.pos > 4) { + for (; c < 4; ++c) + if (h.lo = (h.lo | (this.buf[this.pos] & 127) << c * 7) >>> 0, this.buf[this.pos++] < 128) + return h; + if (h.lo = (h.lo | (this.buf[this.pos] & 127) << 28) >>> 0, h.hi = (h.hi | (this.buf[this.pos] & 127) >> 4) >>> 0, this.buf[this.pos++] < 128) + return h; + c = 0; + } else { + for (; c < 3; ++c) { + if (this.pos >= this.len) + throw g(this); + if (h.lo = (h.lo | (this.buf[this.pos] & 127) << c * 7) >>> 0, this.buf[this.pos++] < 128) + return h; + } + return h.lo = (h.lo | (this.buf[this.pos++] & 127) << c * 7) >>> 0, h; + } + if (this.len - this.pos > 4) { + for (; c < 5; ++c) + if (h.hi = (h.hi | (this.buf[this.pos] & 127) << c * 7 + 3) >>> 0, this.buf[this.pos++] < 128) + return h; + } else + for (; c < 5; ++c) { + if (this.pos >= this.len) + throw g(this); + if (h.hi = (h.hi | (this.buf[this.pos] & 127) << c * 7 + 3) >>> 0, this.buf[this.pos++] < 128) + return h; + } + throw Error("invalid varint encoding"); + } + s.prototype.bool = function() { + return this.uint32() !== 0; + }; + function d(h, c) { + return (h[c - 4] | h[c - 3] << 8 | h[c - 2] << 16 | h[c - 1] << 24) >>> 0; + } + s.prototype.fixed32 = function() { + if (this.pos + 4 > this.len) + throw g(this, 4); + return d(this.buf, this.pos += 4); + }, s.prototype.sfixed32 = function() { + if (this.pos + 4 > this.len) + throw g(this, 4); + return d(this.buf, this.pos += 4) | 0; + }; + function m() { + if (this.pos + 8 > this.len) + throw g(this, 8); + return new o(d(this.buf, this.pos += 4), d(this.buf, this.pos += 4)); + } + s.prototype.float = function() { + if (this.pos + 4 > this.len) + throw g(this, 4); + var c = r.float.readFloatLE(this.buf, this.pos); + return this.pos += 4, c; + }, s.prototype.double = function() { + if (this.pos + 8 > this.len) + throw g(this, 4); + var c = r.float.readDoubleLE(this.buf, this.pos); + return this.pos += 8, c; + }, s.prototype.bytes = function() { + var c = this.uint32(), p = this.pos, w = this.pos + c; + if (w > this.len) + throw g(this, c); + return this.pos += c, Array.isArray(this.buf) ? this.buf.slice(p, w) : p === w ? new this.buf.constructor(0) : this._slice.call(this.buf, p, w); + }, s.prototype.string = function() { + var c = this.bytes(); + return n.read(c, 0, c.length); + }, s.prototype.skip = function(c) { + if (typeof c == "number") { + if (this.pos + c > this.len) + throw g(this, c); + this.pos += c; + } else + do + if (this.pos >= this.len) + throw g(this); + while (this.buf[this.pos++] & 128); + return this; + }, s.prototype.skipType = function(h) { + switch (h) { + case 0: + this.skip(); + break; + case 1: + this.skip(8); + break; + case 2: + this.skip(this.uint32()); + break; + case 3: + for (; (h = this.uint32() & 7) !== 4; ) + this.skipType(h); + break; + case 5: + this.skip(4); + break; + default: + throw Error("invalid wire type " + h + " at offset " + this.pos); + } + return this; + }, s._configure = function(h) { + a = h, s.create = l(), a._configure(); + var c = r.Long ? "toLong" : ( + /* istanbul ignore next */ + "toNumber" + ); + r.merge(s.prototype, { + int64: function() { + return f.call(this)[c](!1); + }, + uint64: function() { + return f.call(this)[c](!0); + }, + sint64: function() { + return f.call(this).zzDecode()[c](!1); + }, + fixed64: function() { + return m.call(this)[c](!0); + }, + sfixed64: function() { + return m.call(this)[c](!1); + } + }); + }; + } +}), require_reader_buffer = __commonJS({ + "node_modules/protobufjs/src/reader_buffer.js"(e, t) { + t.exports = o; + var r = require_reader(); + (o.prototype = Object.create(r.prototype)).constructor = o; + var a = require_minimal(); + function o(n) { + r.call(this, n); + } + o._configure = function() { + a.Buffer && (o.prototype._slice = a.Buffer.prototype.slice); + }, o.prototype.string = function() { + var g = this.uint32(); + return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + g, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + g, this.len)); + }, o._configure(); + } +}), require_service = __commonJS({ + "node_modules/protobufjs/src/rpc/service.js"(e, t) { + t.exports = a; + var r = require_minimal(); + (a.prototype = Object.create(r.EventEmitter.prototype)).constructor = a; + function a(o, n, g) { + if (typeof o != "function") + throw TypeError("rpcImpl must be a function"); + r.EventEmitter.call(this), this.rpcImpl = o, this.requestDelimited = !!n, this.responseDelimited = !!g; + } + a.prototype.rpcCall = function o(n, g, s, u, l) { + if (!u) + throw TypeError("request must be specified"); + var f = this; + if (!l) + return r.asPromise(o, f, n, g, s, u); + if (!f.rpcImpl) { + setTimeout(function() { + l(Error("already ended")); + }, 0); + return; + } + try { + return f.rpcImpl( + n, + g[f.requestDelimited ? "encodeDelimited" : "encode"](u).finish(), + function(m, h) { + if (m) + return f.emit("error", m, n), l(m); + if (h === null) { + f.end( + /* endedByRPC */ + !0 + ); + return; + } + if (!(h instanceof s)) + try { + h = s[f.responseDelimited ? "decodeDelimited" : "decode"](h); + } catch (c) { + return f.emit("error", c, n), l(c); + } + return f.emit("data", h, n), l(null, h); + } + ); + } catch (d) { + f.emit("error", d, n), setTimeout(function() { + l(d); + }, 0); + return; + } + }, a.prototype.end = function(n) { + return this.rpcImpl && (n || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this; + }; + } +}), require_rpc = __commonJS({ + "node_modules/protobufjs/src/rpc.js"(e) { + var t = e; + t.Service = require_service(); + } +}), require_roots = __commonJS({ + "node_modules/protobufjs/src/roots.js"(e, t) { + t.exports = {}; + } +}), require_index_minimal = __commonJS({ + "node_modules/protobufjs/src/index-minimal.js"(e) { + var t = e; + t.build = "minimal", t.Writer = require_writer(), t.BufferWriter = require_writer_buffer(), t.Reader = require_reader(), t.BufferReader = require_reader_buffer(), t.util = require_minimal(), t.rpc = require_rpc(), t.roots = require_roots(), t.configure = r; + function r() { + t.util._configure(), t.Writer._configure(t.BufferWriter), t.Reader._configure(t.BufferReader); + } + r(); + } +}), require_minimal2 = __commonJS({ + "node_modules/protobufjs/minimal.js"(e, t) { + t.exports = require_index_minimal(); + } +}); +const __vite__cjsImport0_protobufjs_minimal = require_minimal2(); +var GoodbyeReason = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.UnsupportedProtocol = 1] = "UnsupportedProtocol", e[e.UnexpectedPacket = 2] = "UnexpectedPacket", e[e.UnexpectedNextState = 3] = "UnexpectedNextState", e[e.UsernameTaken = 4] = "UsernameTaken", e[e.PingPongTimeout = 5] = "PingPongTimeout", e[e.Done = 6] = "Done", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(GoodbyeReason || {}); +function goodbyeReasonFromJSON(e) { + switch (e) { + case 0: + case "UNKNOWN": + return 0; + case 1: + case "UnsupportedProtocol": + return 1; + case 2: + case "UnexpectedPacket": + return 2; + case 3: + case "UnexpectedNextState": + return 3; + case 4: + case "UsernameTaken": + return 4; + case 5: + case "PingPongTimeout": + return 5; + case 6: + case "Done": + return 6; + case -1: + case "UNRECOGNIZED": + default: + return -1; + } +} +function goodbyeReasonToJSON(e) { + switch (e) { + case 0: + return "UNKNOWN"; + case 1: + return "UnsupportedProtocol"; + case 2: + return "UnexpectedPacket"; + case 3: + return "UnexpectedNextState"; + case 4: + return "UsernameTaken"; + case 5: + return "PingPongTimeout"; + case 6: + return "Done"; + case -1: + default: + return "UNRECOGNIZED"; + } +} +var InputType = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.Left = 1] = "Left", e[e.Middle = 2] = "Middle", e[e.Right = 3] = "Right", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(InputType || {}); +function inputTypeFromJSON(e) { + switch (e) { + case 0: + case "UNKNOWN": + return 0; + case 1: + case "Left": + return 1; + case 2: + case "Middle": + return 2; + case 3: + case "Right": + return 3; + case -1: + case "UNRECOGNIZED": + default: + return -1; + } +} +function inputTypeToJSON(e) { + switch (e) { + case 0: + return "UNKNOWN"; + case 1: + return "Left"; + case 2: + return "Middle"; + case 3: + return "Right"; + case -1: + default: + return "UNRECOGNIZED"; + } +} +var State = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.Handshake = 1] = "Handshake", e[e.Play = 2] = "Play", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(State || {}); +function stateFromJSON(e) { + switch (e) { + case 0: + case "UNKNOWN": + return 0; + case 1: + case "Handshake": + return 1; + case 2: + case "Play": + return 2; + case -1: + case "UNRECOGNIZED": + default: + return -1; + } +} +function stateToJSON(e) { + switch (e) { + case 0: + return "UNKNOWN"; + case 1: + return "Handshake"; + case 2: + return "Play"; + case -1: + default: + return "UNRECOGNIZED"; + } +} +const _m0$5 = __vite__cjsImport0_protobufjs_minimal; +var MessageC2SHello_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 1] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SHello_packetInfo || {}), MessageC2SGoodbye_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 2] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SGoodbye_packetInfo || {}), MessageC2SPing_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 4] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SPing_packetInfo || {}), MessageC2SInput_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 11] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SInput_packetInfo || {}), MessageC2SAuthenticateAndBeamOut_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 12] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SAuthenticateAndBeamOut_packetInfo || {}), MessageC2SMouseInput_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 13] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SMouseInput_packetInfo || {}), MessageC2SModuleGrabBegin_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 14] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SModuleGrabBegin_packetInfo || {}), MessageC2SModuleGrabEnd_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 15] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SModuleGrabEnd_packetInfo || {}), MessageC2SModuleDetach_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 16] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageC2SModuleDetach_packetInfo || {}); +function createBaseMessageC2SHello() { + return { version: 0, requestedUsername: "", nextState: 0, token: "", user: "" }; +} +const MessageC2SHello = { + encode(e, t = _m0$5.Writer.create()) { + return e.version !== 0 && t.uint32(8).uint32(e.version), e.requestedUsername !== "" && t.uint32(18).string(e.requestedUsername), e.nextState !== 0 && t.uint32(24).int32(e.nextState), e.token !== "" && t.uint32(34).string(e.token), e.user !== "" && t.uint32(42).string(e.user), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SHello(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.version = r.uint32(); + continue; + case 2: + if (n != 18) + break; + o.requestedUsername = r.string(); + continue; + case 3: + if (n != 24) + break; + o.nextState = r.int32(); + continue; + case 4: + if (n != 34) + break; + o.token = r.string(); + continue; + case 5: + if (n != 42) + break; + o.user = r.string(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + version: isSet$5(e.version) ? Number(e.version) : 0, + requestedUsername: isSet$5(e.requestedUsername) ? String(e.requestedUsername) : "", + nextState: isSet$5(e.nextState) ? stateFromJSON(e.nextState) : 0, + token: isSet$5(e.token) ? String(e.token) : "", + user: isSet$5(e.user) ? String(e.user) : "" + }; + }, + toJSON(e) { + const t = {}; + return e.version !== void 0 && (t.version = Math.round(e.version)), e.requestedUsername !== void 0 && (t.requestedUsername = e.requestedUsername), e.nextState !== void 0 && (t.nextState = stateToJSON(e.nextState)), e.token !== void 0 && (t.token = e.token), e.user !== void 0 && (t.user = e.user), t; + }, + create(e) { + return MessageC2SHello.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SHello(); + return t.version = e.version ?? 0, t.requestedUsername = e.requestedUsername ?? "", t.nextState = e.nextState ?? 0, t.token = e.token ?? "", t.user = e.user ?? "", t; + } +}; +function createBaseMessageC2SGoodbye() { + return { reason: 0 }; +} +const MessageC2SGoodbye = { + encode(e, t = _m0$5.Writer.create()) { + return e.reason !== 0 && t.uint32(8).int32(e.reason), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SGoodbye(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.reason = r.int32(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { reason: isSet$5(e.reason) ? goodbyeReasonFromJSON(e.reason) : 0 }; + }, + toJSON(e) { + const t = {}; + return e.reason !== void 0 && (t.reason = goodbyeReasonToJSON(e.reason)), t; + }, + create(e) { + return MessageC2SGoodbye.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SGoodbye(); + return t.reason = e.reason ?? 0, t; + } +}; +function createBaseMessageC2SPing() { + return {}; +} +const MessageC2SPing = { + encode(e, t = _m0$5.Writer.create()) { + return t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SPing(); + for (; r.pos < a; ) { + const n = r.uint32(); + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return {}; + }, + toJSON(e) { + return {}; + }, + create(e) { + return MessageC2SPing.fromPartial(e ?? {}); + }, + fromPartial(e) { + return createBaseMessageC2SPing(); + } +}; +function createBaseMessageC2SInput() { + return { upPressed: !1, downPressed: !1, leftPressed: !1, rightPressed: !1 }; +} +const MessageC2SInput = { + encode(e, t = _m0$5.Writer.create()) { + return e.upPressed === !0 && t.uint32(8).bool(e.upPressed), e.downPressed === !0 && t.uint32(16).bool(e.downPressed), e.leftPressed === !0 && t.uint32(24).bool(e.leftPressed), e.rightPressed === !0 && t.uint32(32).bool(e.rightPressed), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SInput(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.upPressed = r.bool(); + continue; + case 2: + if (n != 16) + break; + o.downPressed = r.bool(); + continue; + case 3: + if (n != 24) + break; + o.leftPressed = r.bool(); + continue; + case 4: + if (n != 32) + break; + o.rightPressed = r.bool(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + upPressed: isSet$5(e.upPressed) ? !!e.upPressed : !1, + downPressed: isSet$5(e.downPressed) ? !!e.downPressed : !1, + leftPressed: isSet$5(e.leftPressed) ? !!e.leftPressed : !1, + rightPressed: isSet$5(e.rightPressed) ? !!e.rightPressed : !1 + }; + }, + toJSON(e) { + const t = {}; + return e.upPressed !== void 0 && (t.upPressed = e.upPressed), e.downPressed !== void 0 && (t.downPressed = e.downPressed), e.leftPressed !== void 0 && (t.leftPressed = e.leftPressed), e.rightPressed !== void 0 && (t.rightPressed = e.rightPressed), t; + }, + create(e) { + return MessageC2SInput.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SInput(); + return t.upPressed = e.upPressed ?? !1, t.downPressed = e.downPressed ?? !1, t.leftPressed = e.leftPressed ?? !1, t.rightPressed = e.rightPressed ?? !1, t; + } +}; +function createBaseMessageC2SAuthenticateAndBeamOut() { + return { userId: "", token: "" }; +} +const MessageC2SAuthenticateAndBeamOut = { + encode(e, t = _m0$5.Writer.create()) { + return e.userId !== "" && t.uint32(10).string(e.userId), e.token !== "" && t.uint32(18).string(e.token), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SAuthenticateAndBeamOut(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.userId = r.string(); + continue; + case 2: + if (n != 18) + break; + o.token = r.string(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + userId: isSet$5(e.userId) ? String(e.userId) : "", + token: isSet$5(e.token) ? String(e.token) : "" + }; + }, + toJSON(e) { + const t = {}; + return e.userId !== void 0 && (t.userId = e.userId), e.token !== void 0 && (t.token = e.token), t; + }, + create(e) { + return MessageC2SAuthenticateAndBeamOut.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SAuthenticateAndBeamOut(); + return t.userId = e.userId ?? "", t.token = e.token ?? "", t; + } +}; +function createBaseMessageC2SMouseInput() { + return { worldposX: 0, worldposY: 0, button: 0, released: !1 }; +} +const MessageC2SMouseInput = { + encode(e, t = _m0$5.Writer.create()) { + return e.worldposX !== 0 && t.uint32(9).double(e.worldposX), e.worldposY !== 0 && t.uint32(17).double(e.worldposY), e.button !== 0 && t.uint32(24).int32(e.button), e.released === !0 && t.uint32(32).bool(e.released), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SMouseInput(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 9) + break; + o.worldposX = r.double(); + continue; + case 2: + if (n != 17) + break; + o.worldposY = r.double(); + continue; + case 3: + if (n != 24) + break; + o.button = r.int32(); + continue; + case 4: + if (n != 32) + break; + o.released = r.bool(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + worldposX: isSet$5(e.worldposX) ? Number(e.worldposX) : 0, + worldposY: isSet$5(e.worldposY) ? Number(e.worldposY) : 0, + button: isSet$5(e.button) ? inputTypeFromJSON(e.button) : 0, + released: isSet$5(e.released) ? !!e.released : !1 + }; + }, + toJSON(e) { + const t = {}; + return e.worldposX !== void 0 && (t.worldposX = e.worldposX), e.worldposY !== void 0 && (t.worldposY = e.worldposY), e.button !== void 0 && (t.button = inputTypeToJSON(e.button)), e.released !== void 0 && (t.released = e.released), t; + }, + create(e) { + return MessageC2SMouseInput.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SMouseInput(); + return t.worldposX = e.worldposX ?? 0, t.worldposY = e.worldposY ?? 0, t.button = e.button ?? 0, t.released = e.released ?? !1, t; + } +}; +function createBaseMessageC2SModuleGrabBegin() { + return { moduleId: 0, worldposX: 0, worldposY: 0 }; +} +const MessageC2SModuleGrabBegin = { + encode(e, t = _m0$5.Writer.create()) { + return e.moduleId !== 0 && t.uint32(8).uint32(e.moduleId), e.worldposX !== 0 && t.uint32(17).double(e.worldposX), e.worldposY !== 0 && t.uint32(25).double(e.worldposY), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SModuleGrabBegin(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.moduleId = r.uint32(); + continue; + case 2: + if (n != 17) + break; + o.worldposX = r.double(); + continue; + case 3: + if (n != 25) + break; + o.worldposY = r.double(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + moduleId: isSet$5(e.moduleId) ? Number(e.moduleId) : 0, + worldposX: isSet$5(e.worldposX) ? Number(e.worldposX) : 0, + worldposY: isSet$5(e.worldposY) ? Number(e.worldposY) : 0 + }; + }, + toJSON(e) { + const t = {}; + return e.moduleId !== void 0 && (t.moduleId = Math.round(e.moduleId)), e.worldposX !== void 0 && (t.worldposX = e.worldposX), e.worldposY !== void 0 && (t.worldposY = e.worldposY), t; + }, + create(e) { + return MessageC2SModuleGrabBegin.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SModuleGrabBegin(); + return t.moduleId = e.moduleId ?? 0, t.worldposX = e.worldposX ?? 0, t.worldposY = e.worldposY ?? 0, t; + } +}; +function createBaseMessageC2SModuleGrabEnd() { + return { moduleId: 0, worldposX: 0, worldposY: 0 }; +} +const MessageC2SModuleGrabEnd = { + encode(e, t = _m0$5.Writer.create()) { + return e.moduleId !== 0 && t.uint32(8).uint32(e.moduleId), e.worldposX !== 0 && t.uint32(17).double(e.worldposX), e.worldposY !== 0 && t.uint32(25).double(e.worldposY), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SModuleGrabEnd(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.moduleId = r.uint32(); + continue; + case 2: + if (n != 17) + break; + o.worldposX = r.double(); + continue; + case 3: + if (n != 25) + break; + o.worldposY = r.double(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + moduleId: isSet$5(e.moduleId) ? Number(e.moduleId) : 0, + worldposX: isSet$5(e.worldposX) ? Number(e.worldposX) : 0, + worldposY: isSet$5(e.worldposY) ? Number(e.worldposY) : 0 + }; + }, + toJSON(e) { + const t = {}; + return e.moduleId !== void 0 && (t.moduleId = Math.round(e.moduleId)), e.worldposX !== void 0 && (t.worldposX = e.worldposX), e.worldposY !== void 0 && (t.worldposY = e.worldposY), t; + }, + create(e) { + return MessageC2SModuleGrabEnd.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SModuleGrabEnd(); + return t.moduleId = e.moduleId ?? 0, t.worldposX = e.worldposX ?? 0, t.worldposY = e.worldposY ?? 0, t; + } +}; +function createBaseMessageC2SModuleDetach() { + return { moduleId: 0 }; +} +const MessageC2SModuleDetach = { + encode(e, t = _m0$5.Writer.create()) { + return e.moduleId !== 0 && t.uint32(8).uint32(e.moduleId), t; + }, + decode(e, t) { + const r = e instanceof _m0$5.Reader ? e : _m0$5.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageC2SModuleDetach(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.moduleId = r.uint32(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { moduleId: isSet$5(e.moduleId) ? Number(e.moduleId) : 0 }; + }, + toJSON(e) { + const t = {}; + return e.moduleId !== void 0 && (t.moduleId = Math.round(e.moduleId)), t; + }, + create(e) { + return MessageC2SModuleDetach.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageC2SModuleDetach(); + return t.moduleId = e.moduleId ?? 0, t; + } +}; +function isSet$5(e) { + return e != null; +} +var require_long = __commonJS({ + "node_modules/long/src/long.js"(e, t) { + t.exports = a; + var r = null; + try { + r = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([ + 0, + 97, + 115, + 109, + 1, + 0, + 0, + 0, + 1, + 13, + 2, + 96, + 0, + 1, + 127, + 96, + 4, + 127, + 127, + 127, + 127, + 1, + 127, + 3, + 7, + 6, + 0, + 1, + 1, + 1, + 1, + 1, + 6, + 6, + 1, + 127, + 1, + 65, + 0, + 11, + 7, + 50, + 6, + 3, + 109, + 117, + 108, + 0, + 1, + 5, + 100, + 105, + 118, + 95, + 115, + 0, + 2, + 5, + 100, + 105, + 118, + 95, + 117, + 0, + 3, + 5, + 114, + 101, + 109, + 95, + 115, + 0, + 4, + 5, + 114, + 101, + 109, + 95, + 117, + 0, + 5, + 8, + 103, + 101, + 116, + 95, + 104, + 105, + 103, + 104, + 0, + 0, + 10, + 191, + 1, + 6, + 4, + 0, + 35, + 0, + 11, + 36, + 1, + 1, + 126, + 32, + 0, + 173, + 32, + 1, + 173, + 66, + 32, + 134, + 132, + 32, + 2, + 173, + 32, + 3, + 173, + 66, + 32, + 134, + 132, + 126, + 34, + 4, + 66, + 32, + 135, + 167, + 36, + 0, + 32, + 4, + 167, + 11, + 36, + 1, + 1, + 126, + 32, + 0, + 173, + 32, + 1, + 173, + 66, + 32, + 134, + 132, + 32, + 2, + 173, + 32, + 3, + 173, + 66, + 32, + 134, + 132, + 127, + 34, + 4, + 66, + 32, + 135, + 167, + 36, + 0, + 32, + 4, + 167, + 11, + 36, + 1, + 1, + 126, + 32, + 0, + 173, + 32, + 1, + 173, + 66, + 32, + 134, + 132, + 32, + 2, + 173, + 32, + 3, + 173, + 66, + 32, + 134, + 132, + 128, + 34, + 4, + 66, + 32, + 135, + 167, + 36, + 0, + 32, + 4, + 167, + 11, + 36, + 1, + 1, + 126, + 32, + 0, + 173, + 32, + 1, + 173, + 66, + 32, + 134, + 132, + 32, + 2, + 173, + 32, + 3, + 173, + 66, + 32, + 134, + 132, + 129, + 34, + 4, + 66, + 32, + 135, + 167, + 36, + 0, + 32, + 4, + 167, + 11, + 36, + 1, + 1, + 126, + 32, + 0, + 173, + 32, + 1, + 173, + 66, + 32, + 134, + 132, + 32, + 2, + 173, + 32, + 3, + 173, + 66, + 32, + 134, + 132, + 130, + 34, + 4, + 66, + 32, + 135, + 167, + 36, + 0, + 32, + 4, + 167, + 11 + ])), {}).exports; + } catch { + } + function a(_, i, v) { + this.low = _ | 0, this.high = i | 0, this.unsigned = !!v; + } + a.prototype.__isLong__, Object.defineProperty(a.prototype, "__isLong__", { value: !0 }); + function o(_) { + return (_ && _.__isLong__) === !0; + } + a.isLong = o; + var n = {}, g = {}; + function s(_, i) { + var v, E, $; + return i ? (_ >>>= 0, ($ = 0 <= _ && _ < 256) && (E = g[_], E) ? E : (v = l(_, (_ | 0) < 0 ? -1 : 0, !0), $ && (g[_] = v), v)) : (_ |= 0, ($ = -128 <= _ && _ < 128) && (E = n[_], E) ? E : (v = l(_, _ < 0 ? -1 : 0, !1), $ && (n[_] = v), v)); + } + a.fromInt = s; + function u(_, i) { + if (isNaN(_)) + return i ? S : y; + if (i) { + if (_ < 0) + return S; + if (_ >= w) + return q; + } else { + if (_ <= -k) + return P; + if (_ + 1 >= k) + return A; + } + return _ < 0 ? u(-_, i).neg() : l(_ % p | 0, _ / p | 0, i); + } + a.fromNumber = u; + function l(_, i, v) { + return new a(_, i, v); + } + a.fromBits = l; + var f = Math.pow; + function d(_, i, v) { + if (_.length === 0) + throw Error("empty string"); + if (_ === "NaN" || _ === "Infinity" || _ === "+Infinity" || _ === "-Infinity") + return y; + if (typeof i == "number" ? (v = i, i = !1) : i = !!i, v = v || 10, v < 2 || 36 < v) + throw RangeError("radix"); + var E; + if ((E = _.indexOf("-")) > 0) + throw Error("interior hyphen"); + if (E === 0) + return d(_.substring(1), i, v).neg(); + for (var $ = u(f(v, 8)), x = y, M = 0; M < _.length; M += 8) { + var C = Math.min(8, _.length - M), L = parseInt(_.substring(M, M + C), v); + if (C < 8) { + var R = u(f(v, C)); + x = x.mul(R).add(u(L)); + } else + x = x.mul($), x = x.add(u(L)); + } + return x.unsigned = i, x; + } + a.fromString = d; + function m(_, i) { + return typeof _ == "number" ? u(_, i) : typeof _ == "string" ? d(_, i) : l(_.low, _.high, typeof i == "boolean" ? i : _.unsigned); + } + a.fromValue = m; + var h = 1 << 16, c = 1 << 24, p = h * h, w = p * p, k = w / 2, N = s(c), y = s(0); + a.ZERO = y; + var S = s(0, !0); + a.UZERO = S; + var O = s(1); + a.ONE = O; + var T = s(1, !0); + a.UONE = T; + var I = s(-1); + a.NEG_ONE = I; + var A = l(-1, 2147483647, !1); + a.MAX_VALUE = A; + var q = l(-1, -1, !0); + a.MAX_UNSIGNED_VALUE = q; + var P = l(0, -2147483648, !1); + a.MIN_VALUE = P; + var b = a.prototype; + b.toInt = function() { + return this.unsigned ? this.low >>> 0 : this.low; + }, b.toNumber = function() { + return this.unsigned ? (this.high >>> 0) * p + (this.low >>> 0) : this.high * p + (this.low >>> 0); + }, b.toString = function(i) { + if (i = i || 10, i < 2 || 36 < i) + throw RangeError("radix"); + if (this.isZero()) + return "0"; + if (this.isNegative()) + if (this.eq(P)) { + var v = u(i), E = this.div(v), $ = E.mul(v).sub(this); + return E.toString(i) + $.toInt().toString(i); + } else + return "-" + this.neg().toString(i); + for (var x = u(f(i, 6), this.unsigned), M = this, C = ""; ; ) { + var L = M.div(x), R = M.sub(L.mul(x)).toInt() >>> 0, B = R.toString(i); + if (M = L, M.isZero()) + return B + C; + for (; B.length < 6; ) + B = "0" + B; + C = "" + B + C; + } + }, b.getHighBits = function() { + return this.high; + }, b.getHighBitsUnsigned = function() { + return this.high >>> 0; + }, b.getLowBits = function() { + return this.low; + }, b.getLowBitsUnsigned = function() { + return this.low >>> 0; + }, b.getNumBitsAbs = function() { + if (this.isNegative()) + return this.eq(P) ? 64 : this.neg().getNumBitsAbs(); + for (var i = this.high != 0 ? this.high : this.low, v = 31; v > 0 && !(i & 1 << v); v--) + ; + return this.high != 0 ? v + 33 : v + 1; + }, b.isZero = function() { + return this.high === 0 && this.low === 0; + }, b.eqz = b.isZero, b.isNegative = function() { + return !this.unsigned && this.high < 0; + }, b.isPositive = function() { + return this.unsigned || this.high >= 0; + }, b.isOdd = function() { + return (this.low & 1) === 1; + }, b.isEven = function() { + return (this.low & 1) === 0; + }, b.equals = function(i) { + return o(i) || (i = m(i)), this.unsigned !== i.unsigned && this.high >>> 31 === 1 && i.high >>> 31 === 1 ? !1 : this.high === i.high && this.low === i.low; + }, b.eq = b.equals, b.notEquals = function(i) { + return !this.eq( + /* validates */ + i + ); + }, b.neq = b.notEquals, b.ne = b.notEquals, b.lessThan = function(i) { + return this.comp( + /* validates */ + i + ) < 0; + }, b.lt = b.lessThan, b.lessThanOrEqual = function(i) { + return this.comp( + /* validates */ + i + ) <= 0; + }, b.lte = b.lessThanOrEqual, b.le = b.lessThanOrEqual, b.greaterThan = function(i) { + return this.comp( + /* validates */ + i + ) > 0; + }, b.gt = b.greaterThan, b.greaterThanOrEqual = function(i) { + return this.comp( + /* validates */ + i + ) >= 0; + }, b.gte = b.greaterThanOrEqual, b.ge = b.greaterThanOrEqual, b.compare = function(i) { + if (o(i) || (i = m(i)), this.eq(i)) + return 0; + var v = this.isNegative(), E = i.isNegative(); + return v && !E ? -1 : !v && E ? 1 : this.unsigned ? i.high >>> 0 > this.high >>> 0 || i.high === this.high && i.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(i).isNegative() ? -1 : 1; + }, b.comp = b.compare, b.negate = function() { + return !this.unsigned && this.eq(P) ? P : this.not().add(O); + }, b.neg = b.negate, b.add = function(i) { + o(i) || (i = m(i)); + var v = this.high >>> 16, E = this.high & 65535, $ = this.low >>> 16, x = this.low & 65535, M = i.high >>> 16, C = i.high & 65535, L = i.low >>> 16, R = i.low & 65535, B = 0, J = 0, U = 0, D = 0; + return D += x + R, U += D >>> 16, D &= 65535, U += $ + L, J += U >>> 16, U &= 65535, J += E + C, B += J >>> 16, J &= 65535, B += v + M, B &= 65535, l(U << 16 | D, B << 16 | J, this.unsigned); + }, b.subtract = function(i) { + return o(i) || (i = m(i)), this.add(i.neg()); + }, b.sub = b.subtract, b.multiply = function(i) { + if (this.isZero()) + return y; + if (o(i) || (i = m(i)), r) { + var v = r.mul( + this.low, + this.high, + i.low, + i.high + ); + return l(v, r.get_high(), this.unsigned); + } + if (i.isZero()) + return y; + if (this.eq(P)) + return i.isOdd() ? P : y; + if (i.eq(P)) + return this.isOdd() ? P : y; + if (this.isNegative()) + return i.isNegative() ? this.neg().mul(i.neg()) : this.neg().mul(i).neg(); + if (i.isNegative()) + return this.mul(i.neg()).neg(); + if (this.lt(N) && i.lt(N)) + return u(this.toNumber() * i.toNumber(), this.unsigned); + var E = this.high >>> 16, $ = this.high & 65535, x = this.low >>> 16, M = this.low & 65535, C = i.high >>> 16, L = i.high & 65535, R = i.low >>> 16, B = i.low & 65535, J = 0, U = 0, D = 0, W = 0; + return W += M * B, D += W >>> 16, W &= 65535, D += x * B, U += D >>> 16, D &= 65535, D += M * R, U += D >>> 16, D &= 65535, U += $ * B, J += U >>> 16, U &= 65535, U += x * R, J += U >>> 16, U &= 65535, U += M * L, J += U >>> 16, U &= 65535, J += E * B + $ * R + x * L + M * C, J &= 65535, l(D << 16 | W, J << 16 | U, this.unsigned); + }, b.mul = b.multiply, b.divide = function(i) { + if (o(i) || (i = m(i)), i.isZero()) + throw Error("division by zero"); + if (r) { + if (!this.unsigned && this.high === -2147483648 && i.low === -1 && i.high === -1) + return this; + var v = (this.unsigned ? r.div_u : r.div_s)( + this.low, + this.high, + i.low, + i.high + ); + return l(v, r.get_high(), this.unsigned); + } + if (this.isZero()) + return this.unsigned ? S : y; + var E, $, x; + if (this.unsigned) { + if (i.unsigned || (i = i.toUnsigned()), i.gt(this)) + return S; + if (i.gt(this.shru(1))) + return T; + x = S; + } else { + if (this.eq(P)) { + if (i.eq(O) || i.eq(I)) + return P; + if (i.eq(P)) + return O; + var M = this.shr(1); + return E = M.div(i).shl(1), E.eq(y) ? i.isNegative() ? O : I : ($ = this.sub(i.mul(E)), x = E.add($.div(i)), x); + } else if (i.eq(P)) + return this.unsigned ? S : y; + if (this.isNegative()) + return i.isNegative() ? this.neg().div(i.neg()) : this.neg().div(i).neg(); + if (i.isNegative()) + return this.div(i.neg()).neg(); + x = y; + } + for ($ = this; $.gte(i); ) { + E = Math.max(1, Math.floor($.toNumber() / i.toNumber())); + for (var C = Math.ceil(Math.log(E) / Math.LN2), L = C <= 48 ? 1 : f(2, C - 48), R = u(E), B = R.mul(i); B.isNegative() || B.gt($); ) + E -= L, R = u(E, this.unsigned), B = R.mul(i); + R.isZero() && (R = O), x = x.add(R), $ = $.sub(B); + } + return x; + }, b.div = b.divide, b.modulo = function(i) { + if (o(i) || (i = m(i)), r) { + var v = (this.unsigned ? r.rem_u : r.rem_s)( + this.low, + this.high, + i.low, + i.high + ); + return l(v, r.get_high(), this.unsigned); + } + return this.sub(this.div(i).mul(i)); + }, b.mod = b.modulo, b.rem = b.modulo, b.not = function() { + return l(~this.low, ~this.high, this.unsigned); + }, b.and = function(i) { + return o(i) || (i = m(i)), l(this.low & i.low, this.high & i.high, this.unsigned); + }, b.or = function(i) { + return o(i) || (i = m(i)), l(this.low | i.low, this.high | i.high, this.unsigned); + }, b.xor = function(i) { + return o(i) || (i = m(i)), l(this.low ^ i.low, this.high ^ i.high, this.unsigned); + }, b.shiftLeft = function(i) { + return o(i) && (i = i.toInt()), (i &= 63) === 0 ? this : i < 32 ? l(this.low << i, this.high << i | this.low >>> 32 - i, this.unsigned) : l(0, this.low << i - 32, this.unsigned); + }, b.shl = b.shiftLeft, b.shiftRight = function(i) { + return o(i) && (i = i.toInt()), (i &= 63) === 0 ? this : i < 32 ? l(this.low >>> i | this.high << 32 - i, this.high >> i, this.unsigned) : l(this.high >> i - 32, this.high >= 0 ? 0 : -1, this.unsigned); + }, b.shr = b.shiftRight, b.shiftRightUnsigned = function(i) { + if (o(i) && (i = i.toInt()), i &= 63, i === 0) + return this; + var v = this.high; + if (i < 32) { + var E = this.low; + return l(E >>> i | v << 32 - i, v >>> i, this.unsigned); + } else + return i === 32 ? l(v, 0, this.unsigned) : l(v >>> i - 32, 0, this.unsigned); + }, b.shru = b.shiftRightUnsigned, b.shr_u = b.shiftRightUnsigned, b.toSigned = function() { + return this.unsigned ? l(this.low, this.high, !1) : this; + }, b.toUnsigned = function() { + return this.unsigned ? this : l(this.low, this.high, !0); + }, b.toBytes = function(i) { + return i ? this.toBytesLE() : this.toBytesBE(); + }, b.toBytesLE = function() { + var i = this.high, v = this.low; + return [ + v & 255, + v >>> 8 & 255, + v >>> 16 & 255, + v >>> 24, + i & 255, + i >>> 8 & 255, + i >>> 16 & 255, + i >>> 24 + ]; + }, b.toBytesBE = function() { + var i = this.high, v = this.low; + return [ + i >>> 24, + i >>> 16 & 255, + i >>> 8 & 255, + i & 255, + v >>> 24, + v >>> 16 & 255, + v >>> 8 & 255, + v & 255 + ]; + }, a.fromBytes = function(i, v, E) { + return E ? a.fromBytesLE(i, v) : a.fromBytesBE(i, v); + }, a.fromBytesLE = function(i, v) { + return new a( + i[0] | i[1] << 8 | i[2] << 16 | i[3] << 24, + i[4] | i[5] << 8 | i[6] << 16 | i[7] << 24, + v + ); + }, a.fromBytesBE = function(i, v) { + return new a( + i[4] << 24 | i[5] << 16 | i[6] << 8 | i[7], + i[0] << 24 | i[1] << 16 | i[2] << 8 | i[3], + v + ); + }; + } +}); +const __vite__cjsImport0_long = require_long(), Long = __vite__cjsImport0_long, _m0$4 = __vite__cjsImport0_protobufjs_minimal; +function createBasePacketWrapper() { + return { packetId: 0, packetData: new Uint8Array() }; +} +const PacketWrapper = { + encode(e, t = _m0$4.Writer.create()) { + return e.packetId !== 0 && t.uint32(8).int64(e.packetId), e.packetData.length !== 0 && t.uint32(18).bytes(e.packetData), t; + }, + decode(e, t) { + const r = e instanceof _m0$4.Reader ? e : _m0$4.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBasePacketWrapper(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.packetId = longToNumber(r.int64()); + continue; + case 2: + if (n != 18) + break; + o.packetData = r.bytes(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + packetId: isSet$4(e.packetId) ? Number(e.packetId) : 0, + packetData: isSet$4(e.packetData) ? bytesFromBase64(e.packetData) : new Uint8Array() + }; + }, + toJSON(e) { + const t = {}; + return e.packetId !== void 0 && (t.packetId = Math.round(e.packetId)), e.packetData !== void 0 && (t.packetData = base64FromBytes(e.packetData !== void 0 ? e.packetData : new Uint8Array())), t; + }, + create(e) { + return PacketWrapper.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBasePacketWrapper(); + return t.packetId = e.packetId ?? 0, t.packetData = e.packetData ?? new Uint8Array(), t; + } +}; +var tsProtoGlobalThis = (() => { + if (typeof globalThis < "u") + return globalThis; + if (typeof self < "u") + return self; + if (typeof window < "u") + return window; + if (typeof global < "u") + return global; + throw "Unable to locate global object"; +})(); +function bytesFromBase64(e) { + if (tsProtoGlobalThis.Buffer) + return Uint8Array.from(tsProtoGlobalThis.Buffer.from(e, "base64")); + { + const t = tsProtoGlobalThis.atob(e), r = new Uint8Array(t.length); + for (let a = 0; a < t.length; ++a) + r[a] = t.charCodeAt(a); + return r; + } +} +function base64FromBytes(e) { + if (tsProtoGlobalThis.Buffer) + return tsProtoGlobalThis.Buffer.from(e).toString("base64"); + { + const t = []; + return e.forEach((r) => { + t.push(String.fromCharCode(r)); + }), tsProtoGlobalThis.btoa(t.join("")); + } +} +function longToNumber(e) { + if (e.gt(Number.MAX_SAFE_INTEGER)) + throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + return e.toNumber(); +} +_m0$4.util.Long !== Long && (_m0$4.util.Long = Long, _m0$4.configure()); +function isSet$4(e) { + return e != null; +} +function encode(e, t) { + return PacketWrapper.encode({ + packetId: e, + packetData: t + }).finish(); +} +function decode(e) { + let t = PacketWrapper.decode(e); + return [t.packetId, t.packetData]; +} +const _m0$3 = __vite__cjsImport0_protobufjs_minimal; +var ModuleType = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.Cargo = 1] = "Cargo", e[e.LandingThruster = 2] = "LandingThruster", e[e.LandingThrusterSuspension = 3] = "LandingThrusterSuspension", e[e.Hub = 4] = "Hub", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(ModuleType || {}); +function moduleTypeFromJSON(e) { + switch (e) { + case 0: + case "UNKNOWN": + return 0; + case 1: + case "Cargo": + return 1; + case 2: + case "LandingThruster": + return 2; + case 3: + case "LandingThrusterSuspension": + return 3; + case 4: + case "Hub": + return 4; + case -1: + case "UNRECOGNIZED": + default: + return -1; + } +} +function moduleTypeToJSON(e) { + switch (e) { + case 0: + return "UNKNOWN"; + case 1: + return "Cargo"; + case 2: + return "LandingThruster"; + case 3: + return "LandingThrusterSuspension"; + case 4: + return "Hub"; + case -1: + default: + return "UNRECOGNIZED"; + } +} +function createBaseModule() { + return { moduleType: 0, rotation: 0, x: 0, y: 0, id: 0, flags: 0, children: [] }; +} +const Module = { + encode(e, t = _m0$3.Writer.create()) { + e.moduleType !== 0 && t.uint32(8).int32(e.moduleType), e.rotation !== 0 && t.uint32(17).double(e.rotation), e.x !== 0 && t.uint32(25).double(e.x), e.y !== 0 && t.uint32(33).double(e.y), e.id !== 0 && t.uint32(40).uint32(e.id), e.flags !== 0 && t.uint32(48).uint32(e.flags); + for (const r of e.children) + Attachment.encode(r, t.uint32(58).fork()).ldelim(); + return t; + }, + decode(e, t) { + const r = e instanceof _m0$3.Reader ? e : _m0$3.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseModule(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.moduleType = r.int32(); + continue; + case 2: + if (n != 17) + break; + o.rotation = r.double(); + continue; + case 3: + if (n != 25) + break; + o.x = r.double(); + continue; + case 4: + if (n != 33) + break; + o.y = r.double(); + continue; + case 5: + if (n != 40) + break; + o.id = r.uint32(); + continue; + case 6: + if (n != 48) + break; + o.flags = r.uint32(); + continue; + case 7: + if (n != 58) + break; + o.children.push(Attachment.decode(r, r.uint32())); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + moduleType: isSet$3(e.moduleType) ? moduleTypeFromJSON(e.moduleType) : 0, + rotation: isSet$3(e.rotation) ? Number(e.rotation) : 0, + x: isSet$3(e.x) ? Number(e.x) : 0, + y: isSet$3(e.y) ? Number(e.y) : 0, + id: isSet$3(e.id) ? Number(e.id) : 0, + flags: isSet$3(e.flags) ? Number(e.flags) : 0, + children: Array.isArray(e == null ? void 0 : e.children) ? e.children.map((t) => Attachment.fromJSON(t)) : [] + }; + }, + toJSON(e) { + const t = {}; + return e.moduleType !== void 0 && (t.moduleType = moduleTypeToJSON(e.moduleType)), e.rotation !== void 0 && (t.rotation = e.rotation), e.x !== void 0 && (t.x = e.x), e.y !== void 0 && (t.y = e.y), e.id !== void 0 && (t.id = Math.round(e.id)), e.flags !== void 0 && (t.flags = Math.round(e.flags)), e.children ? t.children = e.children.map((r) => r ? Attachment.toJSON(r) : void 0) : t.children = [], t; + }, + create(e) { + return Module.fromPartial(e ?? {}); + }, + fromPartial(e) { + var r; + const t = createBaseModule(); + return t.moduleType = e.moduleType ?? 0, t.rotation = e.rotation ?? 0, t.x = e.x ?? 0, t.y = e.y ?? 0, t.id = e.id ?? 0, t.flags = e.flags ?? 0, t.children = ((r = e.children) == null ? void 0 : r.map((a) => Attachment.fromPartial(a))) || [], t; + } +}; +function createBaseAttachedModule() { + return { moduleType: 0, rotation: 0, x: 0, y: 0, id: 0, children: [] }; +} +const AttachedModule = { + encode(e, t = _m0$3.Writer.create()) { + e.moduleType !== 0 && t.uint32(8).int32(e.moduleType), e.rotation !== 0 && t.uint32(17).double(e.rotation), e.x !== 0 && t.uint32(25).double(e.x), e.y !== 0 && t.uint32(33).double(e.y), e.id !== 0 && t.uint32(40).uint32(e.id); + for (const r of e.children) + Attachment.encode(r, t.uint32(50).fork()).ldelim(); + return t; + }, + decode(e, t) { + const r = e instanceof _m0$3.Reader ? e : _m0$3.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseAttachedModule(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.moduleType = r.int32(); + continue; + case 2: + if (n != 17) + break; + o.rotation = r.double(); + continue; + case 3: + if (n != 25) + break; + o.x = r.double(); + continue; + case 4: + if (n != 33) + break; + o.y = r.double(); + continue; + case 5: + if (n != 40) + break; + o.id = r.uint32(); + continue; + case 6: + if (n != 50) + break; + o.children.push(Attachment.decode(r, r.uint32())); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + moduleType: isSet$3(e.moduleType) ? moduleTypeFromJSON(e.moduleType) : 0, + rotation: isSet$3(e.rotation) ? Number(e.rotation) : 0, + x: isSet$3(e.x) ? Number(e.x) : 0, + y: isSet$3(e.y) ? Number(e.y) : 0, + id: isSet$3(e.id) ? Number(e.id) : 0, + children: Array.isArray(e == null ? void 0 : e.children) ? e.children.map((t) => Attachment.fromJSON(t)) : [] + }; + }, + toJSON(e) { + const t = {}; + return e.moduleType !== void 0 && (t.moduleType = moduleTypeToJSON(e.moduleType)), e.rotation !== void 0 && (t.rotation = e.rotation), e.x !== void 0 && (t.x = e.x), e.y !== void 0 && (t.y = e.y), e.id !== void 0 && (t.id = Math.round(e.id)), e.children ? t.children = e.children.map((r) => r ? Attachment.toJSON(r) : void 0) : t.children = [], t; + }, + create(e) { + return AttachedModule.fromPartial(e ?? {}); + }, + fromPartial(e) { + var r; + const t = createBaseAttachedModule(); + return t.moduleType = e.moduleType ?? 0, t.rotation = e.rotation ?? 0, t.x = e.x ?? 0, t.y = e.y ?? 0, t.id = e.id ?? 0, t.children = ((r = e.children) == null ? void 0 : r.map((a) => Attachment.fromPartial(a))) || [], t; + } +}; +function createBaseAttachment() { + return { id: 0, slot: 0 }; +} +const Attachment = { + encode(e, t = _m0$3.Writer.create()) { + return e.id !== 0 && t.uint32(8).uint32(e.id), e.slot !== 0 && t.uint32(16).uint32(e.slot), t; + }, + decode(e, t) { + const r = e instanceof _m0$3.Reader ? e : _m0$3.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseAttachment(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.id = r.uint32(); + continue; + case 2: + if (n != 16) + break; + o.slot = r.uint32(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { id: isSet$3(e.id) ? Number(e.id) : 0, slot: isSet$3(e.slot) ? Number(e.slot) : 0 }; + }, + toJSON(e) { + const t = {}; + return e.id !== void 0 && (t.id = Math.round(e.id)), e.slot !== void 0 && (t.slot = Math.round(e.slot)), t; + }, + create(e) { + return Attachment.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseAttachment(); + return t.id = e.id ?? 0, t.slot = e.slot ?? 0, t; + } +}; +function isSet$3(e) { + return e != null; +} +const _m0$2 = __vite__cjsImport0_protobufjs_minimal; +var PlanetType = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.Earth = 1] = "Earth", e[e.Moon = 2] = "Moon", e[e.Mars = 3] = "Mars", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(PlanetType || {}); +function planetTypeFromJSON(e) { + switch (e) { + case 0: + case "UNKNOWN": + return 0; + case 1: + case "Earth": + return 1; + case 2: + case "Moon": + return 2; + case 3: + case "Mars": + return 3; + case -1: + case "UNRECOGNIZED": + default: + return -1; + } +} +function planetTypeToJSON(e) { + switch (e) { + case 0: + return "UNKNOWN"; + case 1: + return "Earth"; + case 2: + return "Moon"; + case 3: + return "Mars"; + case -1: + default: + return "UNRECOGNIZED"; + } +} +function createBasePlanet() { + return { planetType: 0, x: 0, y: 0, radius: 0 }; +} +const Planet = { + encode(e, t = _m0$2.Writer.create()) { + return e.planetType !== 0 && t.uint32(8).int32(e.planetType), e.x !== 0 && t.uint32(17).double(e.x), e.y !== 0 && t.uint32(25).double(e.y), e.radius !== 0 && t.uint32(33).double(e.radius), t; + }, + decode(e, t) { + const r = e instanceof _m0$2.Reader ? e : _m0$2.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBasePlanet(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.planetType = r.int32(); + continue; + case 2: + if (n != 17) + break; + o.x = r.double(); + continue; + case 3: + if (n != 25) + break; + o.y = r.double(); + continue; + case 4: + if (n != 33) + break; + o.radius = r.double(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + planetType: isSet$2(e.planetType) ? planetTypeFromJSON(e.planetType) : 0, + x: isSet$2(e.x) ? Number(e.x) : 0, + y: isSet$2(e.y) ? Number(e.y) : 0, + radius: isSet$2(e.radius) ? Number(e.radius) : 0 + }; + }, + toJSON(e) { + const t = {}; + return e.planetType !== void 0 && (t.planetType = planetTypeToJSON(e.planetType)), e.x !== void 0 && (t.x = e.x), e.y !== void 0 && (t.y = e.y), e.radius !== void 0 && (t.radius = e.radius), t; + }, + create(e) { + return Planet.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBasePlanet(); + return t.planetType = e.planetType ?? 0, t.x = e.x ?? 0, t.y = e.y ?? 0, t.radius = e.radius ?? 0, t; + } +}; +function isSet$2(e) { + return e != null; +} +const _m0$1 = __vite__cjsImport0_protobufjs_minimal; +function createBasePlayer() { + return { rotation: 0, x: 0, y: 0, username: "" }; +} +const Player = { + encode(e, t = _m0$1.Writer.create()) { + return e.rotation !== 0 && t.uint32(9).double(e.rotation), e.x !== 0 && t.uint32(17).double(e.x), e.y !== 0 && t.uint32(25).double(e.y), e.username !== "" && t.uint32(34).string(e.username), t; + }, + decode(e, t) { + const r = e instanceof _m0$1.Reader ? e : _m0$1.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBasePlayer(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 9) + break; + o.rotation = r.double(); + continue; + case 2: + if (n != 17) + break; + o.x = r.double(); + continue; + case 3: + if (n != 25) + break; + o.y = r.double(); + continue; + case 4: + if (n != 34) + break; + o.username = r.string(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + rotation: isSet$1(e.rotation) ? Number(e.rotation) : 0, + x: isSet$1(e.x) ? Number(e.x) : 0, + y: isSet$1(e.y) ? Number(e.y) : 0, + username: isSet$1(e.username) ? String(e.username) : "" + }; + }, + toJSON(e) { + const t = {}; + return e.rotation !== void 0 && (t.rotation = e.rotation), e.x !== void 0 && (t.x = e.x), e.y !== void 0 && (t.y = e.y), e.username !== void 0 && (t.username = e.username), t; + }, + create(e) { + return Player.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBasePlayer(); + return t.rotation = e.rotation ?? 0, t.x = e.x ?? 0, t.y = e.y ?? 0, t.username = e.username ?? "", t; + } +}; +function isSet$1(e) { + return e != null; +} +const _m0 = __vite__cjsImport0_protobufjs_minimal; +var MessageS2CHello_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 5] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CHello_packetInfo || {}), MessageS2CGoodbye_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 6] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CGoodbye_packetInfo || {}), MessageS2CChat_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 7] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CChat_packetInfo || {}), MessageS2CPong_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 8] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CPong_packetInfo || {}), MessageS2CPlayersUpdate_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 9] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CPlayersUpdate_packetInfo || {}), MessageS2CPlanetData_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 10] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CPlanetData_packetInfo || {}), MessageS2CModulesUpdate_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 11] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CModulesUpdate_packetInfo || {}), MessageS2CModuleTreeUpdate_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 12] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CModuleTreeUpdate_packetInfo || {}), MessageS2CModuleAdd_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 13] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CModuleAdd_packetInfo || {}), MessageS2CModuleRemove_packetInfo = /* @__PURE__ */ ((e) => (e[e.unknown = 0] = "unknown", e[e.type = 14] = "type", e[e.UNRECOGNIZED = -1] = "UNRECOGNIZED", e))(MessageS2CModuleRemove_packetInfo || {}); +function createBaseMessageS2CHello() { + return { version: 0, givenUsername: "", nextState: 0 }; +} +const MessageS2CHello = { + encode(e, t = _m0.Writer.create()) { + return e.version !== 0 && t.uint32(8).uint32(e.version), e.givenUsername !== "" && t.uint32(18).string(e.givenUsername), e.nextState !== 0 && t.uint32(24).int32(e.nextState), t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CHello(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.version = r.uint32(); + continue; + case 2: + if (n != 18) + break; + o.givenUsername = r.string(); + continue; + case 3: + if (n != 24) + break; + o.nextState = r.int32(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + version: isSet(e.version) ? Number(e.version) : 0, + givenUsername: isSet(e.givenUsername) ? String(e.givenUsername) : "", + nextState: isSet(e.nextState) ? stateFromJSON(e.nextState) : 0 + }; + }, + toJSON(e) { + const t = {}; + return e.version !== void 0 && (t.version = Math.round(e.version)), e.givenUsername !== void 0 && (t.givenUsername = e.givenUsername), e.nextState !== void 0 && (t.nextState = stateToJSON(e.nextState)), t; + }, + create(e) { + return MessageS2CHello.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageS2CHello(); + return t.version = e.version ?? 0, t.givenUsername = e.givenUsername ?? "", t.nextState = e.nextState ?? 0, t; + } +}; +function createBaseMessageS2CGoodbye() { + return { reason: 0 }; +} +const MessageS2CGoodbye = { + encode(e, t = _m0.Writer.create()) { + return e.reason !== 0 && t.uint32(8).int32(e.reason), t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CGoodbye(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 8) + break; + o.reason = r.int32(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { reason: isSet(e.reason) ? goodbyeReasonFromJSON(e.reason) : 0 }; + }, + toJSON(e) { + const t = {}; + return e.reason !== void 0 && (t.reason = goodbyeReasonToJSON(e.reason)), t; + }, + create(e) { + return MessageS2CGoodbye.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageS2CGoodbye(); + return t.reason = e.reason ?? 0, t; + } +}; +function createBaseMessageS2CChat() { + return { from: "", message: "" }; +} +const MessageS2CChat = { + encode(e, t = _m0.Writer.create()) { + return e.from !== "" && t.uint32(10).string(e.from), e.message !== "" && t.uint32(18).string(e.message), t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CChat(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.from = r.string(); + continue; + case 2: + if (n != 18) + break; + o.message = r.string(); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { + from: isSet(e.from) ? String(e.from) : "", + message: isSet(e.message) ? String(e.message) : "" + }; + }, + toJSON(e) { + const t = {}; + return e.from !== void 0 && (t.from = e.from), e.message !== void 0 && (t.message = e.message), t; + }, + create(e) { + return MessageS2CChat.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageS2CChat(); + return t.from = e.from ?? "", t.message = e.message ?? "", t; + } +}; +function createBaseMessageS2CPlayersUpdate() { + return { players: [] }; +} +const MessageS2CPlayersUpdate = { + encode(e, t = _m0.Writer.create()) { + for (const r of e.players) + Player.encode(r, t.uint32(10).fork()).ldelim(); + return t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CPlayersUpdate(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.players.push(Player.decode(r, r.uint32())); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { players: Array.isArray(e == null ? void 0 : e.players) ? e.players.map((t) => Player.fromJSON(t)) : [] }; + }, + toJSON(e) { + const t = {}; + return e.players ? t.players = e.players.map((r) => r ? Player.toJSON(r) : void 0) : t.players = [], t; + }, + create(e) { + return MessageS2CPlayersUpdate.fromPartial(e ?? {}); + }, + fromPartial(e) { + var r; + const t = createBaseMessageS2CPlayersUpdate(); + return t.players = ((r = e.players) == null ? void 0 : r.map((a) => Player.fromPartial(a))) || [], t; + } +}; +function createBaseMessageS2CPlanetData() { + return { planets: [] }; +} +const MessageS2CPlanetData = { + encode(e, t = _m0.Writer.create()) { + for (const r of e.planets) + Planet.encode(r, t.uint32(10).fork()).ldelim(); + return t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CPlanetData(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.planets.push(Planet.decode(r, r.uint32())); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { planets: Array.isArray(e == null ? void 0 : e.planets) ? e.planets.map((t) => Planet.fromJSON(t)) : [] }; + }, + toJSON(e) { + const t = {}; + return e.planets ? t.planets = e.planets.map((r) => r ? Planet.toJSON(r) : void 0) : t.planets = [], t; + }, + create(e) { + return MessageS2CPlanetData.fromPartial(e ?? {}); + }, + fromPartial(e) { + var r; + const t = createBaseMessageS2CPlanetData(); + return t.planets = ((r = e.planets) == null ? void 0 : r.map((a) => Planet.fromPartial(a))) || [], t; + } +}; +function createBaseMessageS2CModulesUpdate() { + return { modules: [] }; +} +const MessageS2CModulesUpdate = { + encode(e, t = _m0.Writer.create()) { + for (const r of e.modules) + Module.encode(r, t.uint32(10).fork()).ldelim(); + return t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CModulesUpdate(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.modules.push(Module.decode(r, r.uint32())); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { modules: Array.isArray(e == null ? void 0 : e.modules) ? e.modules.map((t) => Module.fromJSON(t)) : [] }; + }, + toJSON(e) { + const t = {}; + return e.modules ? t.modules = e.modules.map((r) => r ? Module.toJSON(r) : void 0) : t.modules = [], t; + }, + create(e) { + return MessageS2CModulesUpdate.fromPartial(e ?? {}); + }, + fromPartial(e) { + var r; + const t = createBaseMessageS2CModulesUpdate(); + return t.modules = ((r = e.modules) == null ? void 0 : r.map((a) => Module.fromPartial(a))) || [], t; + } +}; +function createBaseMessageS2CModuleTreeUpdate() { + return { tree: [] }; +} +const MessageS2CModuleTreeUpdate = { + encode(e, t = _m0.Writer.create()) { + for (const r of e.tree) + AttachedModule.encode(r, t.uint32(10).fork()).ldelim(); + return t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CModuleTreeUpdate(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.tree.push(AttachedModule.decode(r, r.uint32())); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { tree: Array.isArray(e == null ? void 0 : e.tree) ? e.tree.map((t) => AttachedModule.fromJSON(t)) : [] }; + }, + toJSON(e) { + const t = {}; + return e.tree ? t.tree = e.tree.map((r) => r ? AttachedModule.toJSON(r) : void 0) : t.tree = [], t; + }, + create(e) { + return MessageS2CModuleTreeUpdate.fromPartial(e ?? {}); + }, + fromPartial(e) { + var r; + const t = createBaseMessageS2CModuleTreeUpdate(); + return t.tree = ((r = e.tree) == null ? void 0 : r.map((a) => AttachedModule.fromPartial(a))) || [], t; + } +}; +function createBaseMessageS2CModuleAdd() { + return { module: void 0 }; +} +const MessageS2CModuleAdd = { + encode(e, t = _m0.Writer.create()) { + return e.module !== void 0 && AttachedModule.encode(e.module, t.uint32(10).fork()).ldelim(), t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CModuleAdd(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.module = AttachedModule.decode(r, r.uint32()); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { module: isSet(e.module) ? AttachedModule.fromJSON(e.module) : void 0 }; + }, + toJSON(e) { + const t = {}; + return e.module !== void 0 && (t.module = e.module ? AttachedModule.toJSON(e.module) : void 0), t; + }, + create(e) { + return MessageS2CModuleAdd.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageS2CModuleAdd(); + return t.module = e.module !== void 0 && e.module !== null ? AttachedModule.fromPartial(e.module) : void 0, t; + } +}; +function createBaseMessageS2CModuleRemove() { + return { module: void 0 }; +} +const MessageS2CModuleRemove = { + encode(e, t = _m0.Writer.create()) { + return e.module !== void 0 && Module.encode(e.module, t.uint32(10).fork()).ldelim(), t; + }, + decode(e, t) { + const r = e instanceof _m0.Reader ? e : _m0.Reader.create(e); + let a = t === void 0 ? r.len : r.pos + t; + const o = createBaseMessageS2CModuleRemove(); + for (; r.pos < a; ) { + const n = r.uint32(); + switch (n >>> 3) { + case 1: + if (n != 10) + break; + o.module = Module.decode(r, r.uint32()); + continue; + } + if ((n & 7) == 4 || n == 0) + break; + r.skipType(n & 7); + } + return o; + }, + fromJSON(e) { + return { module: isSet(e.module) ? Module.fromJSON(e.module) : void 0 }; + }, + toJSON(e) { + const t = {}; + return e.module !== void 0 && (t.module = e.module ? Module.toJSON(e.module) : void 0), t; + }, + create(e) { + return MessageS2CModuleRemove.fromPartial(e ?? {}); + }, + fromPartial(e) { + const t = createBaseMessageS2CModuleRemove(); + return t.module = e.module !== void 0 && e.module !== null ? Module.fromPartial(e.module) : void 0, t; + } +}; +function isSet(e) { + return e != null; +} +const logger$1 = new Logger("Gateway"); +async function gateway_connect(e, t) { + logger$1.info("FAST CONNECT - Connecting to gateway socket at " + e); + let r = await _websocket_connect(e); + logger$1.debug("[fastconnect] connected to gateway, performing handshake with server"); + let a = { + state: State.Handshake, + socket: r, + username: null, + version: null, + ping_timeout: null, + ping_timeout_left: null + }, o = () => { + logger$1.error("Server didn't send back pong in time."); + let s = MessageC2SGoodbye.encode({ reason: GoodbyeReason.PingPongTimeout }).finish(); + a.socket.send(encode(MessageC2SGoodbye_packetInfo.type, s)), a.state = State.Handshake, a.username = null, a.version = null, a.socket.close(); + }; + a.ping_timeout_left = setTimeout(o, 10 * 1e3); + let n = () => { + let s = MessageC2SPing.encode({}).finish(); + a.socket.send(encode(MessageC2SPing_packetInfo.type, s)), setTimeout(n, 5 * 1e3); + }; + a.ping_timeout = setTimeout(n, 5 * 1e3); + let g; + return global$1.can_beam_out ? g = MessageC2SHello.encode({ + version: 6, + requestedUsername: t, + nextState: State.Play, + user: window.localStorage.getItem("user"), + token: window.localStorage.getItem("token") + }).finish() : g = MessageC2SHello.encode({ + version: 6, + requestedUsername: t, + nextState: State.Play, + // @ts-ignore + user: "", + //null, + // @ts-ignore + token: "" + //null + }).finish(), a.socket.send(encode(MessageC2SHello_packetInfo.type, g)), a.socket.addEventListener("message", async (s) => { + let u = decode(new Uint8Array(await s.data.arrayBuffer())), l = u[0], f = u[1]; + if (l != 0) { + if (a.state == State.Handshake) + if (l == MessageS2CHello_packetInfo.type) { + let d = MessageS2CHello.decode(f); + logger$1.info(`FAST CONNECT - Handshake finished with server with protocol v${d.version}, assigned username ${d.givenUsername}, switching to state ${d.nextState}`), a.state = d.nextState, a.username = d.givenUsername, a.version = d.version; + } else if (l == MessageS2CGoodbye_packetInfo.type) { + let d = MessageS2CGoodbye.decode(f); + throw logger$1.error(`Disconnected by server. Reason: ${d.reason}`), a.state = State.Handshake, a.username = null, a.version = null, "Disconnected by server"; + } else + logger$1.warn(`server sent unexpected packet ${l} for state Handshake`); + else if (a.state == State.Play) + if (l == MessageS2CGoodbye_packetInfo.type) { + let d = MessageS2CGoodbye.decode(f); + throw logger$1.error(`Disconnected by server. Reason: ${d.reason}`), a.state = State.Handshake, a.username = null, a.version = null, "Disconnected by server"; + } else if (l == MessageS2CChat_packetInfo.type) { + let d = MessageS2CChat.decode(f); + logger$1.info(`CHAT: [${d.from}] ${d.message}`); + } else if (l == MessageS2CPong_packetInfo.type) + clearTimeout(a.ping_timeout_left), a.ping_timeout_left = setTimeout(o, 10 * 1e3); + else if (l == MessageS2CPlayersUpdate_packetInfo.type) { + let d = MessageS2CPlayersUpdate.decode(f); + global$1.players = d.players; + for (let m = 0; m < d.players.length; m++) + if (d.players[m].username == a.username) { + if (global$1.me !== null) { + let h = (global$1.me.x - d.players[m].x) / 0.05, c = (global$1.me.y - d.players[m].y) / (1 / 20), p = Math.sqrt(h * h + c * c); + global$1.x_vel = h, global$1.y_vel = c, global$1.velocity = p, global$1.direction_radians = Math.atan2(global$1.y_vel, global$1.x_vel); + } + global$1.me = d.players[m]; + } + } else if (l == MessageS2CPlanetData_packetInfo.type) { + let d = MessageS2CPlanetData.decode(f); + global$1.planets = d.planets; + } else if (l == MessageS2CModulesUpdate_packetInfo.type) { + let d = MessageS2CModulesUpdate.decode(f); + global$1.modules = d.modules; + } else if (l == MessageS2CModuleAdd_packetInfo.type) { + let d = MessageS2CModuleAdd.decode(f), m = { + module_type: d.module.moduleType, + rotation: d.module.rotation, + x: d.module.x, + y: d.module.y, + children: d.module.children + }; + global$1.tree.set(d.module.id, m), global$1.clicked = null; + } else if (l == MessageS2CModuleRemove_packetInfo.type) { + let d = MessageS2CModuleRemove.decode(f); + global$1.clicked = d.module.id; + } else if (l == MessageS2CModuleTreeUpdate_packetInfo.type) { + let d = MessageS2CModuleTreeUpdate.decode(f), m = /* @__PURE__ */ new Map(); + d.tree.forEach((h) => { + m.set(h.id, { + module_type: h.moduleType, + rotation: h.rotation, + x: h.x, + y: h.y, + children: h.children + }); + }), global$1.tree = m; + } else + logger$1.warn(`server sent unexpected packet ${l} for state Play`); + } + }), a; +} +let socket; +function _websocket_connect(e) { + return socket && socket.readyState < 2 ? Promise.resolve(socket) : new Promise((t, r) => { + socket = new WebSocket(e), socket.onopen = () => { + t(socket); + }, socket.onerror = (a) => { + r(a); + }; + }); +} +let particles = []; +function createParticle(e) { + particles.push(e); +} +function lerp(e, t, r) { + return e + r * (t - e); +} +function drawParticle(e) { + let t = e.timer / e.lifetime, r = lerp(e.startSize, e.finalSize, t), a = lerp(e.startRotation, e.finalRotation, t); + global$1.context.save(), global$1.context.translate(e.x - global$1.me.x, e.y - global$1.me.y), global$1.context.rotate(a); + let o = Math.trunc(lerp(e.startOpacity, e.endOpacity, t)), n = Math.trunc(lerp(e.startR, e.endR, t)), g = Math.trunc(lerp(e.startG, e.endG, t)), s = Math.trunc(lerp(e.startB, e.endB, t)); + global$1.context.fillStyle = `rgb(${n} ${g} ${s} / ${o}%)`, global$1.context.fillRect(-r / 2, -r / 2, r, r), global$1.context.restore(); +} +function drawParticles() { + for (let e = 0; e < particles.length; e++) + drawParticle(particles[e]); +} +function tickParticles(e) { + let t = []; + for (let r = 0; r < particles.length; r++) + particles[r].timer += e, particles[r].x += particles[r].velocity_x * e, particles[r].y += particles[r].velocity_y * e, particles[r].timer > particles[r].lifetime ? console.log("dropping particle") : t.push(particles[r]); + particles = t; +} +function tickAndDrawParticles(e) { + tickParticles(e), drawParticles(); +} +logSetup(); +const logger = new Logger("client"), global$1 = { + client: null, + players: [], + planets: [], + modules: [], + me: null, + canvas: document.getElementById("canvas"), + spritesheet_img: null, + spritesheet: null, + context: document.getElementById("canvas").getContext("2d"), + keys: { + up: !1, + down: !1, + left: !1, + right: !1 + }, + velocity: 0, + x_vel: 0, + y_vel: 0, + can_beam_out: !1, + direction_radians: 0, + mouse_x: 0, + mouse_y: 0, + tree: /* @__PURE__ */ new Map(), + clicked: null +}; +async function client_main(e, t, r) { + logger.info("StarKingdoms client - starting"), window.localStorage.getItem("token") !== null && window.localStorage.getItem("user") !== null && (global$1.can_beam_out = !0, document.getElementById("beamout").style.setProperty("display", "block"), document.getElementById("beamout").addEventListener("click", () => { + var m; + let d = MessageC2SAuthenticateAndBeamOut.encode({ + userId: window.localStorage.getItem("user"), + token: window.localStorage.getItem("token") + }).finish(); + (m = global$1.client) == null || m.socket.send(encode(MessageC2SAuthenticateAndBeamOut_packetInfo.type, d)); + })), logger.info("Loading textures"); + let a = `/assets/dist/spritesheet-${r}.png`, o = `/assets/dist/spritesheet-${r}.json`; + await new Promise(async (d) => { + const m = new Promise((w, k) => { + const N = document.createElement("img"); + N.src = a, N.onload = () => { + w(N); + }, N.onerror = (y) => k(y); + }), h = fetch(o).then((w) => w.json()); + let c = await m, p = await h; + global$1.spritesheet_img = c, global$1.spritesheet = p, d(); + }), logger.info("Starting the renderer"), global$1.client = await gateway_connect(e, t), global$1.canvas.width = window.innerWidth, global$1.canvas.height = window.innerHeight, window.onresize = () => { + global$1.canvas.width = window.innerWidth, global$1.canvas.height = window.innerHeight; + }, global$1.canvas.style.setProperty("background-image", `url("/assets/final/${r}/starfield.png")`); + let g = document.getElementById("canvas"), s = 0; + document.onmousedown = (d) => { + var m, h, c, p; + if (global$1.me !== null) { + let w = d.clientX - window.innerWidth / 2 + ((m = global$1.me) == null ? void 0 : m.x), k = d.clientY - window.innerHeight / 2 + ((h = global$1.me) == null ? void 0 : h.y), N; + d.button == 0 ? N = InputType.Left : d.button == 1 ? N = InputType.Middle : d.button == 2 && (N = InputType.Right); + for (let S = 0; S < global$1.modules.length; S++) { + let O = global$1.modules[S].x - w, T = global$1.modules[S].y - k, I = -global$1.modules[S].rotation; + O = O * Math.cos(I) - T * Math.sin(I), T = O * Math.sin(I) + T * Math.cos(I); + let A = [-25, 25, -25, 25]; + if (global$1.modules[S].moduleType == ModuleType.Cargo && (A = [-18.75, 18.75, -25, 21.875]), A[0] < O && O < A[1] && A[2] < T && T < A[3]) { + let q = MessageC2SModuleGrabBegin.encode({ + moduleId: global$1.modules[S].id, + worldposX: w, + worldposY: k + }).finish(); + global$1.clicked = global$1.modules[S].id, (c = global$1.client) == null || c.socket.send(encode(MessageC2SModuleGrabBegin_packetInfo.type, q)); + } + } + global$1.tree.forEach((S, O) => { + var _; + if (S.module_type == ModuleType.LandingThrusterSuspension) + return; + let T = S.x - w, I = S.y - k, A = -S.rotation, q = T * Math.cos(A) - I * Math.sin(A), P = T * Math.sin(A) + I * Math.cos(A), b = [-25, 25, -25, 25]; + if (S.module_type == ModuleType.Cargo && (b = [-18.75, 18.75, -25, 21.875]), b[0] < q && q < b[1] && b[2] < P && P < b[3]) { + console.log("relative: " + T + ", " + I), console.log("adjusted: " + q + ", " + P); + let i = MessageC2SModuleDetach.encode({ + moduleId: O + }).finish(); + (_ = global$1.client) == null || _.socket.send(encode(MessageC2SModuleDetach_packetInfo.type, i)); + } + }); + let y = MessageC2SMouseInput.encode({ + worldposX: w, + worldposY: k, + released: !1, + button: N + }).finish(); + (p = global$1.client) == null || p.socket.send(encode(MessageC2SMouseInput_packetInfo.type, y)); + } + }, document.onmouseup = (d) => { + var m, h, c, p; + if (global$1.me !== null) { + let w = d.clientX - window.innerWidth / 2 + ((m = global$1.me) == null ? void 0 : m.x), k = d.clientY - window.innerHeight / 2 + ((h = global$1.me) == null ? void 0 : h.y), N; + d.button == 0 ? N = InputType.Left : d.button == 1 ? N = InputType.Middle : d.button == 2 && (N = InputType.Right); + let y = MessageC2SMouseInput.encode({ + worldposX: w, + worldposY: k, + released: !0, + button: N + }).finish(); + for (let S = 0; S < global$1.modules.length; S++) + if (global$1.clicked === global$1.modules[S].id) { + let O = MessageC2SModuleGrabEnd.encode({ + moduleId: global$1.modules[S].id, + worldposX: w, + worldposY: k + }).finish(); + (c = global$1.client) == null || c.socket.send(encode(MessageC2SModuleGrabEnd_packetInfo.type, O)); + } + global$1.clicked = null, (p = global$1.client) == null || p.socket.send(encode(MessageC2SMouseInput_packetInfo.type, y)); + } + }, document.onmousemove = (d) => { + let m = g.offsetLeft + g.clientLeft, h = g.offsetTop + g.clientTop; + global$1.mouse_x = d.pageX - m, global$1.mouse_y = d.pageY - h; + }, document.onkeydown = (d) => { + var h; + d.code == "ArrowLeft" || d.code == "KeyA" ? global$1.keys.left = !0 : d.code == "ArrowRight" || d.code == "KeyD" ? global$1.keys.right = !0 : d.code == "ArrowUp" || d.code == "KeyW" ? global$1.keys.up = !0 : (d.code == "ArrowDown" || d.code == "KeyS") && (global$1.keys.down = !0); + let m = MessageC2SInput.encode({ + upPressed: global$1.keys.up, + downPressed: global$1.keys.down, + leftPressed: global$1.keys.left, + rightPressed: global$1.keys.right + }).finish(); + (h = global$1.client) == null || h.socket.send(encode(MessageC2SInput_packetInfo.type, m)); + }, document.onkeyup = (d) => { + var h; + d.code == "ArrowLeft" || d.code == "KeyA" ? global$1.keys.left = !1 : d.code == "ArrowRight" || d.code == "KeyD" ? global$1.keys.right = !1 : d.code == "ArrowUp" || d.code == "KeyW" ? global$1.keys.up = !1 : (d.code == "ArrowDown" || d.code == "KeyS") && (global$1.keys.down = !1); + let m = MessageC2SInput.encode({ + upPressed: global$1.keys.up, + downPressed: global$1.keys.down, + leftPressed: global$1.keys.left, + rightPressed: global$1.keys.right + }).finish(); + (h = global$1.client) == null || h.socket.send(encode(MessageC2SInput_packetInfo.type, m)); + }; + let u = performance.now(), l = 0, f = (d) => { + var b, _, i, v; + l = d - u, u = d; + let m = global$1.canvas.width, h = global$1.canvas.height; + global$1.canvas.style.setProperty("background-position", `${-((b = global$1.me) == null ? void 0 : b.x) / 5}px ${-((_ = global$1.me) == null ? void 0 : _.y) / 5}px`), global$1.context.setTransform(1, 0, 0, 1, 0, 0), global$1.context.clearRect(0, 0, m, h), global$1.context.translate(m / 2, h / 2), global$1.context.save(), global$1.context.rotate(global$1.direction_radians + Math.PI); + let c = global$1.spritesheet.frames["trackindicator.png"]; + global$1.context.drawImage( + global$1.spritesheet_img, + c.frame.x, + c.frame.y, + c.frame.w, + c.frame.h, + -c.frame.w / 2, + -c.frame.h / 2, + c.frame.w, + c.frame.h + ), global$1.context.restore(), global$1.me !== null && (document.getElementById("pos").innerText = `Position: ${Math.trunc(global$1.me.x)}, ${Math.trunc(global$1.me.y)}`), document.getElementById("vel").innerText = `Velocity: ${Math.trunc(global$1.velocity)}`, document.getElementById("vel-dir").innerText = `Track Angle: ${global$1.direction_radians}`; + for (let E = 0; E < global$1.planets.length; E++) { + let $ = global$1.planets[E], x = global$1.spritesheet.frames[planet_type_to_tex_id($.planetType)]; + global$1.context.drawImage( + global$1.spritesheet_img, + x.frame.x, + // sx + x.frame.y, + // sy + x.frame.w, + // sw + x.frame.h, + // sh + $.x - $.radius - ((i = global$1.me) == null ? void 0 : i.x), + // dx + $.y - $.radius - ((v = global$1.me) == null ? void 0 : v.y), + // dy + $.radius * 2, + // dw + $.radius * 2 + ), $.planetType == PlanetType.Moon ? global$1.me !== null && (global$1.context.beginPath(), global$1.context.strokeStyle = "gray", global$1.context.lineWidth = 5, global$1.context.moveTo(global$1.me.x - global$1.me.x, global$1.me.y - global$1.me.y), global$1.context.lineTo($.x - global$1.me.x, $.y - global$1.me.y), global$1.context.stroke(), console.log("moon: " + $.x + ", " + $.y), document.getElementById("pos-moon").innerText = `Relative to Moon: ${Math.trunc(global$1.me.x - $.x)}, ${Math.trunc(global$1.me.y - $.y)}`) : $.planetType == PlanetType.Earth ? global$1.me !== null && (global$1.context.beginPath(), global$1.context.strokeStyle = "limegreen", global$1.context.lineWidth = 5, global$1.context.moveTo(global$1.me.x - global$1.me.x, global$1.me.y - global$1.me.y), global$1.context.lineTo($.x - global$1.me.x, $.y - global$1.me.y), global$1.context.stroke()) : $.planetType == PlanetType.Mars && global$1.me !== null && (global$1.context.beginPath(), global$1.context.strokeStyle = "orange", global$1.context.lineWidth = 5, global$1.context.moveTo(global$1.me.x - global$1.me.x, global$1.me.y - global$1.me.y), global$1.context.lineTo($.x - global$1.me.x, $.y - global$1.me.y), global$1.context.stroke()); + } + for (let E = 0; E < global$1.modules.length; E++) + if (global$1.me !== null) { + let $ = global$1.modules[E], x = global$1.spritesheet.frames[module_type_to_tex_id($.moduleType, ($.flags & 1) != 0)]; + global$1.context.save(), global$1.context.translate($.x - global$1.me.x, $.y - global$1.me.y), global$1.context.rotate($.rotation), global$1.context.drawImage( + global$1.spritesheet_img, + x.frame.x, + x.frame.y, + x.frame.w, + x.frame.h, + -25, + -25, + 50, + 50 + ), global$1.context.restore(), global$1.clicked == $.id && (global$1.context.save(), global$1.context.translate( + global$1.mouse_x - window.innerWidth / 2, + global$1.mouse_y - window.innerHeight / 2 + ), global$1.context.rotate($.rotation), global$1.context.globalAlpha = 0.6, global$1.context.drawImage( + global$1.spritesheet_img, + x.frame.x, + x.frame.y, + x.frame.w, + x.frame.h, + -25, + -25, + 50, + 50 + ), global$1.context.globalAlpha = 1, global$1.context.restore()); + } + global$1.tree.forEach((E, $) => { + if (global$1.me !== null) { + let x = global$1.spritesheet.frames[module_type_to_tex_id(E.module_type, !0)]; + global$1.context.save(), global$1.context.translate(E.x - global$1.me.x, E.y - global$1.me.y), global$1.context.rotate(E.rotation), global$1.context.drawImage( + global$1.spritesheet_img, + x.frame.x, + x.frame.y, + x.frame.w, + x.frame.h, + -25, + -25, + 50, + 50 + ), global$1.context.restore(); + } + }); + function p() { + let E = /* @__PURE__ */ new Date("3/20/2022"), $ = /* @__PURE__ */ new Date(); + return E.getMonth() == $.getMonth() && E.getDate() == $.getDate(); + } + function w() { + let E = /* @__PURE__ */ new Date("5/15/2015"), $ = /* @__PURE__ */ new Date(); + return E.getMonth() == $.getMonth() && E.getDate() == $.getDate(); + } + for (let E = 0; E < global$1.players.length; E++) + if (global$1.me !== null) { + let $ = global$1.players[E], x; + p() ? x = global$1.spritesheet.frames["hearty_party.png"] : w() ? x = global$1.spritesheet.frames["hearty_ferris.png"] : x = global$1.spritesheet.frames["hearty.png"], global$1.context.save(), global$1.context.translate($.x - global$1.me.x, $.y - global$1.me.y), global$1.context.textAlign = "center", global$1.context.font = "30px Segoe UI", global$1.context.fillStyle = "white", global$1.context.fillText($.username, 0, -35), global$1.context.rotate($.rotation), global$1.context.drawImage( + global$1.spritesheet_img, + x.frame.x, + // sx + x.frame.y, + // sy + x.frame.w, + // sw + x.frame.h, + // sh + -25, + -25, + 50, + 50 + ), global$1.context.restore(); + } + function k(E, $, x) { + let M = E * Math.cos(x) - $ * Math.sin(x), C = E * Math.sin(x) + $ * Math.cos(x); + return [M, C]; + } + const N = 52, y = 189, S = 235, O = 80, T = 0, I = 4, A = 50, q = 90; + function P(E, $, x, M) { + createParticle({ + x: global$1.me.x + k(E, $, global$1.me.rotation)[0], + y: global$1.me.y + k(E, $, global$1.me.rotation)[1], + lifetime: 500, + timer: 0, + startSize: I, + finalSize: A, + startRotation: 0, + finalRotation: q, + startOpacity: O, + endOpacity: T, + startR: N, + startG: y, + startB: S, + endR: N, + endG: y, + endB: S, + velocity_x: k(x, M, global$1.me.rotation)[0], + velocity_y: k(x, M, global$1.me.rotation)[1] + }); + } + global$1.me !== null && (console.log(s), s += 1, s > 3 ? (console.log("resetting counter"), s = 0) : s == 1 && (console.log("drawing particle"), global$1.keys.up && (P(-25, 25, 0, 0.5), P(25, 25, 0, 0.5)), global$1.keys.down && (P(25, -25, 0, -0.5), P(-25, -25, 0, -0.5)), global$1.keys.left && (P(25, 25, 0, 0.5), P(-25, -25, 0, -0.5)), global$1.keys.right && (P(-25, 25, 0, 0.5), P(25, -25, 0, -0.5))), tickAndDrawParticles(l)), requestAnimationFrame(f); + }; + requestAnimationFrame(f); +} +let query = new URLSearchParams(window.location.search); +query.has("server") || query.has("username") || query.has("textures") || (window.location.href = "/index.html"); +client_main(query.get("server"), query.get("username"), query.get("textures")).then(() => { +}); +function planet_type_to_tex_id(e) { + return e == PlanetType.Earth ? "earth.png" : e == PlanetType.Moon ? "moon.png" : e == PlanetType.Mars ? "mars.png" : "unknown.png"; +} +function module_type_to_tex_id(e, t) { + if (t) { + if (e == ModuleType.Cargo) + return "cargo_on.png"; + if (e == ModuleType.LandingThruster) + return "landingthruster_on.png"; + if (e == ModuleType.LandingThrusterSuspension) + return "landingleg.png"; + if (e == ModuleType.Hub) + return "hub_on.png"; + } else { + if (e == ModuleType.Cargo) + return "cargo_off.png"; + if (e == ModuleType.LandingThruster) + return "landingthruster_off.png"; + if (e == ModuleType.LandingThrusterSuspension) + return "landingleg.png"; + if (e == ModuleType.Hub) + return "hub_off.png"; + } + return "unknown.png"; +}