UNPKG

@scandit/web-barcode-link

Version:

The Scandit Web Barcode Link package

1,923 lines 163 kB
var Bn = Object.defineProperty; var Nn = (n, e, t) => e in n ? Bn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var B = (n, e, t) => Nn(n, typeof e != "symbol" ? e + "" : e, t); class Ln { constructor(e) { this.barcodeLink = e; } getConfiguration() { return { ...this.barcodeLink.configuration }; } onCancel() { this.barcodeLink.dispose(), this.barcodeLink.listeners.forEach((e) => { var t; (t = e.onCancel) == null || t.call(e); }); } onCapture(e, t) { this.barcodeLink.listeners.forEach((i) => { var r; (r = i.onCapture) == null || r.call(i, e, t); }); } onConnectionStateChanged(e) { this.barcodeLink.listeners.forEach((t) => { var i; (i = t.onConnectionStateChanged) == null || i.call(t, e); }); } } var Wt = /* @__PURE__ */ ((n) => (n.Unique = "unique", n.Count = "count", n))(Wt || {}), Yt = /* @__PURE__ */ ((n) => (n.SingleScanning = "singleScanning", n.ContinuousScanning = "continuousScanning", n.SingleListBuilding = "singleListBuilding", n.ContinuousListBuilding = "continuousListBuilding", n))(Yt || {}), G = /* @__PURE__ */ ((n) => (n.Express = "express", n.Web = "web", n))(G || {}); class Jt { constructor(e) { B(this, "configuration", { barcodeLinkMode: Yt.SingleScanning, licenseKey: "", listBehavior: Wt.Unique, symbologies: {} }); B(this, "flow"); B(this, "flowDelegate", new Ln(this)); B(this, "listeners", /* @__PURE__ */ new Set()); this.configuration.licenseKey = e; } static forLicenseKey(e) { return new Jt(e); } setSymbologies(e) { return this.configuration.symbologies = e, this; } setBarcodeLinkMode(e) { return this.configuration.barcodeLinkMode = e, this; } setBarcodeRegexValidation(e) { return this.configuration.barcodeRegexValidation = String(e).slice(1, -1), this; } setBarcodeTransformations(e) { return this.configuration.barcodeTransformations = e, this; } setPlatform(e) { switch (e) { case G.Express: return delete this.configuration.platform, this; case G.Web: return this.configuration.platform = e, this; } } setListBehavior(e) { return this.configuration.listBehavior = e, this; } addListener(e) { return this.listeners.add(e), this; } removeListener(e) { return this.listeners.delete(e), this; } async initialize(e) { return this.flow = e, this.flow.setDelegate(this.flowDelegate), await this.flow.initialize(); } dispose() { var e; (e = this.flow) == null || e.dispose(); } } var te = /* @__PURE__ */ ((n) => (n.MainDeviceReconnected = "mainDeviceReconnected", n.MainDeviceDisconnected = "mainDeviceDisconnected", n.MainDeviceConnectionFailed = "mainDeviceConnectionFailed", n.RemoteDeviceConnected = "remoteDeviceConnected", n.RemoteDeviceDisconnected = "remoteDeviceDisconnected", n))(te || {}); const On = { SCANDIT_BARCODE_LINK_URL: "https://barcode-link.scandit.com", SCANDIT_BARCODE_LINK_WS_URL: "https://ws.barcode-link.scandit.com" }; function $e(n) { const e = n || On; return { production: { barcodeLinkUrl: e.SCANDIT_BARCODE_LINK_URL || "https://barcode-link.scandit.com", barcodeLinkWsUrl: e.SCANDIT_BARCODE_LINK_WS_URL || "https://barcode-link-ws.scandit.com" }, staging: { barcodeLinkUrl: e.SCANDIT_BARCODE_LINK_STAGING_URL || "https://barcode-link.staging.scandit.io", barcodeLinkWsUrl: e.SCANDIT_BARCODE_LINK_WS_STAGING_URL || "https://barcode-link-ws.staging.scandit.io" }, development: { barcodeLinkUrl: e.SCANDIT_BARCODE_LINK_LOCAL_URL || "https://barcode-link.dev.localhost", barcodeLinkWsUrl: e.SCANDIT_BARCODE_LINK_WS_LOCAL_URL || "https://ws.barcode-link.dev.localhost" } }; } class De { /** * Set custom environment variables for testing */ static setEnvironmentVars(e) { this.envMap = $e(e); } /** * Reset environment variables to default */ static resetEnvironmentVars() { this.envMap = $e(); } static getCurrentEnvironment() { if (typeof window > "u") return "production"; const e = new URLSearchParams(window.location.search).get("__barcodeLinkForceEnvironment"); return e && this.envMap[e] ? (console.warn(`Using environment from query parameter: ${e}`), e) : "production"; } /** * Get current barcode link URL */ static get barcodeLinkUrl() { return this.envMap[this.getCurrentEnvironment()].barcodeLinkUrl; } /** * Get current barcode link WebSocket URL */ static get barcodeLinkWsUrl() { return this.envMap[this.getCurrentEnvironment()].barcodeLinkWsUrl; } } B(De, "envMap", $e()); var Mn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, we = {}, In = function() { return typeof Promise == "function" && Promise.prototype && Promise.prototype.then; }, Gt = {}, D = {}; let wt; const Pn = [ 0, // Not used 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706 ]; D.getSymbolSize = function(e) { if (!e) throw new Error('"version" cannot be null or undefined'); if (e < 1 || e > 40) throw new Error('"version" should be in range from 1 to 40'); return e * 4 + 17; }; D.getSymbolTotalCodewords = function(e) { return Pn[e]; }; D.getBCHDigit = function(n) { let e = 0; for (; n !== 0; ) e++, n >>>= 1; return e; }; D.setToSJISFunction = function(e) { if (typeof e != "function") throw new Error('"toSJISFunc" is not a valid function.'); wt = e; }; D.isKanjiModeEnabled = function() { return typeof wt < "u"; }; D.toSJIS = function(e) { return wt(e); }; var Ue = {}; (function(n) { n.L = { bit: 1 }, n.M = { bit: 0 }, n.Q = { bit: 3 }, n.H = { bit: 2 }; function e(t) { if (typeof t != "string") throw new Error("Param is not a string"); switch (t.toLowerCase()) { case "l": case "low": return n.L; case "m": case "medium": return n.M; case "q": case "quartile": return n.Q; case "h": case "high": return n.H; default: throw new Error("Unknown EC Level: " + t); } } n.isValid = function(i) { return i && typeof i.bit < "u" && i.bit >= 0 && i.bit < 4; }, n.from = function(i, r) { if (n.isValid(i)) return i; try { return e(i); } catch { return r; } }; })(Ue); function jt() { this.buffer = [], this.length = 0; } jt.prototype = { get: function(n) { const e = Math.floor(n / 8); return (this.buffer[e] >>> 7 - n % 8 & 1) === 1; }, put: function(n, e) { for (let t = 0; t < e; t++) this.putBit((n >>> e - t - 1 & 1) === 1); }, getLengthInBits: function() { return this.length; }, putBit: function(n) { const e = Math.floor(this.length / 8); this.buffer.length <= e && this.buffer.push(0), n && (this.buffer[e] |= 128 >>> this.length % 8), this.length++; } }; var xn = jt; function be(n) { if (!n || n < 1) throw new Error("BitMatrix size must be defined and greater than 0"); this.size = n, this.data = new Uint8Array(n * n), this.reservedBit = new Uint8Array(n * n); } be.prototype.set = function(n, e, t, i) { const r = n * this.size + e; this.data[r] = t, i && (this.reservedBit[r] = !0); }; be.prototype.get = function(n, e) { return this.data[n * this.size + e]; }; be.prototype.xor = function(n, e, t) { this.data[n * this.size + e] ^= t; }; be.prototype.isReserved = function(n, e) { return this.reservedBit[n * this.size + e]; }; var Dn = be, $t = {}; (function(n) { const e = D.getSymbolSize; n.getRowColCoords = function(i) { if (i === 1) return []; const r = Math.floor(i / 7) + 2, s = e(i), o = s === 145 ? 26 : Math.ceil((s - 13) / (2 * r - 2)) * 2, a = [s - 7]; for (let c = 1; c < r - 1; c++) a[c] = a[c - 1] - o; return a.push(6), a.reverse(); }, n.getPositions = function(i) { const r = [], s = n.getRowColCoords(i), o = s.length; for (let a = 0; a < o; a++) for (let c = 0; c < o; c++) a === 0 && c === 0 || // top-left a === 0 && c === o - 1 || // bottom-left a === o - 1 && c === 0 || r.push([s[a], s[c]]); return r; }; })($t); var Qt = {}; const Un = D.getSymbolSize, Ut = 7; Qt.getPositions = function(e) { const t = Un(e); return [ // top-left [0, 0], // top-right [t - Ut, 0], // bottom-left [0, t - Ut] ]; }; var Xt = {}; (function(n) { n.Patterns = { PATTERN000: 0, PATTERN001: 1, PATTERN010: 2, PATTERN011: 3, PATTERN100: 4, PATTERN101: 5, PATTERN110: 6, PATTERN111: 7 }; const e = { N1: 3, N2: 3, N3: 40, N4: 10 }; n.isValid = function(r) { return r != null && r !== "" && !isNaN(r) && r >= 0 && r <= 7; }, n.from = function(r) { return n.isValid(r) ? parseInt(r, 10) : void 0; }, n.getPenaltyN1 = function(r) { const s = r.size; let o = 0, a = 0, c = 0, w = null, m = null; for (let k = 0; k < s; k++) { a = c = 0, w = m = null; for (let h = 0; h < s; h++) { let d = r.get(k, h); d === w ? a++ : (a >= 5 && (o += e.N1 + (a - 5)), w = d, a = 1), d = r.get(h, k), d === m ? c++ : (c >= 5 && (o += e.N1 + (c - 5)), m = d, c = 1); } a >= 5 && (o += e.N1 + (a - 5)), c >= 5 && (o += e.N1 + (c - 5)); } return o; }, n.getPenaltyN2 = function(r) { const s = r.size; let o = 0; for (let a = 0; a < s - 1; a++) for (let c = 0; c < s - 1; c++) { const w = r.get(a, c) + r.get(a, c + 1) + r.get(a + 1, c) + r.get(a + 1, c + 1); (w === 4 || w === 0) && o++; } return o * e.N2; }, n.getPenaltyN3 = function(r) { const s = r.size; let o = 0, a = 0, c = 0; for (let w = 0; w < s; w++) { a = c = 0; for (let m = 0; m < s; m++) a = a << 1 & 2047 | r.get(w, m), m >= 10 && (a === 1488 || a === 93) && o++, c = c << 1 & 2047 | r.get(m, w), m >= 10 && (c === 1488 || c === 93) && o++; } return o * e.N3; }, n.getPenaltyN4 = function(r) { let s = 0; const o = r.data.length; for (let c = 0; c < o; c++) s += r.data[c]; return Math.abs(Math.ceil(s * 100 / o / 5) - 10) * e.N4; }; function t(i, r, s) { switch (i) { case n.Patterns.PATTERN000: return (r + s) % 2 === 0; case n.Patterns.PATTERN001: return r % 2 === 0; case n.Patterns.PATTERN010: return s % 3 === 0; case n.Patterns.PATTERN011: return (r + s) % 3 === 0; case n.Patterns.PATTERN100: return (Math.floor(r / 2) + Math.floor(s / 3)) % 2 === 0; case n.Patterns.PATTERN101: return r * s % 2 + r * s % 3 === 0; case n.Patterns.PATTERN110: return (r * s % 2 + r * s % 3) % 2 === 0; case n.Patterns.PATTERN111: return (r * s % 3 + (r + s) % 2) % 2 === 0; default: throw new Error("bad maskPattern:" + i); } } n.applyMask = function(r, s) { const o = s.size; for (let a = 0; a < o; a++) for (let c = 0; c < o; c++) s.isReserved(c, a) || s.xor(c, a, t(r, c, a)); }, n.getBestMask = function(r, s) { const o = Object.keys(n.Patterns).length; let a = 0, c = 1 / 0; for (let w = 0; w < o; w++) { s(w), n.applyMask(w, r); const m = n.getPenaltyN1(r) + n.getPenaltyN2(r) + n.getPenaltyN3(r) + n.getPenaltyN4(r); n.applyMask(w, r), m < c && (c = m, a = w); } return a; }; })(Xt); var Fe = {}; const j = Ue, Ae = [ // L M Q H 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 4, 1, 2, 4, 4, 2, 4, 4, 4, 2, 4, 6, 5, 2, 4, 6, 6, 2, 5, 8, 8, 4, 5, 8, 8, 4, 5, 8, 11, 4, 8, 10, 11, 4, 9, 12, 16, 4, 9, 16, 16, 6, 10, 12, 18, 6, 10, 17, 16, 6, 11, 16, 19, 6, 13, 18, 21, 7, 14, 21, 25, 8, 16, 20, 25, 8, 17, 23, 25, 9, 17, 23, 34, 9, 18, 25, 30, 10, 20, 27, 32, 12, 21, 29, 35, 12, 23, 34, 37, 12, 25, 34, 40, 13, 26, 35, 42, 14, 28, 38, 45, 15, 29, 40, 48, 16, 31, 43, 51, 17, 33, 45, 54, 18, 35, 48, 57, 19, 37, 51, 60, 19, 38, 53, 63, 20, 40, 56, 66, 21, 43, 59, 70, 22, 45, 62, 74, 24, 47, 65, 77, 25, 49, 68, 81 ], Te = [ // L M Q H 7, 10, 13, 17, 10, 16, 22, 28, 15, 26, 36, 44, 20, 36, 52, 64, 26, 48, 72, 88, 36, 64, 96, 112, 40, 72, 108, 130, 48, 88, 132, 156, 60, 110, 160, 192, 72, 130, 192, 224, 80, 150, 224, 264, 96, 176, 260, 308, 104, 198, 288, 352, 120, 216, 320, 384, 132, 240, 360, 432, 144, 280, 408, 480, 168, 308, 448, 532, 180, 338, 504, 588, 196, 364, 546, 650, 224, 416, 600, 700, 224, 442, 644, 750, 252, 476, 690, 816, 270, 504, 750, 900, 300, 560, 810, 960, 312, 588, 870, 1050, 336, 644, 952, 1110, 360, 700, 1020, 1200, 390, 728, 1050, 1260, 420, 784, 1140, 1350, 450, 812, 1200, 1440, 480, 868, 1290, 1530, 510, 924, 1350, 1620, 540, 980, 1440, 1710, 570, 1036, 1530, 1800, 570, 1064, 1590, 1890, 600, 1120, 1680, 1980, 630, 1204, 1770, 2100, 660, 1260, 1860, 2220, 720, 1316, 1950, 2310, 750, 1372, 2040, 2430 ]; Fe.getBlocksCount = function(e, t) { switch (t) { case j.L: return Ae[(e - 1) * 4 + 0]; case j.M: return Ae[(e - 1) * 4 + 1]; case j.Q: return Ae[(e - 1) * 4 + 2]; case j.H: return Ae[(e - 1) * 4 + 3]; default: return; } }; Fe.getTotalCodewordsCount = function(e, t) { switch (t) { case j.L: return Te[(e - 1) * 4 + 0]; case j.M: return Te[(e - 1) * 4 + 1]; case j.Q: return Te[(e - 1) * 4 + 2]; case j.H: return Te[(e - 1) * 4 + 3]; default: return; } }; var Zt = {}, qe = {}; const pe = new Uint8Array(512), Ie = new Uint8Array(256); (function() { let e = 1; for (let t = 0; t < 255; t++) pe[t] = e, Ie[e] = t, e <<= 1, e & 256 && (e ^= 285); for (let t = 255; t < 512; t++) pe[t] = pe[t - 255]; })(); qe.log = function(e) { if (e < 1) throw new Error("log(" + e + ")"); return Ie[e]; }; qe.exp = function(e) { return pe[e]; }; qe.mul = function(e, t) { return e === 0 || t === 0 ? 0 : pe[Ie[e] + Ie[t]]; }; (function(n) { const e = qe; n.mul = function(i, r) { const s = new Uint8Array(i.length + r.length - 1); for (let o = 0; o < i.length; o++) for (let a = 0; a < r.length; a++) s[o + a] ^= e.mul(i[o], r[a]); return s; }, n.mod = function(i, r) { let s = new Uint8Array(i); for (; s.length - r.length >= 0; ) { const o = s[0]; for (let c = 0; c < r.length; c++) s[c] ^= e.mul(r[c], o); let a = 0; for (; a < s.length && s[a] === 0; ) a++; s = s.slice(a); } return s; }, n.generateECPolynomial = function(i) { let r = new Uint8Array([1]); for (let s = 0; s < i; s++) r = n.mul(r, new Uint8Array([1, e.exp(s)])); return r; }; })(Zt); const en = Zt; function bt(n) { this.genPoly = void 0, this.degree = n, this.degree && this.initialize(this.degree); } bt.prototype.initialize = function(e) { this.degree = e, this.genPoly = en.generateECPolynomial(this.degree); }; bt.prototype.encode = function(e) { if (!this.genPoly) throw new Error("Encoder not initialized"); const t = new Uint8Array(e.length + this.degree); t.set(e); const i = en.mod(t, this.genPoly), r = this.degree - i.length; if (r > 0) { const s = new Uint8Array(this.degree); return s.set(i, r), s; } return i; }; var Fn = bt, tn = {}, Q = {}, yt = {}; yt.isValid = function(e) { return !isNaN(e) && e >= 1 && e <= 40; }; var W = {}; const nn = "[0-9]+", qn = "[A-Z $%*+\\-./:]+"; let ge = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+"; ge = ge.replace(/u/g, "\\u"); const Vn = "(?:(?![A-Z0-9 $%*+\\-./:]|" + ge + `)(?:.|[\r ]))+`; W.KANJI = new RegExp(ge, "g"); W.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g"); W.BYTE = new RegExp(Vn, "g"); W.NUMERIC = new RegExp(nn, "g"); W.ALPHANUMERIC = new RegExp(qn, "g"); const zn = new RegExp("^" + ge + "$"), Kn = new RegExp("^" + nn + "$"), Hn = new RegExp("^[A-Z0-9 $%*+\\-./:]+$"); W.testKanji = function(e) { return zn.test(e); }; W.testNumeric = function(e) { return Kn.test(e); }; W.testAlphanumeric = function(e) { return Hn.test(e); }; (function(n) { const e = yt, t = W; n.NUMERIC = { id: "Numeric", bit: 1, ccBits: [10, 12, 14] }, n.ALPHANUMERIC = { id: "Alphanumeric", bit: 2, ccBits: [9, 11, 13] }, n.BYTE = { id: "Byte", bit: 4, ccBits: [8, 16, 16] }, n.KANJI = { id: "Kanji", bit: 8, ccBits: [8, 10, 12] }, n.MIXED = { bit: -1 }, n.getCharCountIndicator = function(s, o) { if (!s.ccBits) throw new Error("Invalid mode: " + s); if (!e.isValid(o)) throw new Error("Invalid version: " + o); return o >= 1 && o < 10 ? s.ccBits[0] : o < 27 ? s.ccBits[1] : s.ccBits[2]; }, n.getBestModeForData = function(s) { return t.testNumeric(s) ? n.NUMERIC : t.testAlphanumeric(s) ? n.ALPHANUMERIC : t.testKanji(s) ? n.KANJI : n.BYTE; }, n.toString = function(s) { if (s && s.id) return s.id; throw new Error("Invalid mode"); }, n.isValid = function(s) { return s && s.bit && s.ccBits; }; function i(r) { if (typeof r != "string") throw new Error("Param is not a string"); switch (r.toLowerCase()) { case "numeric": return n.NUMERIC; case "alphanumeric": return n.ALPHANUMERIC; case "kanji": return n.KANJI; case "byte": return n.BYTE; default: throw new Error("Unknown mode: " + r); } } n.from = function(s, o) { if (n.isValid(s)) return s; try { return i(s); } catch { return o; } }; })(Q); (function(n) { const e = D, t = Fe, i = Ue, r = Q, s = yt, o = 7973, a = e.getBCHDigit(o); function c(h, d, l) { for (let u = 1; u <= 40; u++) if (d <= n.getCapacity(u, l, h)) return u; } function w(h, d) { return r.getCharCountIndicator(h, d) + 4; } function m(h, d) { let l = 0; return h.forEach(function(u) { const f = w(u.mode, d); l += f + u.getBitsLength(); }), l; } function k(h, d) { for (let l = 1; l <= 40; l++) if (m(h, l) <= n.getCapacity(l, d, r.MIXED)) return l; } n.from = function(d, l) { return s.isValid(d) ? parseInt(d, 10) : l; }, n.getCapacity = function(d, l, u) { if (!s.isValid(d)) throw new Error("Invalid QR Code version"); typeof u > "u" && (u = r.BYTE); const f = e.getSymbolTotalCodewords(d), b = t.getTotalCodewordsCount(d, l), E = (f - b) * 8; if (u === r.MIXED) return E; const p = E - w(u, d); switch (u) { case r.NUMERIC: return Math.floor(p / 10 * 3); case r.ALPHANUMERIC: return Math.floor(p / 11 * 2); case r.KANJI: return Math.floor(p / 13); case r.BYTE: default: return Math.floor(p / 8); } }, n.getBestVersionForData = function(d, l) { let u; const f = i.from(l, i.M); if (Array.isArray(d)) { if (d.length > 1) return k(d, f); if (d.length === 0) return 1; u = d[0]; } else u = d; return c(u.mode, u.getLength(), f); }, n.getEncodedBits = function(d) { if (!s.isValid(d) || d < 7) throw new Error("Invalid QR Code version"); let l = d << 12; for (; e.getBCHDigit(l) - a >= 0; ) l ^= o << e.getBCHDigit(l) - a; return d << 12 | l; }; })(tn); var rn = {}; const ot = D, sn = 1335, Wn = 21522, Ft = ot.getBCHDigit(sn); rn.getEncodedBits = function(e, t) { const i = e.bit << 3 | t; let r = i << 10; for (; ot.getBCHDigit(r) - Ft >= 0; ) r ^= sn << ot.getBCHDigit(r) - Ft; return (i << 10 | r) ^ Wn; }; var on = {}; const Yn = Q; function ne(n) { this.mode = Yn.NUMERIC, this.data = n.toString(); } ne.getBitsLength = function(e) { return 10 * Math.floor(e / 3) + (e % 3 ? e % 3 * 3 + 1 : 0); }; ne.prototype.getLength = function() { return this.data.length; }; ne.prototype.getBitsLength = function() { return ne.getBitsLength(this.data.length); }; ne.prototype.write = function(e) { let t, i, r; for (t = 0; t + 3 <= this.data.length; t += 3) i = this.data.substr(t, 3), r = parseInt(i, 10), e.put(r, 10); const s = this.data.length - t; s > 0 && (i = this.data.substr(t), r = parseInt(i, 10), e.put(r, s * 3 + 1)); }; var Jn = ne; const Gn = Q, Qe = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", "$", "%", "*", "+", "-", ".", "/", ":" ]; function ie(n) { this.mode = Gn.ALPHANUMERIC, this.data = n; } ie.getBitsLength = function(e) { return 11 * Math.floor(e / 2) + 6 * (e % 2); }; ie.prototype.getLength = function() { return this.data.length; }; ie.prototype.getBitsLength = function() { return ie.getBitsLength(this.data.length); }; ie.prototype.write = function(e) { let t; for (t = 0; t + 2 <= this.data.length; t += 2) { let i = Qe.indexOf(this.data[t]) * 45; i += Qe.indexOf(this.data[t + 1]), e.put(i, 11); } this.data.length % 2 && e.put(Qe.indexOf(this.data[t]), 6); }; var jn = ie; const $n = Q; function re(n) { this.mode = $n.BYTE, typeof n == "string" ? this.data = new TextEncoder().encode(n) : this.data = new Uint8Array(n); } re.getBitsLength = function(e) { return e * 8; }; re.prototype.getLength = function() { return this.data.length; }; re.prototype.getBitsLength = function() { return re.getBitsLength(this.data.length); }; re.prototype.write = function(n) { for (let e = 0, t = this.data.length; e < t; e++) n.put(this.data[e], 8); }; var Qn = re; const Xn = Q, Zn = D; function se(n) { this.mode = Xn.KANJI, this.data = n; } se.getBitsLength = function(e) { return e * 13; }; se.prototype.getLength = function() { return this.data.length; }; se.prototype.getBitsLength = function() { return se.getBitsLength(this.data.length); }; se.prototype.write = function(n) { let e; for (e = 0; e < this.data.length; e++) { let t = Zn.toSJIS(this.data[e]); if (t >= 33088 && t <= 40956) t -= 33088; else if (t >= 57408 && t <= 60351) t -= 49472; else throw new Error( "Invalid SJIS character: " + this.data[e] + ` Make sure your charset is UTF-8` ); t = (t >>> 8 & 255) * 192 + (t & 255), n.put(t, 13); } }; var ei = se, an = { exports: {} }; (function(n) { var e = { single_source_shortest_paths: function(t, i, r) { var s = {}, o = {}; o[i] = 0; var a = e.PriorityQueue.make(); a.push(i, 0); for (var c, w, m, k, h, d, l, u, f; !a.empty(); ) { c = a.pop(), w = c.value, k = c.cost, h = t[w] || {}; for (m in h) h.hasOwnProperty(m) && (d = h[m], l = k + d, u = o[m], f = typeof o[m] > "u", (f || u > l) && (o[m] = l, a.push(m, l), s[m] = w)); } if (typeof r < "u" && typeof o[r] > "u") { var b = ["Could not find a path from ", i, " to ", r, "."].join(""); throw new Error(b); } return s; }, extract_shortest_path_from_predecessor_list: function(t, i) { for (var r = [], s = i; s; ) r.push(s), t[s], s = t[s]; return r.reverse(), r; }, find_path: function(t, i, r) { var s = e.single_source_shortest_paths(t, i, r); return e.extract_shortest_path_from_predecessor_list( s, r ); }, /** * A very naive priority queue implementation. */ PriorityQueue: { make: function(t) { var i = e.PriorityQueue, r = {}, s; t = t || {}; for (s in i) i.hasOwnProperty(s) && (r[s] = i[s]); return r.queue = [], r.sorter = t.sorter || i.default_sorter, r; }, default_sorter: function(t, i) { return t.cost - i.cost; }, /** * Add a new item to the queue and ensure the highest priority element * is at the front of the queue. */ push: function(t, i) { var r = { value: t, cost: i }; this.queue.push(r), this.queue.sort(this.sorter); }, /** * Return the highest priority element in the queue. */ pop: function() { return this.queue.shift(); }, empty: function() { return this.queue.length === 0; } } }; n.exports = e; })(an); var ti = an.exports; (function(n) { const e = Q, t = Jn, i = jn, r = Qn, s = ei, o = W, a = D, c = ti; function w(b) { return unescape(encodeURIComponent(b)).length; } function m(b, E, p) { const g = []; let v; for (; (v = b.exec(p)) !== null; ) g.push({ data: v[0], index: v.index, mode: E, length: v[0].length }); return g; } function k(b) { const E = m(o.NUMERIC, e.NUMERIC, b), p = m(o.ALPHANUMERIC, e.ALPHANUMERIC, b); let g, v; return a.isKanjiModeEnabled() ? (g = m(o.BYTE, e.BYTE, b), v = m(o.KANJI, e.KANJI, b)) : (g = m(o.BYTE_KANJI, e.BYTE, b), v = []), E.concat(p, g, v).sort(function(L, I) { return L.index - I.index; }).map(function(L) { return { data: L.data, mode: L.mode, length: L.length }; }); } function h(b, E) { switch (E) { case e.NUMERIC: return t.getBitsLength(b); case e.ALPHANUMERIC: return i.getBitsLength(b); case e.KANJI: return s.getBitsLength(b); case e.BYTE: return r.getBitsLength(b); } } function d(b) { return b.reduce(function(E, p) { const g = E.length - 1 >= 0 ? E[E.length - 1] : null; return g && g.mode === p.mode ? (E[E.length - 1].data += p.data, E) : (E.push(p), E); }, []); } function l(b) { const E = []; for (let p = 0; p < b.length; p++) { const g = b[p]; switch (g.mode) { case e.NUMERIC: E.push([ g, { data: g.data, mode: e.ALPHANUMERIC, length: g.length }, { data: g.data, mode: e.BYTE, length: g.length } ]); break; case e.ALPHANUMERIC: E.push([ g, { data: g.data, mode: e.BYTE, length: g.length } ]); break; case e.KANJI: E.push([ g, { data: g.data, mode: e.BYTE, length: w(g.data) } ]); break; case e.BYTE: E.push([ { data: g.data, mode: e.BYTE, length: w(g.data) } ]); } } return E; } function u(b, E) { const p = {}, g = { start: {} }; let v = ["start"]; for (let T = 0; T < b.length; T++) { const L = b[T], I = []; for (let x = 0; x < L.length; x++) { const M = L[x], J = "" + T + x; I.push(J), p[J] = { node: M, lastCount: 0 }, g[J] = {}; for (let X = 0; X < v.length; X++) { const P = v[X]; p[P] && p[P].node.mode === M.mode ? (g[P][J] = h(p[P].lastCount + M.length, M.mode) - h(p[P].lastCount, M.mode), p[P].lastCount += M.length) : (p[P] && (p[P].lastCount = M.length), g[P][J] = h(M.length, M.mode) + 4 + e.getCharCountIndicator(M.mode, E)); } } v = I; } for (let T = 0; T < v.length; T++) g[v[T]].end = 0; return { map: g, table: p }; } function f(b, E) { let p; const g = e.getBestModeForData(b); if (p = e.from(E, g), p !== e.BYTE && p.bit < g.bit) throw new Error('"' + b + '" cannot be encoded with mode ' + e.toString(p) + `. Suggested mode is: ` + e.toString(g)); switch (p === e.KANJI && !a.isKanjiModeEnabled() && (p = e.BYTE), p) { case e.NUMERIC: return new t(b); case e.ALPHANUMERIC: return new i(b); case e.KANJI: return new s(b); case e.BYTE: return new r(b); } } n.fromArray = function(E) { return E.reduce(function(p, g) { return typeof g == "string" ? p.push(f(g, null)) : g.data && p.push(f(g.data, g.mode)), p; }, []); }, n.fromString = function(E, p) { const g = k(E, a.isKanjiModeEnabled()), v = l(g), T = u(v, p), L = c.find_path(T.map, "start", "end"), I = []; for (let x = 1; x < L.length - 1; x++) I.push(T.table[L[x]].node); return n.fromArray(d(I)); }, n.rawSplit = function(E) { return n.fromArray( k(E, a.isKanjiModeEnabled()) ); }; })(on); const Ve = D, Xe = Ue, ni = xn, ii = Dn, ri = $t, si = Qt, at = Xt, ct = Fe, oi = Fn, Pe = tn, ai = rn, ci = Q, Ze = on; function hi(n, e) { const t = n.size, i = si.getPositions(e); for (let r = 0; r < i.length; r++) { const s = i[r][0], o = i[r][1]; for (let a = -1; a <= 7; a++) if (!(s + a <= -1 || t <= s + a)) for (let c = -1; c <= 7; c++) o + c <= -1 || t <= o + c || (a >= 0 && a <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (a === 0 || a === 6) || a >= 2 && a <= 4 && c >= 2 && c <= 4 ? n.set(s + a, o + c, !0, !0) : n.set(s + a, o + c, !1, !0)); } } function li(n) { const e = n.size; for (let t = 8; t < e - 8; t++) { const i = t % 2 === 0; n.set(t, 6, i, !0), n.set(6, t, i, !0); } } function ui(n, e) { const t = ri.getPositions(e); for (let i = 0; i < t.length; i++) { const r = t[i][0], s = t[i][1]; for (let o = -2; o <= 2; o++) for (let a = -2; a <= 2; a++) o === -2 || o === 2 || a === -2 || a === 2 || o === 0 && a === 0 ? n.set(r + o, s + a, !0, !0) : n.set(r + o, s + a, !1, !0); } } function di(n, e) { const t = n.size, i = Pe.getEncodedBits(e); let r, s, o; for (let a = 0; a < 18; a++) r = Math.floor(a / 3), s = a % 3 + t - 8 - 3, o = (i >> a & 1) === 1, n.set(r, s, o, !0), n.set(s, r, o, !0); } function et(n, e, t) { const i = n.size, r = ai.getEncodedBits(e, t); let s, o; for (s = 0; s < 15; s++) o = (r >> s & 1) === 1, s < 6 ? n.set(s, 8, o, !0) : s < 8 ? n.set(s + 1, 8, o, !0) : n.set(i - 15 + s, 8, o, !0), s < 8 ? n.set(8, i - s - 1, o, !0) : s < 9 ? n.set(8, 15 - s - 1 + 1, o, !0) : n.set(8, 15 - s - 1, o, !0); n.set(i - 8, 8, 1, !0); } function fi(n, e) { const t = n.size; let i = -1, r = t - 1, s = 7, o = 0; for (let a = t - 1; a > 0; a -= 2) for (a === 6 && a--; ; ) { for (let c = 0; c < 2; c++) if (!n.isReserved(r, a - c)) { let w = !1; o < e.length && (w = (e[o] >>> s & 1) === 1), n.set(r, a - c, w), s--, s === -1 && (o++, s = 7); } if (r += i, r < 0 || t <= r) { r -= i, i = -i; break; } } } function pi(n, e, t) { const i = new ni(); t.forEach(function(c) { i.put(c.mode.bit, 4), i.put(c.getLength(), ci.getCharCountIndicator(c.mode, n)), c.write(i); }); const r = Ve.getSymbolTotalCodewords(n), s = ct.getTotalCodewordsCount(n, e), o = (r - s) * 8; for (i.getLengthInBits() + 4 <= o && i.put(0, 4); i.getLengthInBits() % 8 !== 0; ) i.putBit(0); const a = (o - i.getLengthInBits()) / 8; for (let c = 0; c < a; c++) i.put(c % 2 ? 17 : 236, 8); return gi(i, n, e); } function gi(n, e, t) { const i = Ve.getSymbolTotalCodewords(e), r = ct.getTotalCodewordsCount(e, t), s = i - r, o = ct.getBlocksCount(e, t), a = i % o, c = o - a, w = Math.floor(i / o), m = Math.floor(s / o), k = m + 1, h = w - m, d = new oi(h); let l = 0; const u = new Array(o), f = new Array(o); let b = 0; const E = new Uint8Array(n.buffer); for (let L = 0; L < o; L++) { const I = L < c ? m : k; u[L] = E.slice(l, l + I), f[L] = d.encode(u[L]), l += I, b = Math.max(b, I); } const p = new Uint8Array(i); let g = 0, v, T; for (v = 0; v < b; v++) for (T = 0; T < o; T++) v < u[T].length && (p[g++] = u[T][v]); for (v = 0; v < h; v++) for (T = 0; T < o; T++) p[g++] = f[T][v]; return p; } function mi(n, e, t, i) { let r; if (Array.isArray(n)) r = Ze.fromArray(n); else if (typeof n == "string") { let w = e; if (!w) { const m = Ze.rawSplit(n); w = Pe.getBestVersionForData(m, t); } r = Ze.fromString(n, w || 40); } else throw new Error("Invalid data"); const s = Pe.getBestVersionForData(r, t); if (!s) throw new Error("The amount of data is too big to be stored in a QR Code"); if (!e) e = s; else if (e < s) throw new Error( ` The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: ` + s + `. ` ); const o = pi(e, t, r), a = Ve.getSymbolSize(e), c = new ii(a); return hi(c, e), li(c), ui(c, e), et(c, t, 0), e >= 7 && di(c, e), fi(c, o), isNaN(i) && (i = at.getBestMask( c, et.bind(null, c, t) )), at.applyMask(i, c), et(c, t, i), { modules: c, version: e, errorCorrectionLevel: t, maskPattern: i, segments: r }; } Gt.create = function(e, t) { if (typeof e > "u" || e === "") throw new Error("No input text"); let i = Xe.M, r, s; return typeof t < "u" && (i = Xe.from(t.errorCorrectionLevel, Xe.M), r = Pe.from(t.version), s = at.from(t.maskPattern), t.toSJISFunc && Ve.setToSJISFunction(t.toSJISFunc)), mi(e, r, i, s); }; var cn = {}, _t = {}; (function(n) { function e(t) { if (typeof t == "number" && (t = t.toString()), typeof t != "string") throw new Error("Color should be defined as hex string"); let i = t.slice().replace("#", "").split(""); if (i.length < 3 || i.length === 5 || i.length > 8) throw new Error("Invalid hex color: " + t); (i.length === 3 || i.length === 4) && (i = Array.prototype.concat.apply([], i.map(function(s) { return [s, s]; }))), i.length === 6 && i.push("F", "F"); const r = parseInt(i.join(""), 16); return { r: r >> 24 & 255, g: r >> 16 & 255, b: r >> 8 & 255, a: r & 255, hex: "#" + i.slice(0, 6).join("") }; } n.getOptions = function(i) { i || (i = {}), i.color || (i.color = {}); const r = typeof i.margin > "u" || i.margin === null || i.margin < 0 ? 4 : i.margin, s = i.width && i.width >= 21 ? i.width : void 0, o = i.scale || 4; return { width: s, scale: s ? 4 : o, margin: r, color: { dark: e(i.color.dark || "#000000ff"), light: e(i.color.light || "#ffffffff") }, type: i.type, rendererOpts: i.rendererOpts || {} }; }, n.getScale = function(i, r) { return r.width && r.width >= i + r.margin * 2 ? r.width / (i + r.margin * 2) : r.scale; }, n.getImageWidth = function(i, r) { const s = n.getScale(i, r); return Math.floor((i + r.margin * 2) * s); }, n.qrToImageData = function(i, r, s) { const o = r.modules.size, a = r.modules.data, c = n.getScale(o, s), w = Math.floor((o + s.margin * 2) * c), m = s.margin * c, k = [s.color.light, s.color.dark]; for (let h = 0; h < w; h++) for (let d = 0; d < w; d++) { let l = (h * w + d) * 4, u = s.color.light; if (h >= m && d >= m && h < w - m && d < w - m) { const f = Math.floor((h - m) / c), b = Math.floor((d - m) / c); u = k[a[f * o + b] ? 1 : 0]; } i[l++] = u.r, i[l++] = u.g, i[l++] = u.b, i[l] = u.a; } }; })(_t); (function(n) { const e = _t; function t(r, s, o) { r.clearRect(0, 0, s.width, s.height), s.style || (s.style = {}), s.height = o, s.width = o, s.style.height = o + "px", s.style.width = o + "px"; } function i() { try { return document.createElement("canvas"); } catch { throw new Error("You need to specify a canvas element"); } } n.render = function(s, o, a) { let c = a, w = o; typeof c > "u" && (!o || !o.getContext) && (c = o, o = void 0), o || (w = i()), c = e.getOptions(c); const m = e.getImageWidth(s.modules.size, c), k = w.getContext("2d"), h = k.createImageData(m, m); return e.qrToImageData(h.data, s, c), t(k, w, m), k.putImageData(h, 0, 0), w; }, n.renderToDataURL = function(s, o, a) { let c = a; typeof c > "u" && (!o || !o.getContext) && (c = o, o = void 0), c || (c = {}); const w = n.render(s, o, c), m = c.type || "image/png", k = c.rendererOpts || {}; return w.toDataURL(m, k.quality); }; })(cn); var hn = {}; const wi = _t; function qt(n, e) { const t = n.a / 255, i = e + '="' + n.hex + '"'; return t < 1 ? i + " " + e + '-opacity="' + t.toFixed(2).slice(1) + '"' : i; } function tt(n, e, t) { let i = n + e; return typeof t < "u" && (i += " " + t), i; } function bi(n, e, t) { let i = "", r = 0, s = !1, o = 0; for (let a = 0; a < n.length; a++) { const c = Math.floor(a % e), w = Math.floor(a / e); !c && !s && (s = !0), n[a] ? (o++, a > 0 && c > 0 && n[a - 1] || (i += s ? tt("M", c + t, 0.5 + w + t) : tt("m", r, 0), r = 0, s = !1), c + 1 < e && n[a + 1] || (i += tt("h", o), o = 0)) : r++; } return i; } hn.render = function(e, t, i) { const r = wi.getOptions(t), s = e.modules.size, o = e.modules.data, a = s + r.margin * 2, c = r.color.light.a ? "<path " + qt(r.color.light, "fill") + ' d="M0 0h' + a + "v" + a + 'H0z"/>' : "", w = "<path " + qt(r.color.dark, "stroke") + ' d="' + bi(o, s, r.margin) + '"/>', m = 'viewBox="0 0 ' + a + " " + a + '"', h = '<svg xmlns="http://www.w3.org/2000/svg" ' + (r.width ? 'width="' + r.width + '" height="' + r.width + '" ' : "") + m + ' shape-rendering="crispEdges">' + c + w + `</svg> `; return typeof i == "function" && i(null, h), h; }; const yi = In, ht = Gt, ln = cn, _i = hn; function Et(n, e, t, i, r) { const s = [].slice.call(arguments, 1), o = s.length, a = typeof s[o - 1] == "function"; if (!a && !yi()) throw new Error("Callback required as last argument"); if (a) { if (o < 2) throw new Error("Too few arguments provided"); o === 2 ? (r = t, t = e, e = i = void 0) : o === 3 && (e.getContext && typeof r > "u" ? (r = i, i = void 0) : (r = i, i = t, t = e, e = void 0)); } else { if (o < 1) throw new Error("Too few arguments provided"); return o === 1 ? (t = e, e = i = void 0) : o === 2 && !e.getContext && (i = t, t = e, e = void 0), new Promise(function(c, w) { try { const m = ht.create(t, i); c(n(m, e, i)); } catch (m) { w(m); } }); } try { const c = ht.create(t, i); r(null, n(c, e, i)); } catch (c) { r(c); } } we.create = ht.create; we.toCanvas = Et.bind(null, ln.render); we.toDataURL = Et.bind(null, ln.renderToDataURL); we.toString = Et.bind(null, function(n, e, t) { return _i.render(n, t); }); var de = /* @__PURE__ */ ((n) => (n.AllOthersDisconnected = "allOthersDisconnected", n.Capture = "capture", n.Configuration = "configuration", n.RemoteScanStarted = "remoteScanStarted", n.AllOthersReconnected = "allOthersReconnected", n))(de || {}); const H = /* @__PURE__ */ Object.create(null); H.open = "0"; H.close = "1"; H.ping = "2"; H.pong = "3"; H.message = "4"; H.upgrade = "5"; H.noop = "6"; const Be = /* @__PURE__ */ Object.create(null); Object.keys(H).forEach((n) => { Be[H[n]] = n; }); const lt = { type: "error", data: "parser error" }, un = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", dn = typeof ArrayBuffer == "function", fn = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, vt = ({ type: n, data: e }, t, i) => un && e instanceof Blob ? t ? i(e) : Vt(e, i) : dn && (e instanceof ArrayBuffer || fn(e)) ? t ? i(e) : Vt(new Blob([e]), i) : i(H[n] + (e || "")), Vt = (n, e) => { const t = new FileReader(); return t.onload = function() { const i = t.result.split(",")[1]; e("b" + (i || "")); }, t.readAsDataURL(n); }; function zt(n) { return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength); } let nt; function Ei(n, e) { if (un && n.data instanceof Blob) return n.data.arrayBuffer().then(zt).then(e); if (dn && (n.data instanceof ArrayBuffer || fn(n.data))) return e(zt(n.data)); vt(n, !1, (t) => { nt || (nt = new TextEncoder()), e(nt.encode(t)); }); } const Kt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", fe = typeof Uint8Array > "u" ? [] : new Uint8Array(256); for (let n = 0; n < Kt.length; n++) fe[Kt.charCodeAt(n)] = n; const vi = (n) => { let e = n.length * 0.75, t = n.length, i, r = 0, s, o, a, c; n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--); const w = new ArrayBuffer(e), m = new Uint8Array(w); for (i = 0; i < t; i += 4) s = fe[n.charCodeAt(i)], o = fe[n.charCodeAt(i + 1)], a = fe[n.charCodeAt(i + 2)], c = fe[n.charCodeAt(i + 3)], m[r++] = s << 2 | o >> 4, m[r++] = (o & 15) << 4 | a >> 2, m[r++] = (a & 3) << 6 | c & 63; return w; }, Ci = typeof ArrayBuffer == "function", Ct = (n, e) => { if (typeof n != "string") return { type: "message", data: pn(n, e) }; const t = n.charAt(0); return t === "b" ? { type: "message", data: ki(n.substring(1), e) } : Be[t] ? n.length > 1 ? { type: Be[t], data: n.substring(1) } : { type: Be[t] } : lt; }, ki = (n, e) => { if (Ci) { const t = vi(n); return pn(t, e); } else return { base64: !0, data: n }; }, pn = (n, e) => { switch (e) { case "blob": return n instanceof Blob ? n : new Blob([n]); case "arraybuffer": default: return n instanceof ArrayBuffer ? n : n.buffer; } }, gn = "", Ai = (n, e) => { const t = n.length, i = new Array(t); let r = 0; n.forEach((s, o) => { vt(s, !1, (a) => { i[o] = a, ++r === t && e(i.join(gn)); }); }); }, Ti = (n, e) => { const t = n.split(gn), i = []; for (let r = 0; r < t.length; r++) { const s = Ct(t[r], e); if (i.push(s), s.type === "error") break; } return i; }; function Si() { return new TransformStream({ transform(n, e) { Ei(n, (t) => { const i = t.length; let r; if (i < 126) r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, i); else if (i < 65536) { r = new Uint8Array(3); const s = new DataView(r.buffer); s.setUint8(0, 126), s.setUint16(1, i); } else { r = new Uint8Array(9); const s = new DataView(r.buffer); s.setUint8(0, 127), s.setBigUint64(1, BigInt(i)); } n.data && typeof n.data != "string" && (r[0] |= 128), e.enqueue(r), e.enqueue(t); }); } }); } let it; function Se(n) { return n.reduce((e, t) => e + t.length, 0); } function Re(n, e) { if (n[0].length === e) return n.shift(); const t = new Uint8Array(e); let i = 0; for (let r = 0; r < e; r++) t[r] = n[0][i++], i === n[0].length && (n.shift(), i = 0); return n.length && i < n[0].length && (n[0] = n[0].slice(i)), t; } function Ri(n, e) { it || (it = new TextDecoder()); const t = []; let i = 0, r = -1, s = !1; return new TransformStream({ transform(o, a) { for (t.push(o); ; ) { if (i === 0) { if (Se(t) < 1) break; const c = Re(t, 1); s = (c[0] & 128) === 128, r = c[0] & 127, r < 126 ? i = 3 : r === 126 ? i = 1 : i = 2; } else if (i === 1) { if (Se(t) < 2) break; const c = Re(t, 2); r = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), i = 3; } else if (i === 2) { if (Se(t) < 8) break; const c = Re(t, 8), w = new DataView(c.buffer, c.byteOffset, c.length), m = w.getUint32(0); if (m > Math.pow(2, 21) - 1) { a.enqueue(lt); break; } r = m * Math.pow(2, 32) + w.getUint32(4), i = 3; } else { if (Se(t) < r) break; const c = Re(t, r); a.enqueue(Ct(s ? c : it.decode(c), e)), i = 0; } if (r === 0 || r > n) { a.enqueue(lt); break; } } } }); } const mn = 4; function O(n) { if (n) return Bi(n); } function Bi(n) { for (var e in O.prototype) n[e] = O.prototype[e]; return n; } O.prototype.on = O.prototype.addEventListener = function(n, e) { return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this; }; O.prototype.once = function(n, e) { function t() { this.off(n, t), e.apply(this, arguments); } return t.fn = e, this.on(n, t), this; }; O.prototype.off = O.prototype.removeListener = O.prototype.removeAllListeners = O.prototype.removeEventListener = function(n, e) { if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this; var t = this._callbacks["$" + n]; if (!t) return this; if (arguments.length == 1) return delete this._callbacks["$" + n], this; for (var i, r = 0; r < t.length; r++) if (i = t[r], i === e || i.fn === e) { t.splice(r, 1); break; } return t.length === 0 && delete this._callbacks["$" + n], this; }; O.prototype.emit = function(n) { this._callbacks = this._callbacks || {}; for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], i = 1; i < arguments.length; i++) e[i - 1] = arguments[i]; if (t) { t = t.slice(0); for (var i = 0, r = t.length; i < r; ++i) t[i].apply(this, e); } return this; }; O.prototype.emitReserved = O.prototype.emit; O.prototype.listeners = function(n) { return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || []; }; O.prototype.hasListeners = function(n) { return !!this.listeners(n).length; }; const ze = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), U = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ni = "arraybuffer"; function wn(n, ...e) { return e.reduce((t, i) => (n.hasOwnProperty(i) && (t[i] = n[i]), t), {}); } const Li = U.setTimeout, Oi = U.clearTimeout; function Ke(n, e) { e.useNativeTimers ? (n.setTimeoutFn = Li.bind(U), n.clearTimeoutFn = Oi.bind(U)) : (n.setTimeoutFn = U.setTimeout.bind(U), n.clearTimeoutFn = U.clearTimeout.bind(U)); } const Mi = 1.33; function Ii(n) { return typeof n == "string" ? Pi(n) : Math.ceil((n.byteLength || n.size) * Mi); } function Pi(n) { let e = 0, t = 0; for (let i = 0, r = n.length; i < r; i++) e = n.charCodeAt(i), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (i++, t += 4); return t; } function bn() { return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5); } function xi(n) { let e = ""; for (let t in n) n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t])); return e; } function Di(n) { let e = {}, t = n.split("&"); for (let i = 0, r = t.length; i < r; i++) { let s = t[i].split("="); e[decodeURIComponent(s[0])] = decodeURIComponent(s[1]); } return e; } class Ui extends Error { constructor(e, t, i) { super(e), this.description = t, this.context = i, this.type = "TransportError"; } } class kt extends O { /** * Transport abstract constructor. * * @param {Object} opts - options * @protected */ constructor(e) { super(), this.writable = !1, Ke(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64; } /** * Emits an error. * * @param {String} reason * @param description * @param context - the error context * @return {Transport} for chaining * @protected */ onError(e, t, i) { return super.emitReserved("error", new Ui(e, t, i)), this; } /** * Opens the transport. */ open() { return this.readyState = "opening", this.doOpen(), this; } /** * Closes the transport. */ close() { return (this.readyState === "opening" || this.readyState === "open") && (this.doClose(), this.onClose()), this; } /** * Sends multiple packets. * * @param {Array} packets */ send(e) { this.readyState === "open" && this.write(e); } /** * Called upon open * * @protected */ onOpen() { this.readyState = "open", this.writable = !0, super.emitReserved("open"); } /** * Called with data. * * @param {String} data * @protected */ onData(e) { const t = Ct(e, this.socket.binaryType); this.onPacket(t); } /** * Called with a decoded packet. * * @protected */ onPacket(e) { super.emitReserved("packet", e); } /** * Called upon close. * * @protected */ onClose(e) { this.readyState = "closed", super.emitReserved("close", e); } /** * Pauses the transport, in order not to lose packets during an upgrade. * * @param onPause */ pause(e) { } createUri(e, t = {}) { return e + "://" + this._hostname() + this._port() + this.opts.path + this._query