@ifc-lite/pointcloud 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// The matching source file at src/streaming/inline-worker.ts exports
|
|
3
3
|
// `null` so workspace dev falls back to the new-URL spawn path; this
|
|
4
4
|
// dist override is what published consumers see.
|
|
5
|
-
export const INLINE_WORKER_CODE = "\"use strict\";\n(() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\n var __require = /* @__PURE__ */ ((x) => typeof require !== \"undefined\" ? require : typeof Proxy !== \"undefined\" ? new Proxy(x, {\n get: (a, b) => (typeof require !== \"undefined\" ? require : a)[b]\n }) : x)(function(x) {\n if (typeof require !== \"undefined\") return require.apply(this, arguments);\n throw Error('Dynamic require of \"' + x + '\" is not supported');\n });\n var __esm = (fn, res) => function __init() {\n return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;\n };\n var __commonJS = (cb, mod) => function __require2() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n\n // dist/formats/las.js\n function parseLasHeader(buffer) {\n const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);\n if (bytes.length < 227) {\n throw new Error(\"LAS: header truncated\");\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (view.getUint32(0, true) !== MAGIC) {\n throw new Error('LAS: bad magic \\u2014 expected \"LASF\"');\n }\n const versionMajor = view.getUint8(24);\n const versionMinor = view.getUint8(25);\n const headerSize = view.getUint16(94, true);\n const pointDataOffset = view.getUint32(96, true);\n const numberOfVlrs = view.getUint32(100, true);\n const pointDataFormatId = view.getUint8(104) & 63;\n const pointRecordLength = view.getUint16(105, true);\n const legacyCount = view.getUint32(107, true);\n let pointCount = legacyCount;\n if (versionMajor >= 1 && versionMinor >= 4 && bytes.length >= 255) {\n const fullCount = readU64LE(view, 247);\n if (fullCount > 0)\n pointCount = fullCount;\n }\n if (!Number.isFinite(pointCount) || pointCount < 0) {\n throw new Error(\"LAS: invalid point count\");\n }\n const scale = [\n view.getFloat64(131, true),\n view.getFloat64(139, true),\n view.getFloat64(147, true)\n ];\n const offset = [\n view.getFloat64(155, true),\n view.getFloat64(163, true),\n view.getFloat64(171, true)\n ];\n const maxX = view.getFloat64(179, true);\n const minX = view.getFloat64(187, true);\n const maxY = view.getFloat64(195, true);\n const minY = view.getFloat64(203, true);\n const maxZ = view.getFloat64(211, true);\n const minZ = view.getFloat64(219, true);\n const bbox = {\n min: [minX, minY, minZ],\n max: [maxX, maxY, maxZ]\n };\n if (BASE_RECORD_SIZE[pointDataFormatId] === void 0) {\n throw new Error(`LAS: unsupported point data format ${pointDataFormatId}`);\n }\n const baseSize = BASE_RECORD_SIZE[pointDataFormatId];\n if (pointRecordLength < baseSize) {\n throw new Error(`LAS: header point-record length (${pointRecordLength}) smaller than format ${pointDataFormatId} baseline (${baseSize})`);\n }\n return {\n versionMajor,\n versionMinor,\n headerSize,\n pointDataOffset,\n numberOfVlrs,\n pointDataFormatId,\n pointRecordLength,\n pointCount,\n scale,\n offset,\n bbox,\n hasGpsTime: HAS_GPS.has(pointDataFormatId),\n hasRgb: HAS_RGB.has(pointDataFormatId)\n };\n }\n function decodeLasPoints(bytes, header, count, stride = header.pointRecordLength, rgbScale = 1) {\n if (bytes.length < count * stride) {\n throw new Error(`LAS: decode expects ${count * stride} bytes, got ${bytes.length}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const positions = new Float32Array(count * 3);\n const intensities = new Uint16Array(count);\n const classifications = new Uint8Array(count);\n const colors = header.hasRgb ? new Float32Array(count * 3) : void 0;\n const rgbOffset = rgbOffsetForFormat(header.pointDataFormatId);\n const classOffset = header.pointDataFormatId >= 6 ? 16 : 15;\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i < count; i++) {\n const base = i * stride;\n const x = view.getInt32(base, true) * header.scale[0] + header.offset[0];\n const y = view.getInt32(base + 4, true) * header.scale[1] + header.offset[1];\n const z = view.getInt32(base + 8, true) * header.scale[2] + header.offset[2];\n positions[i * 3] = x;\n positions[i * 3 + 1] = y;\n positions[i * 3 + 2] = z;\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n intensities[i] = view.getUint16(base + 12, true);\n classifications[i] = header.pointDataFormatId >= 6 ? view.getUint8(base + classOffset) : view.getUint8(base + classOffset) & 31;\n if (colors && rgbOffset >= 0) {\n const r = view.getUint16(base + rgbOffset, true);\n const g = view.getUint16(base + rgbOffset + 2, true);\n const b = view.getUint16(base + rgbOffset + 4, true);\n colors[i * 3] = r * rgbScale / 65535;\n colors[i * 3 + 1] = g * rgbScale / 65535;\n colors[i * 3 + 2] = b * rgbScale / 65535;\n }\n }\n return {\n positions,\n colors,\n classifications,\n intensities,\n pointCount: count,\n bbox: { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] }\n };\n }\n function sampleMaxRgbChannel(bytes, header, samples = 1024) {\n if (!header.hasRgb)\n return 0;\n const stride = header.pointRecordLength;\n const total = Math.min(header.pointCount, Math.floor(bytes.length / stride));\n if (total === 0)\n return 0;\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const rgbOff = rgbOffsetForFormat(header.pointDataFormatId);\n if (rgbOff < 0)\n return 0;\n const step = Math.max(1, Math.floor(total / Math.min(samples, total)));\n let max = 0;\n for (let i = 0; i < total; i += step) {\n const base = i * stride;\n const r = view.getUint16(base + rgbOff, true);\n const g = view.getUint16(base + rgbOff + 2, true);\n const b = view.getUint16(base + rgbOff + 4, true);\n if (r > max)\n max = r;\n if (g > max)\n max = g;\n if (b > max)\n max = b;\n }\n return max;\n }\n function rgbOffsetForFormat(format) {\n switch (format) {\n case 2:\n return 20;\n case 3:\n return 28;\n case 5:\n return 28;\n case 7:\n return 30;\n case 8:\n return 30;\n case 10:\n return 30;\n default:\n return -1;\n }\n }\n function readU64LE(view, offset) {\n const lo = view.getUint32(offset, true);\n const hi = view.getUint32(offset + 4, true);\n return hi * 4294967296 + lo;\n }\n var MAGIC, BASE_RECORD_SIZE, HAS_GPS, HAS_RGB;\n var init_las = __esm({\n \"dist/formats/las.js\"() {\n \"use strict\";\n MAGIC = 1179861324;\n BASE_RECORD_SIZE = {\n 0: 20,\n 1: 28,\n 2: 26,\n 3: 34,\n 4: 57,\n 5: 63,\n 6: 30,\n 7: 36,\n 8: 38,\n 9: 59,\n 10: 67\n };\n HAS_GPS = /* @__PURE__ */ new Set([1, 3, 4, 5, 6, 7, 8, 9, 10]);\n HAS_RGB = /* @__PURE__ */ new Set([2, 3, 5, 7, 8, 10]);\n }\n });\n\n // dist/streaming/blob-source.js\n var BlobByteSource;\n var init_blob_source = __esm({\n \"dist/streaming/blob-source.js\"() {\n \"use strict\";\n BlobByteSource = class {\n constructor(blob) {\n __publicField(this, \"blob\");\n this.blob = blob;\n }\n get size() {\n return this.blob.size;\n }\n async read(start, end) {\n const safeStart = Math.max(0, start);\n const safeEnd = Math.min(end, this.blob.size);\n if (safeEnd <= safeStart)\n return new Uint8Array(0);\n const slice = this.blob.slice(safeStart, safeEnd);\n const buf = await slice.arrayBuffer();\n return new Uint8Array(buf);\n }\n };\n }\n });\n\n // dist/streaming/las-source.js\n var las_source_exports = {};\n __export(las_source_exports, {\n LasStreamingSource: () => LasStreamingSource\n });\n function abortIfAborted(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var HEADER_PROBE_BYTES, RGB_PROBE_RECORDS, LasStreamingSource;\n var init_las_source = __esm({\n \"dist/streaming/las-source.js\"() {\n \"use strict\";\n init_las();\n init_blob_source();\n HEADER_PROBE_BYTES = 1024;\n RGB_PROBE_RECORDS = 4096;\n LasStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"bytes\");\n __publicField(this, \"header\", null);\n __publicField(this, \"cursor\", 0);\n // index of NEXT point to emit (0..header.pointCount)\n __publicField(this, \"rgbScale\", 1);\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n this.bytes = new BlobByteSource(blob);\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n if (this.header) {\n return this.toInfo(this.header);\n }\n abortIfAborted(signal);\n const headerBytes = await this.bytes.read(0, HEADER_PROBE_BYTES);\n abortIfAborted(signal);\n const header = parseLasHeader(headerBytes);\n let rgbScale = 1;\n if (header.hasRgb) {\n const probeSize = Math.min(RGB_PROBE_RECORDS * header.pointRecordLength, Math.max(0, this.bytes.size - header.pointDataOffset));\n if (probeSize > 0) {\n const probe = await this.bytes.read(header.pointDataOffset, header.pointDataOffset + probeSize);\n abortIfAborted(signal);\n const max = sampleMaxRgbChannel(probe, header);\n rgbScale = max > 0 && max <= 255 ? 65535 / 255 : 1;\n }\n }\n this.header = header;\n this.rgbScale = rgbScale;\n this.cursor = 0;\n return this.toInfo(header);\n }\n async next(maxPoints, signal) {\n abortIfAborted(signal);\n if (!Number.isFinite(maxPoints) || maxPoints <= 0) {\n throw new Error(`LasStreamingSource: maxPoints must be > 0 (got ${maxPoints})`);\n }\n if (!this.header) {\n throw new Error(\"LasStreamingSource: open() must be awaited before next()\");\n }\n const stride = Math.max(1, this.downsample.stride | 0);\n if (this.cursor >= this.header.pointCount)\n return null;\n if (stride === 1) {\n const remaining = this.header.pointCount - this.cursor;\n const take = Math.min(maxPoints, remaining);\n const startByte2 = this.header.pointDataOffset + this.cursor * this.header.pointRecordLength;\n const endByte2 = startByte2 + take * this.header.pointRecordLength;\n const slab2 = await this.bytes.read(startByte2, endByte2);\n abortIfAborted(signal);\n const chunk2 = decodeLasPoints(slab2, this.header, take, this.header.pointRecordLength, this.rgbScale);\n this.cursor += take;\n return chunk2;\n }\n const remainingSource = this.header.pointCount - this.cursor;\n const sourceTake = Math.min(maxPoints * stride, remainingSource);\n const decodedCount = Math.ceil(sourceTake / stride);\n const startByte = this.header.pointDataOffset + this.cursor * this.header.pointRecordLength;\n const endByte = startByte + sourceTake * this.header.pointRecordLength;\n const slab = await this.bytes.read(startByte, endByte);\n abortIfAborted(signal);\n const compact = new Uint8Array(decodedCount * this.header.pointRecordLength);\n let writeOff = 0;\n for (let i = 0; i < decodedCount; i++) {\n const srcOff = i * stride * this.header.pointRecordLength;\n compact.set(slab.subarray(srcOff, srcOff + this.header.pointRecordLength), writeOff);\n writeOff += this.header.pointRecordLength;\n }\n const chunk = decodeLasPoints(compact, this.header, decodedCount, this.header.pointRecordLength, this.rgbScale);\n this.cursor += sourceTake;\n return chunk;\n }\n close() {\n this.header = null;\n this.cursor = 0;\n }\n toInfo(header) {\n const stride = Math.max(1, this.downsample.stride | 0);\n return {\n totalPointCount: stride === 1 ? header.pointCount : Math.ceil(header.pointCount / stride),\n bbox: header.bbox,\n hasColor: header.hasRgb,\n hasClassification: true,\n hasIntensity: true,\n label: this.label\n };\n }\n };\n }\n });\n\n // ../../node_modules/.pnpm/laz-perf@0.0.6/node_modules/laz-perf/lib/web/laz-perf.js\n var require_laz_perf = __commonJS({\n \"../../node_modules/.pnpm/laz-perf@0.0.6/node_modules/laz-perf/lib/web/laz-perf.js\"(exports, module) {\n var createLazPerf = (() => {\n var _scriptDir = typeof document !== \"undefined\" && document.currentScript ? document.currentScript.src : void 0;\n return function(createLazPerf2) {\n createLazPerf2 = createLazPerf2 || {};\n var Module = typeof createLazPerf2 != \"undefined\" ? createLazPerf2 : {};\n var readyPromiseResolve, readyPromiseReject;\n Module[\"ready\"] = new Promise(function(resolve, reject) {\n readyPromiseResolve = resolve;\n readyPromiseReject = reject;\n });\n [\"_main\", \"___getTypeName\", \"__embind_initialize_bindings\", \"_fflush\", \"onRuntimeInitialized\"].forEach((prop) => {\n if (!Object.getOwnPropertyDescriptor(Module[\"ready\"], prop)) {\n Object.defineProperty(Module[\"ready\"], prop, { get: () => abort(\"You are getting \" + prop + \" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js\"), set: () => abort(\"You are setting \" + prop + \" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js\") });\n }\n });\n var moduleOverrides = Object.assign({}, Module);\n var arguments_ = [];\n var thisProgram = \"./this.program\";\n var quit_ = (status, toThrow) => {\n throw toThrow;\n };\n var ENVIRONMENT_IS_WEB = true;\n var ENVIRONMENT_IS_WORKER = false;\n var ENVIRONMENT_IS_NODE = false;\n var ENVIRONMENT_IS_SHELL = false;\n if (Module[\"ENVIRONMENT\"]) {\n throw new Error(\"Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)\");\n }\n var scriptDirectory = \"\";\n function locateFile(path) {\n if (Module[\"locateFile\"]) {\n return Module[\"locateFile\"](path, scriptDirectory);\n }\n return scriptDirectory + path;\n }\n var read_, readAsync, readBinary, setWindowTitle;\n function logExceptionOnExit(e) {\n if (e instanceof ExitStatus) return;\n let toLog = e;\n if (e && typeof e == \"object\" && e.stack) {\n toLog = [e, e.stack];\n }\n err(\"exiting due to exception: \" + toLog);\n }\n if (ENVIRONMENT_IS_SHELL) {\n if (typeof process == \"object\" && typeof __require === \"function\" || typeof window == \"object\" || typeof importScripts == \"function\") throw new Error(\"not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)\");\n if (typeof read != \"undefined\") {\n read_ = function shell_read(f) {\n return read(f);\n };\n }\n readBinary = function readBinary2(f) {\n let data;\n if (typeof readbuffer == \"function\") {\n return new Uint8Array(readbuffer(f));\n }\n data = read(f, \"binary\");\n assert(typeof data == \"object\");\n return data;\n };\n readAsync = function readAsync2(f, onload, onerror) {\n setTimeout(() => onload(readBinary(f)), 0);\n };\n if (typeof scriptArgs != \"undefined\") {\n arguments_ = scriptArgs;\n } else if (typeof arguments != \"undefined\") {\n arguments_ = arguments;\n }\n if (typeof quit == \"function\") {\n quit_ = (status, toThrow) => {\n logExceptionOnExit(toThrow);\n quit(status);\n };\n }\n if (typeof print != \"undefined\") {\n if (typeof console == \"undefined\") console = {};\n console.log = print;\n console.warn = console.error = typeof printErr != \"undefined\" ? printErr : print;\n }\n } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {\n if (ENVIRONMENT_IS_WORKER) {\n scriptDirectory = self.location.href;\n } else if (typeof document != \"undefined\" && document.currentScript) {\n scriptDirectory = document.currentScript.src;\n }\n if (_scriptDir) {\n scriptDirectory = _scriptDir;\n }\n if (scriptDirectory.indexOf(\"blob:\") !== 0) {\n scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, \"\").lastIndexOf(\"/\") + 1);\n } else {\n scriptDirectory = \"\";\n }\n if (!(typeof window == \"object\" || typeof importScripts == \"function\")) throw new Error(\"not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)\");\n {\n read_ = (url) => {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, false);\n xhr.send(null);\n return xhr.responseText;\n };\n if (ENVIRONMENT_IS_WORKER) {\n readBinary = (url) => {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, false);\n xhr.responseType = \"arraybuffer\";\n xhr.send(null);\n return new Uint8Array(xhr.response);\n };\n }\n readAsync = (url, onload, onerror) => {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, true);\n xhr.responseType = \"arraybuffer\";\n xhr.onload = () => {\n if (xhr.status == 200 || xhr.status == 0 && xhr.response) {\n onload(xhr.response);\n return;\n }\n onerror();\n };\n xhr.onerror = onerror;\n xhr.send(null);\n };\n }\n setWindowTitle = (title) => document.title = title;\n } else {\n throw new Error(\"environment detection error\");\n }\n var out = Module[\"print\"] || console.log.bind(console);\n var err = Module[\"printErr\"] || console.warn.bind(console);\n Object.assign(Module, moduleOverrides);\n moduleOverrides = null;\n checkIncomingModuleAPI();\n if (Module[\"arguments\"]) arguments_ = Module[\"arguments\"];\n legacyModuleProp(\"arguments\", \"arguments_\");\n if (Module[\"thisProgram\"]) thisProgram = Module[\"thisProgram\"];\n legacyModuleProp(\"thisProgram\", \"thisProgram\");\n if (Module[\"quit\"]) quit_ = Module[\"quit\"];\n legacyModuleProp(\"quit\", \"quit_\");\n assert(typeof Module[\"memoryInitializerPrefixURL\"] == \"undefined\", \"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"pthreadMainPrefixURL\"] == \"undefined\", \"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"cdInitializerPrefixURL\"] == \"undefined\", \"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"filePackagePrefixURL\"] == \"undefined\", \"Module.filePackagePrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"read\"] == \"undefined\", \"Module.read option was removed (modify read_ in JS)\");\n assert(typeof Module[\"readAsync\"] == \"undefined\", \"Module.readAsync option was removed (modify readAsync in JS)\");\n assert(typeof Module[\"readBinary\"] == \"undefined\", \"Module.readBinary option was removed (modify readBinary in JS)\");\n assert(typeof Module[\"setWindowTitle\"] == \"undefined\", \"Module.setWindowTitle option was removed (modify setWindowTitle in JS)\");\n assert(typeof Module[\"TOTAL_MEMORY\"] == \"undefined\", \"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY\");\n legacyModuleProp(\"read\", \"read_\");\n legacyModuleProp(\"readAsync\", \"readAsync\");\n legacyModuleProp(\"readBinary\", \"readBinary\");\n legacyModuleProp(\"setWindowTitle\", \"setWindowTitle\");\n assert(!ENVIRONMENT_IS_WORKER, \"worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable.\");\n assert(!ENVIRONMENT_IS_NODE, \"node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable.\");\n assert(!ENVIRONMENT_IS_SHELL, \"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.\");\n var POINTER_SIZE = 4;\n function legacyModuleProp(prop, newName) {\n if (!Object.getOwnPropertyDescriptor(Module, prop)) {\n Object.defineProperty(Module, prop, { configurable: true, get: function() {\n abort(\"Module.\" + prop + \" has been replaced with plain \" + newName + \" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)\");\n } });\n }\n }\n function ignoredModuleProp(prop) {\n if (Object.getOwnPropertyDescriptor(Module, prop)) {\n abort(\"`Module.\" + prop + \"` was supplied but `\" + prop + \"` not included in INCOMING_MODULE_JS_API\");\n }\n }\n function isExportedByForceFilesystem(name) {\n return name === \"FS_createPath\" || name === \"FS_createDataFile\" || name === \"FS_createPreloadedFile\" || name === \"FS_unlink\" || name === \"addRunDependency\" || name === \"FS_createLazyFile\" || name === \"FS_createDevice\" || name === \"removeRunDependency\";\n }\n function missingLibrarySymbol(sym) {\n if (typeof globalThis !== \"undefined\" && !Object.getOwnPropertyDescriptor(globalThis, sym)) {\n Object.defineProperty(globalThis, sym, { configurable: true, get: function() {\n var msg = \"`\" + sym + \"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line\";\n if (isExportedByForceFilesystem(sym)) {\n msg += \". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you\";\n }\n warnOnce(msg);\n return void 0;\n } });\n }\n }\n function unexportedRuntimeSymbol(sym) {\n if (!Object.getOwnPropertyDescriptor(Module, sym)) {\n Object.defineProperty(Module, sym, { configurable: true, get: function() {\n var msg = \"'\" + sym + \"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)\";\n if (isExportedByForceFilesystem(sym)) {\n msg += \". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you\";\n }\n abort(msg);\n } });\n }\n }\n var wasmBinary;\n if (Module[\"wasmBinary\"]) wasmBinary = Module[\"wasmBinary\"];\n legacyModuleProp(\"wasmBinary\", \"wasmBinary\");\n var noExitRuntime = Module[\"noExitRuntime\"] || true;\n legacyModuleProp(\"noExitRuntime\", \"noExitRuntime\");\n if (typeof WebAssembly != \"object\") {\n abort(\"no native wasm support detected\");\n }\n var wasmMemory;\n var ABORT = false;\n var EXITSTATUS;\n function assert(condition, text) {\n if (!condition) {\n abort(\"Assertion failed\" + (text ? \": \" + text : \"\"));\n }\n }\n var UTF8Decoder = typeof TextDecoder != \"undefined\" ? new TextDecoder(\"utf8\") : void 0;\n function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {\n var endIdx = idx + maxBytesToRead;\n var endPtr = idx;\n while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;\n if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {\n return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));\n }\n var str = \"\";\n while (idx < endPtr) {\n var u0 = heapOrArray[idx++];\n if (!(u0 & 128)) {\n str += String.fromCharCode(u0);\n continue;\n }\n var u1 = heapOrArray[idx++] & 63;\n if ((u0 & 224) == 192) {\n str += String.fromCharCode((u0 & 31) << 6 | u1);\n continue;\n }\n var u2 = heapOrArray[idx++] & 63;\n if ((u0 & 240) == 224) {\n u0 = (u0 & 15) << 12 | u1 << 6 | u2;\n } else {\n if ((u0 & 248) != 240) warnOnce(\"Invalid UTF-8 leading byte 0x\" + u0.toString(16) + \" encountered when deserializing a UTF-8 string in wasm memory to a JS string!\");\n u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;\n }\n if (u0 < 65536) {\n str += String.fromCharCode(u0);\n } else {\n var ch = u0 - 65536;\n str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);\n }\n }\n return str;\n }\n function UTF8ToString(ptr, maxBytesToRead) {\n return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : \"\";\n }\n function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {\n if (!(maxBytesToWrite > 0)) return 0;\n var startIdx = outIdx;\n var endIdx = outIdx + maxBytesToWrite - 1;\n for (var i = 0; i < str.length; ++i) {\n var u = str.charCodeAt(i);\n if (u >= 55296 && u <= 57343) {\n var u1 = str.charCodeAt(++i);\n u = 65536 + ((u & 1023) << 10) | u1 & 1023;\n }\n if (u <= 127) {\n if (outIdx >= endIdx) break;\n heap[outIdx++] = u;\n } else if (u <= 2047) {\n if (outIdx + 1 >= endIdx) break;\n heap[outIdx++] = 192 | u >> 6;\n heap[outIdx++] = 128 | u & 63;\n } else if (u <= 65535) {\n if (outIdx + 2 >= endIdx) break;\n heap[outIdx++] = 224 | u >> 12;\n heap[outIdx++] = 128 | u >> 6 & 63;\n heap[outIdx++] = 128 | u & 63;\n } else {\n if (outIdx + 3 >= endIdx) break;\n if (u > 1114111) warnOnce(\"Invalid Unicode code point 0x\" + u.toString(16) + \" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).\");\n heap[outIdx++] = 240 | u >> 18;\n heap[outIdx++] = 128 | u >> 12 & 63;\n heap[outIdx++] = 128 | u >> 6 & 63;\n heap[outIdx++] = 128 | u & 63;\n }\n }\n heap[outIdx] = 0;\n return outIdx - startIdx;\n }\n function stringToUTF8(str, outPtr, maxBytesToWrite) {\n assert(typeof maxBytesToWrite == \"number\", \"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!\");\n return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);\n }\n function lengthBytesUTF8(str) {\n var len = 0;\n for (var i = 0; i < str.length; ++i) {\n var c = str.charCodeAt(i);\n if (c <= 127) {\n len++;\n } else if (c <= 2047) {\n len += 2;\n } else if (c >= 55296 && c <= 57343) {\n len += 4;\n ++i;\n } else {\n len += 3;\n }\n }\n return len;\n }\n var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;\n function updateGlobalBufferAndViews(buf) {\n buffer = buf;\n Module[\"HEAP8\"] = HEAP8 = new Int8Array(buf);\n Module[\"HEAP16\"] = HEAP16 = new Int16Array(buf);\n Module[\"HEAP32\"] = HEAP32 = new Int32Array(buf);\n Module[\"HEAPU8\"] = HEAPU8 = new Uint8Array(buf);\n Module[\"HEAPU16\"] = HEAPU16 = new Uint16Array(buf);\n Module[\"HEAPU32\"] = HEAPU32 = new Uint32Array(buf);\n Module[\"HEAPF32\"] = HEAPF32 = new Float32Array(buf);\n Module[\"HEAPF64\"] = HEAPF64 = new Float64Array(buf);\n }\n var TOTAL_STACK = 65536;\n if (Module[\"TOTAL_STACK\"]) assert(TOTAL_STACK === Module[\"TOTAL_STACK\"], \"the stack size can no longer be determined at runtime\");\n var INITIAL_MEMORY = Module[\"INITIAL_MEMORY\"] || 262144;\n legacyModuleProp(\"INITIAL_MEMORY\", \"INITIAL_MEMORY\");\n assert(INITIAL_MEMORY >= TOTAL_STACK, \"INITIAL_MEMORY should be larger than TOTAL_STACK, was \" + INITIAL_MEMORY + \"! (TOTAL_STACK=\" + TOTAL_STACK + \")\");\n assert(typeof Int32Array != \"undefined\" && typeof Float64Array !== \"undefined\" && Int32Array.prototype.subarray != void 0 && Int32Array.prototype.set != void 0, \"JS engine does not provide full typed array support\");\n assert(!Module[\"wasmMemory\"], \"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally\");\n assert(INITIAL_MEMORY == 262144, \"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically\");\n var wasmTable;\n function writeStackCookie() {\n var max = _emscripten_stack_get_end();\n assert((max & 3) == 0);\n HEAPU32[max >> 2] = 34821223;\n HEAPU32[max + 4 >> 2] = 2310721022;\n HEAPU32[0] = 1668509029;\n }\n function checkStackCookie() {\n if (ABORT) return;\n var max = _emscripten_stack_get_end();\n var cookie1 = HEAPU32[max >> 2];\n var cookie2 = HEAPU32[max + 4 >> 2];\n if (cookie1 != 34821223 || cookie2 != 2310721022) {\n abort(\"Stack overflow! Stack cookie has been overwritten at 0x\" + max.toString(16) + \", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x\" + cookie2.toString(16) + \" 0x\" + cookie1.toString(16));\n }\n if (HEAPU32[0] !== 1668509029) abort(\"Runtime error: The application has corrupted its heap memory area (address zero)!\");\n }\n (function() {\n var h16 = new Int16Array(1);\n var h8 = new Int8Array(h16.buffer);\n h16[0] = 25459;\n if (h8[0] !== 115 || h8[1] !== 99) throw \"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)\";\n })();\n var __ATPRERUN__ = [];\n var __ATINIT__ = [];\n var __ATPOSTRUN__ = [];\n var runtimeInitialized = false;\n function preRun() {\n if (Module[\"preRun\"]) {\n if (typeof Module[\"preRun\"] == \"function\") Module[\"preRun\"] = [Module[\"preRun\"]];\n while (Module[\"preRun\"].length) {\n addOnPreRun(Module[\"preRun\"].shift());\n }\n }\n callRuntimeCallbacks(__ATPRERUN__);\n }\n function initRuntime() {\n assert(!runtimeInitialized);\n runtimeInitialized = true;\n checkStackCookie();\n callRuntimeCallbacks(__ATINIT__);\n }\n function postRun() {\n checkStackCookie();\n if (Module[\"postRun\"]) {\n if (typeof Module[\"postRun\"] == \"function\") Module[\"postRun\"] = [Module[\"postRun\"]];\n while (Module[\"postRun\"].length) {\n addOnPostRun(Module[\"postRun\"].shift());\n }\n }\n callRuntimeCallbacks(__ATPOSTRUN__);\n }\n function addOnPreRun(cb) {\n __ATPRERUN__.unshift(cb);\n }\n function addOnInit(cb) {\n __ATINIT__.unshift(cb);\n }\n function addOnPostRun(cb) {\n __ATPOSTRUN__.unshift(cb);\n }\n assert(Math.imul, \"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n assert(Math.fround, \"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n assert(Math.clz32, \"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n assert(Math.trunc, \"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n var runDependencies = 0;\n var runDependencyWatcher = null;\n var dependenciesFulfilled = null;\n var runDependencyTracking = {};\n function addRunDependency(id) {\n runDependencies++;\n if (Module[\"monitorRunDependencies\"]) {\n Module[\"monitorRunDependencies\"](runDependencies);\n }\n if (id) {\n assert(!runDependencyTracking[id]);\n runDependencyTracking[id] = 1;\n if (runDependencyWatcher === null && typeof setInterval != \"undefined\") {\n runDependencyWatcher = setInterval(function() {\n if (ABORT) {\n clearInterval(runDependencyWatcher);\n runDependencyWatcher = null;\n return;\n }\n var shown = false;\n for (var dep in runDependencyTracking) {\n if (!shown) {\n shown = true;\n err(\"still waiting on run dependencies:\");\n }\n err(\"dependency: \" + dep);\n }\n if (shown) {\n err(\"(end of list)\");\n }\n }, 1e4);\n }\n } else {\n err(\"warning: run dependency added without ID\");\n }\n }\n function removeRunDependency(id) {\n runDependencies--;\n if (Module[\"monitorRunDependencies\"]) {\n Module[\"monitorRunDependencies\"](runDependencies);\n }\n if (id) {\n assert(runDependencyTracking[id]);\n delete runDependencyTracking[id];\n } else {\n err(\"warning: run dependency removed without ID\");\n }\n if (runDependencies == 0) {\n if (runDependencyWatcher !== null) {\n clearInterval(runDependencyWatcher);\n runDependencyWatcher = null;\n }\n if (dependenciesFulfilled) {\n var callback = dependenciesFulfilled;\n dependenciesFulfilled = null;\n callback();\n }\n }\n }\n function abort(what) {\n {\n if (Module[\"onAbort\"]) {\n Module[\"onAbort\"](what);\n }\n }\n what = \"Aborted(\" + what + \")\";\n err(what);\n ABORT = true;\n EXITSTATUS = 1;\n var e = new WebAssembly.RuntimeError(what);\n readyPromiseReject(e);\n throw e;\n }\n var FS = { error: function() {\n abort(\"Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM\");\n }, init: function() {\n FS.error();\n }, createDataFile: function() {\n FS.error();\n }, createPreloadedFile: function() {\n FS.error();\n }, createLazyFile: function() {\n FS.error();\n }, open: function() {\n FS.error();\n }, mkdev: function() {\n FS.error();\n }, registerDevice: function() {\n FS.error();\n }, analyzePath: function() {\n FS.error();\n }, loadFilesFromDB: function() {\n FS.error();\n }, ErrnoError: function ErrnoError() {\n FS.error();\n } };\n Module[\"FS_createDataFile\"] = FS.createDataFile;\n Module[\"FS_createPreloadedFile\"] = FS.createPreloadedFile;\n var dataURIPrefix = \"data:application/octet-stream;base64,\";\n function isDataURI(filename) {\n return filename.startsWith(dataURIPrefix);\n }\n function isFileURI(filename) {\n return filename.startsWith(\"file://\");\n }\n function createExportWrapper(name, fixedasm) {\n return function() {\n var displayName = name;\n var asm2 = fixedasm;\n if (!fixedasm) {\n asm2 = Module[\"asm\"];\n }\n assert(runtimeInitialized, \"native function `\" + displayName + \"` called before runtime initialization\");\n if (!asm2[name]) {\n assert(asm2[name], \"exported native function `\" + displayName + \"` not found\");\n }\n return asm2[name].apply(null, arguments);\n };\n }\n var wasmBinaryFile;\n wasmBinaryFile = \"laz-perf.wasm\";\n if (!isDataURI(wasmBinaryFile)) {\n wasmBinaryFile = locateFile(wasmBinaryFile);\n }\n function getBinary(file) {\n try {\n if (file == wasmBinaryFile && wasmBinary) {\n return new Uint8Array(wasmBinary);\n }\n if (readBinary) {\n return readBinary(file);\n }\n throw \"both async and sync fetching of the wasm failed\";\n } catch (err2) {\n abort(err2);\n }\n }\n function getBinaryPromise() {\n if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {\n if (typeof fetch == \"function\") {\n return fetch(wasmBinaryFile, { credentials: \"same-origin\" }).then(function(response) {\n if (!response[\"ok\"]) {\n throw \"failed to load wasm binary file at '\" + wasmBinaryFile + \"'\";\n }\n return response[\"arrayBuffer\"]();\n }).catch(function() {\n return getBinary(wasmBinaryFile);\n });\n }\n }\n return Promise.resolve().then(function() {\n return getBinary(wasmBinaryFile);\n });\n }\n function createWasm() {\n var info = { \"env\": asmLibraryArg, \"wasi_snapshot_preview1\": asmLibraryArg };\n function receiveInstance(instance, module2) {\n var exports3 = instance.exports;\n Module[\"asm\"] = exports3;\n wasmMemory = Module[\"asm\"][\"memory\"];\n assert(wasmMemory, \"memory not found in wasm exports\");\n updateGlobalBufferAndViews(wasmMemory.buffer);\n wasmTable = Module[\"asm\"][\"__indirect_function_table\"];\n assert(wasmTable, \"table not found in wasm exports\");\n addOnInit(Module[\"asm\"][\"__wasm_call_ctors\"]);\n removeRunDependency(\"wasm-instantiate\");\n }\n addRunDependency(\"wasm-instantiate\");\n var trueModule = Module;\n function receiveInstantiationResult(result) {\n assert(Module === trueModule, \"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?\");\n trueModule = null;\n receiveInstance(result[\"instance\"]);\n }\n function instantiateArrayBuffer(receiver) {\n return getBinaryPromise().then(function(binary) {\n return WebAssembly.instantiate(binary, info);\n }).then(function(instance) {\n return instance;\n }).then(receiver, function(reason) {\n err(\"failed to asynchronously prepare wasm: \" + reason);\n if (isFileURI(wasmBinaryFile)) {\n err(\"warning: Loading from a file URI (\" + wasmBinaryFile + \") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing\");\n }\n abort(reason);\n });\n }\n function instantiateAsync() {\n if (!wasmBinary && typeof WebAssembly.instantiateStreaming == \"function\" && !isDataURI(wasmBinaryFile) && typeof fetch == \"function\") {\n return fetch(wasmBinaryFile, { credentials: \"same-origin\" }).then(function(response) {\n var result = WebAssembly.instantiateStreaming(response, info);\n return result.then(receiveInstantiationResult, function(reason) {\n err(\"wasm streaming compile failed: \" + reason);\n err(\"falling back to ArrayBuffer instantiation\");\n return instantiateArrayBuffer(receiveInstantiationResult);\n });\n });\n } else {\n return instantiateArrayBuffer(receiveInstantiationResult);\n }\n }\n if (Module[\"instantiateWasm\"]) {\n try {\n var exports2 = Module[\"instantiateWasm\"](info, receiveInstance);\n return exports2;\n } catch (e) {\n err(\"Module.instantiateWasm callback failed with error: \" + e);\n return false;\n }\n }\n instantiateAsync().catch(readyPromiseReject);\n return {};\n }\n var tempDouble;\n var tempI64;\n function ExitStatus(status) {\n this.name = \"ExitStatus\";\n this.message = \"Program terminated with exit(\" + status + \")\";\n this.status = status;\n }\n function callRuntimeCallbacks(callbacks) {\n while (callbacks.length > 0) {\n callbacks.shift()(Module);\n }\n }\n function demangle(func) {\n warnOnce(\"warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling\");\n return func;\n }\n function demangleAll(text) {\n var regex = /\\b_Z[\\w\\d_]+/g;\n return text.replace(regex, function(x) {\n var y = demangle(x);\n return x === y ? x : y + \" [\" + x + \"]\";\n });\n }\n function jsStackTrace() {\n var error = new Error();\n if (!error.stack) {\n try {\n throw new Error();\n } catch (e) {\n error = e;\n }\n if (!error.stack) {\n return \"(no stack trace available)\";\n }\n }\n return error.stack.toString();\n }\n function warnOnce(text) {\n if (!warnOnce.shown) warnOnce.shown = {};\n if (!warnOnce.shown[text]) {\n warnOnce.shown[text] = 1;\n err(text);\n }\n }\n function writeArrayToMemory(array, buffer2) {\n assert(array.length >= 0, \"writeArrayToMemory array must have a length (should be an array or typed array)\");\n HEAP8.set(array, buffer2);\n }\n function ___cxa_allocate_exception(size) {\n return _malloc(size + 24) + 24;\n }\n function ExceptionInfo(excPtr) {\n this.excPtr = excPtr;\n this.ptr = excPtr - 24;\n this.set_type = function(type) {\n HEAPU32[this.ptr + 4 >> 2] = type;\n };\n this.get_type = function() {\n return HEAPU32[this.ptr + 4 >> 2];\n };\n this.set_destructor = function(destructor) {\n HEAPU32[this.ptr + 8 >> 2] = destructor;\n };\n this.get_destructor = function() {\n return HEAPU32[this.ptr + 8 >> 2];\n };\n this.set_refcount = function(refcount) {\n HEAP32[this.ptr >> 2] = refcount;\n };\n this.set_caught = function(caught) {\n caught = caught ? 1 : 0;\n HEAP8[this.ptr + 12 >> 0] = caught;\n };\n this.get_caught = function() {\n return HEAP8[this.ptr + 12 >> 0] != 0;\n };\n this.set_rethrown = function(rethrown) {\n rethrown = rethrown ? 1 : 0;\n HEAP8[this.ptr + 13 >> 0] = rethrown;\n };\n this.get_rethrown = function() {\n return HEAP8[this.ptr + 13 >> 0] != 0;\n };\n this.init = function(type, destructor) {\n this.set_adjusted_ptr(0);\n this.set_type(type);\n this.set_destructor(destructor);\n this.set_refcount(0);\n this.set_caught(false);\n this.set_rethrown(false);\n };\n this.add_ref = function() {\n var value = HEAP32[this.ptr >> 2];\n HEAP32[this.ptr >> 2] = value + 1;\n };\n this.release_ref = function() {\n var prev = HEAP32[this.ptr >> 2];\n HEAP32[this.ptr >> 2] = prev - 1;\n assert(prev > 0);\n return prev === 1;\n };\n this.set_adjusted_ptr = function(adjustedPtr) {\n HEAPU32[this.ptr + 16 >> 2] = adjustedPtr;\n };\n this.get_adjusted_ptr = function() {\n return HEAPU32[this.ptr + 16 >> 2];\n };\n this.get_exception_ptr = function() {\n var isPointer = ___cxa_is_pointer_type(this.get_type());\n if (isPointer) {\n return HEAPU32[this.excPtr >> 2];\n }\n var adjusted = this.get_adjusted_ptr();\n if (adjusted !== 0) return adjusted;\n return this.excPtr;\n };\n }\n var exceptionLast = 0;\n var uncaughtExceptionCount = 0;\n function ___cxa_throw(ptr, type, destructor) {\n var info = new ExceptionInfo(ptr);\n info.init(type, destructor);\n exceptionLast = ptr;\n uncaughtExceptionCount++;\n throw ptr + \" - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.\";\n }\n function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) {\n }\n function getShiftFromSize(size) {\n switch (size) {\n case 1:\n return 0;\n case 2:\n return 1;\n case 4:\n return 2;\n case 8:\n return 3;\n default:\n throw new TypeError(\"Unknown type size: \" + size);\n }\n }\n function embind_init_charCodes() {\n var codes = new Array(256);\n for (var i = 0; i < 256; ++i) {\n codes[i] = String.fromCharCode(i);\n }\n embind_charCodes = codes;\n }\n var embind_charCodes = void 0;\n function readLatin1String(ptr) {\n var ret = \"\";\n var c = ptr;\n while (HEAPU8[c]) {\n ret += embind_charCodes[HEAPU8[c++]];\n }\n return ret;\n }\n var awaitingDependencies = {};\n var registeredTypes = {};\n var typeDependencies = {};\n var char_0 = 48;\n var char_9 = 57;\n function makeLegalFunctionName(name) {\n if (void 0 === name) {\n return \"_unknown\";\n }\n name = name.replace(/[^a-zA-Z0-9_]/g, \"$\");\n var f = name.charCodeAt(0);\n if (f >= char_0 && f <= char_9) {\n return \"_\" + name;\n }\n return name;\n }\n function createNamedFunction(name, body) {\n name = makeLegalFunctionName(name);\n return new Function(\"body\", \"return function \" + name + '() {\\n \"use strict\"; return body.apply(this, arguments);\\n};\\n')(body);\n }\n function extendError(baseErrorType, errorName) {\n var errorClass = createNamedFunction(errorName, function(message) {\n this.name = errorName;\n this.message = message;\n var stack = new Error(message).stack;\n if (stack !== void 0) {\n this.stack = this.toString() + \"\\n\" + stack.replace(/^Error(:[^\\n]*)?\\n/, \"\");\n }\n });\n errorClass.prototype = Object.create(baseErrorType.prototype);\n errorClass.prototype.constructor = errorClass;\n errorClass.prototype.toString = function() {\n if (this.message === void 0) {\n return this.name;\n } else {\n return this.name + \": \" + this.message;\n }\n };\n return errorClass;\n }\n var BindingError = void 0;\n function throwBindingError(message) {\n throw new BindingError(message);\n }\n var InternalError = void 0;\n function throwInternalError(message) {\n throw new InternalError(message);\n }\n function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {\n myTypes.forEach(function(type) {\n typeDependencies[type] = dependentTypes;\n });\n function onComplete(typeConverters2) {\n var myTypeConverters = getTypeConverters(typeConverters2);\n if (myTypeConverters.length !== myTypes.length) {\n throwInternalError(\"Mismatched type converter count\");\n }\n for (var i = 0; i < myTypes.length; ++i) {\n registerType(myTypes[i], myTypeConverters[i]);\n }\n }\n var typeConverters = new Array(dependentTypes.length);\n var unregisteredTypes = [];\n var registered = 0;\n dependentTypes.forEach((dt, i) => {\n if (registeredTypes.hasOwnProperty(dt)) {\n typeConverters[i] = registeredTypes[dt];\n } else {\n unregisteredTypes.push(dt);\n if (!awaitingDependencies.hasOwnProperty(dt)) {\n awaitingDependencies[dt] = [];\n }\n awaitingDependencies[dt].push(() => {\n typeConverters[i] = registeredTypes[dt];\n ++registered;\n if (registered === unregisteredTypes.length) {\n onComplete(typeConverters);\n }\n });\n }\n });\n if (0 === unregisteredTypes.length) {\n onComplete(typeConverters);\n }\n }\n function registerType(rawType, registeredInstance, options = {}) {\n if (!(\"argPackAdvance\" in registeredInstance)) {\n throw new TypeError(\"registerType registeredInstance requires argPackAdvance\");\n }\n var name = registeredInstance.name;\n if (!rawType) {\n throwBindingError('type \"' + name + '\" must have a positive integer typeid pointer');\n }\n if (registeredTypes.hasOwnProperty(rawType)) {\n if (options.ignoreDuplicateRegistrations) {\n return;\n } else {\n throwBindingError(\"Cannot register type '\" + name + \"' twice\");\n }\n }\n registeredTypes[rawType] = registeredInstance;\n delete typeDependencies[rawType];\n if (awaitingDependencies.hasOwnProperty(rawType)) {\n var callbacks = awaitingDependencies[rawType];\n delete awaitingDependencies[rawType];\n callbacks.forEach((cb) => cb());\n }\n }\n function __embind_register_bool(rawType, name, size, trueValue, falseValue) {\n var shift = getShiftFromSize(size);\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": function(wt) {\n return !!wt;\n }, \"toWireType\": function(destructors, o) {\n return o ? trueValue : falseValue;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": function(pointer) {\n var heap;\n if (size === 1) {\n heap = HEAP8;\n } else if (size === 2) {\n heap = HEAP16;\n } else if (size === 4) {\n heap = HEAP32;\n } else {\n throw new TypeError(\"Unknown boolean type size: \" + name);\n }\n return this[\"fromWireType\"](heap[pointer >> shift]);\n }, destructorFunction: null });\n }\n function ClassHandle_isAliasOf(other) {\n if (!(this instanceof ClassHandle)) {\n return false;\n }\n if (!(other instanceof ClassHandle)) {\n return false;\n }\n var leftClass = this.$$.ptrType.registeredClass;\n var left = this.$$.ptr;\n var rightClass = other.$$.ptrType.registeredClass;\n var right = other.$$.ptr;\n while (leftClass.baseClass) {\n left = leftClass.upcast(left);\n leftClass = leftClass.baseClass;\n }\n while (rightClass.baseClass) {\n right = rightClass.upcast(right);\n rightClass = rightClass.baseClass;\n }\n return leftClass === rightClass && left === right;\n }\n function shallowCopyInternalPointer(o) {\n return { count: o.count, deleteScheduled: o.deleteScheduled, preservePointerOnDelete: o.preservePointerOnDelete, ptr: o.ptr, ptrType: o.ptrType, smartPtr: o.smartPtr, smartPtrType: o.smartPtrType };\n }\n function throwInstanceAlreadyDeleted(obj) {\n function getInstanceTypeName(handle) {\n return handle.$$.ptrType.registeredClass.name;\n }\n throwBindingError(getInstanceTypeName(obj) + \" instance already deleted\");\n }\n var finalizationRegistry = false;\n function detachFinalizer(handle) {\n }\n function runDestructor($$) {\n if ($$.smartPtr) {\n $$.smartPtrType.rawDestructor($$.smartPtr);\n } else {\n $$.ptrType.registeredClass.rawDestructor($$.ptr);\n }\n }\n function releaseClassHandle($$) {\n $$.count.value -= 1;\n var toDelete = 0 === $$.count.value;\n if (toDelete) {\n runDestructor($$);\n }\n }\n function downcastPointer(ptr, ptrClass, desiredClass) {\n if (ptrClass === desiredClass) {\n return ptr;\n }\n if (void 0 === desiredClass.baseClass) {\n return null;\n }\n var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);\n if (rv === null) {\n return null;\n }\n return desiredClass.downcast(rv);\n }\n var registeredPointers = {};\n function getInheritedInstanceCount() {\n return Object.keys(registeredInstances).length;\n }\n function getLiveInheritedInstances() {\n var rv = [];\n for (var k in registeredInstances) {\n if (registeredInstances.hasOwnProperty(k)) {\n rv.push(registeredInstances[k]);\n }\n }\n return rv;\n }\n var deletionQueue = [];\n function flushPendingDeletes() {\n while (deletionQueue.length) {\n var obj = deletionQueue.pop();\n obj.$$.deleteScheduled = false;\n obj[\"delete\"]();\n }\n }\n var delayFunction = void 0;\n function setDelayFunction(fn) {\n delayFunction = fn;\n if (deletionQueue.length && delayFunction) {\n delayFunction(flushPendingDeletes);\n }\n }\n function init_embind() {\n Module[\"getInheritedInstanceCount\"] = getInheritedInstanceCount;\n Module[\"getLiveInheritedInstances\"] = getLiveInheritedInstances;\n Module[\"flushPendingDeletes\"] = flushPendingDeletes;\n Module[\"setDelayFunction\"] = setDelayFunction;\n }\n var registeredInstances = {};\n function getBasestPointer(class_, ptr) {\n if (ptr === void 0) {\n throwBindingError(\"ptr should not be undefined\");\n }\n while (class_.baseClass) {\n ptr = class_.upcast(ptr);\n class_ = class_.baseClass;\n }\n return ptr;\n }\n function getInheritedInstance(class_, ptr) {\n ptr = getBasestPointer(class_, ptr);\n return registeredInstances[ptr];\n }\n function makeClassHandle(prototype, record) {\n if (!record.ptrType || !record.ptr) {\n throwInternalError(\"makeClassHandle requires ptr and ptrType\");\n }\n var hasSmartPtrType = !!record.smartPtrType;\n var hasSmartPtr = !!record.smartPtr;\n if (hasSmartPtrType !== hasSmartPtr) {\n throwInternalError(\"Both smartPtrType and smartPtr must be specified\");\n }\n record.count = { value: 1 };\n return attachFinalizer(Object.create(prototype, { $$: { value: record } }));\n }\n function RegisteredPointer_fromWireType(ptr) {\n var rawPointer = this.getPointee(ptr);\n if (!rawPointer) {\n this.destructor(ptr);\n return null;\n }\n var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);\n if (void 0 !== registeredInstance) {\n if (0 === registeredInstance.$$.count.value) {\n registeredInstance.$$.ptr = rawPointer;\n registeredInstance.$$.smartPtr = ptr;\n return registeredInstance[\"clone\"]();\n } else {\n var rv = registeredInstance[\"clone\"]();\n this.destructor(ptr);\n return rv;\n }\n }\n function makeDefaultHandle() {\n if (this.isSmartPointer) {\n return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: rawPointer, smartPtrType: this, smartPtr: ptr });\n } else {\n return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this, ptr });\n }\n }\n var actualType = this.registeredClass.getActualType(rawPointer);\n var registeredPointerRecord = registeredPointers[actualType];\n if (!registeredPointerRecord) {\n return makeDefaultHandle.call(this);\n }\n var toType;\n if (this.isConst) {\n toType = registeredPointerRecord.constPointerType;\n } else {\n toType = registeredPointerRecord.pointerType;\n }\n var dp = downcastPointer(rawPointer, this.registeredClass, toType.registeredClass);\n if (dp === null) {\n return makeDefaultHandle.call(this);\n }\n if (this.isSmartPointer) {\n return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp, smartPtrType: this, smartPtr: ptr });\n } else {\n return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp });\n }\n }\n function attachFinalizer(handle) {\n if (\"undefined\" === typeof FinalizationRegistry) {\n attachFinalizer = (handle2) => handle2;\n return handle;\n }\n finalizationRegistry = new FinalizationRegistry((info) => {\n console.warn(info.leakWarning.stack.replace(/^Error: /, \"\"));\n releaseClassHandle(info.$$);\n });\n attachFinalizer = (handle2) => {\n var $$ = handle2.$$;\n var hasSmartPtr = !!$$.smartPtr;\n if (hasSmartPtr) {\n var info = { $$ };\n var cls = $$.ptrType.registeredClass;\n info.leakWarning = new Error(\"Embind found a leaked C++ instance \" + cls.name + \" <0x\" + $$.ptr.toString(16) + \">.\\nWe'll free it automatically in this case, but this functionality is not reliable across various environments.\\nMake sure to invoke .delete() manually once you're done with the instance instead.\\nOriginally allocated\");\n if (\"captureStackTrace\" in Error) {\n Error.captureStackTrace(info.leakWarning, RegisteredPointer_fromWireType);\n }\n finalizationRegistry.register(handle2, info, handle2);\n }\n return handle2;\n };\n detachFinalizer = (handle2) => finalizationRegistry.unregister(handle2);\n return attachFinalizer(handle);\n }\n function ClassHandle_clone() {\n if (!this.$$.ptr) {\n throwInstanceAlreadyDeleted(this);\n }\n if (this.$$.preservePointerOnDelete) {\n this.$$.count.value += 1;\n return this;\n } else {\n var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), { $$: { value: shallowCopyInternalPointer(this.$$) } }));\n clone.$$.count.value += 1;\n clone.$$.deleteScheduled = false;\n return clone;\n }\n }\n function ClassHandle_delete() {\n if (!this.$$.ptr) {\n throwInstanceAlreadyDeleted(this);\n }\n if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {\n throwBindingError(\"Object already scheduled for deletion\");\n }\n detachFinalizer(this);\n releaseClassHandle(this.$$);\n if (!this.$$.preservePointerOnDelete) {\n this.$$.smartPtr = void 0;\n this.$$.ptr = void 0;\n }\n }\n function ClassHandle_isDeleted() {\n return !this.$$.ptr;\n }\n function ClassHandle_deleteLater() {\n if (!this.$$.ptr) {\n throwInstanceAlreadyDeleted(this);\n }\n if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {\n throwBindingError(\"Object already scheduled for deletion\");\n }\n deletionQueue.push(this);\n if (deletionQueue.length === 1 && delayFunction) {\n delayFunction(flushPendingDeletes);\n }\n this.$$.deleteScheduled = true;\n return this;\n }\n function init_ClassHandle() {\n ClassHandle.prototype[\"isAliasOf\"] = ClassHandle_isAliasOf;\n ClassHandle.prototype[\"clone\"] = ClassHandle_clone;\n ClassHandle.prototype[\"delete\"] = ClassHandle_delete;\n ClassHandle.prototype[\"isDeleted\"] = ClassHandle_isDeleted;\n ClassHandle.prototype[\"deleteLater\"] = ClassHandle_deleteLater;\n }\n function ClassHandle() {\n }\n function ensureOverloadTable(proto, methodName, humanName) {\n if (void 0 === proto[methodName].overloadTable) {\n var prevFunc = proto[methodName];\n proto[methodName] = function() {\n if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {\n throwBindingError(\"Function '\" + humanName + \"' called with an invalid number of arguments (\" + arguments.length + \") - expects one of (\" + proto[methodName].overloadTable + \")!\");\n }\n return proto[methodName].overloadTable[arguments.length].apply(this, arguments);\n };\n proto[methodName].overloadTable = [];\n proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;\n }\n }\n function exposePublicSymbol(name, value, numArguments) {\n if (Module.hasOwnProperty(name)) {\n if (void 0 === numArguments || void 0 !== Module[name].overloadTable && void 0 !== Module[name].overloadTable[numArguments]) {\n throwBindingError(\"Cannot register public name '\" + name + \"' twice\");\n }\n ensureOverloadTable(Module, name, name);\n if (Module.hasOwnProperty(numArguments)) {\n throwBindingError(\"Cannot register multiple overloads of a function with the same number of arguments (\" + numArguments + \")!\");\n }\n Module[name].overloadTable[numArguments] = value;\n } else {\n Module[name] = value;\n if (void 0 !== numArguments) {\n Module[name].numArguments = numArguments;\n }\n }\n }\n function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) {\n this.name = name;\n this.constructor = constructor;\n this.instancePrototype = instancePrototype;\n this.rawDestructor = rawDestructor;\n this.baseClass = baseClass;\n this.getActualType = getActualType;\n this.upcast = upcast;\n this.downcast = downcast;\n this.pureVirtualFunctions = [];\n }\n function upcastPointer(ptr, ptrClass, desiredClass) {\n while (ptrClass !== desiredClass) {\n if (!ptrClass.upcast) {\n throwBindingError(\"Expected null or instance of \" + desiredClass.name + \", got an instance of \" + ptrClass.name);\n }\n ptr = ptrClass.upcast(ptr);\n ptrClass = ptrClass.baseClass;\n }\n return ptr;\n }\n function constNoSmartPtrRawPointerToWireType(destructors, handle) {\n if (handle === null) {\n if (this.isReference) {\n throwBindingError(\"null is not a valid \" + this.name);\n }\n return 0;\n }\n if (!handle.$$) {\n throwBindingError('Cannot pass \"' + embindRepr(handle) + '\" as a ' + this.name);\n }\n if (!handle.$$.ptr) {\n throwBindingError(\"Cannot pass deleted object as a pointer of type \" + this.name);\n }\n var handleClass = handle.$$.ptrType.registeredClass;\n var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);\n return ptr;\n }\n function genericPointerToWireType(destructors, handle) {\n var ptr;\n if (handle === null) {\n if (this.isReference) {\n throwBindingError(\"null is not a valid \" + this.name);\n }\n if (this.isSmartPointer) {\n ptr = this.rawConstructor();\n if (destructors !== null) {\n destructors.push(this.rawDestructor, ptr);\n }\n return ptr;\n } else {\n return 0;\n }\n }\n if (!handle.$$) {\n throwBindingError('Cannot pass \"' + embindRepr(handle) + '\" as a ' + this.name);\n }\n if (!handle.$$.ptr) {\n throwBindingError(\"Cannot pass deleted object as a pointer of type \" + this.name);\n }\n if (!this.isConst && handle.$$.ptrType.isConst) {\n throwBindingError(\"Cannot convert argument of type \" + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + \" to parameter type \" + this.name);\n }\n var handleClass = handle.$$.ptrType.registeredClass;\n ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);\n if (this.isSmartPointer) {\n if (void 0 === handle.$$.smartPtr) {\n throwBindingError(\"Passing raw pointer to smart pointer is illegal\");\n }\n switch (this.sharingPolicy) {\n case 0:\n if (handle.$$.smartPtrType === this) {\n ptr = handle.$$.smartPtr;\n } else {\n throwBindingError(\"Cannot convert argument of type \" + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + \" to parameter type \" + this.name);\n }\n break;\n case 1:\n ptr = handle.$$.smartPtr;\n break;\n case 2:\n if (handle.$$.smartPtrType === this) {\n ptr = handle.$$.smartPtr;\n } else {\n var clonedHandle = handle[\"clone\"]();\n ptr = this.rawShare(ptr, Emval.toHandle(function() {\n clonedHandle[\"delete\"]();\n }));\n if (destructors !== null) {\n destructors.push(this.rawDestructor, ptr);\n }\n }\n break;\n default:\n throwBindingError(\"Unsupporting sharing policy\");\n }\n }\n return ptr;\n }\n function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {\n if (handle === null) {\n if (this.isReference) {\n throwBindingError(\"null is not a valid \" + this.name);\n }\n return 0;\n }\n if (!handle.$$) {\n throwBindingError('Cannot pass \"' + embindRepr(handle) + '\" as a ' + this.name);\n }\n if (!handle.$$.ptr) {\n throwBindingError(\"Cannot pass deleted object as a pointer of type \" + this.name);\n }\n if (handle.$$.ptrType.isConst) {\n throwBindingError(\"Cannot convert argument of type \" + handle.$$.ptrType.name + \" to parameter type \" + this.name);\n }\n var handleClass = handle.$$.ptrType.registeredClass;\n var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);\n return ptr;\n }\n function simpleReadValueFromPointer(pointer) {\n return this[\"fromWireType\"](HEAP32[pointer >> 2]);\n }\n function RegisteredPointer_getPointee(ptr) {\n if (this.rawGetPointee) {\n ptr = this.rawGetPointee(ptr);\n }\n return ptr;\n }\n function RegisteredPointer_destructor(ptr) {\n if (this.rawDestructor) {\n this.rawDestructor(ptr);\n }\n }\n function RegisteredPointer_deleteObject(handle) {\n if (handle !== null) {\n handle[\"delete\"]();\n }\n }\n function init_RegisteredPointer() {\n RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;\n RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;\n RegisteredPointer.prototype[\"argPackAdvance\"] = 8;\n RegisteredPointer.prototype[\"readValueFromPointer\"] = simpleReadValueFromPointer;\n RegisteredPointer.prototype[\"deleteObject\"] = RegisteredPointer_deleteObject;\n RegisteredPointer.prototype[\"fromWireType\"] = RegisteredPointer_fromWireType;\n }\n function RegisteredPointer(name, registeredClass, isReference, isConst, isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) {\n this.name = name;\n this.registeredClass = registeredClass;\n this.isReference = isReference;\n this.isConst = isConst;\n this.isSmartPointer = isSmartPointer;\n this.pointeeType = pointeeType;\n this.sharingPolicy = sharingPolicy;\n this.rawGetPointee = rawGetPointee;\n this.rawConstructor = rawConstructor;\n this.rawShare = rawShare;\n this.rawDestructor = rawDestructor;\n if (!isSmartPointer && registeredClass.baseClass === void 0) {\n if (isConst) {\n this[\"toWireType\"] = constNoSmartPtrRawPointerToWireType;\n this.destructorFunction = null;\n } else {\n this[\"toWireType\"] = nonConstNoSmartPtrRawPointerToWireType;\n this.destructorFunction = null;\n }\n } else {\n this[\"toWireType\"] = genericPointerToWireType;\n }\n }\n function replacePublicSymbol(name, value, numArguments) {\n if (!Module.hasOwnProperty(name)) {\n throwInternalError(\"Replacing nonexistant public symbol\");\n }\n if (void 0 !== Module[name].overloadTable && void 0 !== numArguments) {\n Module[name].overloadTable[numArguments] = value;\n } else {\n Module[name] = value;\n Module[name].argCount = numArguments;\n }\n }\n function dynCallLegacy(sig, ptr, args) {\n assert(\"dynCall_\" + sig in Module, \"bad function pointer type - no table for sig '\" + sig + \"'\");\n if (args && args.length) {\n assert(args.length === sig.substring(1).replace(/j/g, \"--\").length);\n } else {\n assert(sig.length == 1);\n }\n var f = Module[\"dynCall_\" + sig];\n return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr);\n }\n var wasmTableMirror = [];\n function getWasmTableEntry(funcPtr) {\n var func = wasmTableMirror[funcPtr];\n if (!func) {\n if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;\n wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);\n }\n assert(wasmTable.get(funcPtr) == func, \"JavaScript-side Wasm function table mirror is out of date!\");\n return func;\n }\n function dynCall(sig, ptr, args) {\n if (sig.includes(\"j\")) {\n return dynCallLegacy(sig, ptr, args);\n }\n assert(getWasmTableEntry(ptr), \"missing table entry in dynCall: \" + ptr);\n var rtn = getWasmTableEntry(ptr).apply(null, args);\n return rtn;\n }\n function getDynCaller(sig, ptr) {\n assert(sig.includes(\"j\") || sig.includes(\"p\"), \"getDynCaller should only be called with i64 sigs\");\n var argCache = [];\n return function() {\n argCache.length = 0;\n Object.assign(argCache, arguments);\n return dynCall(sig, ptr, argCache);\n };\n }\n function embind__requireFunction(signature, rawFunction) {\n signature = readLatin1String(signature);\n function makeDynCaller() {\n if (signature.includes(\"j\")) {\n return getDynCaller(signature, rawFunction);\n }\n return getWasmTableEntry(rawFunction);\n }\n var fp = makeDynCaller();\n if (typeof fp != \"function\") {\n throwBindingError(\"unknown function pointer with signature \" + signature + \": \" + rawFunction);\n }\n return fp;\n }\n var UnboundTypeError = void 0;\n function getTypeName(type) {\n var ptr = ___getTypeName(type);\n var rv = readLatin1String(ptr);\n _free(ptr);\n return rv;\n }\n function throwUnboundTypeError(message, types) {\n var unboundTypes = [];\n var seen = {};\n function visit(type) {\n if (seen[type]) {\n return;\n }\n if (registeredTypes[type]) {\n return;\n }\n if (typeDependencies[type]) {\n typeDependencies[type].forEach(visit);\n return;\n }\n unboundTypes.push(type);\n seen[type] = true;\n }\n types.forEach(visit);\n throw new UnboundTypeError(message + \": \" + unboundTypes.map(getTypeName).join([\", \"]));\n }\n function __embind_register_class(rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) {\n name = readLatin1String(name);\n getActualType = embind__requireFunction(getActualTypeSignature, getActualType);\n if (upcast) {\n upcast = embind__requireFunction(upcastSignature, upcast);\n }\n if (downcast) {\n downcast = embind__requireFunction(downcastSignature, downcast);\n }\n rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);\n var legalFunctionName = makeLegalFunctionName(name);\n exposePublicSymbol(legalFunctionName, function() {\n throwUnboundTypeError(\"Cannot construct \" + name + \" due to unbound types\", [baseClassRawType]);\n });\n whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], function(base) {\n base = base[0];\n var baseClass;\n var basePrototype;\n if (baseClassRawType) {\n baseClass = base.registeredClass;\n basePrototype = baseClass.instancePrototype;\n } else {\n basePrototype = ClassHandle.prototype;\n }\n var constructor = createNamedFunction(legalFunctionName, function() {\n if (Object.getPrototypeOf(this) !== instancePrototype) {\n throw new BindingError(\"Use 'new' to construct \" + name);\n }\n if (void 0 === registeredClass.constructor_body) {\n throw new BindingError(name + \" has no accessible constructor\");\n }\n var body = registeredClass.constructor_body[arguments.length];\n if (void 0 === body) {\n throw new BindingError(\"Tried to invoke ctor of \" + name + \" with invalid number of parameters (\" + arguments.length + \") - expected (\" + Object.keys(registeredClass.constructor_body).toString() + \") parameters instead!\");\n }\n return body.apply(this, arguments);\n });\n var instancePrototype = Object.create(basePrototype, { constructor: { value: constructor } });\n constructor.prototype = instancePrototype;\n var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast);\n var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false);\n var pointerConverter = new RegisteredPointer(name + \"*\", registeredClass, false, false, false);\n var constPointerConverter = new RegisteredPointer(name + \" const*\", registeredClass, false, true, false);\n registeredPointers[rawType] = { pointerType: pointerConverter, constPointerType: constPointerConverter };\n replacePublicSymbol(legalFunctionName, constructor);\n return [referenceConverter, pointerConverter, constPointerConverter];\n });\n }\n function heap32VectorToArray(count, firstElement) {\n var array = [];\n for (var i = 0; i < count; i++) {\n array.push(HEAPU32[firstElement + i * 4 >> 2]);\n }\n return array;\n }\n function runDestructors(destructors) {\n while (destructors.length) {\n var ptr = destructors.pop();\n var del = destructors.pop();\n del(ptr);\n }\n }\n function new_(constructor, argumentList) {\n if (!(constructor instanceof Function)) {\n throw new TypeError(\"new_ called with constructor type \" + typeof constructor + \" which is not a function\");\n }\n var dummy = createNamedFunction(constructor.name || \"unknownFunctionName\", function() {\n });\n dummy.prototype = constructor.prototype;\n var obj = new dummy();\n var r = constructor.apply(obj, argumentList);\n return r instanceof Object ? r : obj;\n }\n function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {\n var argCount = argTypes.length;\n if (argCount < 2) {\n throwBindingError(\"argTypes array size mismatch! Must at least get return value and 'this' types!\");\n }\n var isClassMethodFunc = argTypes[1] !== null && classType !== null;\n var needsDestructorStack = false;\n for (var i = 1; i < argTypes.length; ++i) {\n if (argTypes[i] !== null && argTypes[i].destructorFunction === void 0) {\n needsDestructorStack = true;\n break;\n }\n }\n var returns = argTypes[0].name !== \"void\";\n var argsList = \"\";\n var argsListWired = \"\";\n for (var i = 0; i < argCount - 2; ++i) {\n argsList += (i !== 0 ? \", \" : \"\") + \"arg\" + i;\n argsListWired += (i !== 0 ? \", \" : \"\") + \"arg\" + i + \"Wired\";\n }\n var invokerFnBody = \"return function \" + makeLegalFunctionName(humanName) + \"(\" + argsList + \") {\\nif (arguments.length !== \" + (argCount - 2) + \") {\\nthrowBindingError('function \" + humanName + \" called with ' + arguments.length + ' arguments, expected \" + (argCount - 2) + \" args!');\\n}\\n\";\n if (needsDestructorStack) {\n invokerFnBody += \"var destructors = [];\\n\";\n }\n var dtorStack = needsDestructorStack ? \"destructors\" : \"null\";\n var args1 = [\"throwBindingError\", \"invoker\", \"fn\", \"runDestructors\", \"retType\", \"classParam\"];\n var args2 = [throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];\n if (isClassMethodFunc) {\n invokerFnBody += \"var thisWired = classParam.toWireType(\" + dtorStack + \", this);\\n\";\n }\n for (var i = 0; i < argCount - 2; ++i) {\n invokerFnBody += \"var arg\" + i + \"Wired = argType\" + i + \".toWireType(\" + dtorStack + \", arg\" + i + \"); // \" + argTypes[i + 2].name + \"\\n\";\n args1.push(\"argType\" + i);\n args2.push(argTypes[i + 2]);\n }\n if (isClassMethodFunc) {\n argsListWired = \"thisWired\" + (argsListWired.length > 0 ? \", \" : \"\") + argsListWired;\n }\n invokerFnBody += (returns ? \"var rv = \" : \"\") + \"invoker(fn\" + (argsListWired.length > 0 ? \", \" : \"\") + argsListWired + \");\\n\";\n if (needsDestructorStack) {\n invokerFnBody += \"runDestructors(destructors);\\n\";\n } else {\n for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) {\n var paramName = i === 1 ? \"thisWired\" : \"arg\" + (i - 2) + \"Wired\";\n if (argTypes[i].destructorFunction !== null) {\n invokerFnBody += paramName + \"_dtor(\" + paramName + \"); // \" + argTypes[i].name + \"\\n\";\n args1.push(paramName + \"_dtor\");\n args2.push(argTypes[i].destructorFunction);\n }\n }\n }\n if (returns) {\n invokerFnBody += \"var ret = retType.fromWireType(rv);\\nreturn ret;\\n\";\n } else {\n }\n invokerFnBody += \"}\\n\";\n args1.push(invokerFnBody);\n var invokerFunction = new_(Function, args1).apply(null, args2);\n return invokerFunction;\n }\n function __embind_register_class_constructor(rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) {\n assert(argCount > 0);\n var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);\n invoker = embind__requireFunction(invokerSignature, invoker);\n whenDependentTypesAreResolved([], [rawClassType], function(classType) {\n classType = classType[0];\n var humanName = \"constructor \" + classType.name;\n if (void 0 === classType.registeredClass.constructor_body) {\n classType.registeredClass.constructor_body = [];\n }\n if (void 0 !== classType.registeredClass.constructor_body[argCount - 1]) {\n throw new BindingError(\"Cannot register multiple constructors with identical number of parameters (\" + (argCount - 1) + \") for class '\" + classType.name + \"'! Overload resolution is currently only performed using the parameter count, not actual type info!\");\n }\n classType.registeredClass.constructor_body[argCount - 1] = () => {\n throwUnboundTypeError(\"Cannot construct \" + classType.name + \" due to unbound types\", rawArgTypes);\n };\n whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {\n argTypes.splice(1, 0, null);\n classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);\n return [];\n });\n return [];\n });\n }\n function __embind_register_class_function(rawClassType, methodName, argCount, rawArgTypesAddr, invokerSignature, rawInvoker, context, isPureVirtual) {\n var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);\n methodName = readLatin1String(methodName);\n rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);\n whenDependentTypesAreResolved([], [rawClassType], function(classType) {\n classType = classType[0];\n var humanName = classType.name + \".\" + methodName;\n if (methodName.startsWith(\"@@\")) {\n methodName = Symbol[methodName.substring(2)];\n }\n if (isPureVirtual) {\n classType.registeredClass.pureVirtualFunctions.push(methodName);\n }\n function unboundTypesHandler() {\n throwUnboundTypeError(\"Cannot call \" + humanName + \" due to unbound types\", rawArgTypes);\n }\n var proto = classType.registeredClass.instancePrototype;\n var method = proto[methodName];\n if (void 0 === method || void 0 === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2) {\n unboundTypesHandler.argCount = argCount - 2;\n unboundTypesHandler.className = classType.name;\n proto[methodName] = unboundTypesHandler;\n } else {\n ensureOverloadTable(proto, methodName, humanName);\n proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;\n }\n whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {\n var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context);\n if (void 0 === proto[methodName].overloadTable) {\n memberFunction.argCount = argCount - 2;\n proto[methodName] = memberFunction;\n } else {\n proto[methodName].overloadTable[argCount - 2] = memberFunction;\n }\n return [];\n });\n return [];\n });\n }\n var emval_free_list = [];\n var emval_handle_array = [{}, { value: void 0 }, { value: null }, { value: true }, { value: false }];\n function __emval_decref(handle) {\n if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {\n emval_handle_array[handle] = void 0;\n emval_free_list.push(handle);\n }\n }\n function count_emval_handles() {\n var count = 0;\n for (var i = 5; i < emval_handle_array.length; ++i) {\n if (emval_handle_array[i] !== void 0) {\n ++count;\n }\n }\n return count;\n }\n function get_first_emval() {\n for (var i = 5; i < emval_handle_array.length; ++i) {\n if (emval_handle_array[i] !== void 0) {\n return emval_handle_array[i];\n }\n }\n return null;\n }\n function init_emval() {\n Module[\"count_emval_handles\"] = count_emval_handles;\n Module[\"get_first_emval\"] = get_first_emval;\n }\n var Emval = { toValue: (handle) => {\n if (!handle) {\n throwBindingError(\"Cannot use deleted val. handle = \" + handle);\n }\n return emval_handle_array[handle].value;\n }, toHandle: (value) => {\n switch (value) {\n case void 0:\n return 1;\n case null:\n return 2;\n case true:\n return 3;\n case false:\n return 4;\n default: {\n var handle = emval_free_list.length ? emval_free_list.pop() : emval_handle_array.length;\n emval_handle_array[handle] = { refcount: 1, value };\n return handle;\n }\n }\n } };\n function __embind_register_emval(rawType, name) {\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": function(handle) {\n var rv = Emval.toValue(handle);\n __emval_decref(handle);\n return rv;\n }, \"toWireType\": function(destructors, value) {\n return Emval.toHandle(value);\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": simpleReadValueFromPointer, destructorFunction: null });\n }\n function embindRepr(v) {\n if (v === null) {\n return \"null\";\n }\n var t = typeof v;\n if (t === \"object\" || t === \"array\" || t === \"function\") {\n return v.toString();\n } else {\n return \"\" + v;\n }\n }\n function floatReadValueFromPointer(name, shift) {\n switch (shift) {\n case 2:\n return function(pointer) {\n return this[\"fromWireType\"](HEAPF32[pointer >> 2]);\n };\n case 3:\n return function(pointer) {\n return this[\"fromWireType\"](HEAPF64[pointer >> 3]);\n };\n default:\n throw new TypeError(\"Unknown float type: \" + name);\n }\n }\n function __embind_register_float(rawType, name, size) {\n var shift = getShiftFromSize(size);\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": function(value) {\n return value;\n }, \"toWireType\": function(destructors, value) {\n if (typeof value != \"number\" && typeof value != \"boolean\") {\n throw new TypeError('Cannot convert \"' + embindRepr(value) + '\" to ' + this.name);\n }\n return value;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": floatReadValueFromPointer(name, shift), destructorFunction: null });\n }\n function integerReadValueFromPointer(name, shift, signed) {\n switch (shift) {\n case 0:\n return signed ? function readS8FromPointer(pointer) {\n return HEAP8[pointer];\n } : function readU8FromPointer(pointer) {\n return HEAPU8[pointer];\n };\n case 1:\n return signed ? function readS16FromPointer(pointer) {\n return HEAP16[pointer >> 1];\n } : function readU16FromPointer(pointer) {\n return HEAPU16[pointer >> 1];\n };\n case 2:\n return signed ? function readS32FromPointer(pointer) {\n return HEAP32[pointer >> 2];\n } : function readU32FromPointer(pointer) {\n return HEAPU32[pointer >> 2];\n };\n default:\n throw new TypeError(\"Unknown integer type: \" + name);\n }\n }\n function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {\n name = readLatin1String(name);\n if (maxRange === -1) {\n maxRange = 4294967295;\n }\n var shift = getShiftFromSize(size);\n var fromWireType = (value) => value;\n if (minRange === 0) {\n var bitshift = 32 - 8 * size;\n fromWireType = (value) => value << bitshift >>> bitshift;\n }\n var isUnsignedType = name.includes(\"unsigned\");\n var checkAssertions = (value, toTypeName) => {\n if (typeof value != \"number\" && typeof value != \"boolean\") {\n throw new TypeError('Cannot convert \"' + embindRepr(value) + '\" to ' + toTypeName);\n }\n if (value < minRange || value > maxRange) {\n throw new TypeError('Passing a number \"' + embindRepr(value) + '\" from JS side to C/C++ side to an argument of type \"' + name + '\", which is outside the valid range [' + minRange + \", \" + maxRange + \"]!\");\n }\n };\n var toWireType;\n if (isUnsignedType) {\n toWireType = function(destructors, value) {\n checkAssertions(value, this.name);\n return value >>> 0;\n };\n } else {\n toWireType = function(destructors, value) {\n checkAssertions(value, this.name);\n return value;\n };\n }\n registerType(primitiveType, { name, \"fromWireType\": fromWireType, \"toWireType\": toWireType, \"argPackAdvance\": 8, \"readValueFromPointer\": integerReadValueFromPointer(name, shift, minRange !== 0), destructorFunction: null });\n }\n function __embind_register_memory_view(rawType, dataTypeIndex, name) {\n var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];\n var TA = typeMapping[dataTypeIndex];\n function decodeMemoryView(handle) {\n handle = handle >> 2;\n var heap = HEAPU32;\n var size = heap[handle];\n var data = heap[handle + 1];\n return new TA(buffer, data, size);\n }\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": decodeMemoryView, \"argPackAdvance\": 8, \"readValueFromPointer\": decodeMemoryView }, { ignoreDuplicateRegistrations: true });\n }\n function __embind_register_std_string(rawType, name) {\n name = readLatin1String(name);\n var stdStringIsUTF8 = name === \"std::string\";\n registerType(rawType, { name, \"fromWireType\": function(value) {\n var length = HEAPU32[value >> 2];\n var payload = value + 4;\n var str;\n if (stdStringIsUTF8) {\n var decodeStartPtr = payload;\n for (var i = 0; i <= length; ++i) {\n var currentBytePtr = payload + i;\n if (i == length || HEAPU8[currentBytePtr] == 0) {\n var maxRead = currentBytePtr - decodeStartPtr;\n var stringSegment = UTF8ToString(decodeStartPtr, maxRead);\n if (str === void 0) {\n str = stringSegment;\n } else {\n str += String.fromCharCode(0);\n str += stringSegment;\n }\n decodeStartPtr = currentBytePtr + 1;\n }\n }\n } else {\n var a = new Array(length);\n for (var i = 0; i < length; ++i) {\n a[i] = String.fromCharCode(HEAPU8[payload + i]);\n }\n str = a.join(\"\");\n }\n _free(value);\n return str;\n }, \"toWireType\": function(destructors, value) {\n if (value instanceof ArrayBuffer) {\n value = new Uint8Array(value);\n }\n var length;\n var valueIsOfTypeString = typeof value == \"string\";\n if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {\n throwBindingError(\"Cannot pass non-string to std::string\");\n }\n if (stdStringIsUTF8 && valueIsOfTypeString) {\n length = lengthBytesUTF8(value);\n } else {\n length = value.length;\n }\n var base = _malloc(4 + length + 1);\n var ptr = base + 4;\n HEAPU32[base >> 2] = length;\n if (stdStringIsUTF8 && valueIsOfTypeString) {\n stringToUTF8(value, ptr, length + 1);\n } else {\n if (valueIsOfTypeString) {\n for (var i = 0; i < length; ++i) {\n var charCode = value.charCodeAt(i);\n if (charCode > 255) {\n _free(ptr);\n throwBindingError(\"String has UTF-16 code units that do not fit in 8 bits\");\n }\n HEAPU8[ptr + i] = charCode;\n }\n } else {\n for (var i = 0; i < length; ++i) {\n HEAPU8[ptr + i] = value[i];\n }\n }\n }\n if (destructors !== null) {\n destructors.push(_free, base);\n }\n return base;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": simpleReadValueFromPointer, destructorFunction: function(ptr) {\n _free(ptr);\n } });\n }\n var UTF16Decoder = typeof TextDecoder != \"undefined\" ? new TextDecoder(\"utf-16le\") : void 0;\n function UTF16ToString(ptr, maxBytesToRead) {\n assert(ptr % 2 == 0, \"Pointer passed to UTF16ToString must be aligned to two bytes!\");\n var endPtr = ptr;\n var idx = endPtr >> 1;\n var maxIdx = idx + maxBytesToRead / 2;\n while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;\n endPtr = idx << 1;\n if (endPtr - ptr > 32 && UTF16Decoder) {\n return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));\n } else {\n var str = \"\";\n for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {\n var codeUnit = HEAP16[ptr + i * 2 >> 1];\n if (codeUnit == 0) break;\n str += String.fromCharCode(codeUnit);\n }\n return str;\n }\n }\n function stringToUTF16(str, outPtr, maxBytesToWrite) {\n assert(outPtr % 2 == 0, \"Pointer passed to stringToUTF16 must be aligned to two bytes!\");\n assert(typeof maxBytesToWrite == \"number\", \"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!\");\n if (maxBytesToWrite === void 0) {\n maxBytesToWrite = 2147483647;\n }\n if (maxBytesToWrite < 2) return 0;\n maxBytesToWrite -= 2;\n var startPtr = outPtr;\n var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;\n for (var i = 0; i < numCharsToWrite; ++i) {\n var codeUnit = str.charCodeAt(i);\n HEAP16[outPtr >> 1] = codeUnit;\n outPtr += 2;\n }\n HEAP16[outPtr >> 1] = 0;\n return outPtr - startPtr;\n }\n function lengthBytesUTF16(str) {\n return str.length * 2;\n }\n function UTF32ToString(ptr, maxBytesToRead) {\n assert(ptr % 4 == 0, \"Pointer passed to UTF32ToString must be aligned to four bytes!\");\n var i = 0;\n var str = \"\";\n while (!(i >= maxBytesToRead / 4)) {\n var utf32 = HEAP32[ptr + i * 4 >> 2];\n if (utf32 == 0) break;\n ++i;\n if (utf32 >= 65536) {\n var ch = utf32 - 65536;\n str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);\n } else {\n str += String.fromCharCode(utf32);\n }\n }\n return str;\n }\n function stringToUTF32(str, outPtr, maxBytesToWrite) {\n assert(outPtr % 4 == 0, \"Pointer passed to stringToUTF32 must be aligned to four bytes!\");\n assert(typeof maxBytesToWrite == \"number\", \"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!\");\n if (maxBytesToWrite === void 0) {\n maxBytesToWrite = 2147483647;\n }\n if (maxBytesToWrite < 4) return 0;\n var startPtr = outPtr;\n var endPtr = startPtr + maxBytesToWrite - 4;\n for (var i = 0; i < str.length; ++i) {\n var codeUnit = str.charCodeAt(i);\n if (codeUnit >= 55296 && codeUnit <= 57343) {\n var trailSurrogate = str.charCodeAt(++i);\n codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023;\n }\n HEAP32[outPtr >> 2] = codeUnit;\n outPtr += 4;\n if (outPtr + 4 > endPtr) break;\n }\n HEAP32[outPtr >> 2] = 0;\n return outPtr - startPtr;\n }\n function lengthBytesUTF32(str) {\n var len = 0;\n for (var i = 0; i < str.length; ++i) {\n var codeUnit = str.charCodeAt(i);\n if (codeUnit >= 55296 && codeUnit <= 57343) ++i;\n len += 4;\n }\n return len;\n }\n function __embind_register_std_wstring(rawType, charSize, name) {\n name = readLatin1String(name);\n var decodeString, encodeString, getHeap, lengthBytesUTF, shift;\n if (charSize === 2) {\n decodeString = UTF16ToString;\n encodeString = stringToUTF16;\n lengthBytesUTF = lengthBytesUTF16;\n getHeap = () => HEAPU16;\n shift = 1;\n } else if (charSize === 4) {\n decodeString = UTF32ToString;\n encodeString = stringToUTF32;\n lengthBytesUTF = lengthBytesUTF32;\n getHeap = () => HEAPU32;\n shift = 2;\n }\n registerType(rawType, { name, \"fromWireType\": function(value) {\n var length = HEAPU32[value >> 2];\n var HEAP = getHeap();\n var str;\n var decodeStartPtr = value + 4;\n for (var i = 0; i <= length; ++i) {\n var currentBytePtr = value + 4 + i * charSize;\n if (i == length || HEAP[currentBytePtr >> shift] == 0) {\n var maxReadBytes = currentBytePtr - decodeStartPtr;\n var stringSegment = decodeString(decodeStartPtr, maxReadBytes);\n if (str === void 0) {\n str = stringSegment;\n } else {\n str += String.fromCharCode(0);\n str += stringSegment;\n }\n decodeStartPtr = currentBytePtr + charSize;\n }\n }\n _free(value);\n return str;\n }, \"toWireType\": function(destructors, value) {\n if (!(typeof value == \"string\")) {\n throwBindingError(\"Cannot pass non-string to C++ string type \" + name);\n }\n var length = lengthBytesUTF(value);\n var ptr = _malloc(4 + length + charSize);\n HEAPU32[ptr >> 2] = length >> shift;\n encodeString(value, ptr + 4, length + charSize);\n if (destructors !== null) {\n destructors.push(_free, ptr);\n }\n return ptr;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": simpleReadValueFromPointer, destructorFunction: function(ptr) {\n _free(ptr);\n } });\n }\n function __embind_register_void(rawType, name) {\n name = readLatin1String(name);\n registerType(rawType, { isVoid: true, name, \"argPackAdvance\": 0, \"fromWireType\": function() {\n return void 0;\n }, \"toWireType\": function(destructors, o) {\n return void 0;\n } });\n }\n function _abort() {\n abort(\"native code called abort()\");\n }\n function _emscripten_memcpy_big(dest, src, num) {\n HEAPU8.copyWithin(dest, src, src + num);\n }\n function getHeapMax() {\n return 2147483648;\n }\n function emscripten_realloc_buffer(size) {\n try {\n wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);\n updateGlobalBufferAndViews(wasmMemory.buffer);\n return 1;\n } catch (e) {\n err(\"emscripten_realloc_buffer: Attempted to grow heap from \" + buffer.byteLength + \" bytes to \" + size + \" bytes, but got error: \" + e);\n }\n }\n function _emscripten_resize_heap(requestedSize) {\n var oldSize = HEAPU8.length;\n requestedSize = requestedSize >>> 0;\n assert(requestedSize > oldSize);\n var maxHeapSize = getHeapMax();\n if (requestedSize > maxHeapSize) {\n err(\"Cannot enlarge memory, asked to go up to \" + requestedSize + \" bytes, but the limit is \" + maxHeapSize + \" bytes!\");\n return false;\n }\n let alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;\n for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {\n var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);\n overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);\n var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));\n var replacement = emscripten_realloc_buffer(newSize);\n if (replacement) {\n return true;\n }\n }\n err(\"Failed to grow the heap from \" + oldSize + \" bytes to \" + newSize + \" bytes, not enough memory!\");\n return false;\n }\n var ENV = {};\n function getExecutableName() {\n return thisProgram || \"./this.program\";\n }\n function getEnvStrings() {\n if (!getEnvStrings.strings) {\n var lang = (typeof navigator == \"object\" && navigator.languages && navigator.languages[0] || \"C\").replace(\"-\", \"_\") + \".UTF-8\";\n var env = { \"USER\": \"web_user\", \"LOGNAME\": \"web_user\", \"PATH\": \"/\", \"PWD\": \"/\", \"HOME\": \"/home/web_user\", \"LANG\": lang, \"_\": getExecutableName() };\n for (var x in ENV) {\n if (ENV[x] === void 0) delete env[x];\n else env[x] = ENV[x];\n }\n var strings = [];\n for (var x in env) {\n strings.push(x + \"=\" + env[x]);\n }\n getEnvStrings.strings = strings;\n }\n return getEnvStrings.strings;\n }\n function writeAsciiToMemory(str, buffer2, dontAddNull) {\n for (var i = 0; i < str.length; ++i) {\n assert(str.charCodeAt(i) === (str.charCodeAt(i) & 255));\n HEAP8[buffer2++ >> 0] = str.charCodeAt(i);\n }\n if (!dontAddNull) HEAP8[buffer2 >> 0] = 0;\n }\n var SYSCALLS = { varargs: void 0, get: function() {\n assert(SYSCALLS.varargs != void 0);\n SYSCALLS.varargs += 4;\n var ret = HEAP32[SYSCALLS.varargs - 4 >> 2];\n return ret;\n }, getStr: function(ptr) {\n var ret = UTF8ToString(ptr);\n return ret;\n } };\n function _environ_get(__environ, environ_buf) {\n var bufSize = 0;\n getEnvStrings().forEach(function(string, i) {\n var ptr = environ_buf + bufSize;\n HEAPU32[__environ + i * 4 >> 2] = ptr;\n writeAsciiToMemory(string, ptr);\n bufSize += string.length + 1;\n });\n return 0;\n }\n function _environ_sizes_get(penviron_count, penviron_buf_size) {\n var strings = getEnvStrings();\n HEAPU32[penviron_count >> 2] = strings.length;\n var bufSize = 0;\n strings.forEach(function(string) {\n bufSize += string.length + 1;\n });\n HEAPU32[penviron_buf_size >> 2] = bufSize;\n return 0;\n }\n function _fd_close(fd) {\n abort(\"fd_close called without SYSCALLS_REQUIRE_FILESYSTEM\");\n }\n function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {\n return 70;\n }\n var printCharBuffers = [null, [], []];\n function printChar(stream, curr) {\n var buffer2 = printCharBuffers[stream];\n assert(buffer2);\n if (curr === 0 || curr === 10) {\n (stream === 1 ? out : err)(UTF8ArrayToString(buffer2, 0));\n buffer2.length = 0;\n } else {\n buffer2.push(curr);\n }\n }\n function flush_NO_FILESYSTEM() {\n _fflush(0);\n if (printCharBuffers[1].length) printChar(1, 10);\n if (printCharBuffers[2].length) printChar(2, 10);\n }\n function _fd_write(fd, iov, iovcnt, pnum) {\n var num = 0;\n for (var i = 0; i < iovcnt; i++) {\n var ptr = HEAPU32[iov >> 2];\n var len = HEAPU32[iov + 4 >> 2];\n iov += 8;\n for (var j = 0; j < len; j++) {\n printChar(fd, HEAPU8[ptr + j]);\n }\n num += len;\n }\n HEAPU32[pnum >> 2] = num;\n return 0;\n }\n function __isLeapYear(year) {\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n }\n function __arraySum(array, index) {\n var sum = 0;\n for (var i = 0; i <= index; sum += array[i++]) {\n }\n return sum;\n }\n var __MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n var __MONTH_DAYS_REGULAR = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n function __addDays(date, days) {\n var newDate = new Date(date.getTime());\n while (days > 0) {\n var leap = __isLeapYear(newDate.getFullYear());\n var currentMonth = newDate.getMonth();\n var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];\n if (days > daysInCurrentMonth - newDate.getDate()) {\n days -= daysInCurrentMonth - newDate.getDate() + 1;\n newDate.setDate(1);\n if (currentMonth < 11) {\n newDate.setMonth(currentMonth + 1);\n } else {\n newDate.setMonth(0);\n newDate.setFullYear(newDate.getFullYear() + 1);\n }\n } else {\n newDate.setDate(newDate.getDate() + days);\n return newDate;\n }\n }\n return newDate;\n }\n function intArrayFromString(stringy, dontAddNull, length) {\n var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;\n var u8array = new Array(len);\n var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);\n if (dontAddNull) u8array.length = numBytesWritten;\n return u8array;\n }\n function _strftime(s, maxsize, format, tm) {\n var tm_zone = HEAP32[tm + 40 >> 2];\n var date = { tm_sec: HEAP32[tm >> 2], tm_min: HEAP32[tm + 4 >> 2], tm_hour: HEAP32[tm + 8 >> 2], tm_mday: HEAP32[tm + 12 >> 2], tm_mon: HEAP32[tm + 16 >> 2], tm_year: HEAP32[tm + 20 >> 2], tm_wday: HEAP32[tm + 24 >> 2], tm_yday: HEAP32[tm + 28 >> 2], tm_isdst: HEAP32[tm + 32 >> 2], tm_gmtoff: HEAP32[tm + 36 >> 2], tm_zone: tm_zone ? UTF8ToString(tm_zone) : \"\" };\n var pattern = UTF8ToString(format);\n var EXPANSION_RULES_1 = { \"%c\": \"%a %b %d %H:%M:%S %Y\", \"%D\": \"%m/%d/%y\", \"%F\": \"%Y-%m-%d\", \"%h\": \"%b\", \"%r\": \"%I:%M:%S %p\", \"%R\": \"%H:%M\", \"%T\": \"%H:%M:%S\", \"%x\": \"%m/%d/%y\", \"%X\": \"%H:%M:%S\", \"%Ec\": \"%c\", \"%EC\": \"%C\", \"%Ex\": \"%m/%d/%y\", \"%EX\": \"%H:%M:%S\", \"%Ey\": \"%y\", \"%EY\": \"%Y\", \"%Od\": \"%d\", \"%Oe\": \"%e\", \"%OH\": \"%H\", \"%OI\": \"%I\", \"%Om\": \"%m\", \"%OM\": \"%M\", \"%OS\": \"%S\", \"%Ou\": \"%u\", \"%OU\": \"%U\", \"%OV\": \"%V\", \"%Ow\": \"%w\", \"%OW\": \"%W\", \"%Oy\": \"%y\" };\n for (var rule in EXPANSION_RULES_1) {\n pattern = pattern.replace(new RegExp(rule, \"g\"), EXPANSION_RULES_1[rule]);\n }\n var WEEKDAYS = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n var MONTHS = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\n function leadingSomething(value, digits, character) {\n var str = typeof value == \"number\" ? value.toString() : value || \"\";\n while (str.length < digits) {\n str = character[0] + str;\n }\n return str;\n }\n function leadingNulls(value, digits) {\n return leadingSomething(value, digits, \"0\");\n }\n function compareByDay(date1, date2) {\n function sgn(value) {\n return value < 0 ? -1 : value > 0 ? 1 : 0;\n }\n var compare;\n if ((compare = sgn(date1.getFullYear() - date2.getFullYear())) === 0) {\n if ((compare = sgn(date1.getMonth() - date2.getMonth())) === 0) {\n compare = sgn(date1.getDate() - date2.getDate());\n }\n }\n return compare;\n }\n function getFirstWeekStartDate(janFourth) {\n switch (janFourth.getDay()) {\n case 0:\n return new Date(janFourth.getFullYear() - 1, 11, 29);\n case 1:\n return janFourth;\n case 2:\n return new Date(janFourth.getFullYear(), 0, 3);\n case 3:\n return new Date(janFourth.getFullYear(), 0, 2);\n case 4:\n return new Date(janFourth.getFullYear(), 0, 1);\n case 5:\n return new Date(janFourth.getFullYear() - 1, 11, 31);\n case 6:\n return new Date(janFourth.getFullYear() - 1, 11, 30);\n }\n }\n function getWeekBasedYear(date2) {\n var thisDate = __addDays(new Date(date2.tm_year + 1900, 0, 1), date2.tm_yday);\n var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);\n var janFourthNextYear = new Date(thisDate.getFullYear() + 1, 0, 4);\n var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);\n var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);\n if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {\n if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {\n return thisDate.getFullYear() + 1;\n }\n return thisDate.getFullYear();\n }\n return thisDate.getFullYear() - 1;\n }\n var EXPANSION_RULES_2 = { \"%a\": function(date2) {\n return WEEKDAYS[date2.tm_wday].substring(0, 3);\n }, \"%A\": function(date2) {\n return WEEKDAYS[date2.tm_wday];\n }, \"%b\": function(date2) {\n return MONTHS[date2.tm_mon].substring(0, 3);\n }, \"%B\": function(date2) {\n return MONTHS[date2.tm_mon];\n }, \"%C\": function(date2) {\n var year = date2.tm_year + 1900;\n return leadingNulls(year / 100 | 0, 2);\n }, \"%d\": function(date2) {\n return leadingNulls(date2.tm_mday, 2);\n }, \"%e\": function(date2) {\n return leadingSomething(date2.tm_mday, 2, \" \");\n }, \"%g\": function(date2) {\n return getWeekBasedYear(date2).toString().substring(2);\n }, \"%G\": function(date2) {\n return getWeekBasedYear(date2);\n }, \"%H\": function(date2) {\n return leadingNulls(date2.tm_hour, 2);\n }, \"%I\": function(date2) {\n var twelveHour = date2.tm_hour;\n if (twelveHour == 0) twelveHour = 12;\n else if (twelveHour > 12) twelveHour -= 12;\n return leadingNulls(twelveHour, 2);\n }, \"%j\": function(date2) {\n return leadingNulls(date2.tm_mday + __arraySum(__isLeapYear(date2.tm_year + 1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date2.tm_mon - 1), 3);\n }, \"%m\": function(date2) {\n return leadingNulls(date2.tm_mon + 1, 2);\n }, \"%M\": function(date2) {\n return leadingNulls(date2.tm_min, 2);\n }, \"%n\": function() {\n return \"\\n\";\n }, \"%p\": function(date2) {\n if (date2.tm_hour >= 0 && date2.tm_hour < 12) {\n return \"AM\";\n }\n return \"PM\";\n }, \"%S\": function(date2) {\n return leadingNulls(date2.tm_sec, 2);\n }, \"%t\": function() {\n return \"\t\";\n }, \"%u\": function(date2) {\n return date2.tm_wday || 7;\n }, \"%U\": function(date2) {\n var days = date2.tm_yday + 7 - date2.tm_wday;\n return leadingNulls(Math.floor(days / 7), 2);\n }, \"%V\": function(date2) {\n var val = Math.floor((date2.tm_yday + 7 - (date2.tm_wday + 6) % 7) / 7);\n if ((date2.tm_wday + 371 - date2.tm_yday - 2) % 7 <= 2) {\n val++;\n }\n if (!val) {\n val = 52;\n var dec31 = (date2.tm_wday + 7 - date2.tm_yday - 1) % 7;\n if (dec31 == 4 || dec31 == 5 && __isLeapYear(date2.tm_year % 400 - 1)) {\n val++;\n }\n } else if (val == 53) {\n var jan1 = (date2.tm_wday + 371 - date2.tm_yday) % 7;\n if (jan1 != 4 && (jan1 != 3 || !__isLeapYear(date2.tm_year))) val = 1;\n }\n return leadingNulls(val, 2);\n }, \"%w\": function(date2) {\n return date2.tm_wday;\n }, \"%W\": function(date2) {\n var days = date2.tm_yday + 7 - (date2.tm_wday + 6) % 7;\n return leadingNulls(Math.floor(days / 7), 2);\n }, \"%y\": function(date2) {\n return (date2.tm_year + 1900).toString().substring(2);\n }, \"%Y\": function(date2) {\n return date2.tm_year + 1900;\n }, \"%z\": function(date2) {\n var off = date2.tm_gmtoff;\n var ahead = off >= 0;\n off = Math.abs(off) / 60;\n off = off / 60 * 100 + off % 60;\n return (ahead ? \"+\" : \"-\") + String(\"0000\" + off).slice(-4);\n }, \"%Z\": function(date2) {\n return date2.tm_zone;\n }, \"%%\": function() {\n return \"%\";\n } };\n pattern = pattern.replace(/%%/g, \"\\0\\0\");\n for (var rule in EXPANSION_RULES_2) {\n if (pattern.includes(rule)) {\n pattern = pattern.replace(new RegExp(rule, \"g\"), EXPANSION_RULES_2[rule](date));\n }\n }\n pattern = pattern.replace(/\\0\\0/g, \"%\");\n var bytes = intArrayFromString(pattern, false);\n if (bytes.length > maxsize) {\n return 0;\n }\n writeArrayToMemory(bytes, s);\n return bytes.length - 1;\n }\n function _strftime_l(s, maxsize, format, tm) {\n return _strftime(s, maxsize, format, tm);\n }\n function uleb128Encode(n, target) {\n assert(n < 16384);\n if (n < 128) {\n target.push(n);\n } else {\n target.push(n % 128 | 128, n >> 7);\n }\n }\n function sigToWasmTypes(sig) {\n var typeNames = { \"i\": \"i32\", \"j\": \"i64\", \"f\": \"f32\", \"d\": \"f64\", \"p\": \"i32\" };\n var type = { parameters: [], results: sig[0] == \"v\" ? [] : [typeNames[sig[0]]] };\n for (var i = 1; i < sig.length; ++i) {\n assert(sig[i] in typeNames, \"invalid signature char: \" + sig[i]);\n type.parameters.push(typeNames[sig[i]]);\n }\n return type;\n }\n function convertJsFunctionToWasm(func, sig) {\n if (typeof WebAssembly.Function == \"function\") {\n return new WebAssembly.Function(sigToWasmTypes(sig), func);\n }\n var typeSectionBody = [1, 96];\n var sigRet = sig.slice(0, 1);\n var sigParam = sig.slice(1);\n var typeCodes = { \"i\": 127, \"p\": 127, \"j\": 126, \"f\": 125, \"d\": 124 };\n uleb128Encode(sigParam.length, typeSectionBody);\n for (var i = 0; i < sigParam.length; ++i) {\n assert(sigParam[i] in typeCodes, \"invalid signature char: \" + sigParam[i]);\n typeSectionBody.push(typeCodes[sigParam[i]]);\n }\n if (sigRet == \"v\") {\n typeSectionBody.push(0);\n } else {\n typeSectionBody.push(1, typeCodes[sigRet]);\n }\n var bytes = [0, 97, 115, 109, 1, 0, 0, 0, 1];\n uleb128Encode(typeSectionBody.length, bytes);\n bytes.push.apply(bytes, typeSectionBody);\n bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);\n var module2 = new WebAssembly.Module(new Uint8Array(bytes));\n var instance = new WebAssembly.Instance(module2, { \"e\": { \"f\": func } });\n var wrappedFunc = instance.exports[\"f\"];\n return wrappedFunc;\n }\n function updateTableMap(offset, count) {\n if (functionsInTableMap) {\n for (var i = offset; i < offset + count; i++) {\n var item = getWasmTableEntry(i);\n if (item) {\n functionsInTableMap.set(item, i);\n }\n }\n }\n }\n var functionsInTableMap = void 0;\n var freeTableIndexes = [];\n function getEmptyTableSlot() {\n if (freeTableIndexes.length) {\n return freeTableIndexes.pop();\n }\n try {\n wasmTable.grow(1);\n } catch (err2) {\n if (!(err2 instanceof RangeError)) {\n throw err2;\n }\n throw \"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.\";\n }\n return wasmTable.length - 1;\n }\n function setWasmTableEntry(idx, func) {\n wasmTable.set(idx, func);\n wasmTableMirror[idx] = wasmTable.get(idx);\n }\n var ALLOC_STACK = 1;\n function getCFunc(ident) {\n var func = Module[\"_\" + ident];\n assert(func, \"Cannot call unknown function \" + ident + \", make sure it is exported\");\n return func;\n }\n function ccall(ident, returnType, argTypes, args, opts) {\n var toC = { \"string\": (str) => {\n var ret2 = 0;\n if (str !== null && str !== void 0 && str !== 0) {\n var len = (str.length << 2) + 1;\n ret2 = stackAlloc(len);\n stringToUTF8(str, ret2, len);\n }\n return ret2;\n }, \"array\": (arr) => {\n var ret2 = stackAlloc(arr.length);\n writeArrayToMemory(arr, ret2);\n return ret2;\n } };\n function convertReturnValue(ret2) {\n if (returnType === \"string\") {\n return UTF8ToString(ret2);\n }\n if (returnType === \"boolean\") return Boolean(ret2);\n return ret2;\n }\n var func = getCFunc(ident);\n var cArgs = [];\n var stack = 0;\n assert(returnType !== \"array\", 'Return type should not be \"array\".');\n if (args) {\n for (var i = 0; i < args.length; i++) {\n var converter = toC[argTypes[i]];\n if (converter) {\n if (stack === 0) stack = stackSave();\n cArgs[i] = converter(args[i]);\n } else {\n cArgs[i] = args[i];\n }\n }\n }\n var ret = func.apply(null, cArgs);\n function onDone(ret2) {\n if (stack !== 0) stackRestore(stack);\n return convertReturnValue(ret2);\n }\n ret = onDone(ret);\n return ret;\n }\n embind_init_charCodes();\n BindingError = Module[\"BindingError\"] = extendError(Error, \"BindingError\");\n InternalError = Module[\"InternalError\"] = extendError(Error, \"InternalError\");\n init_ClassHandle();\n init_embind();\n init_RegisteredPointer();\n UnboundTypeError = Module[\"UnboundTypeError\"] = extendError(Error, \"UnboundTypeError\");\n init_emval();\n var ASSERTIONS = true;\n function checkIncomingModuleAPI() {\n ignoredModuleProp(\"fetchSettings\");\n }\n var asmLibraryArg = { \"__cxa_allocate_exception\": ___cxa_allocate_exception, \"__cxa_throw\": ___cxa_throw, \"_embind_register_bigint\": __embind_register_bigint, \"_embind_register_bool\": __embind_register_bool, \"_embind_register_class\": __embind_register_class, \"_embind_register_class_constructor\": __embind_register_class_constructor, \"_embind_register_class_function\": __embind_register_class_function, \"_embind_register_emval\": __embind_register_emval, \"_embind_register_float\": __embind_register_float, \"_embind_register_integer\": __embind_register_integer, \"_embind_register_memory_view\": __embind_register_memory_view, \"_embind_register_std_string\": __embind_register_std_string, \"_embind_register_std_wstring\": __embind_register_std_wstring, \"_embind_register_void\": __embind_register_void, \"abort\": _abort, \"emscripten_memcpy_big\": _emscripten_memcpy_big, \"emscripten_resize_heap\": _emscripten_resize_heap, \"environ_get\": _environ_get, \"environ_sizes_get\": _environ_sizes_get, \"fd_close\": _fd_close, \"fd_seek\": _fd_seek, \"fd_write\": _fd_write, \"strftime_l\": _strftime_l };\n var asm = createWasm();\n var ___wasm_call_ctors = Module[\"___wasm_call_ctors\"] = createExportWrapper(\"__wasm_call_ctors\");\n var _malloc = Module[\"_malloc\"] = createExportWrapper(\"malloc\");\n var _free = Module[\"_free\"] = createExportWrapper(\"free\");\n var ___getTypeName = Module[\"___getTypeName\"] = createExportWrapper(\"__getTypeName\");\n var __embind_initialize_bindings = Module[\"__embind_initialize_bindings\"] = createExportWrapper(\"_embind_initialize_bindings\");\n var ___errno_location = Module[\"___errno_location\"] = createExportWrapper(\"__errno_location\");\n var _fflush = Module[\"_fflush\"] = createExportWrapper(\"fflush\");\n var _emscripten_stack_init = Module[\"_emscripten_stack_init\"] = function() {\n return (_emscripten_stack_init = Module[\"_emscripten_stack_init\"] = Module[\"asm\"][\"emscripten_stack_init\"]).apply(null, arguments);\n };\n var _emscripten_stack_get_free = Module[\"_emscripten_stack_get_free\"] = function() {\n return (_emscripten_stack_get_free = Module[\"_emscripten_stack_get_free\"] = Module[\"asm\"][\"emscripten_stack_get_free\"]).apply(null, arguments);\n };\n var _emscripten_stack_get_base = Module[\"_emscripten_stack_get_base\"] = function() {\n return (_emscripten_stack_get_base = Module[\"_emscripten_stack_get_base\"] = Module[\"asm\"][\"emscripten_stack_get_base\"]).apply(null, arguments);\n };\n var _emscripten_stack_get_end = Module[\"_emscripten_stack_get_end\"] = function() {\n return (_emscripten_stack_get_end = Module[\"_emscripten_stack_get_end\"] = Module[\"asm\"][\"emscripten_stack_get_end\"]).apply(null, arguments);\n };\n var stackSave = Module[\"stackSave\"] = createExportWrapper(\"stackSave\");\n var stackRestore = Module[\"stackRestore\"] = createExportWrapper(\"stackRestore\");\n var stackAlloc = Module[\"stackAlloc\"] = createExportWrapper(\"stackAlloc\");\n var ___cxa_is_pointer_type = Module[\"___cxa_is_pointer_type\"] = createExportWrapper(\"__cxa_is_pointer_type\");\n var dynCall_viijii = Module[\"dynCall_viijii\"] = createExportWrapper(\"dynCall_viijii\");\n var dynCall_ji = Module[\"dynCall_ji\"] = createExportWrapper(\"dynCall_ji\");\n var dynCall_jiji = Module[\"dynCall_jiji\"] = createExportWrapper(\"dynCall_jiji\");\n var dynCall_iiiiij = Module[\"dynCall_iiiiij\"] = createExportWrapper(\"dynCall_iiiiij\");\n var dynCall_iiiiijj = Module[\"dynCall_iiiiijj\"] = createExportWrapper(\"dynCall_iiiiijj\");\n var dynCall_iiiiiijj = Module[\"dynCall_iiiiiijj\"] = createExportWrapper(\"dynCall_iiiiiijj\");\n var unexportedRuntimeSymbols = [\"run\", \"UTF8ArrayToString\", \"UTF8ToString\", \"stringToUTF8Array\", \"stringToUTF8\", \"lengthBytesUTF8\", \"addOnPreRun\", \"addOnInit\", \"addOnPreMain\", \"addOnExit\", \"addOnPostRun\", \"addRunDependency\", \"removeRunDependency\", \"FS_createFolder\", \"FS_createPath\", \"FS_createDataFile\", \"FS_createPreloadedFile\", \"FS_createLazyFile\", \"FS_createLink\", \"FS_createDevice\", \"FS_unlink\", \"getLEB\", \"getFunctionTables\", \"alignFunctionTables\", \"registerFunctions\", \"prettyPrint\", \"getCompilerSetting\", \"print\", \"printErr\", \"callMain\", \"abort\", \"keepRuntimeAlive\", \"wasmMemory\", \"stackAlloc\", \"stackSave\", \"stackRestore\", \"getTempRet0\", \"setTempRet0\", \"writeStackCookie\", \"checkStackCookie\", \"ptrToString\", \"zeroMemory\", \"stringToNewUTF8\", \"exitJS\", \"getHeapMax\", \"emscripten_realloc_buffer\", \"ENV\", \"ERRNO_CODES\", \"ERRNO_MESSAGES\", \"setErrNo\", \"inetPton4\", \"inetNtop4\", \"inetPton6\", \"inetNtop6\", \"readSockaddr\", \"writeSockaddr\", \"DNS\", \"getHostByName\", \"Protocols\", \"Sockets\", \"getRandomDevice\", \"warnOnce\", \"traverseStack\", \"UNWIND_CACHE\", \"convertPCtoSourceLocation\", \"readAsmConstArgsArray\", \"readAsmConstArgs\", \"mainThreadEM_ASM\", \"jstoi_q\", \"jstoi_s\", \"getExecutableName\", \"listenOnce\", \"autoResumeAudioContext\", \"dynCallLegacy\", \"getDynCaller\", \"dynCall\", \"handleException\", \"runtimeKeepalivePush\", \"runtimeKeepalivePop\", \"callUserCallback\", \"maybeExit\", \"safeSetTimeout\", \"asmjsMangle\", \"asyncLoad\", \"alignMemory\", \"mmapAlloc\", \"writeI53ToI64\", \"writeI53ToI64Clamped\", \"writeI53ToI64Signaling\", \"writeI53ToU64Clamped\", \"writeI53ToU64Signaling\", \"readI53FromI64\", \"readI53FromU64\", \"convertI32PairToI53\", \"convertI32PairToI53Checked\", \"convertU32PairToI53\", \"getCFunc\", \"ccall\", \"cwrap\", \"uleb128Encode\", \"sigToWasmTypes\", \"convertJsFunctionToWasm\", \"freeTableIndexes\", \"functionsInTableMap\", \"getEmptyTableSlot\", \"updateTableMap\", \"addFunction\", \"removeFunction\", \"reallyNegative\", \"unSign\", \"strLen\", \"reSign\", \"formatString\", \"setValue\", \"getValue\", \"PATH\", \"PATH_FS\", \"intArrayFromString\", \"intArrayToString\", \"AsciiToString\", \"stringToAscii\", \"UTF16Decoder\", \"UTF16ToString\", \"stringToUTF16\", \"lengthBytesUTF16\", \"UTF32ToString\", \"stringToUTF32\", \"lengthBytesUTF32\", \"allocateUTF8\", \"allocateUTF8OnStack\", \"writeStringToMemory\", \"writeArrayToMemory\", \"writeAsciiToMemory\", \"SYSCALLS\", \"getSocketFromFD\", \"getSocketAddress\", \"JSEvents\", \"registerKeyEventCallback\", \"specialHTMLTargets\", \"maybeCStringToJsString\", \"findEventTarget\", \"findCanvasEventTarget\", \"getBoundingClientRect\", \"fillMouseEventData\", \"registerMouseEventCallback\", \"registerWheelEventCallback\", \"registerUiEventCallback\", \"registerFocusEventCallback\", \"fillDeviceOrientationEventData\", \"registerDeviceOrientationEventCallback\", \"fillDeviceMotionEventData\", \"registerDeviceMotionEventCallback\", \"screenOrientation\", \"fillOrientationChangeEventData\", \"registerOrientationChangeEventCallback\", \"fillFullscreenChangeEventData\", \"registerFullscreenChangeEventCallback\", \"JSEvents_requestFullscreen\", \"JSEvents_resizeCanvasForFullscreen\", \"registerRestoreOldStyle\", \"hideEverythingExceptGivenElement\", \"restoreHiddenElements\", \"setLetterbox\", \"currentFullscreenStrategy\", \"restoreOldWindowedStyle\", \"softFullscreenResizeWebGLRenderTarget\", \"doRequestFullscreen\", \"fillPointerlockChangeEventData\", \"registerPointerlockChangeEventCallback\", \"registerPointerlockErrorEventCallback\", \"requestPointerLock\", \"fillVisibilityChangeEventData\", \"registerVisibilityChangeEventCallback\", \"registerTouchEventCallback\", \"fillGamepadEventData\", \"registerGamepadEventCallback\", \"registerBeforeUnloadEventCallback\", \"fillBatteryEventData\", \"battery\", \"registerBatteryEventCallback\", \"setCanvasElementSize\", \"getCanvasElementSize\", \"demangle\", \"demangleAll\", \"jsStackTrace\", \"stackTrace\", \"ExitStatus\", \"getEnvStrings\", \"checkWasiClock\", \"flush_NO_FILESYSTEM\", \"dlopenMissingError\", \"setImmediateWrapped\", \"clearImmediateWrapped\", \"polyfillSetImmediate\", \"uncaughtExceptionCount\", \"exceptionLast\", \"exceptionCaught\", \"ExceptionInfo\", \"exception_addRef\", \"exception_decRef\", \"Browser\", \"setMainLoop\", \"wget\", \"FS\", \"MEMFS\", \"TTY\", \"PIPEFS\", \"SOCKFS\", \"_setNetworkCallback\", \"tempFixedLengthArray\", \"miniTempWebGLFloatBuffers\", \"heapObjectForWebGLType\", \"heapAccessShiftForWebGLHeap\", \"GL\", \"emscriptenWebGLGet\", \"computeUnpackAlignedImageSize\", \"emscriptenWebGLGetTexPixelData\", \"emscriptenWebGLGetUniform\", \"webglGetUniformLocation\", \"webglPrepareUniformLocationsBeforeFirstUse\", \"webglGetLeftBracePos\", \"emscriptenWebGLGetVertexAttrib\", \"writeGLArray\", \"AL\", \"SDL_unicode\", \"SDL_ttfContext\", \"SDL_audio\", \"SDL\", \"SDL_gfx\", \"GLUT\", \"EGL\", \"GLFW_Window\", \"GLFW\", \"GLEW\", \"IDBStore\", \"runAndAbortIfError\", \"ALLOC_NORMAL\", \"ALLOC_STACK\", \"allocate\", \"InternalError\", \"BindingError\", \"UnboundTypeError\", \"PureVirtualError\", \"init_embind\", \"throwInternalError\", \"throwBindingError\", \"throwUnboundTypeError\", \"ensureOverloadTable\", \"exposePublicSymbol\", \"replacePublicSymbol\", \"extendError\", \"createNamedFunction\", \"embindRepr\", \"registeredInstances\", \"getBasestPointer\", \"registerInheritedInstance\", \"unregisterInheritedInstance\", \"getInheritedInstance\", \"getInheritedInstanceCount\", \"getLiveInheritedInstances\", \"registeredTypes\", \"awaitingDependencies\", \"typeDependencies\", \"registeredPointers\", \"registerType\", \"whenDependentTypesAreResolved\", \"embind_charCodes\", \"embind_init_charCodes\", \"readLatin1String\", \"getTypeName\", \"heap32VectorToArray\", \"requireRegisteredType\", \"getShiftFromSize\", \"integerReadValueFromPointer\", \"enumReadValueFromPointer\", \"floatReadValueFromPointer\", \"simpleReadValueFromPointer\", \"runDestructors\", \"new_\", \"craftInvokerFunction\", \"embind__requireFunction\", \"tupleRegistrations\", \"structRegistrations\", \"genericPointerToWireType\", \"constNoSmartPtrRawPointerToWireType\", \"nonConstNoSmartPtrRawPointerToWireType\", \"init_RegisteredPointer\", \"RegisteredPointer\", \"RegisteredPointer_getPointee\", \"RegisteredPointer_destructor\", \"RegisteredPointer_deleteObject\", \"RegisteredPointer_fromWireType\", \"runDestructor\", \"releaseClassHandle\", \"finalizationRegistry\", \"detachFinalizer_deps\", \"detachFinalizer\", \"attachFinalizer\", \"makeClassHandle\", \"init_ClassHandle\", \"ClassHandle\", \"ClassHandle_isAliasOf\", \"throwInstanceAlreadyDeleted\", \"ClassHandle_clone\", \"ClassHandle_delete\", \"deletionQueue\", \"ClassHandle_isDeleted\", \"ClassHandle_deleteLater\", \"flushPendingDeletes\", \"delayFunction\", \"setDelayFunction\", \"RegisteredClass\", \"shallowCopyInternalPointer\", \"downcastPointer\", \"upcastPointer\", \"validateThis\", \"char_0\", \"char_9\", \"makeLegalFunctionName\", \"emval_handle_array\", \"emval_free_list\", \"emval_symbols\", \"init_emval\", \"count_emval_handles\", \"get_first_emval\", \"getStringOrSymbol\", \"Emval\", \"emval_newers\", \"craftEmvalAllocator\", \"emval_get_global\", \"emval_lookupTypes\", \"emval_allocateDestructors\", \"emval_methodCallers\", \"emval_addMethodCaller\", \"emval_registeredMethods\"];\n unexportedRuntimeSymbols.forEach(unexportedRuntimeSymbol);\n var missingLibrarySymbols = [\"ptrToString\", \"zeroMemory\", \"stringToNewUTF8\", \"exitJS\", \"setErrNo\", \"inetPton4\", \"inetNtop4\", \"inetPton6\", \"inetNtop6\", \"readSockaddr\", \"writeSockaddr\", \"getHostByName\", \"getRandomDevice\", \"traverseStack\", \"convertPCtoSourceLocation\", \"readAsmConstArgs\", \"mainThreadEM_ASM\", \"jstoi_q\", \"jstoi_s\", \"listenOnce\", \"autoResumeAudioContext\", \"runtimeKeepalivePush\", \"runtimeKeepalivePop\", \"callUserCallback\", \"maybeExit\", \"safeSetTimeout\", \"asmjsMangle\", \"asyncLoad\", \"alignMemory\", \"mmapAlloc\", \"writeI53ToI64\", \"writeI53ToI64Clamped\", \"writeI53ToI64Signaling\", \"writeI53ToU64Clamped\", \"writeI53ToU64Signaling\", \"readI53FromI64\", \"readI53FromU64\", \"convertI32PairToI53\", \"convertU32PairToI53\", \"reallyNegative\", \"unSign\", \"strLen\", \"reSign\", \"formatString\", \"getSocketFromFD\", \"getSocketAddress\", \"registerKeyEventCallback\", \"maybeCStringToJsString\", \"findEventTarget\", \"findCanvasEventTarget\", \"getBoundingClientRect\", \"fillMouseEventData\", \"registerMouseEventCallback\", \"registerWheelEventCallback\", \"registerUiEventCallback\", \"registerFocusEventCallback\", \"fillDeviceOrientationEventData\", \"registerDeviceOrientationEventCallback\", \"fillDeviceMotionEventData\", \"registerDeviceMotionEventCallback\", \"screenOrientation\", \"fillOrientationChangeEventData\", \"registerOrientationChangeEventCallback\", \"fillFullscreenChangeEventData\", \"registerFullscreenChangeEventCallback\", \"JSEvents_requestFullscreen\", \"JSEvents_resizeCanvasForFullscreen\", \"registerRestoreOldStyle\", \"hideEverythingExceptGivenElement\", \"restoreHiddenElements\", \"setLetterbox\", \"softFullscreenResizeWebGLRenderTarget\", \"doRequestFullscreen\", \"fillPointerlockChangeEventData\", \"registerPointerlockChangeEventCallback\", \"registerPointerlockErrorEventCallback\", \"requestPointerLock\", \"fillVisibilityChangeEventData\", \"registerVisibilityChangeEventCallback\", \"registerTouchEventCallback\", \"fillGamepadEventData\", \"registerGamepadEventCallback\", \"registerBeforeUnloadEventCallback\", \"fillBatteryEventData\", \"battery\", \"registerBatteryEventCallback\", \"setCanvasElementSize\", \"getCanvasElementSize\", \"checkWasiClock\", \"setImmediateWrapped\", \"clearImmediateWrapped\", \"polyfillSetImmediate\", \"exception_addRef\", \"exception_decRef\", \"setMainLoop\", \"_setNetworkCallback\", \"heapObjectForWebGLType\", \"heapAccessShiftForWebGLHeap\", \"emscriptenWebGLGet\", \"computeUnpackAlignedImageSize\", \"emscriptenWebGLGetTexPixelData\", \"emscriptenWebGLGetUniform\", \"webglGetUniformLocation\", \"webglPrepareUniformLocationsBeforeFirstUse\", \"webglGetLeftBracePos\", \"emscriptenWebGLGetVertexAttrib\", \"writeGLArray\", \"SDL_unicode\", \"SDL_ttfContext\", \"SDL_audio\", \"GLFW_Window\", \"runAndAbortIfError\", \"registerInheritedInstance\", \"unregisterInheritedInstance\", \"requireRegisteredType\", \"enumReadValueFromPointer\", \"validateThis\", \"getStringOrSymbol\", \"craftEmvalAllocator\", \"emval_get_global\", \"emval_lookupTypes\", \"emval_allocateDestructors\", \"emval_addMethodCaller\"];\n missingLibrarySymbols.forEach(missingLibrarySymbol);\n var calledRun;\n dependenciesFulfilled = function runCaller() {\n if (!calledRun) run();\n if (!calledRun) dependenciesFulfilled = runCaller;\n };\n function stackCheckInit() {\n _emscripten_stack_init();\n writeStackCookie();\n }\n function run(args) {\n args = args || arguments_;\n if (runDependencies > 0) {\n return;\n }\n stackCheckInit();\n preRun();\n if (runDependencies > 0) {\n return;\n }\n function doRun() {\n if (calledRun) return;\n calledRun = true;\n Module[\"calledRun\"] = true;\n if (ABORT) return;\n initRuntime();\n readyPromiseResolve(Module);\n if (Module[\"onRuntimeInitialized\"]) Module[\"onRuntimeInitialized\"]();\n assert(!Module[\"_main\"], 'compiled without a main, but one is present. if you added it from JS, use Module[\"onRuntimeInitialized\"]');\n postRun();\n }\n if (Module[\"setStatus\"]) {\n Module[\"setStatus\"](\"Running...\");\n setTimeout(function() {\n setTimeout(function() {\n Module[\"setStatus\"](\"\");\n }, 1);\n doRun();\n }, 1);\n } else {\n doRun();\n }\n checkStackCookie();\n }\n if (Module[\"preInit\"]) {\n if (typeof Module[\"preInit\"] == \"function\") Module[\"preInit\"] = [Module[\"preInit\"]];\n while (Module[\"preInit\"].length > 0) {\n Module[\"preInit\"].pop()();\n }\n }\n run();\n return createLazPerf2.ready;\n };\n })();\n if (typeof exports === \"object\" && typeof module === \"object\")\n module.exports = createLazPerf;\n else if (typeof define === \"function\" && define[\"amd\"])\n define([], function() {\n return createLazPerf;\n });\n else if (typeof exports === \"object\")\n exports[\"createLazPerf\"] = createLazPerf;\n }\n });\n\n // ../../node_modules/.pnpm/laz-perf@0.0.6/node_modules/laz-perf/lib/web/index.js\n var require_web = __commonJS({\n \"../../node_modules/.pnpm/laz-perf@0.0.6/node_modules/laz-perf/lib/web/index.js\"(exports) {\n \"use strict\";\n var __importDefault = exports && exports.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n };\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.LazPerf = exports.create = exports.createLazPerf = void 0;\n var laz_perf_js_1 = __importDefault(require_laz_perf());\n exports.createLazPerf = laz_perf_js_1.default;\n exports.create = laz_perf_js_1.default;\n exports.LazPerf = { create: laz_perf_js_1.default };\n }\n });\n\n // dist/streaming/laz-source.js\n var laz_source_exports = {};\n __export(laz_source_exports, {\n LazStreamingSource: () => LazStreamingSource\n });\n async function loadLazPerf() {\n if (!modulePromise) {\n modulePromise = (async () => {\n const wasmBinary = await fetchLazPerfWasm();\n const ns = await Promise.resolve().then(() => __toESM(require_web(), 1));\n const dflt = ns.default;\n const candidates = [\n ns.createLazPerf,\n typeof dflt === \"object\" && dflt !== null ? dflt.createLazPerf : void 0,\n dflt,\n // Some bundlers expose the CJS module as the namespace object itself.\n ns\n ];\n const factory = candidates.find((c) => typeof c === \"function\");\n if (!factory) {\n const keys = Object.keys(ns).join(\", \");\n throw new Error(`laz-perf: could not find createLazPerf factory (saw keys: ${keys || \"<empty>\"})`);\n }\n return factory({ wasmBinary });\n })();\n }\n return modulePromise;\n }\n async function fetchLazPerfWasm() {\n let wasmUrl;\n try {\n const mod = await import(\"laz-perf/lib/web/laz-perf.wasm?url\");\n wasmUrl = mod.default;\n } catch (err) {\n throw new Error(`laz-perf: could not resolve wasm asset URL (${err instanceof Error ? err.message : String(err)}). Ensure the bundler treats \\`laz-perf/lib/web/laz-perf.wasm?url\\` as a static asset.`);\n }\n const response = await fetch(wasmUrl);\n if (!response.ok) {\n throw new Error(`laz-perf: wasm fetch failed (${response.status} ${response.statusText}) for ${wasmUrl}`);\n }\n const buffer = await response.arrayBuffer();\n return new Uint8Array(buffer);\n }\n function abortIfAborted2(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var modulePromise, LazStreamingSource;\n var init_laz_source = __esm({\n \"dist/streaming/laz-source.js\"() {\n \"use strict\";\n init_las();\n modulePromise = null;\n LazStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n // Populated by open()\n __publicField(this, \"mod\", null);\n __publicField(this, \"laszip\", null);\n __publicField(this, \"header\", null);\n __publicField(this, \"fileBytes\", null);\n __publicField(this, \"filePtr\", 0);\n __publicField(this, \"pointPtr\", 0);\n __publicField(this, \"pointBuffer\", null);\n __publicField(this, \"cursor\", 0);\n __publicField(this, \"rgbScale\", 1);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n if (this.header)\n return this.toInfo(this.header);\n abortIfAborted2(signal);\n let mod;\n let filePtr = 0;\n let pointPtr = 0;\n let laszip;\n try {\n const buf = await this.blob.arrayBuffer();\n abortIfAborted2(signal);\n const bytes = new Uint8Array(buf);\n const header = parseLasHeader(bytes);\n mod = await loadLazPerf();\n abortIfAborted2(signal);\n filePtr = mod._malloc(bytes.byteLength);\n mod.HEAPU8.set(bytes, filePtr);\n laszip = new mod.LASZip();\n laszip.open(filePtr, bytes.byteLength);\n const pointSize = laszip.getPointLength();\n pointPtr = mod._malloc(pointSize);\n const pointBuffer = new Uint8Array(pointSize);\n let rgbScale = 1;\n if (header.hasRgb) {\n const probe = Math.min(4096, header.pointCount);\n const tempBuf = new Uint8Array(probe * pointSize);\n for (let i = 0; i < probe; i++) {\n laszip.getPoint(pointPtr);\n tempBuf.set(mod.HEAPU8.subarray(pointPtr, pointPtr + pointSize), i * pointSize);\n }\n const max = sampleMaxRgbChannel(tempBuf, header);\n rgbScale = max > 0 && max <= 255 ? 65535 / 255 : 1;\n laszip.delete();\n laszip = new mod.LASZip();\n laszip.open(filePtr, bytes.byteLength);\n }\n this.fileBytes = bytes;\n this.mod = mod;\n this.filePtr = filePtr;\n this.laszip = laszip;\n this.pointPtr = pointPtr;\n this.pointBuffer = pointBuffer;\n this.rgbScale = rgbScale;\n this.header = header;\n this.cursor = 0;\n return this.toInfo(header);\n } catch (err) {\n try {\n laszip?.delete();\n } catch {\n }\n if (mod && pointPtr) {\n try {\n mod._free(pointPtr);\n } catch {\n }\n }\n if (mod && filePtr) {\n try {\n mod._free(filePtr);\n } catch {\n }\n }\n throw err;\n }\n }\n async next(maxPoints, signal) {\n abortIfAborted2(signal);\n if (!Number.isFinite(maxPoints) || maxPoints <= 0) {\n throw new Error(`LazStreamingSource: maxPoints must be > 0 (got ${maxPoints})`);\n }\n if (!this.header || !this.mod || !this.laszip || !this.pointBuffer) {\n throw new Error(\"LazStreamingSource: open() must be awaited before next()\");\n }\n const stride = Math.max(1, this.downsample.stride | 0);\n if (this.cursor >= this.header.pointCount)\n return null;\n const pointSize = this.pointBuffer.byteLength;\n const remainingSource = this.header.pointCount - this.cursor;\n const sourceTake = stride === 1 ? Math.min(maxPoints, remainingSource) : Math.min(maxPoints * stride, remainingSource);\n const decodedCount = stride === 1 ? sourceTake : Math.ceil(sourceTake / stride);\n const slab = new Uint8Array(decodedCount * pointSize);\n let writeIdx = 0;\n for (let i = 0; i < sourceTake; i++) {\n this.laszip.getPoint(this.pointPtr);\n if (stride === 1 || i % stride === 0) {\n slab.set(this.mod.HEAPU8.subarray(this.pointPtr, this.pointPtr + pointSize), writeIdx * pointSize);\n writeIdx++;\n }\n }\n this.cursor += sourceTake;\n return decodeLasPoints(slab, this.header, decodedCount, pointSize, this.rgbScale);\n }\n close() {\n try {\n this.laszip?.delete();\n } catch {\n }\n if (this.mod && this.pointPtr) {\n try {\n this.mod._free(this.pointPtr);\n } catch {\n }\n }\n if (this.mod && this.filePtr) {\n try {\n this.mod._free(this.filePtr);\n } catch {\n }\n }\n this.laszip = null;\n this.mod = null;\n this.header = null;\n this.fileBytes = null;\n this.pointBuffer = null;\n this.filePtr = 0;\n this.pointPtr = 0;\n this.cursor = 0;\n }\n toInfo(header) {\n const stride = Math.max(1, this.downsample.stride | 0);\n return {\n totalPointCount: stride === 1 ? header.pointCount : Math.ceil(header.pointCount / stride),\n bbox: header.bbox,\n hasColor: header.hasRgb,\n hasClassification: true,\n hasIntensity: true,\n label: this.label\n };\n }\n };\n }\n });\n\n // dist/formats/ply.js\n function parsePlyHeader(buffer) {\n const probeLen = Math.min(65536, buffer.length);\n const probe = TEXT_DECODER.decode(buffer.subarray(0, probeLen));\n if (!probe.startsWith(\"ply\")) {\n throw new Error('PLY: missing magic \\u2014 file does not start with \"ply\"');\n }\n const endIdx = probe.indexOf(\"end_header\");\n if (endIdx < 0) {\n throw new Error(\"PLY: missing end_header line in first \" + probeLen + \" bytes\");\n }\n const newline = probe.indexOf(\"\\n\", endIdx);\n if (newline < 0) {\n throw new Error(\"PLY: end_header line not terminated by newline\");\n }\n const headerText = probe.slice(0, newline + 1);\n const bodyOffset = newline + 1;\n const lines = headerText.split(\"\\n\").map((l) => l.trim()).filter((l) => l.length > 0);\n let format = null;\n let version = \"1.0\";\n const elements = [];\n let current = null;\n for (const line of lines) {\n if (line === \"ply\" || line === \"end_header\")\n continue;\n if (line.startsWith(\"comment\"))\n continue;\n if (line.startsWith(\"obj_info\"))\n continue;\n if (line.startsWith(\"format \")) {\n const parts = line.split(/\\s+/);\n const f = parts[1];\n version = parts[2] ?? \"1.0\";\n if (f === \"ascii\" || f === \"binary_little_endian\" || f === \"binary_big_endian\") {\n format = f;\n } else {\n throw new Error(`PLY: unsupported format \"${f}\"`);\n }\n continue;\n }\n if (line.startsWith(\"element \")) {\n const parts = line.split(/\\s+/);\n current = {\n name: parts[1],\n count: parseInt(parts[2], 10),\n properties: [],\n recordSize: 0\n };\n elements.push(current);\n continue;\n }\n if (line.startsWith(\"property \")) {\n if (!current) {\n throw new Error(`PLY: property declared before any element: \"${line}\"`);\n }\n const parts = line.split(/\\s+/);\n if (parts[1] === \"list\")\n continue;\n const type = parts[1];\n const name = parts[2];\n const size = TYPE_SIZES[type];\n if (size === void 0) {\n throw new Error(`PLY: unknown property type \"${type}\"`);\n }\n current.properties.push({ name, type, size, offset: current.recordSize });\n current.recordSize += size;\n continue;\n }\n }\n if (!format)\n throw new Error(\"PLY: missing `format` line in header\");\n if (!elements.some((e) => e.name === \"vertex\")) {\n throw new Error(\"PLY: missing `vertex` element\");\n }\n return { format, version, elements, bodyOffset };\n }\n function decodePly(buffer) {\n const header = parsePlyHeader(buffer);\n const vertex = header.elements.find((e) => e.name === \"vertex\");\n if (!vertex)\n throw new Error(\"PLY: no vertex element\");\n if (header.elements[0] !== vertex) {\n throw new Error(`PLY: vertex element must appear first; saw \"${header.elements[0]?.name}\" first`);\n }\n const xProp = vertex.properties.find((p) => p.name === \"x\");\n const yProp = vertex.properties.find((p) => p.name === \"y\");\n const zProp = vertex.properties.find((p) => p.name === \"z\");\n if (!xProp || !yProp || !zProp) {\n throw new Error(\"PLY: vertex element must define x, y, z properties\");\n }\n const rProp = vertex.properties.find((p) => p.name === \"red\" || p.name === \"r\");\n const gProp = vertex.properties.find((p) => p.name === \"green\" || p.name === \"g\");\n const bProp = vertex.properties.find((p) => p.name === \"blue\" || p.name === \"b\");\n const hasRgb = !!(rProp && gProp && bProp);\n const intensityProp = vertex.properties.find((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\");\n const count = vertex.count;\n const positions = new Float32Array(count * 3);\n const colors = hasRgb ? new Float32Array(count * 3) : void 0;\n const intensities = intensityProp ? new Uint16Array(count) : void 0;\n if (header.format === \"ascii\") {\n decodeAsciiBody(buffer, header, vertex, positions, colors, intensities);\n } else {\n decodeBinaryBody(buffer, header, vertex, positions, colors, intensities, header.format === \"binary_little_endian\");\n }\n return {\n positions,\n colors,\n intensities,\n pointCount: count,\n bbox: computeBBox(positions)\n };\n }\n function decodeAsciiBody(buffer, header, vertex, positions, colors, intensities) {\n const text = TEXT_DECODER.decode(buffer.subarray(header.bodyOffset));\n const xCol = vertex.properties.findIndex((p) => p.name === \"x\");\n const yCol = vertex.properties.findIndex((p) => p.name === \"y\");\n const zCol = vertex.properties.findIndex((p) => p.name === \"z\");\n const rCol = vertex.properties.findIndex((p) => p.name === \"red\" || p.name === \"r\");\n const gCol = vertex.properties.findIndex((p) => p.name === \"green\" || p.name === \"g\");\n const bCol = vertex.properties.findIndex((p) => p.name === \"blue\" || p.name === \"b\");\n const iCol = vertex.properties.findIndex((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\");\n let lineStart = 0;\n let written = 0;\n while (written < vertex.count && lineStart < text.length) {\n let lineEnd = text.indexOf(\"\\n\", lineStart);\n if (lineEnd < 0)\n lineEnd = text.length;\n const line = text.slice(lineStart, lineEnd).trim();\n lineStart = lineEnd + 1;\n if (!line)\n continue;\n const parts = line.split(/\\s+/);\n positions[written * 3] = Number(parts[xCol]);\n positions[written * 3 + 1] = Number(parts[yCol]);\n positions[written * 3 + 2] = Number(parts[zCol]);\n if (colors && rCol >= 0 && gCol >= 0 && bCol >= 0) {\n colors[written * 3] = clamp01(Number(parts[rCol]) / 255);\n colors[written * 3 + 1] = clamp01(Number(parts[gCol]) / 255);\n colors[written * 3 + 2] = clamp01(Number(parts[bCol]) / 255);\n }\n if (intensities && iCol >= 0) {\n intensities[written] = Math.min(65535, Math.max(0, Number(parts[iCol]) | 0));\n }\n written++;\n }\n if (written !== vertex.count) {\n throw new Error(`PLY ascii: expected ${vertex.count} vertex lines, got ${written}`);\n }\n }\n function decodeBinaryBody(buffer, header, vertex, positions, colors, intensities, littleEndian) {\n const stride = vertex.recordSize;\n const need = vertex.count * stride;\n if (buffer.length < header.bodyOffset + need) {\n throw new Error(`PLY binary: expected ${need} body bytes, got ${buffer.length - header.bodyOffset}`);\n }\n const view = new DataView(buffer.buffer, buffer.byteOffset + header.bodyOffset, need);\n const xProp = vertex.properties.find((p) => p.name === \"x\");\n const yProp = vertex.properties.find((p) => p.name === \"y\");\n const zProp = vertex.properties.find((p) => p.name === \"z\");\n const rProp = colors ? vertex.properties.find((p) => p.name === \"red\" || p.name === \"r\") : void 0;\n const gProp = colors ? vertex.properties.find((p) => p.name === \"green\" || p.name === \"g\") : void 0;\n const bProp = colors ? vertex.properties.find((p) => p.name === \"blue\" || p.name === \"b\") : void 0;\n const iProp = intensities ? vertex.properties.find((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\") : void 0;\n for (let i = 0; i < vertex.count; i++) {\n const base = i * stride;\n positions[i * 3] = readScalar(view, base + xProp.offset, xProp, littleEndian);\n positions[i * 3 + 1] = readScalar(view, base + yProp.offset, yProp, littleEndian);\n positions[i * 3 + 2] = readScalar(view, base + zProp.offset, zProp, littleEndian);\n if (colors && rProp && gProp && bProp) {\n colors[i * 3] = clamp01(readScalar(view, base + rProp.offset, rProp, littleEndian) / 255);\n colors[i * 3 + 1] = clamp01(readScalar(view, base + gProp.offset, gProp, littleEndian) / 255);\n colors[i * 3 + 2] = clamp01(readScalar(view, base + bProp.offset, bProp, littleEndian) / 255);\n }\n if (intensities && iProp) {\n intensities[i] = Math.min(65535, Math.max(0, readScalar(view, base + iProp.offset, iProp, littleEndian) | 0));\n }\n }\n }\n function readScalar(view, offset, prop, le) {\n switch (prop.type) {\n case \"char\":\n case \"int8\":\n return view.getInt8(offset);\n case \"uchar\":\n case \"uint8\":\n return view.getUint8(offset);\n case \"short\":\n case \"int16\":\n return view.getInt16(offset, le);\n case \"ushort\":\n case \"uint16\":\n return view.getUint16(offset, le);\n case \"int\":\n case \"int32\":\n return view.getInt32(offset, le);\n case \"uint\":\n case \"uint32\":\n return view.getUint32(offset, le);\n case \"float\":\n case \"float32\":\n return view.getFloat32(offset, le);\n case \"double\":\n case \"float64\":\n return view.getFloat64(offset, le);\n default:\n throw new Error(`PLY: cannot read scalar of type \"${prop.type}\"`);\n }\n }\n function clamp01(v) {\n return v < 0 ? 0 : v > 1 ? 1 : v;\n }\n function computeBBox(positions) {\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i < positions.length; i += 3) {\n const x = positions[i], y = positions[i + 1], z = positions[i + 2];\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n }\n return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };\n }\n var TYPE_SIZES, TEXT_DECODER;\n var init_ply = __esm({\n \"dist/formats/ply.js\"() {\n \"use strict\";\n TYPE_SIZES = {\n char: 1,\n int8: 1,\n uchar: 1,\n uint8: 1,\n short: 2,\n int16: 2,\n ushort: 2,\n uint16: 2,\n int: 4,\n int32: 4,\n uint: 4,\n uint32: 4,\n float: 4,\n float32: 4,\n double: 8,\n float64: 8\n };\n TEXT_DECODER = new TextDecoder();\n }\n });\n\n // dist/streaming/ply-source.js\n var ply_source_exports = {};\n __export(ply_source_exports, {\n PlyStreamingSource: () => PlyStreamingSource\n });\n function applyStride(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const classifications = chunk.classifications ? new Uint8Array(newCount) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (classifications && chunk.classifications) {\n classifications[dst] = chunk.classifications[i];\n }\n if (intensities && chunk.intensities) {\n intensities[dst] = chunk.intensities[i];\n }\n dst++;\n }\n return {\n positions,\n colors,\n classifications,\n intensities,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted3(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var PlyStreamingSource;\n var init_ply_source = __esm({\n \"dist/streaming/ply-source.js\"() {\n \"use strict\";\n init_ply();\n PlyStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted3(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted3(signal);\n const bytes = new Uint8Array(buf);\n const header = parsePlyHeader(bytes);\n const vertex = header.elements.find((e) => e.name === \"vertex\");\n if (!vertex)\n throw new Error(\"PLY: no vertex element\");\n const hasRgb = !!vertex.properties.find((p) => p.name === \"red\" || p.name === \"r\") && !!vertex.properties.find((p) => p.name === \"green\" || p.name === \"g\") && !!vertex.properties.find((p) => p.name === \"blue\" || p.name === \"b\");\n const hasIntensity = !!vertex.properties.find((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\");\n const fullChunk = decodePly(bytes);\n this.chunk = applyStride(fullChunk, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: hasRgb,\n hasClassification: false,\n hasIntensity,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted3(signal);\n if (!this.chunk || this.served)\n return null;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/lzf.js\n function decompressLZF(input, outputSize) {\n const output = new Uint8Array(outputSize);\n let ip = 0;\n let op = 0;\n const ie = input.length;\n while (ip < ie) {\n let ctrl = input[ip++];\n if (ctrl < 32) {\n const run = ctrl + 1;\n if (ip + run > ie) {\n throw new Error(\"LZF: literal run exceeds input bounds\");\n }\n if (op + run > outputSize) {\n throw new Error(\"LZF: literal run exceeds output bounds\");\n }\n output.set(input.subarray(ip, ip + run), op);\n ip += run;\n op += run;\n } else {\n let len = ctrl >> 5;\n if (len === 7) {\n if (ip >= ie)\n throw new Error(\"LZF: truncated extended length\");\n len += input[ip++];\n }\n len += 2;\n if (ip >= ie)\n throw new Error(\"LZF: truncated back-reference offset\");\n const ref = op - ((ctrl & 31) << 8) - input[ip++] - 1;\n if (ref < 0) {\n throw new Error(\"LZF: back-reference points before output start\");\n }\n if (op + len > outputSize) {\n throw new Error(\"LZF: back-reference exceeds output bounds\");\n }\n for (let i = 0; i < len; i++) {\n output[op + i] = output[ref + i];\n }\n op += len;\n }\n }\n if (op !== outputSize) {\n throw new Error(`LZF: decompressed ${op} bytes, expected ${outputSize}`);\n }\n return output;\n }\n var init_lzf = __esm({\n \"dist/lzf.js\"() {\n \"use strict\";\n }\n });\n\n // dist/formats/pcd.js\n function decodePcd(buffer) {\n const header = parseHeader(buffer);\n let positions;\n let colors;\n if (header.data === \"ascii\") {\n ({ positions, colors } = decodeAscii(buffer, header));\n } else if (header.data === \"binary\") {\n ({ positions, colors } = decodeBinary(buffer, header));\n } else {\n ({ positions, colors } = decodeBinaryCompressed(buffer, header));\n }\n return {\n positions,\n colors,\n pointCount: header.pointCount,\n bbox: computeBBox2(positions)\n };\n }\n function parseHeader(buffer) {\n const probeLen = Math.min(65536, buffer.length);\n const probe = TEXT_DECODER2.decode(buffer.subarray(0, probeLen));\n const dataIdx = probe.search(/^DATA\\s+(\\S+)/m);\n if (dataIdx < 0) {\n throw new Error(\"PCD: missing DATA line in header (scanned first \" + probeLen + \" bytes)\");\n }\n const headerText = probe.slice(0, dataIdx);\n const dataLineMatch = probe.slice(dataIdx).match(/^DATA\\s+(\\S+)\\s*\\n/);\n if (!dataLineMatch) {\n throw new Error(\"PCD: malformed DATA line\");\n }\n const dataKind = dataLineMatch[1].toLowerCase();\n if (dataKind !== \"ascii\" && dataKind !== \"binary\" && dataKind !== \"binary_compressed\") {\n throw new Error(`PCD: unsupported DATA kind \"${dataKind}\"`);\n }\n const bodyOffset = dataIdx + dataLineMatch[0].length;\n const tokens = /* @__PURE__ */ new Map();\n for (const rawLine of headerText.split(\"\\n\")) {\n const line = rawLine.replace(/#.*$/, \"\").trim();\n if (!line)\n continue;\n const parts = line.split(/\\s+/);\n const key = parts[0].toUpperCase();\n tokens.set(key, parts.slice(1));\n }\n const fieldNames = tokens.get(\"FIELDS\") ?? [];\n const sizes = (tokens.get(\"SIZE\") ?? []).map(Number);\n const types = tokens.get(\"TYPE\") ?? [];\n const counts = (tokens.get(\"COUNT\") ?? []).map(Number);\n const widthRaw = tokens.get(\"WIDTH\")?.[0];\n const heightRaw = tokens.get(\"HEIGHT\")?.[0];\n const pointsRaw = tokens.get(\"POINTS\")?.[0];\n if (fieldNames.length === 0)\n throw new Error(\"PCD: missing FIELDS\");\n if (sizes.length !== fieldNames.length)\n throw new Error(\"PCD: SIZE/FIELDS length mismatch\");\n if (types.length !== fieldNames.length)\n throw new Error(\"PCD: TYPE/FIELDS length mismatch\");\n const fields = [];\n let stride = 0;\n for (let i = 0; i < fieldNames.length; i++) {\n const count = counts[i] ?? 1;\n const size = sizes[i];\n const type = types[i];\n if (type !== \"F\" && type !== \"I\" && type !== \"U\") {\n throw new Error(`PCD: unsupported field TYPE \"${type}\"`);\n }\n fields.push({ name: fieldNames[i], size, type, count, offset: stride });\n stride += size * count;\n }\n const width = widthRaw !== void 0 ? parseInt(widthRaw, 10) : 0;\n const height = heightRaw !== void 0 ? parseInt(heightRaw, 10) : 1;\n const pointCount = pointsRaw !== void 0 ? parseInt(pointsRaw, 10) : width * height;\n if (!Number.isFinite(pointCount) || pointCount <= 0) {\n throw new Error(\"PCD: invalid point count\");\n }\n return {\n version: tokens.get(\"VERSION\")?.[0] ?? \"0.7\",\n fields,\n width,\n height,\n pointCount,\n pointStride: stride,\n data: dataKind,\n bodyOffset\n };\n }\n function planChannels(header) {\n const plan = {};\n for (const field of header.fields) {\n const name = field.name.toLowerCase();\n if (name === \"x\")\n plan.xField = field;\n else if (name === \"y\")\n plan.yField = field;\n else if (name === \"z\")\n plan.zField = field;\n else if (name === \"rgb\" || name === \"rgba\")\n plan.rgbField = field;\n }\n if (!plan.xField || !plan.yField || !plan.zField) {\n throw new Error(\"PCD: x/y/z fields are required\");\n }\n return plan;\n }\n function decodeAscii(buffer, header) {\n const plan = planChannels(header);\n const text = TEXT_DECODER2.decode(buffer.subarray(header.bodyOffset));\n const positions = new Float32Array(header.pointCount * 3);\n const colors = plan.rgbField ? new Float32Array(header.pointCount * 3) : void 0;\n const colMap = buildAsciiColumnMap(header, plan);\n let writeIdx = 0;\n let lineStart = 0;\n let pointsRead = 0;\n while (pointsRead < header.pointCount && lineStart < text.length) {\n let lineEnd = text.indexOf(\"\\n\", lineStart);\n if (lineEnd < 0)\n lineEnd = text.length;\n const line = text.slice(lineStart, lineEnd).trim();\n lineStart = lineEnd + 1;\n if (!line)\n continue;\n const parts = line.split(/\\s+/);\n positions[writeIdx * 3] = Number(parts[colMap.xCol]);\n positions[writeIdx * 3 + 1] = Number(parts[colMap.yCol]);\n positions[writeIdx * 3 + 2] = Number(parts[colMap.zCol]);\n if (colors && colMap.rgbCol >= 0) {\n const packed = parsePackedRgb(parts[colMap.rgbCol], plan.rgbField);\n colors[writeIdx * 3] = (packed >> 16 & 255) / 255;\n colors[writeIdx * 3 + 1] = (packed >> 8 & 255) / 255;\n colors[writeIdx * 3 + 2] = (packed & 255) / 255;\n }\n writeIdx++;\n pointsRead++;\n }\n if (pointsRead !== header.pointCount) {\n throw new Error(`PCD ascii: expected ${header.pointCount} points, got ${pointsRead}`);\n }\n return { positions, colors };\n }\n function buildAsciiColumnMap(header, plan) {\n let col = 0;\n let xCol = -1;\n let yCol = -1;\n let zCol = -1;\n let rgbCol = -1;\n for (const field of header.fields) {\n if (field === plan.xField)\n xCol = col;\n if (field === plan.yField)\n yCol = col;\n if (field === plan.zField)\n zCol = col;\n if (field === plan.rgbField)\n rgbCol = col;\n col += field.count;\n }\n return { xCol, yCol, zCol, rgbCol };\n }\n function decodeBinary(buffer, header) {\n const plan = planChannels(header);\n const view = new DataView(buffer.buffer, buffer.byteOffset + header.bodyOffset, header.pointCount * header.pointStride);\n const positions = new Float32Array(header.pointCount * 3);\n const colors = plan.rgbField ? new Float32Array(header.pointCount * 3) : void 0;\n for (let i = 0; i < header.pointCount; i++) {\n const base = i * header.pointStride;\n positions[i * 3] = readScalar2(view, base + plan.xField.offset, plan.xField);\n positions[i * 3 + 1] = readScalar2(view, base + plan.yField.offset, plan.yField);\n positions[i * 3 + 2] = readScalar2(view, base + plan.zField.offset, plan.zField);\n if (colors && plan.rgbField) {\n const packed = view.getUint32(base + plan.rgbField.offset, true);\n colors[i * 3] = (packed >> 16 & 255) / 255;\n colors[i * 3 + 1] = (packed >> 8 & 255) / 255;\n colors[i * 3 + 2] = (packed & 255) / 255;\n }\n }\n return { positions, colors };\n }\n function decodeBinaryCompressed(buffer, header) {\n if (buffer.length < header.bodyOffset + 8) {\n throw new Error(\"PCD binary_compressed: truncated size header\");\n }\n const sizeView = new DataView(buffer.buffer, buffer.byteOffset + header.bodyOffset, 8);\n const compressedSize = sizeView.getUint32(0, true);\n const uncompressedSize = sizeView.getUint32(4, true);\n const expectedUncompressed = header.pointCount * header.pointStride;\n if (uncompressedSize !== expectedUncompressed) {\n throw new Error(`PCD binary_compressed: declared uncompressed=${uncompressedSize} does not match fields*points=${expectedUncompressed}`);\n }\n const compressed = buffer.subarray(header.bodyOffset + 8, header.bodyOffset + 8 + compressedSize);\n const raw = decompressLZF(compressed, uncompressedSize);\n const plan = planChannels(header);\n const fieldStart = /* @__PURE__ */ new Map();\n let cursor = 0;\n for (const field of header.fields) {\n fieldStart.set(field, cursor);\n cursor += header.pointCount * field.size * field.count;\n }\n const view = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);\n const positions = new Float32Array(header.pointCount * 3);\n const colors = plan.rgbField ? new Float32Array(header.pointCount * 3) : void 0;\n const xBase = fieldStart.get(plan.xField);\n const yBase = fieldStart.get(plan.yField);\n const zBase = fieldStart.get(plan.zField);\n const rgbBase = plan.rgbField ? fieldStart.get(plan.rgbField) : 0;\n for (let i = 0; i < header.pointCount; i++) {\n positions[i * 3] = readScalar2(view, xBase + i * plan.xField.size, plan.xField);\n positions[i * 3 + 1] = readScalar2(view, yBase + i * plan.yField.size, plan.yField);\n positions[i * 3 + 2] = readScalar2(view, zBase + i * plan.zField.size, plan.zField);\n if (colors && plan.rgbField) {\n const packed = view.getUint32(rgbBase + i * plan.rgbField.size, true);\n colors[i * 3] = (packed >> 16 & 255) / 255;\n colors[i * 3 + 1] = (packed >> 8 & 255) / 255;\n colors[i * 3 + 2] = (packed & 255) / 255;\n }\n }\n return { positions, colors };\n }\n function readScalar2(view, offset, field) {\n if (field.type === \"F\") {\n return field.size === 8 ? view.getFloat64(offset, true) : view.getFloat32(offset, true);\n }\n if (field.type === \"U\") {\n if (field.size === 1)\n return view.getUint8(offset);\n if (field.size === 2)\n return view.getUint16(offset, true);\n if (field.size === 4)\n return view.getUint32(offset, true);\n } else {\n if (field.size === 1)\n return view.getInt8(offset);\n if (field.size === 2)\n return view.getInt16(offset, true);\n if (field.size === 4)\n return view.getInt32(offset, true);\n }\n throw new Error(`PCD: unsupported field width ${field.size} for type ${field.type}`);\n }\n function parsePackedRgb(token, field) {\n if (field.type === \"F\") {\n PARSE_F32[0] = Number(token);\n return PARSE_U32[0];\n }\n return Number(token) >>> 0;\n }\n function computeBBox2(positions) {\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i < positions.length; i += 3) {\n const x = positions[i], y = positions[i + 1], z = positions[i + 2];\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n }\n return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };\n }\n var TEXT_DECODER2, PARSE_BUFFER, PARSE_F32, PARSE_U32;\n var init_pcd = __esm({\n \"dist/formats/pcd.js\"() {\n \"use strict\";\n init_lzf();\n TEXT_DECODER2 = new TextDecoder();\n PARSE_BUFFER = new ArrayBuffer(4);\n PARSE_F32 = new Float32Array(PARSE_BUFFER);\n PARSE_U32 = new Uint32Array(PARSE_BUFFER);\n }\n });\n\n // dist/streaming/pcd-source.js\n var pcd_source_exports = {};\n __export(pcd_source_exports, {\n PcdStreamingSource: () => PcdStreamingSource\n });\n function applyStride2(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const classifications = chunk.classifications ? new Uint8Array(newCount) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (classifications && chunk.classifications)\n classifications[dst] = chunk.classifications[i];\n if (intensities && chunk.intensities)\n intensities[dst] = chunk.intensities[i];\n dst++;\n }\n return {\n positions,\n colors,\n classifications,\n intensities,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted4(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var PcdStreamingSource;\n var init_pcd_source = __esm({\n \"dist/streaming/pcd-source.js\"() {\n \"use strict\";\n init_pcd();\n PcdStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted4(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted4(signal);\n const decoded = decodePcd(new Uint8Array(buf));\n this.chunk = applyStride2(decoded, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: !!this.chunk.colors,\n hasClassification: !!this.chunk.classifications,\n hasIntensity: !!this.chunk.intensities,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted4(signal);\n if (!this.chunk || this.served)\n return null;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/formats/e57-page.js\n function parseE57FileHeader(bytes) {\n if (bytes.length < 48)\n throw new Error(\"E57: header truncated (need 48 bytes)\");\n const magic = String.fromCharCode(...bytes.subarray(0, 8));\n if (magic !== E57_MAGIC) {\n throw new Error(`E57: bad magic \"${magic}\" (expected \"${E57_MAGIC}\")`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n return {\n majorVersion: view.getUint32(8, true),\n minorVersion: view.getUint32(12, true),\n fileLogicalSize: readU64LE2(view, 16),\n // Physical XML offset → we convert to logical below; xmlLogicalLength\n // is the byte length AFTER stripping page CRCs.\n xmlLogicalOffset: physicalToLogical(readU64LE2(view, 24), readU64LE2(view, 40)),\n xmlLogicalLength: readU64LE2(view, 32),\n pageSize: readU64LE2(view, 40)\n };\n }\n function stripPageCrc(bytes, pageSize) {\n if (pageSize <= 4)\n throw new Error(\"E57: pageSize too small\");\n const payloadPerPage = pageSize - 4;\n const fullPages = Math.floor(bytes.length / pageSize);\n const tail = bytes.length - fullPages * pageSize;\n const out = new Uint8Array(fullPages * payloadPerPage + Math.max(0, tail - 4));\n let dst = 0;\n for (let p = 0; p < fullPages; p++) {\n const src = p * pageSize;\n out.set(bytes.subarray(src, src + payloadPerPage), dst);\n dst += payloadPerPage;\n }\n if (tail > 4) {\n const src = fullPages * pageSize;\n out.set(bytes.subarray(src, src + tail - 4), dst);\n }\n return out;\n }\n function physicalToLogical(physical, pageSize) {\n const payloadPerPage = pageSize - 4;\n const pages = Math.floor(physical / pageSize);\n const within = physical - pages * pageSize;\n return pages * payloadPerPage + within;\n }\n function resolveCompressedVectorDataOffset(logical, physicalSectionOffset, pageSize) {\n const sectionLogical = physicalToLogical(physicalSectionOffset, pageSize);\n if (sectionLogical + 32 > logical.length) {\n throw new Error(`E57: CompressedVector section header at logical ${sectionLogical} runs past end of file (length ${logical.length})`);\n }\n const view = new DataView(logical.buffer, logical.byteOffset + sectionLogical, 32);\n const sectionId = view.getUint8(0);\n if (sectionId !== 1) {\n throw new Error(`E57: expected CompressedVector section (id=1) at physical ${physicalSectionOffset}, got id=${sectionId}`);\n }\n const dataPhysicalOffset = readU64LE2(view, 16);\n return physicalToLogical(dataPhysicalOffset, pageSize);\n }\n function readU64LE2(view, offset) {\n const lo = view.getUint32(offset, true);\n const hi = view.getUint32(offset + 4, true);\n return hi * 4294967296 + lo;\n }\n var E57_MAGIC;\n var init_e57_page = __esm({\n \"dist/formats/e57-page.js\"() {\n \"use strict\";\n E57_MAGIC = \"ASTM-E57\";\n }\n });\n\n // dist/xml-mini.js\n function parseXml(xml) {\n const root = { name: \"\", attrs: /* @__PURE__ */ new Map(), children: [], text: \"\" };\n const stack = [root];\n let i = 0;\n const n = xml.length;\n let textStart = -1;\n const flushText = (end) => {\n if (textStart < 0 || textStart >= end) {\n textStart = -1;\n return;\n }\n const slice = xml.slice(textStart, end).trim();\n if (slice.length > 0) {\n const top = stack[stack.length - 1];\n if (top.children.length === 0) {\n top.text = top.text + decodeEntities(slice);\n }\n }\n textStart = -1;\n };\n while (i < n) {\n const ch = xml.charCodeAt(i);\n if (ch !== 60) {\n if (textStart < 0)\n textStart = i;\n i++;\n continue;\n }\n flushText(i);\n if (xml.startsWith(\"<?\", i)) {\n const end = xml.indexOf(\"?>\", i + 2);\n i = end < 0 ? n : end + 2;\n continue;\n }\n if (xml.startsWith(\"<!--\", i)) {\n const end = xml.indexOf(\"-->\", i + 4);\n i = end < 0 ? n : end + 3;\n continue;\n }\n if (xml.startsWith(\"<![CDATA[\", i)) {\n const end = xml.indexOf(\"]]>\", i + 9);\n const cdata = xml.slice(i + 9, end < 0 ? n : end);\n const top = stack[stack.length - 1];\n if (top.children.length === 0)\n top.text = top.text + cdata;\n i = end < 0 ? n : end + 3;\n continue;\n }\n if (xml.startsWith(\"<!\", i)) {\n const end = xml.indexOf(\">\", i + 2);\n i = end < 0 ? n : end + 1;\n continue;\n }\n if (xml.charCodeAt(i + 1) === 47) {\n const end = xml.indexOf(\">\", i + 2);\n if (end < 0)\n throw new Error(\"XML: unterminated closing tag\");\n const name2 = xml.slice(i + 2, end).trim();\n const top = stack[stack.length - 1];\n if (top.name !== name2) {\n throw new Error(`XML: mismatched closing tag </${name2}> (expected </${top.name}>)`);\n }\n stack.pop();\n i = end + 1;\n continue;\n }\n const tagEnd = findTagEnd(xml, i + 1);\n if (tagEnd < 0)\n throw new Error(\"XML: unterminated tag\");\n let inner = xml.slice(i + 1, tagEnd).trim();\n let selfClosing = false;\n if (inner.endsWith(\"/\")) {\n selfClosing = true;\n inner = inner.slice(0, -1).trim();\n }\n const nameMatch = inner.match(/^([A-Za-z_][\\w:.\\-]*)/);\n if (!nameMatch) {\n i = tagEnd + 1;\n continue;\n }\n const name = nameMatch[1];\n const attrSpan = inner.slice(name.length).trim();\n const attrs = parseAttrs(attrSpan);\n const node = { name, attrs, children: [], text: \"\" };\n if (stack.length === 1 && root.name === \"\") {\n root.name = name;\n root.attrs = attrs;\n if (!selfClosing)\n stack.push(root);\n } else {\n stack[stack.length - 1].children.push(node);\n if (!selfClosing)\n stack.push(node);\n }\n i = tagEnd + 1;\n }\n flushText(n);\n if (stack.length !== 1) {\n throw new Error(`XML: unclosed tag <${stack[stack.length - 1].name}>`);\n }\n if (root.name === \"\") {\n throw new Error(\"XML: missing root element\");\n }\n return root;\n }\n function findTagEnd(xml, from) {\n let inAttr = false;\n for (let i = from; i < xml.length; i++) {\n const c = xml.charCodeAt(i);\n if (c === 34)\n inAttr = !inAttr;\n else if (c === 62 && !inAttr)\n return i;\n }\n return -1;\n }\n function parseAttrs(span) {\n const out = /* @__PURE__ */ new Map();\n if (!span)\n return out;\n let m;\n ATTR_RE.lastIndex = 0;\n while ((m = ATTR_RE.exec(span)) !== null) {\n out.set(m[1], decodeEntities(m[2]));\n }\n return out;\n }\n function decodeEntities(s) {\n if (s.indexOf(\"&\") < 0)\n return s;\n return s.replace(/</g, \"<\").replace(/>/g, \">\").replace(/"/g, '\"').replace(/'/g, \"'\").replace(/&#(\\d+);/g, (_, d) => String.fromCharCode(parseInt(d, 10))).replace(/&#x([0-9a-fA-F]+);/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/&/g, \"&\");\n }\n function childByName(parent, name) {\n for (const c of parent.children) {\n if (c.name === name)\n return c;\n }\n return null;\n }\n function childrenByName(parent, name) {\n return parent.children.filter((c) => c.name === name);\n }\n function textChild(parent, name) {\n const c = childByName(parent, name);\n if (!c)\n return null;\n const t = c.text.trim();\n return t.length > 0 ? t : null;\n }\n var ATTR_RE;\n var init_xml_mini = __esm({\n \"dist/xml-mini.js\"() {\n \"use strict\";\n ATTR_RE = /([A-Za-z_][\\w:.\\-]*)\\s*=\\s*\"([^\"]*)\"/g;\n }\n });\n\n // dist/formats/e57-xml.js\n function parseE57Xml(xmlText) {\n const root = parseXml(xmlText);\n if (root.name !== \"e57Root\") {\n throw new Error(`E57: XML root is not <e57Root> (saw <${root.name || \"?\"}>)`);\n }\n const data3D = childByName(root, \"data3D\");\n if (!data3D)\n return [];\n const entries = [];\n for (const scan of childrenByName(data3D, \"vectorChild\")) {\n const points = childByName(scan, \"points\");\n if (!points)\n continue;\n if (points.attrs.get(\"type\") !== \"CompressedVector\") {\n continue;\n }\n const fileOffsetAttr = points.attrs.get(\"fileOffset\");\n const recordCountAttr = points.attrs.get(\"recordCount\");\n if (!fileOffsetAttr || !recordCountAttr)\n continue;\n const binaryFileOffset = Number(fileOffsetAttr);\n const recordCount = Number(recordCountAttr);\n if (!Number.isFinite(binaryFileOffset) || binaryFileOffset < 0)\n continue;\n if (!Number.isFinite(recordCount) || recordCount < 0)\n continue;\n const proto = childByName(points, \"prototype\");\n if (!proto)\n continue;\n const fields = [];\n for (const f of proto.children) {\n const type = f.attrs.get(\"type\") ?? \"\";\n if (type === \"Float\") {\n fields.push({\n name: f.name,\n kind: \"Float\",\n precision: f.attrs.get(\"precision\") === \"single\" ? \"single\" : \"double\"\n });\n } else if (type === \"ScaledInteger\") {\n fields.push({\n name: f.name,\n kind: \"ScaledInteger\",\n scale: Number(f.attrs.get(\"scale\") ?? \"1\"),\n offset: Number(f.attrs.get(\"offset\") ?? \"0\"),\n minimum: Number(f.attrs.get(\"minimum\") ?? \"0\"),\n maximum: Number(f.attrs.get(\"maximum\") ?? \"0\")\n });\n } else if (type === \"Integer\") {\n fields.push({\n name: f.name,\n kind: \"Integer\",\n minimum: Number(f.attrs.get(\"minimum\") ?? \"0\"),\n maximum: Number(f.attrs.get(\"maximum\") ?? \"0\")\n });\n }\n }\n entries.push({\n guid: textChild(scan, \"guid\") ?? \"\",\n name: textChild(scan, \"name\") ?? void 0,\n recordCount,\n binaryFileOffset,\n prototype: fields,\n pose: parsePoseElement(childByName(scan, \"pose\")) ?? void 0\n });\n }\n return entries;\n }\n function parsePoseElement(poseEl) {\n if (!poseEl)\n return null;\n const rotation = childByName(poseEl, \"rotation\");\n const translation = childByName(poseEl, \"translation\");\n if (!rotation || !translation)\n return null;\n const qw = Number(textChild(rotation, \"w\") ?? \"1\");\n const qx = Number(textChild(rotation, \"x\") ?? \"0\");\n const qy = Number(textChild(rotation, \"y\") ?? \"0\");\n const qz = Number(textChild(rotation, \"z\") ?? \"0\");\n const tx = Number(textChild(translation, \"x\") ?? \"0\");\n const ty = Number(textChild(translation, \"y\") ?? \"0\");\n const tz = Number(textChild(translation, \"z\") ?? \"0\");\n if (![qw, qx, qy, qz, tx, ty, tz].every(Number.isFinite))\n return null;\n return {\n rotation: { w: qw, x: qx, y: qy, z: qz },\n translation: { x: tx, y: ty, z: tz }\n };\n }\n function findField(proto, name) {\n return proto.find((p) => p.name === name);\n }\n var init_e57_xml = __esm({\n \"dist/formats/e57-xml.js\"() {\n \"use strict\";\n init_xml_mini();\n }\n });\n\n // dist/formats/e57-decode.js\n function decodeE57Scan(logical, entry) {\n const xField = findField(entry.prototype, \"cartesianX\");\n const yField = findField(entry.prototype, \"cartesianY\");\n const zField = findField(entry.prototype, \"cartesianZ\");\n if (!xField || !yField || !zField) {\n throw new Error(\"E57: prototype missing cartesianX/Y/Z\");\n }\n for (const f of [xField, yField, zField]) {\n if (f.kind === \"Integer\") {\n throw new Error(`E57: cartesian${f.name.slice(-1)} encoded as plain Integer (only Float / ScaledInteger supported)`);\n }\n }\n const rField = findField(entry.prototype, \"colorRed\");\n const gField = findField(entry.prototype, \"colorGreen\");\n const bField = findField(entry.prototype, \"colorBlue\");\n const hasRgb = !!(rField && gField && bField);\n const iField = findField(entry.prototype, \"intensity\");\n const cField = findField(entry.prototype, \"classification\");\n const positions = new Float32Array(entry.recordCount * 3);\n const colors = hasRgb ? new Float32Array(entry.recordCount * 3) : void 0;\n const intensities = iField && (iField.kind === \"Float\" || iField.kind === \"Integer\" || iField.kind === \"ScaledInteger\") ? new Uint16Array(entry.recordCount) : void 0;\n const classifications = cField && (cField.kind === \"Integer\" || cField.kind === \"ScaledInteger\") ? new Uint8Array(entry.recordCount) : void 0;\n let offset = entry.binaryFileOffset;\n const view = new DataView(logical.buffer, logical.byteOffset, logical.byteLength);\n let written = 0;\n while (written < entry.recordCount && offset < logical.length) {\n if (offset + 4 > logical.length) {\n throw new Error(\"E57: truncated DataPacket header\");\n }\n const packetType = view.getUint8(offset);\n const packetLogicalLength = view.getUint16(offset + 2, true) + 1;\n if (packetType !== 1) {\n offset += packetLogicalLength;\n continue;\n }\n const packetEnd = offset + packetLogicalLength;\n if (packetEnd > logical.length) {\n throw new Error(\"E57: DataPacket runs past end of logical bytes\");\n }\n const payloadEnd = packetEnd;\n if (offset + 6 > payloadEnd) {\n throw new Error(\"E57: truncated DataPacket header\");\n }\n const bytestreamCount = view.getUint16(offset + 4, true);\n if (bytestreamCount !== entry.prototype.length) {\n throw new Error(`E57: packet bytestreamCount (${bytestreamCount}) \\u2260 prototype length (${entry.prototype.length})`);\n }\n const bytestreamLengths = [];\n let cursor = offset + 6;\n for (let i = 0; i < bytestreamCount; i++) {\n if (cursor + 2 > payloadEnd) {\n throw new Error(\"E57: truncated bytestream length table\");\n }\n bytestreamLengths.push(view.getUint16(cursor, true));\n cursor += 2;\n }\n const fieldOffsets = /* @__PURE__ */ new Map();\n let streamCursor = cursor;\n for (let i = 0; i < bytestreamCount; i++) {\n if (streamCursor + bytestreamLengths[i] > payloadEnd) {\n throw new Error(`E57: bytestream ${entry.prototype[i].name} (${bytestreamLengths[i]} bytes) runs past packet payload at offset ${streamCursor}`);\n }\n fieldOffsets.set(entry.prototype[i].name, { start: streamCursor, length: bytestreamLengths[i] });\n streamCursor += bytestreamLengths[i];\n }\n const xPos = fieldOffsets.get(\"cartesianX\");\n const yPos = fieldOffsets.get(\"cartesianY\");\n const zPos = fieldOffsets.get(\"cartesianZ\");\n const xCapacity = floatOrSiPointCapacity(xField, xPos.length);\n const yCapacity = floatOrSiPointCapacity(yField, yPos.length);\n const zCapacity = floatOrSiPointCapacity(zField, zPos.length);\n const pointsInPacket = Math.min(xCapacity, yCapacity, zCapacity);\n const take = Math.min(pointsInPacket, entry.recordCount - written);\n readCartesianStream(logical, view, xField, xPos.start, positions, written, take, 0);\n readCartesianStream(logical, view, yField, yPos.start, positions, written, take, 1);\n readCartesianStream(logical, view, zField, zPos.start, positions, written, take, 2);\n if (colors && rField && gField && bField) {\n writeColorChannel(view, fieldOffsets.get(\"colorRed\").start, rField, colors, written, take, 0, logical);\n writeColorChannel(view, fieldOffsets.get(\"colorGreen\").start, gField, colors, written, take, 1, logical);\n writeColorChannel(view, fieldOffsets.get(\"colorBlue\").start, bField, colors, written, take, 2, logical);\n }\n if (intensities && iField) {\n readIntensityStream(logical, view, iField, fieldOffsets.get(\"intensity\").start, intensities, written, take);\n }\n if (classifications && cField) {\n readClassificationStream(logical, view, cField, fieldOffsets.get(\"classification\").start, classifications, written, take);\n }\n written += take;\n offset = packetEnd;\n }\n if (written < entry.recordCount) {\n return finalize(positions.subarray(0, written * 3), colors?.subarray(0, written * 3), intensities?.subarray(0, written), classifications?.subarray(0, written), written);\n }\n return finalize(positions, colors, intensities, classifications, entry.recordCount);\n }\n function writeColorChannel(view, start, field, colors, written, take, channelOffset, bytes) {\n if (field.kind === \"Float\") {\n const stride = field.precision === \"single\" ? 4 : 8;\n for (let i = 0; i < take; i++) {\n const v = stride === 4 ? view.getFloat32(start + i * stride, true) : view.getFloat64(start + i * stride, true);\n colors[(written + i) * 3 + channelOffset] = clamp012(v);\n }\n } else if (field.kind === \"Integer\") {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 255;\n const span = max - min;\n const inv = span > 0 ? 1 / span : 1;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const stride = widest > 255 ? 2 : 1;\n const signed = min < 0;\n for (let i = 0; i < take; i++) {\n const off = start + i * stride;\n const raw = stride === 2 ? signed ? view.getInt16(off, true) : view.getUint16(off, true) : signed ? view.getInt8(off) : view.getUint8(off);\n colors[(written + i) * 3 + channelOffset] = clamp012((raw - min) * inv);\n }\n } else {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 1;\n const span = max - min;\n const inv = span > 0 ? 1 / span : 1;\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n colors[(written + i) * 3 + channelOffset] = clamp012(raw * inv);\n }\n }\n }\n function readCartesianStream(bytes, view, field, start, positions, written, take, axis) {\n if (field.kind === \"Float\") {\n const stride = field.precision === \"single\" ? 4 : 8;\n if (stride === 4) {\n for (let i = 0; i < take; i++) {\n positions[(written + i) * 3 + axis] = view.getFloat32(start + i * stride, true);\n }\n } else {\n for (let i = 0; i < take; i++) {\n positions[(written + i) * 3 + axis] = view.getFloat64(start + i * stride, true);\n }\n }\n return;\n }\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const minimum = field.minimum ?? 0;\n const scale = field.scale ?? 1;\n const offset = field.offset ?? 0;\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n positions[(written + i) * 3 + axis] = (raw + minimum) * scale + offset;\n }\n }\n function readIntensityStream(bytes, view, field, start, intensities, written, take) {\n if (field.kind === \"Float\") {\n const stride = field.precision === \"single\" ? 4 : 8;\n for (let i = 0; i < take; i++) {\n const v = stride === 4 ? view.getFloat32(start + i * stride, true) : view.getFloat64(start + i * stride, true);\n intensities[written + i] = Math.min(65535, Math.max(0, Math.round(v * 65535)));\n }\n return;\n }\n if (field.kind === \"Integer\") {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 65535;\n const span2 = max - min;\n const inv2 = span2 > 0 ? 1 / span2 : 1;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const stride = widest > 255 ? 2 : 1;\n const signed = min < 0;\n for (let i = 0; i < take; i++) {\n const off = start + i * stride;\n const raw = stride === 2 ? signed ? view.getInt16(off, true) : view.getUint16(off, true) : signed ? view.getInt8(off) : view.getUint8(off);\n const norm = (raw - min) * inv2;\n intensities[written + i] = Math.min(65535, Math.max(0, Math.round(norm * 65535)));\n }\n return;\n }\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const minimum = field.minimum ?? 0;\n const maximum = field.maximum ?? minimum;\n const span = maximum - minimum;\n const inv = span > 0 ? 1 / span : 1;\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n intensities[written + i] = Math.min(65535, Math.max(0, Math.round(raw * inv * 65535)));\n }\n }\n function scaledIntegerBitsPerRecord(field) {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? min;\n const span = Math.max(0, max - min);\n if (span === 0)\n return 1;\n const bits = Math.ceil(Math.log2(span + 1));\n if (bits > 53) {\n throw new Error(`E57: ScaledInteger field \"${field.name}\" needs ${bits} bits \\u2014 exceeds the 53-bit Number-precision limit`);\n }\n return Math.max(1, bits);\n }\n function floatOrSiPointCapacity(field, lengthBytes) {\n if (field.kind === \"Float\") {\n const byteSize2 = field.precision === \"single\" ? 4 : 8;\n return Math.floor(lengthBytes / byteSize2);\n }\n if (field.kind === \"ScaledInteger\") {\n const bits = scaledIntegerBitsPerRecord(field);\n return Math.floor(lengthBytes * 8 / bits);\n }\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 255;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const byteSize = widest > 255 ? 2 : 1;\n return Math.floor(lengthBytes / byteSize);\n }\n function readBitsLE(bytes, bitOffset, bitsPerRecord) {\n let value = 0;\n let bitsRead = 0;\n let cur = bitOffset >>> 3;\n let inByte = bitOffset & 7;\n while (bitsRead < bitsPerRecord) {\n const avail = 8 - inByte;\n const take = Math.min(avail, bitsPerRecord - bitsRead);\n const mask = (1 << take) - 1;\n const piece = bytes[cur] >>> inByte & mask;\n value += piece * Math.pow(2, bitsRead);\n bitsRead += take;\n inByte = 0;\n cur++;\n }\n return value;\n }\n function finalize(positions, colors, intensities, classifications, pointCount) {\n return {\n positions: new Float32Array(positions),\n colors: colors ? new Float32Array(colors) : void 0,\n intensities: intensities ? new Uint16Array(intensities) : void 0,\n classifications: classifications ? new Uint8Array(classifications) : void 0,\n pointCount,\n bbox: computeBBox3(positions)\n };\n }\n function readClassificationStream(bytes, view, field, start, classifications, written, take) {\n if (field.kind === \"Integer\") {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 255;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const stride = widest > 255 ? 2 : 1;\n const signed = min < 0;\n for (let i = 0; i < take; i++) {\n const off = start + i * stride;\n const raw = stride === 2 ? signed ? view.getInt16(off, true) : view.getUint16(off, true) : signed ? view.getInt8(off) : view.getUint8(off);\n classifications[written + i] = Math.max(0, Math.min(255, raw));\n }\n return;\n }\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const minimum = field.minimum ?? 0;\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n classifications[written + i] = Math.max(0, Math.min(255, raw + minimum));\n }\n }\n function clamp012(v) {\n return v < 0 ? 0 : v > 1 ? 1 : v;\n }\n function computeBBox3(positions) {\n if (positions.length < 3) {\n return { min: [0, 0, 0], max: [0, 0, 0] };\n }\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n let any = false;\n for (let i = 0; i + 2 < positions.length; i += 3) {\n const x = positions[i], y = positions[i + 1], z = positions[i + 2];\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))\n continue;\n any = true;\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n }\n if (!any)\n return { min: [0, 0, 0], max: [0, 0, 0] };\n return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };\n }\n var init_e57_decode = __esm({\n \"dist/formats/e57-decode.js\"() {\n \"use strict\";\n init_e57_xml();\n }\n });\n\n // dist/formats/e57.js\n function decodeE57(bytes) {\n const header = parseE57FileHeader(bytes);\n const logical = stripPageCrc(bytes, header.pageSize);\n const xmlBytes = logical.subarray(header.xmlLogicalOffset, header.xmlLogicalOffset + header.xmlLogicalLength);\n const xmlText = TEXT_DECODER3.decode(xmlBytes);\n const entries = parseE57Xml(xmlText);\n if (entries.length === 0)\n return null;\n const chunks = entries.map((entry) => {\n const dataLogicalOffset = resolveCompressedVectorDataOffset(logical, entry.binaryFileOffset, header.pageSize);\n const chunk = decodeE57Scan(logical, { ...entry, binaryFileOffset: dataLogicalOffset });\n if (entry.pose) {\n applyPoseInPlace(chunk.positions, chunk.pointCount, entry.pose);\n chunk.bbox = computeBBox3(chunk.positions);\n }\n return chunk;\n });\n if (chunks.length === 1)\n return chunks[0];\n let total = 0;\n for (const c of chunks)\n total += c.pointCount;\n const positions = new Float32Array(total * 3);\n const hasColors = chunks.some((c) => c.colors);\n const hasIntensity = chunks.some((c) => c.intensities);\n const colors = hasColors ? new Float32Array(total * 3) : void 0;\n const intensities = hasIntensity ? new Uint16Array(total) : void 0;\n let off = 0;\n for (const c of chunks) {\n positions.set(c.positions, off * 3);\n if (colors && c.colors)\n colors.set(c.colors, off * 3);\n if (intensities && c.intensities)\n intensities.set(c.intensities, off);\n off += c.pointCount;\n }\n return {\n positions,\n colors,\n intensities,\n pointCount: total,\n bbox: computeBBox3(positions)\n };\n }\n function applyPoseInPlace(positions, pointCount, pose) {\n const { w, x, y, z } = pose.rotation;\n const tx = pose.translation.x;\n const ty = pose.translation.y;\n const tz = pose.translation.z;\n const r00 = 1 - 2 * (y * y + z * z);\n const r01 = 2 * (x * y - w * z);\n const r02 = 2 * (x * z + w * y);\n const r10 = 2 * (x * y + w * z);\n const r11 = 1 - 2 * (x * x + z * z);\n const r12 = 2 * (y * z - w * x);\n const r20 = 2 * (x * z - w * y);\n const r21 = 2 * (y * z + w * x);\n const r22 = 1 - 2 * (x * x + y * y);\n for (let i = 0; i < pointCount; i++) {\n const px = positions[i * 3];\n const py = positions[i * 3 + 1];\n const pz = positions[i * 3 + 2];\n positions[i * 3] = r00 * px + r01 * py + r02 * pz + tx;\n positions[i * 3 + 1] = r10 * px + r11 * py + r12 * pz + ty;\n positions[i * 3 + 2] = r20 * px + r21 * py + r22 * pz + tz;\n }\n }\n var TEXT_DECODER3;\n var init_e57 = __esm({\n \"dist/formats/e57.js\"() {\n \"use strict\";\n init_e57_page();\n init_e57_xml();\n init_e57_decode();\n init_e57_page();\n init_e57_xml();\n init_e57_decode();\n TEXT_DECODER3 = new TextDecoder();\n }\n });\n\n // dist/streaming/e57-source.js\n var e57_source_exports = {};\n __export(e57_source_exports, {\n E57StreamingSource: () => E57StreamingSource\n });\n function applyStride3(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n const classifications = chunk.classifications ? new Uint8Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (intensities && chunk.intensities) {\n intensities[dst] = chunk.intensities[i];\n }\n if (classifications && chunk.classifications) {\n classifications[dst] = chunk.classifications[i];\n }\n dst++;\n }\n return {\n positions,\n colors,\n intensities,\n classifications,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted5(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var E57StreamingSource;\n var init_e57_source = __esm({\n \"dist/streaming/e57-source.js\"() {\n \"use strict\";\n init_e57();\n E57StreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted5(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted5(signal);\n const decoded = decodeE57(new Uint8Array(buf));\n if (!decoded) {\n throw new Error(\"E57: file contains no Data3D scans\");\n }\n this.chunk = applyStride3(decoded, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: !!this.chunk.colors,\n hasClassification: !!this.chunk.classifications,\n hasIntensity: !!this.chunk.intensities,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted5(signal);\n if (!this.chunk || this.served)\n return null;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/formats/ascii-points.js\n function probeAsciiPointsLayout(buffer, format) {\n const probeLen = Math.min(16384, buffer.length);\n const text = TEXT_DECODER4.decode(buffer.subarray(0, probeLen));\n const lines = text.split(/\\r?\\n/);\n let firstDataLine = null;\n let hasHeaderCount = false;\n for (let i = 0; i < lines.length; i++) {\n const trimmed = lines[i].trim();\n if (trimmed.length === 0)\n continue;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"//\"))\n continue;\n if (i === 0 || !hasHeaderCount) {\n const tokens2 = trimmed.split(/\\s+/);\n if (tokens2.length === 1 && /^\\d+$/.test(tokens2[0])) {\n hasHeaderCount = true;\n continue;\n }\n }\n firstDataLine = trimmed;\n break;\n }\n if (firstDataLine === null)\n return null;\n const tokens = firstDataLine.split(/\\s+/);\n const columns = tokens.length;\n for (const t of tokens) {\n if (!Number.isFinite(Number(t)))\n return null;\n }\n const fields = layoutFromColumnCount(columns, format);\n if (!fields)\n return null;\n return { columns, hasHeaderCount, fields };\n }\n function layoutFromColumnCount(columns, format) {\n switch (columns) {\n case 3:\n return [\"x\", \"y\", \"z\"];\n case 4:\n return [\"x\", \"y\", \"z\", \"i\"];\n case 6:\n return [\"x\", \"y\", \"z\", \"r\", \"g\", \"b\"];\n case 7:\n return [\"x\", \"y\", \"z\", \"i\", \"r\", \"g\", \"b\"];\n case 9:\n return [\"x\", \"y\", \"z\", \"r\", \"g\", \"b\", \"skip\", \"skip\", \"skip\"];\n case 10:\n return [\"x\", \"y\", \"z\", \"i\", \"r\", \"g\", \"b\", \"skip\", \"skip\", \"skip\"];\n default:\n if (columns >= 3 && format === \"xyz\") {\n const fields = [\"x\", \"y\", \"z\"];\n for (let i = 3; i < columns; i++)\n fields.push(\"skip\");\n return fields;\n }\n return null;\n }\n }\n function decodeAsciiPoints(bytes, format) {\n const layout = probeAsciiPointsLayout(bytes, format);\n if (!layout) {\n throw new Error(`${format.toUpperCase()}: file does not look like ASCII point data`);\n }\n const text = TEXT_DECODER4.decode(bytes);\n return decodeAsciiPointsFromText(text, layout);\n }\n function decodeAsciiPointsFromText(text, layout) {\n const lines = text.split(/\\r?\\n/);\n let dataLineCount = 0;\n let headerSkipped = !layout.hasHeaderCount;\n for (const raw of lines) {\n const trimmed = raw.trim();\n if (trimmed.length === 0)\n continue;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"//\"))\n continue;\n if (!headerSkipped) {\n headerSkipped = true;\n continue;\n }\n dataLineCount++;\n }\n const xIdx = layout.fields.indexOf(\"x\");\n const yIdx = layout.fields.indexOf(\"y\");\n const zIdx = layout.fields.indexOf(\"z\");\n const iIdx = layout.fields.indexOf(\"i\");\n const rIdx = layout.fields.indexOf(\"r\");\n const gIdx = layout.fields.indexOf(\"g\");\n const bIdx = layout.fields.indexOf(\"b\");\n const hasIntensity = iIdx >= 0;\n const hasColor = rIdx >= 0 && gIdx >= 0 && bIdx >= 0;\n const positions = new Float32Array(dataLineCount * 3);\n const intensitiesRaw = hasIntensity ? new Float32Array(dataLineCount) : null;\n const colorsRaw = hasColor ? new Float32Array(dataLineCount * 3) : null;\n let written = 0;\n let intensityMax = 0;\n let colorMax = 0;\n let bboxMinX = Infinity, bboxMinY = Infinity, bboxMinZ = Infinity;\n let bboxMaxX = -Infinity, bboxMaxY = -Infinity, bboxMaxZ = -Infinity;\n headerSkipped = !layout.hasHeaderCount;\n for (const raw of lines) {\n const trimmed = raw.trim();\n if (trimmed.length === 0)\n continue;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"//\"))\n continue;\n if (!headerSkipped) {\n headerSkipped = true;\n continue;\n }\n const tokens = trimmed.split(/\\s+/);\n if (tokens.length < layout.columns)\n continue;\n const x = Number(tokens[xIdx]);\n const y = Number(tokens[yIdx]);\n const z = Number(tokens[zIdx]);\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))\n continue;\n positions[written * 3] = x;\n positions[written * 3 + 1] = y;\n positions[written * 3 + 2] = z;\n if (x < bboxMinX)\n bboxMinX = x;\n if (x > bboxMaxX)\n bboxMaxX = x;\n if (y < bboxMinY)\n bboxMinY = y;\n if (y > bboxMaxY)\n bboxMaxY = y;\n if (z < bboxMinZ)\n bboxMinZ = z;\n if (z > bboxMaxZ)\n bboxMaxZ = z;\n if (intensitiesRaw) {\n const v = Number(tokens[iIdx]);\n const f = Number.isFinite(v) ? v : 0;\n intensitiesRaw[written] = f;\n if (f > intensityMax)\n intensityMax = f;\n }\n if (colorsRaw) {\n const r = Number(tokens[rIdx]);\n const g = Number(tokens[gIdx]);\n const b = Number(tokens[bIdx]);\n const rf = Number.isFinite(r) ? r : 0;\n const gf = Number.isFinite(g) ? g : 0;\n const bf = Number.isFinite(b) ? b : 0;\n colorsRaw[written * 3] = rf;\n colorsRaw[written * 3 + 1] = gf;\n colorsRaw[written * 3 + 2] = bf;\n const m = Math.max(rf, gf, bf);\n if (m > colorMax)\n colorMax = m;\n }\n written++;\n }\n const trimmedPositions = written === dataLineCount ? positions : positions.subarray(0, written * 3);\n let intensities;\n if (intensitiesRaw) {\n intensities = new Uint16Array(written);\n const scale = intensityMax > 1 ? intensityMax > 255 ? 65535 / intensityMax : 65535 / 255 : 65535;\n for (let i = 0; i < written; i++) {\n const v = intensitiesRaw[i] * scale;\n intensities[i] = v < 0 ? 0 : v > 65535 ? 65535 : Math.round(v);\n }\n }\n let colors;\n if (colorsRaw) {\n colors = new Float32Array(written * 3);\n const scale = colorMax > 1 ? 1 / 255 : 1;\n for (let i = 0; i < written * 3; i++) {\n const v = colorsRaw[i] * scale;\n colors[i] = v < 0 ? 0 : v > 1 ? 1 : v;\n }\n }\n const bbox = written === 0 ? { min: [0, 0, 0], max: [0, 0, 0] } : { min: [bboxMinX, bboxMinY, bboxMinZ], max: [bboxMaxX, bboxMaxY, bboxMaxZ] };\n return {\n positions: written === dataLineCount ? positions : new Float32Array(trimmedPositions),\n colors,\n intensities,\n pointCount: written,\n bbox\n };\n }\n var TEXT_DECODER4;\n var init_ascii_points = __esm({\n \"dist/formats/ascii-points.js\"() {\n \"use strict\";\n TEXT_DECODER4 = new TextDecoder();\n }\n });\n\n // dist/streaming/ascii-points-source.js\n var ascii_points_source_exports = {};\n __export(ascii_points_source_exports, {\n AsciiPointsStreamingSource: () => AsciiPointsStreamingSource\n });\n function applyStride4(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (intensities && chunk.intensities) {\n intensities[dst] = chunk.intensities[i];\n }\n dst++;\n }\n return {\n positions,\n colors,\n intensities,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted6(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var AsciiPointsStreamingSource;\n var init_ascii_points_source = __esm({\n \"dist/streaming/ascii-points-source.js\"() {\n \"use strict\";\n init_ascii_points();\n AsciiPointsStreamingSource = class {\n constructor(blob, format, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"format\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.format = format;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted6(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted6(signal);\n const bytes = new Uint8Array(buf);\n const fullChunk = decodeAsciiPoints(bytes, this.format);\n this.chunk = applyStride4(fullChunk, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: !!this.chunk.colors,\n hasClassification: false,\n hasIntensity: !!this.chunk.intensities,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted6(signal);\n if (!this.chunk || this.served)\n return null;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/streaming/protocol.js\n function chunkToWire(chunk) {\n const positions = chunk.positions.buffer;\n const transfer = [positions];\n const payload = {\n positions,\n pointCount: chunk.pointCount,\n bbox: chunk.bbox\n };\n if (chunk.colors) {\n const buf = chunk.colors.buffer;\n payload.colors = buf;\n transfer.push(buf);\n }\n if (chunk.classifications) {\n const buf = chunk.classifications.buffer;\n payload.classifications = buf;\n transfer.push(buf);\n }\n if (chunk.intensities) {\n const buf = chunk.intensities.buffer;\n payload.intensities = buf;\n transfer.push(buf);\n }\n return { payload, transfer };\n }\n function chunkFromWire(payload) {\n return {\n positions: new Float32Array(payload.positions),\n colors: payload.colors ? new Float32Array(payload.colors) : void 0,\n classifications: payload.classifications ? new Uint8Array(payload.classifications) : void 0,\n intensities: payload.intensities ? new Uint16Array(payload.intensities) : void 0,\n pointCount: payload.pointCount,\n bbox: payload.bbox\n };\n }\n\n // dist/streaming/decode-worker.js\n var sources = /* @__PURE__ */ new Map();\n var nextSourceId = 1;\n self.onmessage = (event) => {\n const msg = event.data;\n switch (msg.kind) {\n case \"open\":\n void handleOpen(msg);\n return;\n case \"next\":\n void handleNext(msg);\n return;\n case \"close\":\n handleClose(msg.sourceId);\n return;\n case \"abort\":\n handleAbort(msg.sourceId);\n return;\n }\n };\n async function handleOpen(msg) {\n try {\n const source = await createSource(msg.format, msg.blob, {\n label: msg.label,\n downsample: { stride: Math.max(1, msg.stride | 0) }\n });\n const abort = new AbortController();\n const info = await source.open(abort.signal);\n const sourceId = nextSourceId++;\n sources.set(sourceId, { source, abort });\n post({\n kind: \"opened\",\n requestId: msg.requestId,\n sourceId,\n info\n });\n } catch (err) {\n post({\n kind: \"error\",\n requestId: msg.requestId,\n message: errMessage(err)\n });\n }\n }\n async function handleNext(msg) {\n const open = sources.get(msg.sourceId);\n if (!open) {\n post({\n kind: \"error\",\n requestId: msg.requestId,\n message: `Unknown sourceId ${msg.sourceId}`\n });\n return;\n }\n try {\n const chunk = await open.source.next(msg.maxPoints, open.abort.signal);\n if (!chunk) {\n post({\n kind: \"chunk\",\n requestId: msg.requestId,\n sourceId: msg.sourceId,\n chunk: null\n });\n return;\n }\n const { payload, transfer } = chunkToWire(chunk);\n post({\n kind: \"chunk\",\n requestId: msg.requestId,\n sourceId: msg.sourceId,\n chunk: payload\n }, transfer);\n } catch (err) {\n post({\n kind: \"error\",\n requestId: msg.requestId,\n message: errMessage(err)\n });\n }\n }\n function handleClose(sourceId) {\n const open = sources.get(sourceId);\n if (!open)\n return;\n try {\n open.abort.abort();\n open.source.close();\n } catch (err) {\n console.warn(\"[decode-worker] close failed:\", errMessage(err));\n }\n sources.delete(sourceId);\n }\n function handleAbort(sourceId) {\n const open = sources.get(sourceId);\n if (!open)\n return;\n open.abort.abort();\n }\n async function createSource(format, blob, opts) {\n switch (format) {\n case \"las\": {\n const { LasStreamingSource: LasStreamingSource2 } = await Promise.resolve().then(() => (init_las_source(), las_source_exports));\n return new LasStreamingSource2(blob, opts);\n }\n case \"laz\": {\n const { LazStreamingSource: LazStreamingSource2 } = await Promise.resolve().then(() => (init_laz_source(), laz_source_exports));\n return new LazStreamingSource2(blob, opts);\n }\n case \"ply\": {\n const { PlyStreamingSource: PlyStreamingSource2 } = await Promise.resolve().then(() => (init_ply_source(), ply_source_exports));\n return new PlyStreamingSource2(blob, opts);\n }\n case \"pcd\": {\n const { PcdStreamingSource: PcdStreamingSource2 } = await Promise.resolve().then(() => (init_pcd_source(), pcd_source_exports));\n return new PcdStreamingSource2(blob, opts);\n }\n case \"e57\": {\n const { E57StreamingSource: E57StreamingSource2 } = await Promise.resolve().then(() => (init_e57_source(), e57_source_exports));\n return new E57StreamingSource2(blob, opts);\n }\n case \"pts\": {\n const { AsciiPointsStreamingSource: AsciiPointsStreamingSource2 } = await Promise.resolve().then(() => (init_ascii_points_source(), ascii_points_source_exports));\n return new AsciiPointsStreamingSource2(blob, \"pts\", opts);\n }\n case \"xyz\": {\n const { AsciiPointsStreamingSource: AsciiPointsStreamingSource2 } = await Promise.resolve().then(() => (init_ascii_points_source(), ascii_points_source_exports));\n return new AsciiPointsStreamingSource2(blob, \"xyz\", opts);\n }\n default:\n throw new Error(`decode-worker: unknown format \"${format}\"`);\n }\n }\n function post(msg, transfer = []) {\n self.postMessage(msg, transfer);\n }\n function errMessage(err) {\n if (err instanceof Error)\n return err.message;\n return String(err);\n }\n})();\n";
|
|
5
|
+
export const INLINE_WORKER_CODE = "\"use strict\";\n(() => {\n var __create = Object.create;\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __getProtoOf = Object.getPrototypeOf;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\n var __require = /* @__PURE__ */ ((x) => typeof require !== \"undefined\" ? require : typeof Proxy !== \"undefined\" ? new Proxy(x, {\n get: (a, b) => (typeof require !== \"undefined\" ? require : a)[b]\n }) : x)(function(x) {\n if (typeof require !== \"undefined\") return require.apply(this, arguments);\n throw Error('Dynamic require of \"' + x + '\" is not supported');\n });\n var __esm = (fn, res) => function __init() {\n return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;\n };\n var __commonJS = (cb, mod) => function __require2() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n };\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n ));\n var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\n\n // dist/formats/las.js\n function parseLasHeader(buffer) {\n const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);\n if (bytes.length < 227) {\n throw new Error(\"LAS: header truncated\");\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (view.getUint32(0, true) !== MAGIC) {\n throw new Error('LAS: bad magic \\u2014 expected \"LASF\"');\n }\n const versionMajor = view.getUint8(24);\n const versionMinor = view.getUint8(25);\n const headerSize = view.getUint16(94, true);\n const pointDataOffset = view.getUint32(96, true);\n const numberOfVlrs = view.getUint32(100, true);\n const pointDataFormatId = view.getUint8(104) & 63;\n const pointRecordLength = view.getUint16(105, true);\n const legacyCount = view.getUint32(107, true);\n let pointCount = legacyCount;\n if (versionMajor >= 1 && versionMinor >= 4 && bytes.length >= 255) {\n const fullCount = readU64LE(view, 247);\n if (fullCount > 0)\n pointCount = fullCount;\n }\n if (!Number.isFinite(pointCount) || pointCount < 0) {\n throw new Error(\"LAS: invalid point count\");\n }\n const scale = [\n view.getFloat64(131, true),\n view.getFloat64(139, true),\n view.getFloat64(147, true)\n ];\n const offset = [\n view.getFloat64(155, true),\n view.getFloat64(163, true),\n view.getFloat64(171, true)\n ];\n const maxX = view.getFloat64(179, true);\n const minX = view.getFloat64(187, true);\n const maxY = view.getFloat64(195, true);\n const minY = view.getFloat64(203, true);\n const maxZ = view.getFloat64(211, true);\n const minZ = view.getFloat64(219, true);\n const bbox = {\n min: [minX, minY, minZ],\n max: [maxX, maxY, maxZ]\n };\n if (BASE_RECORD_SIZE[pointDataFormatId] === void 0) {\n throw new Error(`LAS: unsupported point data format ${pointDataFormatId}`);\n }\n const baseSize = BASE_RECORD_SIZE[pointDataFormatId];\n if (pointRecordLength < baseSize) {\n throw new Error(`LAS: header point-record length (${pointRecordLength}) smaller than format ${pointDataFormatId} baseline (${baseSize})`);\n }\n return {\n versionMajor,\n versionMinor,\n headerSize,\n pointDataOffset,\n numberOfVlrs,\n pointDataFormatId,\n pointRecordLength,\n pointCount,\n scale,\n offset,\n bbox,\n hasGpsTime: HAS_GPS.has(pointDataFormatId),\n hasRgb: HAS_RGB.has(pointDataFormatId)\n };\n }\n function decodeLasPoints(bytes, header, count, stride = header.pointRecordLength, rgbScale = 1) {\n if (bytes.length < count * stride) {\n throw new Error(`LAS: decode expects ${count * stride} bytes, got ${bytes.length}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const positions = new Float32Array(count * 3);\n const intensities = new Uint16Array(count);\n const classifications = new Uint8Array(count);\n const colors = header.hasRgb ? new Float32Array(count * 3) : void 0;\n const rgbOffset = rgbOffsetForFormat(header.pointDataFormatId);\n const classOffset = header.pointDataFormatId >= 6 ? 16 : 15;\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i < count; i++) {\n const base = i * stride;\n const x = view.getInt32(base, true) * header.scale[0] + header.offset[0];\n const y = view.getInt32(base + 4, true) * header.scale[1] + header.offset[1];\n const z = view.getInt32(base + 8, true) * header.scale[2] + header.offset[2];\n positions[i * 3] = x;\n positions[i * 3 + 1] = y;\n positions[i * 3 + 2] = z;\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n intensities[i] = view.getUint16(base + 12, true);\n classifications[i] = header.pointDataFormatId >= 6 ? view.getUint8(base + classOffset) : view.getUint8(base + classOffset) & 31;\n if (colors && rgbOffset >= 0) {\n const r = view.getUint16(base + rgbOffset, true);\n const g = view.getUint16(base + rgbOffset + 2, true);\n const b = view.getUint16(base + rgbOffset + 4, true);\n colors[i * 3] = r * rgbScale / 65535;\n colors[i * 3 + 1] = g * rgbScale / 65535;\n colors[i * 3 + 2] = b * rgbScale / 65535;\n }\n }\n return {\n positions,\n colors,\n classifications,\n intensities,\n pointCount: count,\n bbox: { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] }\n };\n }\n function sampleMaxRgbChannel(bytes, header, samples = 1024) {\n if (!header.hasRgb)\n return 0;\n const stride = header.pointRecordLength;\n const total = Math.min(header.pointCount, Math.floor(bytes.length / stride));\n if (total === 0)\n return 0;\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const rgbOff = rgbOffsetForFormat(header.pointDataFormatId);\n if (rgbOff < 0)\n return 0;\n const step = Math.max(1, Math.floor(total / Math.min(samples, total)));\n let max = 0;\n for (let i = 0; i < total; i += step) {\n const base = i * stride;\n const r = view.getUint16(base + rgbOff, true);\n const g = view.getUint16(base + rgbOff + 2, true);\n const b = view.getUint16(base + rgbOff + 4, true);\n if (r > max)\n max = r;\n if (g > max)\n max = g;\n if (b > max)\n max = b;\n }\n return max;\n }\n function rgbOffsetForFormat(format) {\n switch (format) {\n case 2:\n return 20;\n case 3:\n return 28;\n case 5:\n return 28;\n case 7:\n return 30;\n case 8:\n return 30;\n case 10:\n return 30;\n default:\n return -1;\n }\n }\n function readU64LE(view, offset) {\n const lo = view.getUint32(offset, true);\n const hi = view.getUint32(offset + 4, true);\n return hi * 4294967296 + lo;\n }\n var MAGIC, BASE_RECORD_SIZE, HAS_GPS, HAS_RGB;\n var init_las = __esm({\n \"dist/formats/las.js\"() {\n \"use strict\";\n MAGIC = 1179861324;\n BASE_RECORD_SIZE = {\n 0: 20,\n 1: 28,\n 2: 26,\n 3: 34,\n 4: 57,\n 5: 63,\n 6: 30,\n 7: 36,\n 8: 38,\n 9: 59,\n 10: 67\n };\n HAS_GPS = /* @__PURE__ */ new Set([1, 3, 4, 5, 6, 7, 8, 9, 10]);\n HAS_RGB = /* @__PURE__ */ new Set([2, 3, 5, 7, 8, 10]);\n }\n });\n\n // dist/streaming/blob-source.js\n var BlobByteSource;\n var init_blob_source = __esm({\n \"dist/streaming/blob-source.js\"() {\n \"use strict\";\n BlobByteSource = class {\n constructor(blob) {\n __publicField(this, \"blob\");\n this.blob = blob;\n }\n get size() {\n return this.blob.size;\n }\n async read(start, end) {\n const safeStart = Math.max(0, start);\n const safeEnd = Math.min(end, this.blob.size);\n if (safeEnd <= safeStart)\n return new Uint8Array(0);\n const slice = this.blob.slice(safeStart, safeEnd);\n const buf = await slice.arrayBuffer();\n return new Uint8Array(buf);\n }\n };\n }\n });\n\n // dist/streaming/las-source.js\n var las_source_exports = {};\n __export(las_source_exports, {\n LasStreamingSource: () => LasStreamingSource\n });\n function abortIfAborted(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var HEADER_PROBE_BYTES, RGB_PROBE_RECORDS, LasStreamingSource;\n var init_las_source = __esm({\n \"dist/streaming/las-source.js\"() {\n \"use strict\";\n init_las();\n init_blob_source();\n HEADER_PROBE_BYTES = 1024;\n RGB_PROBE_RECORDS = 4096;\n LasStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"bytes\");\n __publicField(this, \"header\", null);\n __publicField(this, \"cursor\", 0);\n // index of NEXT point to emit (0..header.pointCount)\n __publicField(this, \"rgbScale\", 1);\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n this.bytes = new BlobByteSource(blob);\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n if (this.header) {\n return this.toInfo(this.header);\n }\n abortIfAborted(signal);\n const headerBytes = await this.bytes.read(0, HEADER_PROBE_BYTES);\n abortIfAborted(signal);\n const header = parseLasHeader(headerBytes);\n let rgbScale = 1;\n if (header.hasRgb) {\n const probeSize = Math.min(RGB_PROBE_RECORDS * header.pointRecordLength, Math.max(0, this.bytes.size - header.pointDataOffset));\n if (probeSize > 0) {\n const probe = await this.bytes.read(header.pointDataOffset, header.pointDataOffset + probeSize);\n abortIfAborted(signal);\n const max = sampleMaxRgbChannel(probe, header);\n rgbScale = max > 0 && max <= 255 ? 65535 / 255 : 1;\n }\n }\n this.header = header;\n this.rgbScale = rgbScale;\n this.cursor = 0;\n return this.toInfo(header);\n }\n async next(maxPoints, signal) {\n abortIfAborted(signal);\n if (!Number.isFinite(maxPoints) || maxPoints <= 0) {\n throw new Error(`LasStreamingSource: maxPoints must be > 0 (got ${maxPoints})`);\n }\n if (!this.header) {\n throw new Error(\"LasStreamingSource: open() must be awaited before next()\");\n }\n const stride = Math.max(1, this.downsample.stride | 0);\n if (this.cursor >= this.header.pointCount)\n return null;\n if (stride === 1) {\n const remaining = this.header.pointCount - this.cursor;\n const take = Math.min(maxPoints, remaining);\n const startByte2 = this.header.pointDataOffset + this.cursor * this.header.pointRecordLength;\n const endByte2 = startByte2 + take * this.header.pointRecordLength;\n const slab2 = await this.bytes.read(startByte2, endByte2);\n abortIfAborted(signal);\n const chunk2 = decodeLasPoints(slab2, this.header, take, this.header.pointRecordLength, this.rgbScale);\n this.cursor += take;\n return chunk2;\n }\n const remainingSource = this.header.pointCount - this.cursor;\n const sourceTake = Math.min(maxPoints * stride, remainingSource);\n const decodedCount = Math.ceil(sourceTake / stride);\n const startByte = this.header.pointDataOffset + this.cursor * this.header.pointRecordLength;\n const endByte = startByte + sourceTake * this.header.pointRecordLength;\n const slab = await this.bytes.read(startByte, endByte);\n abortIfAborted(signal);\n const compact = new Uint8Array(decodedCount * this.header.pointRecordLength);\n let writeOff = 0;\n for (let i = 0; i < decodedCount; i++) {\n const srcOff = i * stride * this.header.pointRecordLength;\n compact.set(slab.subarray(srcOff, srcOff + this.header.pointRecordLength), writeOff);\n writeOff += this.header.pointRecordLength;\n }\n const chunk = decodeLasPoints(compact, this.header, decodedCount, this.header.pointRecordLength, this.rgbScale);\n this.cursor += sourceTake;\n return chunk;\n }\n close() {\n this.header = null;\n this.cursor = 0;\n }\n toInfo(header) {\n const stride = Math.max(1, this.downsample.stride | 0);\n return {\n totalPointCount: stride === 1 ? header.pointCount : Math.ceil(header.pointCount / stride),\n bbox: header.bbox,\n hasColor: header.hasRgb,\n hasClassification: true,\n hasIntensity: true,\n label: this.label\n };\n }\n };\n }\n });\n\n // ../../node_modules/.pnpm/laz-perf@0.0.7/node_modules/laz-perf/lib/web/laz-perf.js\n var require_laz_perf = __commonJS({\n \"../../node_modules/.pnpm/laz-perf@0.0.7/node_modules/laz-perf/lib/web/laz-perf.js\"(exports, module) {\n var createLazPerf = (() => {\n var _scriptDir = typeof document !== \"undefined\" && document.currentScript ? document.currentScript.src : void 0;\n return (function(createLazPerf2) {\n createLazPerf2 = createLazPerf2 || {};\n var Module = typeof createLazPerf2 != \"undefined\" ? createLazPerf2 : {};\n var readyPromiseResolve, readyPromiseReject;\n Module[\"ready\"] = new Promise(function(resolve, reject) {\n readyPromiseResolve = resolve;\n readyPromiseReject = reject;\n });\n [\"_main\", \"___getTypeName\", \"__embind_initialize_bindings\", \"_fflush\", \"onRuntimeInitialized\"].forEach((prop) => {\n if (!Object.getOwnPropertyDescriptor(Module[\"ready\"], prop)) {\n Object.defineProperty(Module[\"ready\"], prop, { get: () => abort(\"You are getting \" + prop + \" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js\"), set: () => abort(\"You are setting \" + prop + \" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js\") });\n }\n });\n var moduleOverrides = Object.assign({}, Module);\n var arguments_ = [];\n var thisProgram = \"./this.program\";\n var quit_ = (status, toThrow) => {\n throw toThrow;\n };\n var ENVIRONMENT_IS_WEB = true;\n var ENVIRONMENT_IS_WORKER = false;\n var ENVIRONMENT_IS_NODE = false;\n var ENVIRONMENT_IS_SHELL = false;\n if (Module[\"ENVIRONMENT\"]) {\n throw new Error(\"Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)\");\n }\n var scriptDirectory = \"\";\n function locateFile(path) {\n if (Module[\"locateFile\"]) {\n return Module[\"locateFile\"](path, scriptDirectory);\n }\n return scriptDirectory + path;\n }\n var read_, readAsync, readBinary, setWindowTitle;\n function logExceptionOnExit(e) {\n if (e instanceof ExitStatus) return;\n let toLog = e;\n if (e && typeof e == \"object\" && e.stack) {\n toLog = [e, e.stack];\n }\n err(\"exiting due to exception: \" + toLog);\n }\n if (ENVIRONMENT_IS_SHELL) {\n if (typeof process == \"object\" && typeof __require === \"function\" || typeof window == \"object\" || typeof importScripts == \"function\") throw new Error(\"not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)\");\n if (typeof read != \"undefined\") {\n read_ = function shell_read(f) {\n return read(f);\n };\n }\n readBinary = function readBinary2(f) {\n let data;\n if (typeof readbuffer == \"function\") {\n return new Uint8Array(readbuffer(f));\n }\n data = read(f, \"binary\");\n assert(typeof data == \"object\");\n return data;\n };\n readAsync = function readAsync2(f, onload, onerror) {\n setTimeout(() => onload(readBinary(f)), 0);\n };\n if (typeof scriptArgs != \"undefined\") {\n arguments_ = scriptArgs;\n } else if (typeof arguments != \"undefined\") {\n arguments_ = arguments;\n }\n if (typeof quit == \"function\") {\n quit_ = (status, toThrow) => {\n logExceptionOnExit(toThrow);\n quit(status);\n };\n }\n if (typeof print != \"undefined\") {\n if (typeof console == \"undefined\") console = {};\n console.log = print;\n console.warn = console.error = typeof printErr != \"undefined\" ? printErr : print;\n }\n } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {\n if (ENVIRONMENT_IS_WORKER) {\n scriptDirectory = self.location.href;\n } else if (typeof document != \"undefined\" && document.currentScript) {\n scriptDirectory = document.currentScript.src;\n }\n if (_scriptDir) {\n scriptDirectory = _scriptDir;\n }\n if (scriptDirectory.indexOf(\"blob:\") !== 0) {\n scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, \"\").lastIndexOf(\"/\") + 1);\n } else {\n scriptDirectory = \"\";\n }\n if (!(typeof window == \"object\" || typeof importScripts == \"function\")) throw new Error(\"not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)\");\n {\n read_ = (url) => {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, false);\n xhr.send(null);\n return xhr.responseText;\n };\n if (ENVIRONMENT_IS_WORKER) {\n readBinary = (url) => {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, false);\n xhr.responseType = \"arraybuffer\";\n xhr.send(null);\n return new Uint8Array(xhr.response);\n };\n }\n readAsync = (url, onload, onerror) => {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, true);\n xhr.responseType = \"arraybuffer\";\n xhr.onload = () => {\n if (xhr.status == 200 || xhr.status == 0 && xhr.response) {\n onload(xhr.response);\n return;\n }\n onerror();\n };\n xhr.onerror = onerror;\n xhr.send(null);\n };\n }\n setWindowTitle = (title) => document.title = title;\n } else {\n throw new Error(\"environment detection error\");\n }\n var out = Module[\"print\"] || console.log.bind(console);\n var err = Module[\"printErr\"] || console.warn.bind(console);\n Object.assign(Module, moduleOverrides);\n moduleOverrides = null;\n checkIncomingModuleAPI();\n if (Module[\"arguments\"]) arguments_ = Module[\"arguments\"];\n legacyModuleProp(\"arguments\", \"arguments_\");\n if (Module[\"thisProgram\"]) thisProgram = Module[\"thisProgram\"];\n legacyModuleProp(\"thisProgram\", \"thisProgram\");\n if (Module[\"quit\"]) quit_ = Module[\"quit\"];\n legacyModuleProp(\"quit\", \"quit_\");\n assert(typeof Module[\"memoryInitializerPrefixURL\"] == \"undefined\", \"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"pthreadMainPrefixURL\"] == \"undefined\", \"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"cdInitializerPrefixURL\"] == \"undefined\", \"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"filePackagePrefixURL\"] == \"undefined\", \"Module.filePackagePrefixURL option was removed, use Module.locateFile instead\");\n assert(typeof Module[\"read\"] == \"undefined\", \"Module.read option was removed (modify read_ in JS)\");\n assert(typeof Module[\"readAsync\"] == \"undefined\", \"Module.readAsync option was removed (modify readAsync in JS)\");\n assert(typeof Module[\"readBinary\"] == \"undefined\", \"Module.readBinary option was removed (modify readBinary in JS)\");\n assert(typeof Module[\"setWindowTitle\"] == \"undefined\", \"Module.setWindowTitle option was removed (modify setWindowTitle in JS)\");\n assert(typeof Module[\"TOTAL_MEMORY\"] == \"undefined\", \"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY\");\n legacyModuleProp(\"read\", \"read_\");\n legacyModuleProp(\"readAsync\", \"readAsync\");\n legacyModuleProp(\"readBinary\", \"readBinary\");\n legacyModuleProp(\"setWindowTitle\", \"setWindowTitle\");\n assert(!ENVIRONMENT_IS_WORKER, \"worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable.\");\n assert(!ENVIRONMENT_IS_NODE, \"node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable.\");\n assert(!ENVIRONMENT_IS_SHELL, \"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.\");\n var POINTER_SIZE = 4;\n function legacyModuleProp(prop, newName) {\n if (!Object.getOwnPropertyDescriptor(Module, prop)) {\n Object.defineProperty(Module, prop, { configurable: true, get: function() {\n abort(\"Module.\" + prop + \" has been replaced with plain \" + newName + \" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)\");\n } });\n }\n }\n function ignoredModuleProp(prop) {\n if (Object.getOwnPropertyDescriptor(Module, prop)) {\n abort(\"`Module.\" + prop + \"` was supplied but `\" + prop + \"` not included in INCOMING_MODULE_JS_API\");\n }\n }\n function isExportedByForceFilesystem(name) {\n return name === \"FS_createPath\" || name === \"FS_createDataFile\" || name === \"FS_createPreloadedFile\" || name === \"FS_unlink\" || name === \"addRunDependency\" || name === \"FS_createLazyFile\" || name === \"FS_createDevice\" || name === \"removeRunDependency\";\n }\n function missingLibrarySymbol(sym) {\n if (typeof globalThis !== \"undefined\" && !Object.getOwnPropertyDescriptor(globalThis, sym)) {\n Object.defineProperty(globalThis, sym, { configurable: true, get: function() {\n var msg = \"`\" + sym + \"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line\";\n if (isExportedByForceFilesystem(sym)) {\n msg += \". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you\";\n }\n warnOnce(msg);\n return void 0;\n } });\n }\n }\n function unexportedRuntimeSymbol(sym) {\n if (!Object.getOwnPropertyDescriptor(Module, sym)) {\n Object.defineProperty(Module, sym, { configurable: true, get: function() {\n var msg = \"'\" + sym + \"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)\";\n if (isExportedByForceFilesystem(sym)) {\n msg += \". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you\";\n }\n abort(msg);\n } });\n }\n }\n var wasmBinary;\n if (Module[\"wasmBinary\"]) wasmBinary = Module[\"wasmBinary\"];\n legacyModuleProp(\"wasmBinary\", \"wasmBinary\");\n var noExitRuntime = Module[\"noExitRuntime\"] || true;\n legacyModuleProp(\"noExitRuntime\", \"noExitRuntime\");\n if (typeof WebAssembly != \"object\") {\n abort(\"no native wasm support detected\");\n }\n var wasmMemory;\n var ABORT = false;\n var EXITSTATUS;\n function assert(condition, text) {\n if (!condition) {\n abort(\"Assertion failed\" + (text ? \": \" + text : \"\"));\n }\n }\n var UTF8Decoder = typeof TextDecoder != \"undefined\" ? new TextDecoder(\"utf8\") : void 0;\n function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {\n var endIdx = idx + maxBytesToRead;\n var endPtr = idx;\n while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;\n if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {\n return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));\n }\n var str = \"\";\n while (idx < endPtr) {\n var u0 = heapOrArray[idx++];\n if (!(u0 & 128)) {\n str += String.fromCharCode(u0);\n continue;\n }\n var u1 = heapOrArray[idx++] & 63;\n if ((u0 & 224) == 192) {\n str += String.fromCharCode((u0 & 31) << 6 | u1);\n continue;\n }\n var u2 = heapOrArray[idx++] & 63;\n if ((u0 & 240) == 224) {\n u0 = (u0 & 15) << 12 | u1 << 6 | u2;\n } else {\n if ((u0 & 248) != 240) warnOnce(\"Invalid UTF-8 leading byte 0x\" + u0.toString(16) + \" encountered when deserializing a UTF-8 string in wasm memory to a JS string!\");\n u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;\n }\n if (u0 < 65536) {\n str += String.fromCharCode(u0);\n } else {\n var ch = u0 - 65536;\n str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);\n }\n }\n return str;\n }\n function UTF8ToString(ptr, maxBytesToRead) {\n return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : \"\";\n }\n function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {\n if (!(maxBytesToWrite > 0)) return 0;\n var startIdx = outIdx;\n var endIdx = outIdx + maxBytesToWrite - 1;\n for (var i = 0; i < str.length; ++i) {\n var u = str.charCodeAt(i);\n if (u >= 55296 && u <= 57343) {\n var u1 = str.charCodeAt(++i);\n u = 65536 + ((u & 1023) << 10) | u1 & 1023;\n }\n if (u <= 127) {\n if (outIdx >= endIdx) break;\n heap[outIdx++] = u;\n } else if (u <= 2047) {\n if (outIdx + 1 >= endIdx) break;\n heap[outIdx++] = 192 | u >> 6;\n heap[outIdx++] = 128 | u & 63;\n } else if (u <= 65535) {\n if (outIdx + 2 >= endIdx) break;\n heap[outIdx++] = 224 | u >> 12;\n heap[outIdx++] = 128 | u >> 6 & 63;\n heap[outIdx++] = 128 | u & 63;\n } else {\n if (outIdx + 3 >= endIdx) break;\n if (u > 1114111) warnOnce(\"Invalid Unicode code point 0x\" + u.toString(16) + \" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).\");\n heap[outIdx++] = 240 | u >> 18;\n heap[outIdx++] = 128 | u >> 12 & 63;\n heap[outIdx++] = 128 | u >> 6 & 63;\n heap[outIdx++] = 128 | u & 63;\n }\n }\n heap[outIdx] = 0;\n return outIdx - startIdx;\n }\n function stringToUTF8(str, outPtr, maxBytesToWrite) {\n assert(typeof maxBytesToWrite == \"number\", \"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!\");\n return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);\n }\n function lengthBytesUTF8(str) {\n var len = 0;\n for (var i = 0; i < str.length; ++i) {\n var c = str.charCodeAt(i);\n if (c <= 127) {\n len++;\n } else if (c <= 2047) {\n len += 2;\n } else if (c >= 55296 && c <= 57343) {\n len += 4;\n ++i;\n } else {\n len += 3;\n }\n }\n return len;\n }\n var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;\n function updateGlobalBufferAndViews(buf) {\n buffer = buf;\n Module[\"HEAP8\"] = HEAP8 = new Int8Array(buf);\n Module[\"HEAP16\"] = HEAP16 = new Int16Array(buf);\n Module[\"HEAP32\"] = HEAP32 = new Int32Array(buf);\n Module[\"HEAPU8\"] = HEAPU8 = new Uint8Array(buf);\n Module[\"HEAPU16\"] = HEAPU16 = new Uint16Array(buf);\n Module[\"HEAPU32\"] = HEAPU32 = new Uint32Array(buf);\n Module[\"HEAPF32\"] = HEAPF32 = new Float32Array(buf);\n Module[\"HEAPF64\"] = HEAPF64 = new Float64Array(buf);\n }\n var TOTAL_STACK = 65536;\n if (Module[\"TOTAL_STACK\"]) assert(TOTAL_STACK === Module[\"TOTAL_STACK\"], \"the stack size can no longer be determined at runtime\");\n var INITIAL_MEMORY = Module[\"INITIAL_MEMORY\"] || 262144;\n legacyModuleProp(\"INITIAL_MEMORY\", \"INITIAL_MEMORY\");\n assert(INITIAL_MEMORY >= TOTAL_STACK, \"INITIAL_MEMORY should be larger than TOTAL_STACK, was \" + INITIAL_MEMORY + \"! (TOTAL_STACK=\" + TOTAL_STACK + \")\");\n assert(typeof Int32Array != \"undefined\" && typeof Float64Array !== \"undefined\" && Int32Array.prototype.subarray != void 0 && Int32Array.prototype.set != void 0, \"JS engine does not provide full typed array support\");\n assert(!Module[\"wasmMemory\"], \"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally\");\n assert(INITIAL_MEMORY == 262144, \"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically\");\n var wasmTable;\n function writeStackCookie() {\n var max = _emscripten_stack_get_end();\n assert((max & 3) == 0);\n HEAPU32[max >> 2] = 34821223;\n HEAPU32[max + 4 >> 2] = 2310721022;\n HEAPU32[0] = 1668509029;\n }\n function checkStackCookie() {\n if (ABORT) return;\n var max = _emscripten_stack_get_end();\n var cookie1 = HEAPU32[max >> 2];\n var cookie2 = HEAPU32[max + 4 >> 2];\n if (cookie1 != 34821223 || cookie2 != 2310721022) {\n abort(\"Stack overflow! Stack cookie has been overwritten at 0x\" + max.toString(16) + \", expected hex dwords 0x89BACDFE and 0x2135467, but received 0x\" + cookie2.toString(16) + \" 0x\" + cookie1.toString(16));\n }\n if (HEAPU32[0] !== 1668509029) abort(\"Runtime error: The application has corrupted its heap memory area (address zero)!\");\n }\n (function() {\n var h16 = new Int16Array(1);\n var h8 = new Int8Array(h16.buffer);\n h16[0] = 25459;\n if (h8[0] !== 115 || h8[1] !== 99) throw \"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)\";\n })();\n var __ATPRERUN__ = [];\n var __ATINIT__ = [];\n var __ATPOSTRUN__ = [];\n var runtimeInitialized = false;\n function preRun() {\n if (Module[\"preRun\"]) {\n if (typeof Module[\"preRun\"] == \"function\") Module[\"preRun\"] = [Module[\"preRun\"]];\n while (Module[\"preRun\"].length) {\n addOnPreRun(Module[\"preRun\"].shift());\n }\n }\n callRuntimeCallbacks(__ATPRERUN__);\n }\n function initRuntime() {\n assert(!runtimeInitialized);\n runtimeInitialized = true;\n checkStackCookie();\n callRuntimeCallbacks(__ATINIT__);\n }\n function postRun() {\n checkStackCookie();\n if (Module[\"postRun\"]) {\n if (typeof Module[\"postRun\"] == \"function\") Module[\"postRun\"] = [Module[\"postRun\"]];\n while (Module[\"postRun\"].length) {\n addOnPostRun(Module[\"postRun\"].shift());\n }\n }\n callRuntimeCallbacks(__ATPOSTRUN__);\n }\n function addOnPreRun(cb) {\n __ATPRERUN__.unshift(cb);\n }\n function addOnInit(cb) {\n __ATINIT__.unshift(cb);\n }\n function addOnPostRun(cb) {\n __ATPOSTRUN__.unshift(cb);\n }\n assert(Math.imul, \"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n assert(Math.fround, \"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n assert(Math.clz32, \"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n assert(Math.trunc, \"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill\");\n var runDependencies = 0;\n var runDependencyWatcher = null;\n var dependenciesFulfilled = null;\n var runDependencyTracking = {};\n function addRunDependency(id) {\n runDependencies++;\n if (Module[\"monitorRunDependencies\"]) {\n Module[\"monitorRunDependencies\"](runDependencies);\n }\n if (id) {\n assert(!runDependencyTracking[id]);\n runDependencyTracking[id] = 1;\n if (runDependencyWatcher === null && typeof setInterval != \"undefined\") {\n runDependencyWatcher = setInterval(function() {\n if (ABORT) {\n clearInterval(runDependencyWatcher);\n runDependencyWatcher = null;\n return;\n }\n var shown = false;\n for (var dep in runDependencyTracking) {\n if (!shown) {\n shown = true;\n err(\"still waiting on run dependencies:\");\n }\n err(\"dependency: \" + dep);\n }\n if (shown) {\n err(\"(end of list)\");\n }\n }, 1e4);\n }\n } else {\n err(\"warning: run dependency added without ID\");\n }\n }\n function removeRunDependency(id) {\n runDependencies--;\n if (Module[\"monitorRunDependencies\"]) {\n Module[\"monitorRunDependencies\"](runDependencies);\n }\n if (id) {\n assert(runDependencyTracking[id]);\n delete runDependencyTracking[id];\n } else {\n err(\"warning: run dependency removed without ID\");\n }\n if (runDependencies == 0) {\n if (runDependencyWatcher !== null) {\n clearInterval(runDependencyWatcher);\n runDependencyWatcher = null;\n }\n if (dependenciesFulfilled) {\n var callback = dependenciesFulfilled;\n dependenciesFulfilled = null;\n callback();\n }\n }\n }\n function abort(what) {\n {\n if (Module[\"onAbort\"]) {\n Module[\"onAbort\"](what);\n }\n }\n what = \"Aborted(\" + what + \")\";\n err(what);\n ABORT = true;\n EXITSTATUS = 1;\n var e = new WebAssembly.RuntimeError(what);\n readyPromiseReject(e);\n throw e;\n }\n var FS = { error: function() {\n abort(\"Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM\");\n }, init: function() {\n FS.error();\n }, createDataFile: function() {\n FS.error();\n }, createPreloadedFile: function() {\n FS.error();\n }, createLazyFile: function() {\n FS.error();\n }, open: function() {\n FS.error();\n }, mkdev: function() {\n FS.error();\n }, registerDevice: function() {\n FS.error();\n }, analyzePath: function() {\n FS.error();\n }, loadFilesFromDB: function() {\n FS.error();\n }, ErrnoError: function ErrnoError() {\n FS.error();\n } };\n Module[\"FS_createDataFile\"] = FS.createDataFile;\n Module[\"FS_createPreloadedFile\"] = FS.createPreloadedFile;\n var dataURIPrefix = \"data:application/octet-stream;base64,\";\n function isDataURI(filename) {\n return filename.startsWith(dataURIPrefix);\n }\n function isFileURI(filename) {\n return filename.startsWith(\"file://\");\n }\n function createExportWrapper(name, fixedasm) {\n return function() {\n var displayName = name;\n var asm2 = fixedasm;\n if (!fixedasm) {\n asm2 = Module[\"asm\"];\n }\n assert(runtimeInitialized, \"native function `\" + displayName + \"` called before runtime initialization\");\n if (!asm2[name]) {\n assert(asm2[name], \"exported native function `\" + displayName + \"` not found\");\n }\n return asm2[name].apply(null, arguments);\n };\n }\n var wasmBinaryFile;\n wasmBinaryFile = \"laz-perf.wasm\";\n if (!isDataURI(wasmBinaryFile)) {\n wasmBinaryFile = locateFile(wasmBinaryFile);\n }\n function getBinary(file) {\n try {\n if (file == wasmBinaryFile && wasmBinary) {\n return new Uint8Array(wasmBinary);\n }\n if (readBinary) {\n return readBinary(file);\n }\n throw \"both async and sync fetching of the wasm failed\";\n } catch (err2) {\n abort(err2);\n }\n }\n function getBinaryPromise() {\n if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {\n if (typeof fetch == \"function\") {\n return fetch(wasmBinaryFile, { credentials: \"same-origin\" }).then(function(response) {\n if (!response[\"ok\"]) {\n throw \"failed to load wasm binary file at '\" + wasmBinaryFile + \"'\";\n }\n return response[\"arrayBuffer\"]();\n }).catch(function() {\n return getBinary(wasmBinaryFile);\n });\n }\n }\n return Promise.resolve().then(function() {\n return getBinary(wasmBinaryFile);\n });\n }\n function createWasm() {\n var info = { \"env\": asmLibraryArg, \"wasi_snapshot_preview1\": asmLibraryArg };\n function receiveInstance(instance, module2) {\n var exports3 = instance.exports;\n Module[\"asm\"] = exports3;\n wasmMemory = Module[\"asm\"][\"memory\"];\n assert(wasmMemory, \"memory not found in wasm exports\");\n updateGlobalBufferAndViews(wasmMemory.buffer);\n wasmTable = Module[\"asm\"][\"__indirect_function_table\"];\n assert(wasmTable, \"table not found in wasm exports\");\n addOnInit(Module[\"asm\"][\"__wasm_call_ctors\"]);\n removeRunDependency(\"wasm-instantiate\");\n }\n addRunDependency(\"wasm-instantiate\");\n var trueModule = Module;\n function receiveInstantiationResult(result) {\n assert(Module === trueModule, \"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?\");\n trueModule = null;\n receiveInstance(result[\"instance\"]);\n }\n function instantiateArrayBuffer(receiver) {\n return getBinaryPromise().then(function(binary) {\n return WebAssembly.instantiate(binary, info);\n }).then(function(instance) {\n return instance;\n }).then(receiver, function(reason) {\n err(\"failed to asynchronously prepare wasm: \" + reason);\n if (isFileURI(wasmBinaryFile)) {\n err(\"warning: Loading from a file URI (\" + wasmBinaryFile + \") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing\");\n }\n abort(reason);\n });\n }\n function instantiateAsync() {\n if (!wasmBinary && typeof WebAssembly.instantiateStreaming == \"function\" && !isDataURI(wasmBinaryFile) && typeof fetch == \"function\") {\n return fetch(wasmBinaryFile, { credentials: \"same-origin\" }).then(function(response) {\n var result = WebAssembly.instantiateStreaming(response, info);\n return result.then(receiveInstantiationResult, function(reason) {\n err(\"wasm streaming compile failed: \" + reason);\n err(\"falling back to ArrayBuffer instantiation\");\n return instantiateArrayBuffer(receiveInstantiationResult);\n });\n });\n } else {\n return instantiateArrayBuffer(receiveInstantiationResult);\n }\n }\n if (Module[\"instantiateWasm\"]) {\n try {\n var exports2 = Module[\"instantiateWasm\"](info, receiveInstance);\n return exports2;\n } catch (e) {\n err(\"Module.instantiateWasm callback failed with error: \" + e);\n return false;\n }\n }\n instantiateAsync().catch(readyPromiseReject);\n return {};\n }\n var tempDouble;\n var tempI64;\n function ExitStatus(status) {\n this.name = \"ExitStatus\";\n this.message = \"Program terminated with exit(\" + status + \")\";\n this.status = status;\n }\n function callRuntimeCallbacks(callbacks) {\n while (callbacks.length > 0) {\n callbacks.shift()(Module);\n }\n }\n function demangle(func) {\n warnOnce(\"warning: build with -sDEMANGLE_SUPPORT to link in libcxxabi demangling\");\n return func;\n }\n function demangleAll(text) {\n var regex = /\\b_Z[\\w\\d_]+/g;\n return text.replace(regex, function(x) {\n var y = demangle(x);\n return x === y ? x : y + \" [\" + x + \"]\";\n });\n }\n function jsStackTrace() {\n var error = new Error();\n if (!error.stack) {\n try {\n throw new Error();\n } catch (e) {\n error = e;\n }\n if (!error.stack) {\n return \"(no stack trace available)\";\n }\n }\n return error.stack.toString();\n }\n function warnOnce(text) {\n if (!warnOnce.shown) warnOnce.shown = {};\n if (!warnOnce.shown[text]) {\n warnOnce.shown[text] = 1;\n err(text);\n }\n }\n function writeArrayToMemory(array, buffer2) {\n assert(array.length >= 0, \"writeArrayToMemory array must have a length (should be an array or typed array)\");\n HEAP8.set(array, buffer2);\n }\n function ___cxa_allocate_exception(size) {\n return _malloc(size + 24) + 24;\n }\n function ExceptionInfo(excPtr) {\n this.excPtr = excPtr;\n this.ptr = excPtr - 24;\n this.set_type = function(type) {\n HEAPU32[this.ptr + 4 >> 2] = type;\n };\n this.get_type = function() {\n return HEAPU32[this.ptr + 4 >> 2];\n };\n this.set_destructor = function(destructor) {\n HEAPU32[this.ptr + 8 >> 2] = destructor;\n };\n this.get_destructor = function() {\n return HEAPU32[this.ptr + 8 >> 2];\n };\n this.set_refcount = function(refcount) {\n HEAP32[this.ptr >> 2] = refcount;\n };\n this.set_caught = function(caught) {\n caught = caught ? 1 : 0;\n HEAP8[this.ptr + 12 >> 0] = caught;\n };\n this.get_caught = function() {\n return HEAP8[this.ptr + 12 >> 0] != 0;\n };\n this.set_rethrown = function(rethrown) {\n rethrown = rethrown ? 1 : 0;\n HEAP8[this.ptr + 13 >> 0] = rethrown;\n };\n this.get_rethrown = function() {\n return HEAP8[this.ptr + 13 >> 0] != 0;\n };\n this.init = function(type, destructor) {\n this.set_adjusted_ptr(0);\n this.set_type(type);\n this.set_destructor(destructor);\n this.set_refcount(0);\n this.set_caught(false);\n this.set_rethrown(false);\n };\n this.add_ref = function() {\n var value = HEAP32[this.ptr >> 2];\n HEAP32[this.ptr >> 2] = value + 1;\n };\n this.release_ref = function() {\n var prev = HEAP32[this.ptr >> 2];\n HEAP32[this.ptr >> 2] = prev - 1;\n assert(prev > 0);\n return prev === 1;\n };\n this.set_adjusted_ptr = function(adjustedPtr) {\n HEAPU32[this.ptr + 16 >> 2] = adjustedPtr;\n };\n this.get_adjusted_ptr = function() {\n return HEAPU32[this.ptr + 16 >> 2];\n };\n this.get_exception_ptr = function() {\n var isPointer = ___cxa_is_pointer_type(this.get_type());\n if (isPointer) {\n return HEAPU32[this.excPtr >> 2];\n }\n var adjusted = this.get_adjusted_ptr();\n if (adjusted !== 0) return adjusted;\n return this.excPtr;\n };\n }\n var exceptionLast = 0;\n var uncaughtExceptionCount = 0;\n function ___cxa_throw(ptr, type, destructor) {\n var info = new ExceptionInfo(ptr);\n info.init(type, destructor);\n exceptionLast = ptr;\n uncaughtExceptionCount++;\n throw ptr + \" - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.\";\n }\n function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) {\n }\n function getShiftFromSize(size) {\n switch (size) {\n case 1:\n return 0;\n case 2:\n return 1;\n case 4:\n return 2;\n case 8:\n return 3;\n default:\n throw new TypeError(\"Unknown type size: \" + size);\n }\n }\n function embind_init_charCodes() {\n var codes = new Array(256);\n for (var i = 0; i < 256; ++i) {\n codes[i] = String.fromCharCode(i);\n }\n embind_charCodes = codes;\n }\n var embind_charCodes = void 0;\n function readLatin1String(ptr) {\n var ret = \"\";\n var c = ptr;\n while (HEAPU8[c]) {\n ret += embind_charCodes[HEAPU8[c++]];\n }\n return ret;\n }\n var awaitingDependencies = {};\n var registeredTypes = {};\n var typeDependencies = {};\n var char_0 = 48;\n var char_9 = 57;\n function makeLegalFunctionName(name) {\n if (void 0 === name) {\n return \"_unknown\";\n }\n name = name.replace(/[^a-zA-Z0-9_]/g, \"$\");\n var f = name.charCodeAt(0);\n if (f >= char_0 && f <= char_9) {\n return \"_\" + name;\n }\n return name;\n }\n function createNamedFunction(name, body) {\n name = makeLegalFunctionName(name);\n return function() {\n \"use strict\";\n return body.apply(this, arguments);\n };\n }\n function extendError(baseErrorType, errorName) {\n var errorClass = createNamedFunction(errorName, function(message) {\n this.name = errorName;\n this.message = message;\n var stack = new Error(message).stack;\n if (stack !== void 0) {\n this.stack = this.toString() + \"\\n\" + stack.replace(/^Error(:[^\\n]*)?\\n/, \"\");\n }\n });\n errorClass.prototype = Object.create(baseErrorType.prototype);\n errorClass.prototype.constructor = errorClass;\n errorClass.prototype.toString = function() {\n if (this.message === void 0) {\n return this.name;\n } else {\n return this.name + \": \" + this.message;\n }\n };\n return errorClass;\n }\n var BindingError = void 0;\n function throwBindingError(message) {\n throw new BindingError(message);\n }\n var InternalError = void 0;\n function throwInternalError(message) {\n throw new InternalError(message);\n }\n function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {\n myTypes.forEach(function(type) {\n typeDependencies[type] = dependentTypes;\n });\n function onComplete(typeConverters2) {\n var myTypeConverters = getTypeConverters(typeConverters2);\n if (myTypeConverters.length !== myTypes.length) {\n throwInternalError(\"Mismatched type converter count\");\n }\n for (var i = 0; i < myTypes.length; ++i) {\n registerType(myTypes[i], myTypeConverters[i]);\n }\n }\n var typeConverters = new Array(dependentTypes.length);\n var unregisteredTypes = [];\n var registered = 0;\n dependentTypes.forEach((dt, i) => {\n if (registeredTypes.hasOwnProperty(dt)) {\n typeConverters[i] = registeredTypes[dt];\n } else {\n unregisteredTypes.push(dt);\n if (!awaitingDependencies.hasOwnProperty(dt)) {\n awaitingDependencies[dt] = [];\n }\n awaitingDependencies[dt].push(() => {\n typeConverters[i] = registeredTypes[dt];\n ++registered;\n if (registered === unregisteredTypes.length) {\n onComplete(typeConverters);\n }\n });\n }\n });\n if (0 === unregisteredTypes.length) {\n onComplete(typeConverters);\n }\n }\n function registerType(rawType, registeredInstance, options = {}) {\n if (!(\"argPackAdvance\" in registeredInstance)) {\n throw new TypeError(\"registerType registeredInstance requires argPackAdvance\");\n }\n var name = registeredInstance.name;\n if (!rawType) {\n throwBindingError('type \"' + name + '\" must have a positive integer typeid pointer');\n }\n if (registeredTypes.hasOwnProperty(rawType)) {\n if (options.ignoreDuplicateRegistrations) {\n return;\n } else {\n throwBindingError(\"Cannot register type '\" + name + \"' twice\");\n }\n }\n registeredTypes[rawType] = registeredInstance;\n delete typeDependencies[rawType];\n if (awaitingDependencies.hasOwnProperty(rawType)) {\n var callbacks = awaitingDependencies[rawType];\n delete awaitingDependencies[rawType];\n callbacks.forEach((cb) => cb());\n }\n }\n function __embind_register_bool(rawType, name, size, trueValue, falseValue) {\n var shift = getShiftFromSize(size);\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": function(wt) {\n return !!wt;\n }, \"toWireType\": function(destructors, o) {\n return o ? trueValue : falseValue;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": function(pointer) {\n var heap;\n if (size === 1) {\n heap = HEAP8;\n } else if (size === 2) {\n heap = HEAP16;\n } else if (size === 4) {\n heap = HEAP32;\n } else {\n throw new TypeError(\"Unknown boolean type size: \" + name);\n }\n return this[\"fromWireType\"](heap[pointer >> shift]);\n }, destructorFunction: null });\n }\n function ClassHandle_isAliasOf(other) {\n if (!(this instanceof ClassHandle)) {\n return false;\n }\n if (!(other instanceof ClassHandle)) {\n return false;\n }\n var leftClass = this.$$.ptrType.registeredClass;\n var left = this.$$.ptr;\n var rightClass = other.$$.ptrType.registeredClass;\n var right = other.$$.ptr;\n while (leftClass.baseClass) {\n left = leftClass.upcast(left);\n leftClass = leftClass.baseClass;\n }\n while (rightClass.baseClass) {\n right = rightClass.upcast(right);\n rightClass = rightClass.baseClass;\n }\n return leftClass === rightClass && left === right;\n }\n function shallowCopyInternalPointer(o) {\n return { count: o.count, deleteScheduled: o.deleteScheduled, preservePointerOnDelete: o.preservePointerOnDelete, ptr: o.ptr, ptrType: o.ptrType, smartPtr: o.smartPtr, smartPtrType: o.smartPtrType };\n }\n function throwInstanceAlreadyDeleted(obj) {\n function getInstanceTypeName(handle) {\n return handle.$$.ptrType.registeredClass.name;\n }\n throwBindingError(getInstanceTypeName(obj) + \" instance already deleted\");\n }\n var finalizationRegistry = false;\n function detachFinalizer(handle) {\n }\n function runDestructor($$) {\n if ($$.smartPtr) {\n $$.smartPtrType.rawDestructor($$.smartPtr);\n } else {\n $$.ptrType.registeredClass.rawDestructor($$.ptr);\n }\n }\n function releaseClassHandle($$) {\n $$.count.value -= 1;\n var toDelete = 0 === $$.count.value;\n if (toDelete) {\n runDestructor($$);\n }\n }\n function downcastPointer(ptr, ptrClass, desiredClass) {\n if (ptrClass === desiredClass) {\n return ptr;\n }\n if (void 0 === desiredClass.baseClass) {\n return null;\n }\n var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass);\n if (rv === null) {\n return null;\n }\n return desiredClass.downcast(rv);\n }\n var registeredPointers = {};\n function getInheritedInstanceCount() {\n return Object.keys(registeredInstances).length;\n }\n function getLiveInheritedInstances() {\n var rv = [];\n for (var k in registeredInstances) {\n if (registeredInstances.hasOwnProperty(k)) {\n rv.push(registeredInstances[k]);\n }\n }\n return rv;\n }\n var deletionQueue = [];\n function flushPendingDeletes() {\n while (deletionQueue.length) {\n var obj = deletionQueue.pop();\n obj.$$.deleteScheduled = false;\n obj[\"delete\"]();\n }\n }\n var delayFunction = void 0;\n function setDelayFunction(fn) {\n delayFunction = fn;\n if (deletionQueue.length && delayFunction) {\n delayFunction(flushPendingDeletes);\n }\n }\n function init_embind() {\n Module[\"getInheritedInstanceCount\"] = getInheritedInstanceCount;\n Module[\"getLiveInheritedInstances\"] = getLiveInheritedInstances;\n Module[\"flushPendingDeletes\"] = flushPendingDeletes;\n Module[\"setDelayFunction\"] = setDelayFunction;\n }\n var registeredInstances = {};\n function getBasestPointer(class_, ptr) {\n if (ptr === void 0) {\n throwBindingError(\"ptr should not be undefined\");\n }\n while (class_.baseClass) {\n ptr = class_.upcast(ptr);\n class_ = class_.baseClass;\n }\n return ptr;\n }\n function getInheritedInstance(class_, ptr) {\n ptr = getBasestPointer(class_, ptr);\n return registeredInstances[ptr];\n }\n function makeClassHandle(prototype, record) {\n if (!record.ptrType || !record.ptr) {\n throwInternalError(\"makeClassHandle requires ptr and ptrType\");\n }\n var hasSmartPtrType = !!record.smartPtrType;\n var hasSmartPtr = !!record.smartPtr;\n if (hasSmartPtrType !== hasSmartPtr) {\n throwInternalError(\"Both smartPtrType and smartPtr must be specified\");\n }\n record.count = { value: 1 };\n return attachFinalizer(Object.create(prototype, { $$: { value: record } }));\n }\n function RegisteredPointer_fromWireType(ptr) {\n var rawPointer = this.getPointee(ptr);\n if (!rawPointer) {\n this.destructor(ptr);\n return null;\n }\n var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);\n if (void 0 !== registeredInstance) {\n if (0 === registeredInstance.$$.count.value) {\n registeredInstance.$$.ptr = rawPointer;\n registeredInstance.$$.smartPtr = ptr;\n return registeredInstance[\"clone\"]();\n } else {\n var rv = registeredInstance[\"clone\"]();\n this.destructor(ptr);\n return rv;\n }\n }\n function makeDefaultHandle() {\n if (this.isSmartPointer) {\n return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: rawPointer, smartPtrType: this, smartPtr: ptr });\n } else {\n return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this, ptr });\n }\n }\n var actualType = this.registeredClass.getActualType(rawPointer);\n var registeredPointerRecord = registeredPointers[actualType];\n if (!registeredPointerRecord) {\n return makeDefaultHandle.call(this);\n }\n var toType;\n if (this.isConst) {\n toType = registeredPointerRecord.constPointerType;\n } else {\n toType = registeredPointerRecord.pointerType;\n }\n var dp = downcastPointer(rawPointer, this.registeredClass, toType.registeredClass);\n if (dp === null) {\n return makeDefaultHandle.call(this);\n }\n if (this.isSmartPointer) {\n return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp, smartPtrType: this, smartPtr: ptr });\n } else {\n return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp });\n }\n }\n function attachFinalizer(handle) {\n if (\"undefined\" === typeof FinalizationRegistry) {\n attachFinalizer = (handle2) => handle2;\n return handle;\n }\n finalizationRegistry = new FinalizationRegistry((info) => {\n console.warn(info.leakWarning.stack.replace(/^Error: /, \"\"));\n releaseClassHandle(info.$$);\n });\n attachFinalizer = (handle2) => {\n var $$ = handle2.$$;\n var hasSmartPtr = !!$$.smartPtr;\n if (hasSmartPtr) {\n var info = { $$ };\n var cls = $$.ptrType.registeredClass;\n info.leakWarning = new Error(\"Embind found a leaked C++ instance \" + cls.name + \" <0x\" + $$.ptr.toString(16) + \">.\\nWe'll free it automatically in this case, but this functionality is not reliable across various environments.\\nMake sure to invoke .delete() manually once you're done with the instance instead.\\nOriginally allocated\");\n if (\"captureStackTrace\" in Error) {\n Error.captureStackTrace(info.leakWarning, RegisteredPointer_fromWireType);\n }\n finalizationRegistry.register(handle2, info, handle2);\n }\n return handle2;\n };\n detachFinalizer = (handle2) => finalizationRegistry.unregister(handle2);\n return attachFinalizer(handle);\n }\n function ClassHandle_clone() {\n if (!this.$$.ptr) {\n throwInstanceAlreadyDeleted(this);\n }\n if (this.$$.preservePointerOnDelete) {\n this.$$.count.value += 1;\n return this;\n } else {\n var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), { $$: { value: shallowCopyInternalPointer(this.$$) } }));\n clone.$$.count.value += 1;\n clone.$$.deleteScheduled = false;\n return clone;\n }\n }\n function ClassHandle_delete() {\n if (!this.$$.ptr) {\n throwInstanceAlreadyDeleted(this);\n }\n if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {\n throwBindingError(\"Object already scheduled for deletion\");\n }\n detachFinalizer(this);\n releaseClassHandle(this.$$);\n if (!this.$$.preservePointerOnDelete) {\n this.$$.smartPtr = void 0;\n this.$$.ptr = void 0;\n }\n }\n function ClassHandle_isDeleted() {\n return !this.$$.ptr;\n }\n function ClassHandle_deleteLater() {\n if (!this.$$.ptr) {\n throwInstanceAlreadyDeleted(this);\n }\n if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {\n throwBindingError(\"Object already scheduled for deletion\");\n }\n deletionQueue.push(this);\n if (deletionQueue.length === 1 && delayFunction) {\n delayFunction(flushPendingDeletes);\n }\n this.$$.deleteScheduled = true;\n return this;\n }\n function init_ClassHandle() {\n ClassHandle.prototype[\"isAliasOf\"] = ClassHandle_isAliasOf;\n ClassHandle.prototype[\"clone\"] = ClassHandle_clone;\n ClassHandle.prototype[\"delete\"] = ClassHandle_delete;\n ClassHandle.prototype[\"isDeleted\"] = ClassHandle_isDeleted;\n ClassHandle.prototype[\"deleteLater\"] = ClassHandle_deleteLater;\n }\n function ClassHandle() {\n }\n function ensureOverloadTable(proto, methodName, humanName) {\n if (void 0 === proto[methodName].overloadTable) {\n var prevFunc = proto[methodName];\n proto[methodName] = function() {\n if (!proto[methodName].overloadTable.hasOwnProperty(arguments.length)) {\n throwBindingError(\"Function '\" + humanName + \"' called with an invalid number of arguments (\" + arguments.length + \") - expects one of (\" + proto[methodName].overloadTable + \")!\");\n }\n return proto[methodName].overloadTable[arguments.length].apply(this, arguments);\n };\n proto[methodName].overloadTable = [];\n proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;\n }\n }\n function exposePublicSymbol(name, value, numArguments) {\n if (Module.hasOwnProperty(name)) {\n if (void 0 === numArguments || void 0 !== Module[name].overloadTable && void 0 !== Module[name].overloadTable[numArguments]) {\n throwBindingError(\"Cannot register public name '\" + name + \"' twice\");\n }\n ensureOverloadTable(Module, name, name);\n if (Module.hasOwnProperty(numArguments)) {\n throwBindingError(\"Cannot register multiple overloads of a function with the same number of arguments (\" + numArguments + \")!\");\n }\n Module[name].overloadTable[numArguments] = value;\n } else {\n Module[name] = value;\n if (void 0 !== numArguments) {\n Module[name].numArguments = numArguments;\n }\n }\n }\n function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) {\n this.name = name;\n this.constructor = constructor;\n this.instancePrototype = instancePrototype;\n this.rawDestructor = rawDestructor;\n this.baseClass = baseClass;\n this.getActualType = getActualType;\n this.upcast = upcast;\n this.downcast = downcast;\n this.pureVirtualFunctions = [];\n }\n function upcastPointer(ptr, ptrClass, desiredClass) {\n while (ptrClass !== desiredClass) {\n if (!ptrClass.upcast) {\n throwBindingError(\"Expected null or instance of \" + desiredClass.name + \", got an instance of \" + ptrClass.name);\n }\n ptr = ptrClass.upcast(ptr);\n ptrClass = ptrClass.baseClass;\n }\n return ptr;\n }\n function constNoSmartPtrRawPointerToWireType(destructors, handle) {\n if (handle === null) {\n if (this.isReference) {\n throwBindingError(\"null is not a valid \" + this.name);\n }\n return 0;\n }\n if (!handle.$$) {\n throwBindingError('Cannot pass \"' + embindRepr(handle) + '\" as a ' + this.name);\n }\n if (!handle.$$.ptr) {\n throwBindingError(\"Cannot pass deleted object as a pointer of type \" + this.name);\n }\n var handleClass = handle.$$.ptrType.registeredClass;\n var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);\n return ptr;\n }\n function genericPointerToWireType(destructors, handle) {\n var ptr;\n if (handle === null) {\n if (this.isReference) {\n throwBindingError(\"null is not a valid \" + this.name);\n }\n if (this.isSmartPointer) {\n ptr = this.rawConstructor();\n if (destructors !== null) {\n destructors.push(this.rawDestructor, ptr);\n }\n return ptr;\n } else {\n return 0;\n }\n }\n if (!handle.$$) {\n throwBindingError('Cannot pass \"' + embindRepr(handle) + '\" as a ' + this.name);\n }\n if (!handle.$$.ptr) {\n throwBindingError(\"Cannot pass deleted object as a pointer of type \" + this.name);\n }\n if (!this.isConst && handle.$$.ptrType.isConst) {\n throwBindingError(\"Cannot convert argument of type \" + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + \" to parameter type \" + this.name);\n }\n var handleClass = handle.$$.ptrType.registeredClass;\n ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);\n if (this.isSmartPointer) {\n if (void 0 === handle.$$.smartPtr) {\n throwBindingError(\"Passing raw pointer to smart pointer is illegal\");\n }\n switch (this.sharingPolicy) {\n case 0:\n if (handle.$$.smartPtrType === this) {\n ptr = handle.$$.smartPtr;\n } else {\n throwBindingError(\"Cannot convert argument of type \" + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + \" to parameter type \" + this.name);\n }\n break;\n case 1:\n ptr = handle.$$.smartPtr;\n break;\n case 2:\n if (handle.$$.smartPtrType === this) {\n ptr = handle.$$.smartPtr;\n } else {\n var clonedHandle = handle[\"clone\"]();\n ptr = this.rawShare(ptr, Emval.toHandle(function() {\n clonedHandle[\"delete\"]();\n }));\n if (destructors !== null) {\n destructors.push(this.rawDestructor, ptr);\n }\n }\n break;\n default:\n throwBindingError(\"Unsupporting sharing policy\");\n }\n }\n return ptr;\n }\n function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) {\n if (handle === null) {\n if (this.isReference) {\n throwBindingError(\"null is not a valid \" + this.name);\n }\n return 0;\n }\n if (!handle.$$) {\n throwBindingError('Cannot pass \"' + embindRepr(handle) + '\" as a ' + this.name);\n }\n if (!handle.$$.ptr) {\n throwBindingError(\"Cannot pass deleted object as a pointer of type \" + this.name);\n }\n if (handle.$$.ptrType.isConst) {\n throwBindingError(\"Cannot convert argument of type \" + handle.$$.ptrType.name + \" to parameter type \" + this.name);\n }\n var handleClass = handle.$$.ptrType.registeredClass;\n var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);\n return ptr;\n }\n function simpleReadValueFromPointer(pointer) {\n return this[\"fromWireType\"](HEAP32[pointer >> 2]);\n }\n function RegisteredPointer_getPointee(ptr) {\n if (this.rawGetPointee) {\n ptr = this.rawGetPointee(ptr);\n }\n return ptr;\n }\n function RegisteredPointer_destructor(ptr) {\n if (this.rawDestructor) {\n this.rawDestructor(ptr);\n }\n }\n function RegisteredPointer_deleteObject(handle) {\n if (handle !== null) {\n handle[\"delete\"]();\n }\n }\n function init_RegisteredPointer() {\n RegisteredPointer.prototype.getPointee = RegisteredPointer_getPointee;\n RegisteredPointer.prototype.destructor = RegisteredPointer_destructor;\n RegisteredPointer.prototype[\"argPackAdvance\"] = 8;\n RegisteredPointer.prototype[\"readValueFromPointer\"] = simpleReadValueFromPointer;\n RegisteredPointer.prototype[\"deleteObject\"] = RegisteredPointer_deleteObject;\n RegisteredPointer.prototype[\"fromWireType\"] = RegisteredPointer_fromWireType;\n }\n function RegisteredPointer(name, registeredClass, isReference, isConst, isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) {\n this.name = name;\n this.registeredClass = registeredClass;\n this.isReference = isReference;\n this.isConst = isConst;\n this.isSmartPointer = isSmartPointer;\n this.pointeeType = pointeeType;\n this.sharingPolicy = sharingPolicy;\n this.rawGetPointee = rawGetPointee;\n this.rawConstructor = rawConstructor;\n this.rawShare = rawShare;\n this.rawDestructor = rawDestructor;\n if (!isSmartPointer && registeredClass.baseClass === void 0) {\n if (isConst) {\n this[\"toWireType\"] = constNoSmartPtrRawPointerToWireType;\n this.destructorFunction = null;\n } else {\n this[\"toWireType\"] = nonConstNoSmartPtrRawPointerToWireType;\n this.destructorFunction = null;\n }\n } else {\n this[\"toWireType\"] = genericPointerToWireType;\n }\n }\n function replacePublicSymbol(name, value, numArguments) {\n if (!Module.hasOwnProperty(name)) {\n throwInternalError(\"Replacing nonexistant public symbol\");\n }\n if (void 0 !== Module[name].overloadTable && void 0 !== numArguments) {\n Module[name].overloadTable[numArguments] = value;\n } else {\n Module[name] = value;\n Module[name].argCount = numArguments;\n }\n }\n function dynCallLegacy(sig, ptr, args) {\n assert(\"dynCall_\" + sig in Module, \"bad function pointer type - no table for sig '\" + sig + \"'\");\n if (args && args.length) {\n assert(args.length === sig.substring(1).replace(/j/g, \"--\").length);\n } else {\n assert(sig.length == 1);\n }\n var f = Module[\"dynCall_\" + sig];\n return args && args.length ? f.apply(null, [ptr].concat(args)) : f.call(null, ptr);\n }\n var wasmTableMirror = [];\n function getWasmTableEntry(funcPtr) {\n var func = wasmTableMirror[funcPtr];\n if (!func) {\n if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;\n wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);\n }\n assert(wasmTable.get(funcPtr) == func, \"JavaScript-side Wasm function table mirror is out of date!\");\n return func;\n }\n function dynCall(sig, ptr, args) {\n if (sig.includes(\"j\")) {\n return dynCallLegacy(sig, ptr, args);\n }\n assert(getWasmTableEntry(ptr), \"missing table entry in dynCall: \" + ptr);\n var rtn = getWasmTableEntry(ptr).apply(null, args);\n return rtn;\n }\n function getDynCaller(sig, ptr) {\n assert(sig.includes(\"j\") || sig.includes(\"p\"), \"getDynCaller should only be called with i64 sigs\");\n var argCache = [];\n return function() {\n argCache.length = 0;\n Object.assign(argCache, arguments);\n return dynCall(sig, ptr, argCache);\n };\n }\n function embind__requireFunction(signature, rawFunction) {\n signature = readLatin1String(signature);\n function makeDynCaller() {\n if (signature.includes(\"j\")) {\n return getDynCaller(signature, rawFunction);\n }\n return getWasmTableEntry(rawFunction);\n }\n var fp = makeDynCaller();\n if (typeof fp != \"function\") {\n throwBindingError(\"unknown function pointer with signature \" + signature + \": \" + rawFunction);\n }\n return fp;\n }\n var UnboundTypeError = void 0;\n function getTypeName(type) {\n var ptr = ___getTypeName(type);\n var rv = readLatin1String(ptr);\n _free(ptr);\n return rv;\n }\n function throwUnboundTypeError(message, types) {\n var unboundTypes = [];\n var seen = {};\n function visit(type) {\n if (seen[type]) {\n return;\n }\n if (registeredTypes[type]) {\n return;\n }\n if (typeDependencies[type]) {\n typeDependencies[type].forEach(visit);\n return;\n }\n unboundTypes.push(type);\n seen[type] = true;\n }\n types.forEach(visit);\n throw new UnboundTypeError(message + \": \" + unboundTypes.map(getTypeName).join([\", \"]));\n }\n function __embind_register_class(rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) {\n name = readLatin1String(name);\n getActualType = embind__requireFunction(getActualTypeSignature, getActualType);\n if (upcast) {\n upcast = embind__requireFunction(upcastSignature, upcast);\n }\n if (downcast) {\n downcast = embind__requireFunction(downcastSignature, downcast);\n }\n rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);\n var legalFunctionName = makeLegalFunctionName(name);\n exposePublicSymbol(legalFunctionName, function() {\n throwUnboundTypeError(\"Cannot construct \" + name + \" due to unbound types\", [baseClassRawType]);\n });\n whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], function(base) {\n base = base[0];\n var baseClass;\n var basePrototype;\n if (baseClassRawType) {\n baseClass = base.registeredClass;\n basePrototype = baseClass.instancePrototype;\n } else {\n basePrototype = ClassHandle.prototype;\n }\n var constructor = createNamedFunction(legalFunctionName, function() {\n if (Object.getPrototypeOf(this) !== instancePrototype) {\n throw new BindingError(\"Use 'new' to construct \" + name);\n }\n if (void 0 === registeredClass.constructor_body) {\n throw new BindingError(name + \" has no accessible constructor\");\n }\n var body = registeredClass.constructor_body[arguments.length];\n if (void 0 === body) {\n throw new BindingError(\"Tried to invoke ctor of \" + name + \" with invalid number of parameters (\" + arguments.length + \") - expected (\" + Object.keys(registeredClass.constructor_body).toString() + \") parameters instead!\");\n }\n return body.apply(this, arguments);\n });\n var instancePrototype = Object.create(basePrototype, { constructor: { value: constructor } });\n constructor.prototype = instancePrototype;\n var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast);\n var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false);\n var pointerConverter = new RegisteredPointer(name + \"*\", registeredClass, false, false, false);\n var constPointerConverter = new RegisteredPointer(name + \" const*\", registeredClass, false, true, false);\n registeredPointers[rawType] = { pointerType: pointerConverter, constPointerType: constPointerConverter };\n replacePublicSymbol(legalFunctionName, constructor);\n return [referenceConverter, pointerConverter, constPointerConverter];\n });\n }\n function heap32VectorToArray(count, firstElement) {\n var array = [];\n for (var i = 0; i < count; i++) {\n array.push(HEAPU32[firstElement + i * 4 >> 2]);\n }\n return array;\n }\n function runDestructors(destructors) {\n while (destructors.length) {\n var ptr = destructors.pop();\n var del = destructors.pop();\n del(ptr);\n }\n }\n function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc) {\n var argCount = argTypes.length;\n if (argCount < 2) {\n throwBindingError(\"argTypes array size mismatch! Must at least get return value and 'this' types!\");\n }\n var isClassMethodFunc = argTypes[1] !== null && classType !== null;\n var needsDestructorStack = false;\n for (var i = 1; i < argTypes.length; ++i) {\n if (argTypes[i] !== null && argTypes[i].destructorFunction === void 0) {\n needsDestructorStack = true;\n break;\n }\n }\n var returns = argTypes[0].name !== \"void\";\n var expectedArgCount = argCount - 2;\n var argsWired = new Array(expectedArgCount);\n var invokerFuncArgs = [];\n var destructors = [];\n return function() {\n if (arguments.length !== expectedArgCount) {\n throwBindingError(\"function \" + humanName + \" called with \" + arguments.length + \" arguments, expected \" + expectedArgCount + \" args!\");\n }\n destructors.length = 0;\n var thisWired;\n invokerFuncArgs.length = isClassMethodFunc ? 2 : 1;\n invokerFuncArgs[0] = cppTargetFunc;\n if (isClassMethodFunc) {\n thisWired = argTypes[1][\"toWireType\"](destructors, this);\n invokerFuncArgs[1] = thisWired;\n }\n for (var i2 = 0; i2 < expectedArgCount; ++i2) {\n argsWired[i2] = argTypes[i2 + 2][\"toWireType\"](destructors, arguments[i2]);\n invokerFuncArgs.push(argsWired[i2]);\n }\n var rv = cppInvokerFunc.apply(null, invokerFuncArgs);\n function onDone(rv2) {\n if (needsDestructorStack) {\n runDestructors(destructors);\n } else {\n for (var i3 = isClassMethodFunc ? 1 : 2; i3 < argTypes.length; i3++) {\n var param = i3 === 1 ? thisWired : argsWired[i3 - 2];\n if (argTypes[i3].destructorFunction !== null) {\n argTypes[i3].destructorFunction(param);\n }\n }\n }\n if (returns) {\n return argTypes[0][\"fromWireType\"](rv2);\n }\n }\n return onDone(rv);\n };\n }\n function __embind_register_class_constructor(rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) {\n assert(argCount > 0);\n var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);\n invoker = embind__requireFunction(invokerSignature, invoker);\n whenDependentTypesAreResolved([], [rawClassType], function(classType) {\n classType = classType[0];\n var humanName = \"constructor \" + classType.name;\n if (void 0 === classType.registeredClass.constructor_body) {\n classType.registeredClass.constructor_body = [];\n }\n if (void 0 !== classType.registeredClass.constructor_body[argCount - 1]) {\n throw new BindingError(\"Cannot register multiple constructors with identical number of parameters (\" + (argCount - 1) + \") for class '\" + classType.name + \"'! Overload resolution is currently only performed using the parameter count, not actual type info!\");\n }\n classType.registeredClass.constructor_body[argCount - 1] = () => {\n throwUnboundTypeError(\"Cannot construct \" + classType.name + \" due to unbound types\", rawArgTypes);\n };\n whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {\n argTypes.splice(1, 0, null);\n classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);\n return [];\n });\n return [];\n });\n }\n function __embind_register_class_function(rawClassType, methodName, argCount, rawArgTypesAddr, invokerSignature, rawInvoker, context, isPureVirtual) {\n var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);\n methodName = readLatin1String(methodName);\n rawInvoker = embind__requireFunction(invokerSignature, rawInvoker);\n whenDependentTypesAreResolved([], [rawClassType], function(classType) {\n classType = classType[0];\n var humanName = classType.name + \".\" + methodName;\n if (methodName.startsWith(\"@@\")) {\n methodName = Symbol[methodName.substring(2)];\n }\n if (isPureVirtual) {\n classType.registeredClass.pureVirtualFunctions.push(methodName);\n }\n function unboundTypesHandler() {\n throwUnboundTypeError(\"Cannot call \" + humanName + \" due to unbound types\", rawArgTypes);\n }\n var proto = classType.registeredClass.instancePrototype;\n var method = proto[methodName];\n if (void 0 === method || void 0 === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2) {\n unboundTypesHandler.argCount = argCount - 2;\n unboundTypesHandler.className = classType.name;\n proto[methodName] = unboundTypesHandler;\n } else {\n ensureOverloadTable(proto, methodName, humanName);\n proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;\n }\n whenDependentTypesAreResolved([], rawArgTypes, function(argTypes) {\n var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context);\n if (void 0 === proto[methodName].overloadTable) {\n memberFunction.argCount = argCount - 2;\n proto[methodName] = memberFunction;\n } else {\n proto[methodName].overloadTable[argCount - 2] = memberFunction;\n }\n return [];\n });\n return [];\n });\n }\n var emval_free_list = [];\n var emval_handle_array = [{}, { value: void 0 }, { value: null }, { value: true }, { value: false }];\n function __emval_decref(handle) {\n if (handle > 4 && 0 === --emval_handle_array[handle].refcount) {\n emval_handle_array[handle] = void 0;\n emval_free_list.push(handle);\n }\n }\n function count_emval_handles() {\n var count = 0;\n for (var i = 5; i < emval_handle_array.length; ++i) {\n if (emval_handle_array[i] !== void 0) {\n ++count;\n }\n }\n return count;\n }\n function get_first_emval() {\n for (var i = 5; i < emval_handle_array.length; ++i) {\n if (emval_handle_array[i] !== void 0) {\n return emval_handle_array[i];\n }\n }\n return null;\n }\n function init_emval() {\n Module[\"count_emval_handles\"] = count_emval_handles;\n Module[\"get_first_emval\"] = get_first_emval;\n }\n var Emval = { toValue: (handle) => {\n if (!handle) {\n throwBindingError(\"Cannot use deleted val. handle = \" + handle);\n }\n return emval_handle_array[handle].value;\n }, toHandle: (value) => {\n switch (value) {\n case void 0:\n return 1;\n case null:\n return 2;\n case true:\n return 3;\n case false:\n return 4;\n default: {\n var handle = emval_free_list.length ? emval_free_list.pop() : emval_handle_array.length;\n emval_handle_array[handle] = { refcount: 1, value };\n return handle;\n }\n }\n } };\n function __embind_register_emval(rawType, name) {\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": function(handle) {\n var rv = Emval.toValue(handle);\n __emval_decref(handle);\n return rv;\n }, \"toWireType\": function(destructors, value) {\n return Emval.toHandle(value);\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": simpleReadValueFromPointer, destructorFunction: null });\n }\n function embindRepr(v) {\n if (v === null) {\n return \"null\";\n }\n var t = typeof v;\n if (t === \"object\" || t === \"array\" || t === \"function\") {\n return v.toString();\n } else {\n return \"\" + v;\n }\n }\n function floatReadValueFromPointer(name, shift) {\n switch (shift) {\n case 2:\n return function(pointer) {\n return this[\"fromWireType\"](HEAPF32[pointer >> 2]);\n };\n case 3:\n return function(pointer) {\n return this[\"fromWireType\"](HEAPF64[pointer >> 3]);\n };\n default:\n throw new TypeError(\"Unknown float type: \" + name);\n }\n }\n function __embind_register_float(rawType, name, size) {\n var shift = getShiftFromSize(size);\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": function(value) {\n return value;\n }, \"toWireType\": function(destructors, value) {\n if (typeof value != \"number\" && typeof value != \"boolean\") {\n throw new TypeError('Cannot convert \"' + embindRepr(value) + '\" to ' + this.name);\n }\n return value;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": floatReadValueFromPointer(name, shift), destructorFunction: null });\n }\n function integerReadValueFromPointer(name, shift, signed) {\n switch (shift) {\n case 0:\n return signed ? function readS8FromPointer(pointer) {\n return HEAP8[pointer];\n } : function readU8FromPointer(pointer) {\n return HEAPU8[pointer];\n };\n case 1:\n return signed ? function readS16FromPointer(pointer) {\n return HEAP16[pointer >> 1];\n } : function readU16FromPointer(pointer) {\n return HEAPU16[pointer >> 1];\n };\n case 2:\n return signed ? function readS32FromPointer(pointer) {\n return HEAP32[pointer >> 2];\n } : function readU32FromPointer(pointer) {\n return HEAPU32[pointer >> 2];\n };\n default:\n throw new TypeError(\"Unknown integer type: \" + name);\n }\n }\n function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {\n name = readLatin1String(name);\n if (maxRange === -1) {\n maxRange = 4294967295;\n }\n var shift = getShiftFromSize(size);\n var fromWireType = (value) => value;\n if (minRange === 0) {\n var bitshift = 32 - 8 * size;\n fromWireType = (value) => value << bitshift >>> bitshift;\n }\n var isUnsignedType = name.includes(\"unsigned\");\n var checkAssertions = (value, toTypeName) => {\n if (typeof value != \"number\" && typeof value != \"boolean\") {\n throw new TypeError('Cannot convert \"' + embindRepr(value) + '\" to ' + toTypeName);\n }\n if (value < minRange || value > maxRange) {\n throw new TypeError('Passing a number \"' + embindRepr(value) + '\" from JS side to C/C++ side to an argument of type \"' + name + '\", which is outside the valid range [' + minRange + \", \" + maxRange + \"]!\");\n }\n };\n var toWireType;\n if (isUnsignedType) {\n toWireType = function(destructors, value) {\n checkAssertions(value, this.name);\n return value >>> 0;\n };\n } else {\n toWireType = function(destructors, value) {\n checkAssertions(value, this.name);\n return value;\n };\n }\n registerType(primitiveType, { name, \"fromWireType\": fromWireType, \"toWireType\": toWireType, \"argPackAdvance\": 8, \"readValueFromPointer\": integerReadValueFromPointer(name, shift, minRange !== 0), destructorFunction: null });\n }\n function __embind_register_memory_view(rawType, dataTypeIndex, name) {\n var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array];\n var TA = typeMapping[dataTypeIndex];\n function decodeMemoryView(handle) {\n handle = handle >> 2;\n var heap = HEAPU32;\n var size = heap[handle];\n var data = heap[handle + 1];\n return new TA(buffer, data, size);\n }\n name = readLatin1String(name);\n registerType(rawType, { name, \"fromWireType\": decodeMemoryView, \"argPackAdvance\": 8, \"readValueFromPointer\": decodeMemoryView }, { ignoreDuplicateRegistrations: true });\n }\n function __embind_register_std_string(rawType, name) {\n name = readLatin1String(name);\n var stdStringIsUTF8 = name === \"std::string\";\n registerType(rawType, { name, \"fromWireType\": function(value) {\n var length = HEAPU32[value >> 2];\n var payload = value + 4;\n var str;\n if (stdStringIsUTF8) {\n var decodeStartPtr = payload;\n for (var i = 0; i <= length; ++i) {\n var currentBytePtr = payload + i;\n if (i == length || HEAPU8[currentBytePtr] == 0) {\n var maxRead = currentBytePtr - decodeStartPtr;\n var stringSegment = UTF8ToString(decodeStartPtr, maxRead);\n if (str === void 0) {\n str = stringSegment;\n } else {\n str += String.fromCharCode(0);\n str += stringSegment;\n }\n decodeStartPtr = currentBytePtr + 1;\n }\n }\n } else {\n var a = new Array(length);\n for (var i = 0; i < length; ++i) {\n a[i] = String.fromCharCode(HEAPU8[payload + i]);\n }\n str = a.join(\"\");\n }\n _free(value);\n return str;\n }, \"toWireType\": function(destructors, value) {\n if (value instanceof ArrayBuffer) {\n value = new Uint8Array(value);\n }\n var length;\n var valueIsOfTypeString = typeof value == \"string\";\n if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {\n throwBindingError(\"Cannot pass non-string to std::string\");\n }\n if (stdStringIsUTF8 && valueIsOfTypeString) {\n length = lengthBytesUTF8(value);\n } else {\n length = value.length;\n }\n var base = _malloc(4 + length + 1);\n var ptr = base + 4;\n HEAPU32[base >> 2] = length;\n if (stdStringIsUTF8 && valueIsOfTypeString) {\n stringToUTF8(value, ptr, length + 1);\n } else {\n if (valueIsOfTypeString) {\n for (var i = 0; i < length; ++i) {\n var charCode = value.charCodeAt(i);\n if (charCode > 255) {\n _free(ptr);\n throwBindingError(\"String has UTF-16 code units that do not fit in 8 bits\");\n }\n HEAPU8[ptr + i] = charCode;\n }\n } else {\n for (var i = 0; i < length; ++i) {\n HEAPU8[ptr + i] = value[i];\n }\n }\n }\n if (destructors !== null) {\n destructors.push(_free, base);\n }\n return base;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": simpleReadValueFromPointer, destructorFunction: function(ptr) {\n _free(ptr);\n } });\n }\n var UTF16Decoder = typeof TextDecoder != \"undefined\" ? new TextDecoder(\"utf-16le\") : void 0;\n function UTF16ToString(ptr, maxBytesToRead) {\n assert(ptr % 2 == 0, \"Pointer passed to UTF16ToString must be aligned to two bytes!\");\n var endPtr = ptr;\n var idx = endPtr >> 1;\n var maxIdx = idx + maxBytesToRead / 2;\n while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;\n endPtr = idx << 1;\n if (endPtr - ptr > 32 && UTF16Decoder) {\n return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));\n } else {\n var str = \"\";\n for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {\n var codeUnit = HEAP16[ptr + i * 2 >> 1];\n if (codeUnit == 0) break;\n str += String.fromCharCode(codeUnit);\n }\n return str;\n }\n }\n function stringToUTF16(str, outPtr, maxBytesToWrite) {\n assert(outPtr % 2 == 0, \"Pointer passed to stringToUTF16 must be aligned to two bytes!\");\n assert(typeof maxBytesToWrite == \"number\", \"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!\");\n if (maxBytesToWrite === void 0) {\n maxBytesToWrite = 2147483647;\n }\n if (maxBytesToWrite < 2) return 0;\n maxBytesToWrite -= 2;\n var startPtr = outPtr;\n var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;\n for (var i = 0; i < numCharsToWrite; ++i) {\n var codeUnit = str.charCodeAt(i);\n HEAP16[outPtr >> 1] = codeUnit;\n outPtr += 2;\n }\n HEAP16[outPtr >> 1] = 0;\n return outPtr - startPtr;\n }\n function lengthBytesUTF16(str) {\n return str.length * 2;\n }\n function UTF32ToString(ptr, maxBytesToRead) {\n assert(ptr % 4 == 0, \"Pointer passed to UTF32ToString must be aligned to four bytes!\");\n var i = 0;\n var str = \"\";\n while (!(i >= maxBytesToRead / 4)) {\n var utf32 = HEAP32[ptr + i * 4 >> 2];\n if (utf32 == 0) break;\n ++i;\n if (utf32 >= 65536) {\n var ch = utf32 - 65536;\n str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);\n } else {\n str += String.fromCharCode(utf32);\n }\n }\n return str;\n }\n function stringToUTF32(str, outPtr, maxBytesToWrite) {\n assert(outPtr % 4 == 0, \"Pointer passed to stringToUTF32 must be aligned to four bytes!\");\n assert(typeof maxBytesToWrite == \"number\", \"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!\");\n if (maxBytesToWrite === void 0) {\n maxBytesToWrite = 2147483647;\n }\n if (maxBytesToWrite < 4) return 0;\n var startPtr = outPtr;\n var endPtr = startPtr + maxBytesToWrite - 4;\n for (var i = 0; i < str.length; ++i) {\n var codeUnit = str.charCodeAt(i);\n if (codeUnit >= 55296 && codeUnit <= 57343) {\n var trailSurrogate = str.charCodeAt(++i);\n codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023;\n }\n HEAP32[outPtr >> 2] = codeUnit;\n outPtr += 4;\n if (outPtr + 4 > endPtr) break;\n }\n HEAP32[outPtr >> 2] = 0;\n return outPtr - startPtr;\n }\n function lengthBytesUTF32(str) {\n var len = 0;\n for (var i = 0; i < str.length; ++i) {\n var codeUnit = str.charCodeAt(i);\n if (codeUnit >= 55296 && codeUnit <= 57343) ++i;\n len += 4;\n }\n return len;\n }\n function __embind_register_std_wstring(rawType, charSize, name) {\n name = readLatin1String(name);\n var decodeString, encodeString, getHeap, lengthBytesUTF, shift;\n if (charSize === 2) {\n decodeString = UTF16ToString;\n encodeString = stringToUTF16;\n lengthBytesUTF = lengthBytesUTF16;\n getHeap = () => HEAPU16;\n shift = 1;\n } else if (charSize === 4) {\n decodeString = UTF32ToString;\n encodeString = stringToUTF32;\n lengthBytesUTF = lengthBytesUTF32;\n getHeap = () => HEAPU32;\n shift = 2;\n }\n registerType(rawType, { name, \"fromWireType\": function(value) {\n var length = HEAPU32[value >> 2];\n var HEAP = getHeap();\n var str;\n var decodeStartPtr = value + 4;\n for (var i = 0; i <= length; ++i) {\n var currentBytePtr = value + 4 + i * charSize;\n if (i == length || HEAP[currentBytePtr >> shift] == 0) {\n var maxReadBytes = currentBytePtr - decodeStartPtr;\n var stringSegment = decodeString(decodeStartPtr, maxReadBytes);\n if (str === void 0) {\n str = stringSegment;\n } else {\n str += String.fromCharCode(0);\n str += stringSegment;\n }\n decodeStartPtr = currentBytePtr + charSize;\n }\n }\n _free(value);\n return str;\n }, \"toWireType\": function(destructors, value) {\n if (!(typeof value == \"string\")) {\n throwBindingError(\"Cannot pass non-string to C++ string type \" + name);\n }\n var length = lengthBytesUTF(value);\n var ptr = _malloc(4 + length + charSize);\n HEAPU32[ptr >> 2] = length >> shift;\n encodeString(value, ptr + 4, length + charSize);\n if (destructors !== null) {\n destructors.push(_free, ptr);\n }\n return ptr;\n }, \"argPackAdvance\": 8, \"readValueFromPointer\": simpleReadValueFromPointer, destructorFunction: function(ptr) {\n _free(ptr);\n } });\n }\n function __embind_register_void(rawType, name) {\n name = readLatin1String(name);\n registerType(rawType, { isVoid: true, name, \"argPackAdvance\": 0, \"fromWireType\": function() {\n return void 0;\n }, \"toWireType\": function(destructors, o) {\n return void 0;\n } });\n }\n function _abort() {\n abort(\"native code called abort()\");\n }\n function _emscripten_memcpy_big(dest, src, num) {\n HEAPU8.copyWithin(dest, src, src + num);\n }\n function getHeapMax() {\n return 2147483648;\n }\n function emscripten_realloc_buffer(size) {\n try {\n wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);\n updateGlobalBufferAndViews(wasmMemory.buffer);\n return 1;\n } catch (e) {\n err(\"emscripten_realloc_buffer: Attempted to grow heap from \" + buffer.byteLength + \" bytes to \" + size + \" bytes, but got error: \" + e);\n }\n }\n function _emscripten_resize_heap(requestedSize) {\n var oldSize = HEAPU8.length;\n requestedSize = requestedSize >>> 0;\n assert(requestedSize > oldSize);\n var maxHeapSize = getHeapMax();\n if (requestedSize > maxHeapSize) {\n err(\"Cannot enlarge memory, asked to go up to \" + requestedSize + \" bytes, but the limit is \" + maxHeapSize + \" bytes!\");\n return false;\n }\n let alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;\n for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {\n var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);\n overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);\n var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));\n var replacement = emscripten_realloc_buffer(newSize);\n if (replacement) {\n return true;\n }\n }\n err(\"Failed to grow the heap from \" + oldSize + \" bytes to \" + newSize + \" bytes, not enough memory!\");\n return false;\n }\n var ENV = {};\n function getExecutableName() {\n return thisProgram || \"./this.program\";\n }\n function getEnvStrings() {\n if (!getEnvStrings.strings) {\n var lang = (typeof navigator == \"object\" && navigator.languages && navigator.languages[0] || \"C\").replace(\"-\", \"_\") + \".UTF-8\";\n var env = { \"USER\": \"web_user\", \"LOGNAME\": \"web_user\", \"PATH\": \"/\", \"PWD\": \"/\", \"HOME\": \"/home/web_user\", \"LANG\": lang, \"_\": getExecutableName() };\n for (var x in ENV) {\n if (ENV[x] === void 0) delete env[x];\n else env[x] = ENV[x];\n }\n var strings = [];\n for (var x in env) {\n strings.push(x + \"=\" + env[x]);\n }\n getEnvStrings.strings = strings;\n }\n return getEnvStrings.strings;\n }\n function writeAsciiToMemory(str, buffer2, dontAddNull) {\n for (var i = 0; i < str.length; ++i) {\n assert(str.charCodeAt(i) === (str.charCodeAt(i) & 255));\n HEAP8[buffer2++ >> 0] = str.charCodeAt(i);\n }\n if (!dontAddNull) HEAP8[buffer2 >> 0] = 0;\n }\n var SYSCALLS = { varargs: void 0, get: function() {\n assert(SYSCALLS.varargs != void 0);\n SYSCALLS.varargs += 4;\n var ret = HEAP32[SYSCALLS.varargs - 4 >> 2];\n return ret;\n }, getStr: function(ptr) {\n var ret = UTF8ToString(ptr);\n return ret;\n } };\n function _environ_get(__environ, environ_buf) {\n var bufSize = 0;\n getEnvStrings().forEach(function(string, i) {\n var ptr = environ_buf + bufSize;\n HEAPU32[__environ + i * 4 >> 2] = ptr;\n writeAsciiToMemory(string, ptr);\n bufSize += string.length + 1;\n });\n return 0;\n }\n function _environ_sizes_get(penviron_count, penviron_buf_size) {\n var strings = getEnvStrings();\n HEAPU32[penviron_count >> 2] = strings.length;\n var bufSize = 0;\n strings.forEach(function(string) {\n bufSize += string.length + 1;\n });\n HEAPU32[penviron_buf_size >> 2] = bufSize;\n return 0;\n }\n function _fd_close(fd) {\n abort(\"fd_close called without SYSCALLS_REQUIRE_FILESYSTEM\");\n }\n function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {\n return 70;\n }\n var printCharBuffers = [null, [], []];\n function printChar(stream, curr) {\n var buffer2 = printCharBuffers[stream];\n assert(buffer2);\n if (curr === 0 || curr === 10) {\n (stream === 1 ? out : err)(UTF8ArrayToString(buffer2, 0));\n buffer2.length = 0;\n } else {\n buffer2.push(curr);\n }\n }\n function flush_NO_FILESYSTEM() {\n _fflush(0);\n if (printCharBuffers[1].length) printChar(1, 10);\n if (printCharBuffers[2].length) printChar(2, 10);\n }\n function _fd_write(fd, iov, iovcnt, pnum) {\n var num = 0;\n for (var i = 0; i < iovcnt; i++) {\n var ptr = HEAPU32[iov >> 2];\n var len = HEAPU32[iov + 4 >> 2];\n iov += 8;\n for (var j = 0; j < len; j++) {\n printChar(fd, HEAPU8[ptr + j]);\n }\n num += len;\n }\n HEAPU32[pnum >> 2] = num;\n return 0;\n }\n function __isLeapYear(year) {\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n }\n function __arraySum(array, index) {\n var sum = 0;\n for (var i = 0; i <= index; sum += array[i++]) {\n }\n return sum;\n }\n var __MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n var __MONTH_DAYS_REGULAR = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n function __addDays(date, days) {\n var newDate = new Date(date.getTime());\n while (days > 0) {\n var leap = __isLeapYear(newDate.getFullYear());\n var currentMonth = newDate.getMonth();\n var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];\n if (days > daysInCurrentMonth - newDate.getDate()) {\n days -= daysInCurrentMonth - newDate.getDate() + 1;\n newDate.setDate(1);\n if (currentMonth < 11) {\n newDate.setMonth(currentMonth + 1);\n } else {\n newDate.setMonth(0);\n newDate.setFullYear(newDate.getFullYear() + 1);\n }\n } else {\n newDate.setDate(newDate.getDate() + days);\n return newDate;\n }\n }\n return newDate;\n }\n function intArrayFromString(stringy, dontAddNull, length) {\n var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;\n var u8array = new Array(len);\n var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);\n if (dontAddNull) u8array.length = numBytesWritten;\n return u8array;\n }\n function _strftime(s, maxsize, format, tm) {\n var tm_zone = HEAP32[tm + 40 >> 2];\n var date = { tm_sec: HEAP32[tm >> 2], tm_min: HEAP32[tm + 4 >> 2], tm_hour: HEAP32[tm + 8 >> 2], tm_mday: HEAP32[tm + 12 >> 2], tm_mon: HEAP32[tm + 16 >> 2], tm_year: HEAP32[tm + 20 >> 2], tm_wday: HEAP32[tm + 24 >> 2], tm_yday: HEAP32[tm + 28 >> 2], tm_isdst: HEAP32[tm + 32 >> 2], tm_gmtoff: HEAP32[tm + 36 >> 2], tm_zone: tm_zone ? UTF8ToString(tm_zone) : \"\" };\n var pattern = UTF8ToString(format);\n var EXPANSION_RULES_1 = { \"%c\": \"%a %b %d %H:%M:%S %Y\", \"%D\": \"%m/%d/%y\", \"%F\": \"%Y-%m-%d\", \"%h\": \"%b\", \"%r\": \"%I:%M:%S %p\", \"%R\": \"%H:%M\", \"%T\": \"%H:%M:%S\", \"%x\": \"%m/%d/%y\", \"%X\": \"%H:%M:%S\", \"%Ec\": \"%c\", \"%EC\": \"%C\", \"%Ex\": \"%m/%d/%y\", \"%EX\": \"%H:%M:%S\", \"%Ey\": \"%y\", \"%EY\": \"%Y\", \"%Od\": \"%d\", \"%Oe\": \"%e\", \"%OH\": \"%H\", \"%OI\": \"%I\", \"%Om\": \"%m\", \"%OM\": \"%M\", \"%OS\": \"%S\", \"%Ou\": \"%u\", \"%OU\": \"%U\", \"%OV\": \"%V\", \"%Ow\": \"%w\", \"%OW\": \"%W\", \"%Oy\": \"%y\" };\n for (var rule in EXPANSION_RULES_1) {\n pattern = pattern.replace(new RegExp(rule, \"g\"), EXPANSION_RULES_1[rule]);\n }\n var WEEKDAYS = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n var MONTHS = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\n function leadingSomething(value, digits, character) {\n var str = typeof value == \"number\" ? value.toString() : value || \"\";\n while (str.length < digits) {\n str = character[0] + str;\n }\n return str;\n }\n function leadingNulls(value, digits) {\n return leadingSomething(value, digits, \"0\");\n }\n function compareByDay(date1, date2) {\n function sgn(value) {\n return value < 0 ? -1 : value > 0 ? 1 : 0;\n }\n var compare;\n if ((compare = sgn(date1.getFullYear() - date2.getFullYear())) === 0) {\n if ((compare = sgn(date1.getMonth() - date2.getMonth())) === 0) {\n compare = sgn(date1.getDate() - date2.getDate());\n }\n }\n return compare;\n }\n function getFirstWeekStartDate(janFourth) {\n switch (janFourth.getDay()) {\n case 0:\n return new Date(janFourth.getFullYear() - 1, 11, 29);\n case 1:\n return janFourth;\n case 2:\n return new Date(janFourth.getFullYear(), 0, 3);\n case 3:\n return new Date(janFourth.getFullYear(), 0, 2);\n case 4:\n return new Date(janFourth.getFullYear(), 0, 1);\n case 5:\n return new Date(janFourth.getFullYear() - 1, 11, 31);\n case 6:\n return new Date(janFourth.getFullYear() - 1, 11, 30);\n }\n }\n function getWeekBasedYear(date2) {\n var thisDate = __addDays(new Date(date2.tm_year + 1900, 0, 1), date2.tm_yday);\n var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);\n var janFourthNextYear = new Date(thisDate.getFullYear() + 1, 0, 4);\n var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);\n var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);\n if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {\n if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {\n return thisDate.getFullYear() + 1;\n }\n return thisDate.getFullYear();\n }\n return thisDate.getFullYear() - 1;\n }\n var EXPANSION_RULES_2 = { \"%a\": function(date2) {\n return WEEKDAYS[date2.tm_wday].substring(0, 3);\n }, \"%A\": function(date2) {\n return WEEKDAYS[date2.tm_wday];\n }, \"%b\": function(date2) {\n return MONTHS[date2.tm_mon].substring(0, 3);\n }, \"%B\": function(date2) {\n return MONTHS[date2.tm_mon];\n }, \"%C\": function(date2) {\n var year = date2.tm_year + 1900;\n return leadingNulls(year / 100 | 0, 2);\n }, \"%d\": function(date2) {\n return leadingNulls(date2.tm_mday, 2);\n }, \"%e\": function(date2) {\n return leadingSomething(date2.tm_mday, 2, \" \");\n }, \"%g\": function(date2) {\n return getWeekBasedYear(date2).toString().substring(2);\n }, \"%G\": function(date2) {\n return getWeekBasedYear(date2);\n }, \"%H\": function(date2) {\n return leadingNulls(date2.tm_hour, 2);\n }, \"%I\": function(date2) {\n var twelveHour = date2.tm_hour;\n if (twelveHour == 0) twelveHour = 12;\n else if (twelveHour > 12) twelveHour -= 12;\n return leadingNulls(twelveHour, 2);\n }, \"%j\": function(date2) {\n return leadingNulls(date2.tm_mday + __arraySum(__isLeapYear(date2.tm_year + 1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date2.tm_mon - 1), 3);\n }, \"%m\": function(date2) {\n return leadingNulls(date2.tm_mon + 1, 2);\n }, \"%M\": function(date2) {\n return leadingNulls(date2.tm_min, 2);\n }, \"%n\": function() {\n return \"\\n\";\n }, \"%p\": function(date2) {\n if (date2.tm_hour >= 0 && date2.tm_hour < 12) {\n return \"AM\";\n }\n return \"PM\";\n }, \"%S\": function(date2) {\n return leadingNulls(date2.tm_sec, 2);\n }, \"%t\": function() {\n return \"\t\";\n }, \"%u\": function(date2) {\n return date2.tm_wday || 7;\n }, \"%U\": function(date2) {\n var days = date2.tm_yday + 7 - date2.tm_wday;\n return leadingNulls(Math.floor(days / 7), 2);\n }, \"%V\": function(date2) {\n var val = Math.floor((date2.tm_yday + 7 - (date2.tm_wday + 6) % 7) / 7);\n if ((date2.tm_wday + 371 - date2.tm_yday - 2) % 7 <= 2) {\n val++;\n }\n if (!val) {\n val = 52;\n var dec31 = (date2.tm_wday + 7 - date2.tm_yday - 1) % 7;\n if (dec31 == 4 || dec31 == 5 && __isLeapYear(date2.tm_year % 400 - 1)) {\n val++;\n }\n } else if (val == 53) {\n var jan1 = (date2.tm_wday + 371 - date2.tm_yday) % 7;\n if (jan1 != 4 && (jan1 != 3 || !__isLeapYear(date2.tm_year))) val = 1;\n }\n return leadingNulls(val, 2);\n }, \"%w\": function(date2) {\n return date2.tm_wday;\n }, \"%W\": function(date2) {\n var days = date2.tm_yday + 7 - (date2.tm_wday + 6) % 7;\n return leadingNulls(Math.floor(days / 7), 2);\n }, \"%y\": function(date2) {\n return (date2.tm_year + 1900).toString().substring(2);\n }, \"%Y\": function(date2) {\n return date2.tm_year + 1900;\n }, \"%z\": function(date2) {\n var off = date2.tm_gmtoff;\n var ahead = off >= 0;\n off = Math.abs(off) / 60;\n off = off / 60 * 100 + off % 60;\n return (ahead ? \"+\" : \"-\") + String(\"0000\" + off).slice(-4);\n }, \"%Z\": function(date2) {\n return date2.tm_zone;\n }, \"%%\": function() {\n return \"%\";\n } };\n pattern = pattern.replace(/%%/g, \"\\0\\0\");\n for (var rule in EXPANSION_RULES_2) {\n if (pattern.includes(rule)) {\n pattern = pattern.replace(new RegExp(rule, \"g\"), EXPANSION_RULES_2[rule](date));\n }\n }\n pattern = pattern.replace(/\\0\\0/g, \"%\");\n var bytes = intArrayFromString(pattern, false);\n if (bytes.length > maxsize) {\n return 0;\n }\n writeArrayToMemory(bytes, s);\n return bytes.length - 1;\n }\n function _strftime_l(s, maxsize, format, tm) {\n return _strftime(s, maxsize, format, tm);\n }\n function uleb128Encode(n, target) {\n assert(n < 16384);\n if (n < 128) {\n target.push(n);\n } else {\n target.push(n % 128 | 128, n >> 7);\n }\n }\n function sigToWasmTypes(sig) {\n var typeNames = { \"i\": \"i32\", \"j\": \"i64\", \"f\": \"f32\", \"d\": \"f64\", \"p\": \"i32\" };\n var type = { parameters: [], results: sig[0] == \"v\" ? [] : [typeNames[sig[0]]] };\n for (var i = 1; i < sig.length; ++i) {\n assert(sig[i] in typeNames, \"invalid signature char: \" + sig[i]);\n type.parameters.push(typeNames[sig[i]]);\n }\n return type;\n }\n function convertJsFunctionToWasm(func, sig) {\n if (typeof WebAssembly.Function == \"function\") {\n return new WebAssembly.Function(sigToWasmTypes(sig), func);\n }\n var typeSectionBody = [1, 96];\n var sigRet = sig.slice(0, 1);\n var sigParam = sig.slice(1);\n var typeCodes = { \"i\": 127, \"p\": 127, \"j\": 126, \"f\": 125, \"d\": 124 };\n uleb128Encode(sigParam.length, typeSectionBody);\n for (var i = 0; i < sigParam.length; ++i) {\n assert(sigParam[i] in typeCodes, \"invalid signature char: \" + sigParam[i]);\n typeSectionBody.push(typeCodes[sigParam[i]]);\n }\n if (sigRet == \"v\") {\n typeSectionBody.push(0);\n } else {\n typeSectionBody.push(1, typeCodes[sigRet]);\n }\n var bytes = [0, 97, 115, 109, 1, 0, 0, 0, 1];\n uleb128Encode(typeSectionBody.length, bytes);\n bytes.push.apply(bytes, typeSectionBody);\n bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);\n var module2 = new WebAssembly.Module(new Uint8Array(bytes));\n var instance = new WebAssembly.Instance(module2, { \"e\": { \"f\": func } });\n var wrappedFunc = instance.exports[\"f\"];\n return wrappedFunc;\n }\n function updateTableMap(offset, count) {\n if (functionsInTableMap) {\n for (var i = offset; i < offset + count; i++) {\n var item = getWasmTableEntry(i);\n if (item) {\n functionsInTableMap.set(item, i);\n }\n }\n }\n }\n var functionsInTableMap = void 0;\n var freeTableIndexes = [];\n function getEmptyTableSlot() {\n if (freeTableIndexes.length) {\n return freeTableIndexes.pop();\n }\n try {\n wasmTable.grow(1);\n } catch (err2) {\n if (!(err2 instanceof RangeError)) {\n throw err2;\n }\n throw \"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.\";\n }\n return wasmTable.length - 1;\n }\n function setWasmTableEntry(idx, func) {\n wasmTable.set(idx, func);\n wasmTableMirror[idx] = wasmTable.get(idx);\n }\n var ALLOC_STACK = 1;\n function getCFunc(ident) {\n var func = Module[\"_\" + ident];\n assert(func, \"Cannot call unknown function \" + ident + \", make sure it is exported\");\n return func;\n }\n function ccall(ident, returnType, argTypes, args, opts) {\n var toC = { \"string\": (str) => {\n var ret2 = 0;\n if (str !== null && str !== void 0 && str !== 0) {\n var len = (str.length << 2) + 1;\n ret2 = stackAlloc(len);\n stringToUTF8(str, ret2, len);\n }\n return ret2;\n }, \"array\": (arr) => {\n var ret2 = stackAlloc(arr.length);\n writeArrayToMemory(arr, ret2);\n return ret2;\n } };\n function convertReturnValue(ret2) {\n if (returnType === \"string\") {\n return UTF8ToString(ret2);\n }\n if (returnType === \"boolean\") return Boolean(ret2);\n return ret2;\n }\n var func = getCFunc(ident);\n var cArgs = [];\n var stack = 0;\n assert(returnType !== \"array\", 'Return type should not be \"array\".');\n if (args) {\n for (var i = 0; i < args.length; i++) {\n var converter = toC[argTypes[i]];\n if (converter) {\n if (stack === 0) stack = stackSave();\n cArgs[i] = converter(args[i]);\n } else {\n cArgs[i] = args[i];\n }\n }\n }\n var ret = func.apply(null, cArgs);\n function onDone(ret2) {\n if (stack !== 0) stackRestore(stack);\n return convertReturnValue(ret2);\n }\n ret = onDone(ret);\n return ret;\n }\n embind_init_charCodes();\n BindingError = Module[\"BindingError\"] = extendError(Error, \"BindingError\");\n InternalError = Module[\"InternalError\"] = extendError(Error, \"InternalError\");\n init_ClassHandle();\n init_embind();\n init_RegisteredPointer();\n UnboundTypeError = Module[\"UnboundTypeError\"] = extendError(Error, \"UnboundTypeError\");\n init_emval();\n var ASSERTIONS = true;\n function checkIncomingModuleAPI() {\n ignoredModuleProp(\"fetchSettings\");\n }\n var asmLibraryArg = { \"__cxa_allocate_exception\": ___cxa_allocate_exception, \"__cxa_throw\": ___cxa_throw, \"_embind_register_bigint\": __embind_register_bigint, \"_embind_register_bool\": __embind_register_bool, \"_embind_register_class\": __embind_register_class, \"_embind_register_class_constructor\": __embind_register_class_constructor, \"_embind_register_class_function\": __embind_register_class_function, \"_embind_register_emval\": __embind_register_emval, \"_embind_register_float\": __embind_register_float, \"_embind_register_integer\": __embind_register_integer, \"_embind_register_memory_view\": __embind_register_memory_view, \"_embind_register_std_string\": __embind_register_std_string, \"_embind_register_std_wstring\": __embind_register_std_wstring, \"_embind_register_void\": __embind_register_void, \"abort\": _abort, \"emscripten_memcpy_big\": _emscripten_memcpy_big, \"emscripten_resize_heap\": _emscripten_resize_heap, \"environ_get\": _environ_get, \"environ_sizes_get\": _environ_sizes_get, \"fd_close\": _fd_close, \"fd_seek\": _fd_seek, \"fd_write\": _fd_write, \"strftime_l\": _strftime_l };\n var asm = createWasm();\n var ___wasm_call_ctors = Module[\"___wasm_call_ctors\"] = createExportWrapper(\"__wasm_call_ctors\");\n var _malloc = Module[\"_malloc\"] = createExportWrapper(\"malloc\");\n var _free = Module[\"_free\"] = createExportWrapper(\"free\");\n var ___getTypeName = Module[\"___getTypeName\"] = createExportWrapper(\"__getTypeName\");\n var __embind_initialize_bindings = Module[\"__embind_initialize_bindings\"] = createExportWrapper(\"_embind_initialize_bindings\");\n var ___errno_location = Module[\"___errno_location\"] = createExportWrapper(\"__errno_location\");\n var _fflush = Module[\"_fflush\"] = createExportWrapper(\"fflush\");\n var _emscripten_stack_init = Module[\"_emscripten_stack_init\"] = function() {\n return (_emscripten_stack_init = Module[\"_emscripten_stack_init\"] = Module[\"asm\"][\"emscripten_stack_init\"]).apply(null, arguments);\n };\n var _emscripten_stack_get_free = Module[\"_emscripten_stack_get_free\"] = function() {\n return (_emscripten_stack_get_free = Module[\"_emscripten_stack_get_free\"] = Module[\"asm\"][\"emscripten_stack_get_free\"]).apply(null, arguments);\n };\n var _emscripten_stack_get_base = Module[\"_emscripten_stack_get_base\"] = function() {\n return (_emscripten_stack_get_base = Module[\"_emscripten_stack_get_base\"] = Module[\"asm\"][\"emscripten_stack_get_base\"]).apply(null, arguments);\n };\n var _emscripten_stack_get_end = Module[\"_emscripten_stack_get_end\"] = function() {\n return (_emscripten_stack_get_end = Module[\"_emscripten_stack_get_end\"] = Module[\"asm\"][\"emscripten_stack_get_end\"]).apply(null, arguments);\n };\n var stackSave = Module[\"stackSave\"] = createExportWrapper(\"stackSave\");\n var stackRestore = Module[\"stackRestore\"] = createExportWrapper(\"stackRestore\");\n var stackAlloc = Module[\"stackAlloc\"] = createExportWrapper(\"stackAlloc\");\n var ___cxa_is_pointer_type = Module[\"___cxa_is_pointer_type\"] = createExportWrapper(\"__cxa_is_pointer_type\");\n var dynCall_viijii = Module[\"dynCall_viijii\"] = createExportWrapper(\"dynCall_viijii\");\n var dynCall_ji = Module[\"dynCall_ji\"] = createExportWrapper(\"dynCall_ji\");\n var dynCall_jiji = Module[\"dynCall_jiji\"] = createExportWrapper(\"dynCall_jiji\");\n var dynCall_iiiiij = Module[\"dynCall_iiiiij\"] = createExportWrapper(\"dynCall_iiiiij\");\n var dynCall_iiiiijj = Module[\"dynCall_iiiiijj\"] = createExportWrapper(\"dynCall_iiiiijj\");\n var dynCall_iiiiiijj = Module[\"dynCall_iiiiiijj\"] = createExportWrapper(\"dynCall_iiiiiijj\");\n var unexportedRuntimeSymbols = [\"run\", \"UTF8ArrayToString\", \"UTF8ToString\", \"stringToUTF8Array\", \"stringToUTF8\", \"lengthBytesUTF8\", \"addOnPreRun\", \"addOnInit\", \"addOnPreMain\", \"addOnExit\", \"addOnPostRun\", \"addRunDependency\", \"removeRunDependency\", \"FS_createFolder\", \"FS_createPath\", \"FS_createDataFile\", \"FS_createPreloadedFile\", \"FS_createLazyFile\", \"FS_createLink\", \"FS_createDevice\", \"FS_unlink\", \"getLEB\", \"getFunctionTables\", \"alignFunctionTables\", \"registerFunctions\", \"prettyPrint\", \"getCompilerSetting\", \"print\", \"printErr\", \"callMain\", \"abort\", \"keepRuntimeAlive\", \"wasmMemory\", \"stackAlloc\", \"stackSave\", \"stackRestore\", \"getTempRet0\", \"setTempRet0\", \"writeStackCookie\", \"checkStackCookie\", \"ptrToString\", \"zeroMemory\", \"stringToNewUTF8\", \"exitJS\", \"getHeapMax\", \"emscripten_realloc_buffer\", \"ENV\", \"ERRNO_CODES\", \"ERRNO_MESSAGES\", \"setErrNo\", \"inetPton4\", \"inetNtop4\", \"inetPton6\", \"inetNtop6\", \"readSockaddr\", \"writeSockaddr\", \"DNS\", \"getHostByName\", \"Protocols\", \"Sockets\", \"getRandomDevice\", \"warnOnce\", \"traverseStack\", \"UNWIND_CACHE\", \"convertPCtoSourceLocation\", \"readAsmConstArgsArray\", \"readAsmConstArgs\", \"mainThreadEM_ASM\", \"jstoi_q\", \"jstoi_s\", \"getExecutableName\", \"listenOnce\", \"autoResumeAudioContext\", \"dynCallLegacy\", \"getDynCaller\", \"dynCall\", \"handleException\", \"runtimeKeepalivePush\", \"runtimeKeepalivePop\", \"callUserCallback\", \"maybeExit\", \"safeSetTimeout\", \"asmjsMangle\", \"asyncLoad\", \"alignMemory\", \"mmapAlloc\", \"writeI53ToI64\", \"writeI53ToI64Clamped\", \"writeI53ToI64Signaling\", \"writeI53ToU64Clamped\", \"writeI53ToU64Signaling\", \"readI53FromI64\", \"readI53FromU64\", \"convertI32PairToI53\", \"convertI32PairToI53Checked\", \"convertU32PairToI53\", \"getCFunc\", \"ccall\", \"cwrap\", \"uleb128Encode\", \"sigToWasmTypes\", \"convertJsFunctionToWasm\", \"freeTableIndexes\", \"functionsInTableMap\", \"getEmptyTableSlot\", \"updateTableMap\", \"addFunction\", \"removeFunction\", \"reallyNegative\", \"unSign\", \"strLen\", \"reSign\", \"formatString\", \"setValue\", \"getValue\", \"PATH\", \"PATH_FS\", \"intArrayFromString\", \"intArrayToString\", \"AsciiToString\", \"stringToAscii\", \"UTF16Decoder\", \"UTF16ToString\", \"stringToUTF16\", \"lengthBytesUTF16\", \"UTF32ToString\", \"stringToUTF32\", \"lengthBytesUTF32\", \"allocateUTF8\", \"allocateUTF8OnStack\", \"writeStringToMemory\", \"writeArrayToMemory\", \"writeAsciiToMemory\", \"SYSCALLS\", \"getSocketFromFD\", \"getSocketAddress\", \"JSEvents\", \"registerKeyEventCallback\", \"specialHTMLTargets\", \"maybeCStringToJsString\", \"findEventTarget\", \"findCanvasEventTarget\", \"getBoundingClientRect\", \"fillMouseEventData\", \"registerMouseEventCallback\", \"registerWheelEventCallback\", \"registerUiEventCallback\", \"registerFocusEventCallback\", \"fillDeviceOrientationEventData\", \"registerDeviceOrientationEventCallback\", \"fillDeviceMotionEventData\", \"registerDeviceMotionEventCallback\", \"screenOrientation\", \"fillOrientationChangeEventData\", \"registerOrientationChangeEventCallback\", \"fillFullscreenChangeEventData\", \"registerFullscreenChangeEventCallback\", \"JSEvents_requestFullscreen\", \"JSEvents_resizeCanvasForFullscreen\", \"registerRestoreOldStyle\", \"hideEverythingExceptGivenElement\", \"restoreHiddenElements\", \"setLetterbox\", \"currentFullscreenStrategy\", \"restoreOldWindowedStyle\", \"softFullscreenResizeWebGLRenderTarget\", \"doRequestFullscreen\", \"fillPointerlockChangeEventData\", \"registerPointerlockChangeEventCallback\", \"registerPointerlockErrorEventCallback\", \"requestPointerLock\", \"fillVisibilityChangeEventData\", \"registerVisibilityChangeEventCallback\", \"registerTouchEventCallback\", \"fillGamepadEventData\", \"registerGamepadEventCallback\", \"registerBeforeUnloadEventCallback\", \"fillBatteryEventData\", \"battery\", \"registerBatteryEventCallback\", \"setCanvasElementSize\", \"getCanvasElementSize\", \"demangle\", \"demangleAll\", \"jsStackTrace\", \"stackTrace\", \"ExitStatus\", \"getEnvStrings\", \"checkWasiClock\", \"flush_NO_FILESYSTEM\", \"dlopenMissingError\", \"setImmediateWrapped\", \"clearImmediateWrapped\", \"polyfillSetImmediate\", \"uncaughtExceptionCount\", \"exceptionLast\", \"exceptionCaught\", \"ExceptionInfo\", \"exception_addRef\", \"exception_decRef\", \"Browser\", \"setMainLoop\", \"wget\", \"FS\", \"MEMFS\", \"TTY\", \"PIPEFS\", \"SOCKFS\", \"_setNetworkCallback\", \"tempFixedLengthArray\", \"miniTempWebGLFloatBuffers\", \"heapObjectForWebGLType\", \"heapAccessShiftForWebGLHeap\", \"GL\", \"emscriptenWebGLGet\", \"computeUnpackAlignedImageSize\", \"emscriptenWebGLGetTexPixelData\", \"emscriptenWebGLGetUniform\", \"webglGetUniformLocation\", \"webglPrepareUniformLocationsBeforeFirstUse\", \"webglGetLeftBracePos\", \"emscriptenWebGLGetVertexAttrib\", \"writeGLArray\", \"AL\", \"SDL_unicode\", \"SDL_ttfContext\", \"SDL_audio\", \"SDL\", \"SDL_gfx\", \"GLUT\", \"EGL\", \"GLFW_Window\", \"GLFW\", \"GLEW\", \"IDBStore\", \"runAndAbortIfError\", \"ALLOC_NORMAL\", \"ALLOC_STACK\", \"allocate\", \"InternalError\", \"BindingError\", \"UnboundTypeError\", \"PureVirtualError\", \"init_embind\", \"throwInternalError\", \"throwBindingError\", \"throwUnboundTypeError\", \"ensureOverloadTable\", \"exposePublicSymbol\", \"replacePublicSymbol\", \"extendError\", \"createNamedFunction\", \"embindRepr\", \"registeredInstances\", \"getBasestPointer\", \"registerInheritedInstance\", \"unregisterInheritedInstance\", \"getInheritedInstance\", \"getInheritedInstanceCount\", \"getLiveInheritedInstances\", \"registeredTypes\", \"awaitingDependencies\", \"typeDependencies\", \"registeredPointers\", \"registerType\", \"whenDependentTypesAreResolved\", \"embind_charCodes\", \"embind_init_charCodes\", \"readLatin1String\", \"getTypeName\", \"heap32VectorToArray\", \"requireRegisteredType\", \"getShiftFromSize\", \"integerReadValueFromPointer\", \"enumReadValueFromPointer\", \"floatReadValueFromPointer\", \"simpleReadValueFromPointer\", \"runDestructors\", \"new_\", \"craftInvokerFunction\", \"embind__requireFunction\", \"tupleRegistrations\", \"structRegistrations\", \"genericPointerToWireType\", \"constNoSmartPtrRawPointerToWireType\", \"nonConstNoSmartPtrRawPointerToWireType\", \"init_RegisteredPointer\", \"RegisteredPointer\", \"RegisteredPointer_getPointee\", \"RegisteredPointer_destructor\", \"RegisteredPointer_deleteObject\", \"RegisteredPointer_fromWireType\", \"runDestructor\", \"releaseClassHandle\", \"finalizationRegistry\", \"detachFinalizer_deps\", \"detachFinalizer\", \"attachFinalizer\", \"makeClassHandle\", \"init_ClassHandle\", \"ClassHandle\", \"ClassHandle_isAliasOf\", \"throwInstanceAlreadyDeleted\", \"ClassHandle_clone\", \"ClassHandle_delete\", \"deletionQueue\", \"ClassHandle_isDeleted\", \"ClassHandle_deleteLater\", \"flushPendingDeletes\", \"delayFunction\", \"setDelayFunction\", \"RegisteredClass\", \"shallowCopyInternalPointer\", \"downcastPointer\", \"upcastPointer\", \"validateThis\", \"char_0\", \"char_9\", \"makeLegalFunctionName\", \"emval_handle_array\", \"emval_free_list\", \"emval_symbols\", \"init_emval\", \"count_emval_handles\", \"get_first_emval\", \"getStringOrSymbol\", \"Emval\", \"emval_newers\", \"craftEmvalAllocator\", \"emval_get_global\", \"emval_lookupTypes\", \"emval_allocateDestructors\", \"emval_methodCallers\", \"emval_addMethodCaller\", \"emval_registeredMethods\"];\n unexportedRuntimeSymbols.forEach(unexportedRuntimeSymbol);\n var missingLibrarySymbols = [\"ptrToString\", \"zeroMemory\", \"stringToNewUTF8\", \"exitJS\", \"setErrNo\", \"inetPton4\", \"inetNtop4\", \"inetPton6\", \"inetNtop6\", \"readSockaddr\", \"writeSockaddr\", \"getHostByName\", \"getRandomDevice\", \"traverseStack\", \"convertPCtoSourceLocation\", \"readAsmConstArgs\", \"mainThreadEM_ASM\", \"jstoi_q\", \"jstoi_s\", \"listenOnce\", \"autoResumeAudioContext\", \"runtimeKeepalivePush\", \"runtimeKeepalivePop\", \"callUserCallback\", \"maybeExit\", \"safeSetTimeout\", \"asmjsMangle\", \"asyncLoad\", \"alignMemory\", \"mmapAlloc\", \"writeI53ToI64\", \"writeI53ToI64Clamped\", \"writeI53ToI64Signaling\", \"writeI53ToU64Clamped\", \"writeI53ToU64Signaling\", \"readI53FromI64\", \"readI53FromU64\", \"convertI32PairToI53\", \"convertU32PairToI53\", \"reallyNegative\", \"unSign\", \"strLen\", \"reSign\", \"formatString\", \"getSocketFromFD\", \"getSocketAddress\", \"registerKeyEventCallback\", \"maybeCStringToJsString\", \"findEventTarget\", \"findCanvasEventTarget\", \"getBoundingClientRect\", \"fillMouseEventData\", \"registerMouseEventCallback\", \"registerWheelEventCallback\", \"registerUiEventCallback\", \"registerFocusEventCallback\", \"fillDeviceOrientationEventData\", \"registerDeviceOrientationEventCallback\", \"fillDeviceMotionEventData\", \"registerDeviceMotionEventCallback\", \"screenOrientation\", \"fillOrientationChangeEventData\", \"registerOrientationChangeEventCallback\", \"fillFullscreenChangeEventData\", \"registerFullscreenChangeEventCallback\", \"JSEvents_requestFullscreen\", \"JSEvents_resizeCanvasForFullscreen\", \"registerRestoreOldStyle\", \"hideEverythingExceptGivenElement\", \"restoreHiddenElements\", \"setLetterbox\", \"softFullscreenResizeWebGLRenderTarget\", \"doRequestFullscreen\", \"fillPointerlockChangeEventData\", \"registerPointerlockChangeEventCallback\", \"registerPointerlockErrorEventCallback\", \"requestPointerLock\", \"fillVisibilityChangeEventData\", \"registerVisibilityChangeEventCallback\", \"registerTouchEventCallback\", \"fillGamepadEventData\", \"registerGamepadEventCallback\", \"registerBeforeUnloadEventCallback\", \"fillBatteryEventData\", \"battery\", \"registerBatteryEventCallback\", \"setCanvasElementSize\", \"getCanvasElementSize\", \"checkWasiClock\", \"setImmediateWrapped\", \"clearImmediateWrapped\", \"polyfillSetImmediate\", \"exception_addRef\", \"exception_decRef\", \"setMainLoop\", \"_setNetworkCallback\", \"heapObjectForWebGLType\", \"heapAccessShiftForWebGLHeap\", \"emscriptenWebGLGet\", \"computeUnpackAlignedImageSize\", \"emscriptenWebGLGetTexPixelData\", \"emscriptenWebGLGetUniform\", \"webglGetUniformLocation\", \"webglPrepareUniformLocationsBeforeFirstUse\", \"webglGetLeftBracePos\", \"emscriptenWebGLGetVertexAttrib\", \"writeGLArray\", \"SDL_unicode\", \"SDL_ttfContext\", \"SDL_audio\", \"GLFW_Window\", \"runAndAbortIfError\", \"registerInheritedInstance\", \"unregisterInheritedInstance\", \"requireRegisteredType\", \"enumReadValueFromPointer\", \"validateThis\", \"getStringOrSymbol\", \"craftEmvalAllocator\", \"emval_get_global\", \"emval_lookupTypes\", \"emval_allocateDestructors\", \"emval_addMethodCaller\"];\n missingLibrarySymbols.forEach(missingLibrarySymbol);\n var calledRun;\n dependenciesFulfilled = function runCaller() {\n if (!calledRun) run();\n if (!calledRun) dependenciesFulfilled = runCaller;\n };\n function stackCheckInit() {\n _emscripten_stack_init();\n writeStackCookie();\n }\n function run(args) {\n args = args || arguments_;\n if (runDependencies > 0) {\n return;\n }\n stackCheckInit();\n preRun();\n if (runDependencies > 0) {\n return;\n }\n function doRun() {\n if (calledRun) return;\n calledRun = true;\n Module[\"calledRun\"] = true;\n if (ABORT) return;\n initRuntime();\n readyPromiseResolve(Module);\n if (Module[\"onRuntimeInitialized\"]) Module[\"onRuntimeInitialized\"]();\n assert(!Module[\"_main\"], 'compiled without a main, but one is present. if you added it from JS, use Module[\"onRuntimeInitialized\"]');\n postRun();\n }\n if (Module[\"setStatus\"]) {\n Module[\"setStatus\"](\"Running...\");\n setTimeout(function() {\n setTimeout(function() {\n Module[\"setStatus\"](\"\");\n }, 1);\n doRun();\n }, 1);\n } else {\n doRun();\n }\n checkStackCookie();\n }\n if (Module[\"preInit\"]) {\n if (typeof Module[\"preInit\"] == \"function\") Module[\"preInit\"] = [Module[\"preInit\"]];\n while (Module[\"preInit\"].length > 0) {\n Module[\"preInit\"].pop()();\n }\n }\n run();\n return createLazPerf2.ready;\n });\n })();\n if (typeof exports === \"object\" && typeof module === \"object\")\n module.exports = createLazPerf;\n else if (typeof define === \"function\" && define[\"amd\"])\n define([], function() {\n return createLazPerf;\n });\n else if (typeof exports === \"object\")\n exports[\"createLazPerf\"] = createLazPerf;\n }\n });\n\n // ../../node_modules/.pnpm/laz-perf@0.0.7/node_modules/laz-perf/lib/web/index.js\n var require_web = __commonJS({\n \"../../node_modules/.pnpm/laz-perf@0.0.7/node_modules/laz-perf/lib/web/index.js\"(exports) {\n \"use strict\";\n var __importDefault = exports && exports.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : { \"default\": mod };\n };\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.LazPerf = exports.create = exports.createLazPerf = void 0;\n var laz_perf_js_1 = __importDefault(require_laz_perf());\n exports.createLazPerf = laz_perf_js_1.default;\n exports.create = laz_perf_js_1.default;\n exports.LazPerf = { create: laz_perf_js_1.default };\n }\n });\n\n // dist/streaming/laz-source.js\n var laz_source_exports = {};\n __export(laz_source_exports, {\n LazStreamingSource: () => LazStreamingSource\n });\n async function loadLazPerf() {\n if (!modulePromise) {\n modulePromise = (async () => {\n const wasmBinary = await fetchLazPerfWasm();\n const ns = await Promise.resolve().then(() => __toESM(require_web(), 1));\n const dflt = ns.default;\n const candidates = [\n ns.createLazPerf,\n typeof dflt === \"object\" && dflt !== null ? dflt.createLazPerf : void 0,\n dflt,\n // Some bundlers expose the CJS module as the namespace object itself.\n ns\n ];\n const factory = candidates.find((c) => typeof c === \"function\");\n if (!factory) {\n const keys = Object.keys(ns).join(\", \");\n throw new Error(`laz-perf: could not find createLazPerf factory (saw keys: ${keys || \"<empty>\"})`);\n }\n return factory({ wasmBinary });\n })();\n }\n return modulePromise;\n }\n async function fetchLazPerfWasm() {\n let wasmUrl;\n try {\n const mod = await import(\"laz-perf/lib/web/laz-perf.wasm?url\");\n wasmUrl = mod.default;\n } catch (err) {\n throw new Error(`laz-perf: could not resolve wasm asset URL (${err instanceof Error ? err.message : String(err)}). Ensure the bundler treats \\`laz-perf/lib/web/laz-perf.wasm?url\\` as a static asset.`);\n }\n const response = await fetch(wasmUrl);\n if (!response.ok) {\n throw new Error(`laz-perf: wasm fetch failed (${response.status} ${response.statusText}) for ${wasmUrl}`);\n }\n const buffer = await response.arrayBuffer();\n return new Uint8Array(buffer);\n }\n function abortIfAborted2(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var modulePromise, LazStreamingSource;\n var init_laz_source = __esm({\n \"dist/streaming/laz-source.js\"() {\n \"use strict\";\n init_las();\n modulePromise = null;\n LazStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n // Populated by open()\n __publicField(this, \"mod\", null);\n __publicField(this, \"laszip\", null);\n __publicField(this, \"header\", null);\n __publicField(this, \"fileBytes\", null);\n __publicField(this, \"filePtr\", 0);\n __publicField(this, \"pointPtr\", 0);\n __publicField(this, \"pointBuffer\", null);\n __publicField(this, \"cursor\", 0);\n __publicField(this, \"rgbScale\", 1);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n if (this.header)\n return this.toInfo(this.header);\n abortIfAborted2(signal);\n let mod;\n let filePtr = 0;\n let pointPtr = 0;\n let laszip;\n try {\n const buf = await this.blob.arrayBuffer();\n abortIfAborted2(signal);\n const bytes = new Uint8Array(buf);\n const header = parseLasHeader(bytes);\n mod = await loadLazPerf();\n abortIfAborted2(signal);\n filePtr = mod._malloc(bytes.byteLength);\n mod.HEAPU8.set(bytes, filePtr);\n laszip = new mod.LASZip();\n laszip.open(filePtr, bytes.byteLength);\n const pointSize = laszip.getPointLength();\n pointPtr = mod._malloc(pointSize);\n const pointBuffer = new Uint8Array(pointSize);\n let rgbScale = 1;\n if (header.hasRgb) {\n const probe = Math.min(4096, header.pointCount);\n const tempBuf = new Uint8Array(probe * pointSize);\n for (let i = 0; i < probe; i++) {\n laszip.getPoint(pointPtr);\n tempBuf.set(mod.HEAPU8.subarray(pointPtr, pointPtr + pointSize), i * pointSize);\n }\n const max = sampleMaxRgbChannel(tempBuf, header);\n rgbScale = max > 0 && max <= 255 ? 65535 / 255 : 1;\n laszip.delete();\n laszip = new mod.LASZip();\n laszip.open(filePtr, bytes.byteLength);\n }\n this.fileBytes = bytes;\n this.mod = mod;\n this.filePtr = filePtr;\n this.laszip = laszip;\n this.pointPtr = pointPtr;\n this.pointBuffer = pointBuffer;\n this.rgbScale = rgbScale;\n this.header = header;\n this.cursor = 0;\n return this.toInfo(header);\n } catch (err) {\n try {\n laszip?.delete();\n } catch {\n }\n if (mod && pointPtr) {\n try {\n mod._free(pointPtr);\n } catch {\n }\n }\n if (mod && filePtr) {\n try {\n mod._free(filePtr);\n } catch {\n }\n }\n throw err;\n }\n }\n async next(maxPoints, signal) {\n abortIfAborted2(signal);\n if (!Number.isFinite(maxPoints) || maxPoints <= 0) {\n throw new Error(`LazStreamingSource: maxPoints must be > 0 (got ${maxPoints})`);\n }\n if (!this.header || !this.mod || !this.laszip || !this.pointBuffer) {\n throw new Error(\"LazStreamingSource: open() must be awaited before next()\");\n }\n const stride = Math.max(1, this.downsample.stride | 0);\n if (this.cursor >= this.header.pointCount)\n return null;\n const pointSize = this.pointBuffer.byteLength;\n const remainingSource = this.header.pointCount - this.cursor;\n const sourceTake = stride === 1 ? Math.min(maxPoints, remainingSource) : Math.min(maxPoints * stride, remainingSource);\n const decodedCount = stride === 1 ? sourceTake : Math.ceil(sourceTake / stride);\n const slab = new Uint8Array(decodedCount * pointSize);\n let writeIdx = 0;\n for (let i = 0; i < sourceTake; i++) {\n this.laszip.getPoint(this.pointPtr);\n if (stride === 1 || i % stride === 0) {\n slab.set(this.mod.HEAPU8.subarray(this.pointPtr, this.pointPtr + pointSize), writeIdx * pointSize);\n writeIdx++;\n }\n }\n this.cursor += sourceTake;\n return decodeLasPoints(slab, this.header, decodedCount, pointSize, this.rgbScale);\n }\n close() {\n try {\n this.laszip?.delete();\n } catch {\n }\n if (this.mod && this.pointPtr) {\n try {\n this.mod._free(this.pointPtr);\n } catch {\n }\n }\n if (this.mod && this.filePtr) {\n try {\n this.mod._free(this.filePtr);\n } catch {\n }\n }\n this.laszip = null;\n this.mod = null;\n this.header = null;\n this.fileBytes = null;\n this.pointBuffer = null;\n this.filePtr = 0;\n this.pointPtr = 0;\n this.cursor = 0;\n }\n toInfo(header) {\n const stride = Math.max(1, this.downsample.stride | 0);\n return {\n totalPointCount: stride === 1 ? header.pointCount : Math.ceil(header.pointCount / stride),\n bbox: header.bbox,\n hasColor: header.hasRgb,\n hasClassification: true,\n hasIntensity: true,\n label: this.label\n };\n }\n };\n }\n });\n\n // dist/formats/ply.js\n function parsePlyHeader(buffer) {\n const probeLen = Math.min(65536, buffer.length);\n const probe = TEXT_DECODER.decode(buffer.subarray(0, probeLen));\n if (!probe.startsWith(\"ply\")) {\n throw new Error('PLY: missing magic \\u2014 file does not start with \"ply\"');\n }\n const endIdx = probe.indexOf(\"end_header\");\n if (endIdx < 0) {\n throw new Error(\"PLY: missing end_header line in first \" + probeLen + \" bytes\");\n }\n const newline = probe.indexOf(\"\\n\", endIdx);\n if (newline < 0) {\n throw new Error(\"PLY: end_header line not terminated by newline\");\n }\n const headerText = probe.slice(0, newline + 1);\n const bodyOffset = newline + 1;\n const lines = headerText.split(\"\\n\").map((l) => l.trim()).filter((l) => l.length > 0);\n let format = null;\n let version = \"1.0\";\n const elements = [];\n let current = null;\n for (const line of lines) {\n if (line === \"ply\" || line === \"end_header\")\n continue;\n if (line.startsWith(\"comment\"))\n continue;\n if (line.startsWith(\"obj_info\"))\n continue;\n if (line.startsWith(\"format \")) {\n const parts = line.split(/\\s+/);\n const f = parts[1];\n version = parts[2] ?? \"1.0\";\n if (f === \"ascii\" || f === \"binary_little_endian\" || f === \"binary_big_endian\") {\n format = f;\n } else {\n throw new Error(`PLY: unsupported format \"${f}\"`);\n }\n continue;\n }\n if (line.startsWith(\"element \")) {\n const parts = line.split(/\\s+/);\n current = {\n name: parts[1],\n count: parseInt(parts[2], 10),\n properties: [],\n recordSize: 0\n };\n elements.push(current);\n continue;\n }\n if (line.startsWith(\"property \")) {\n if (!current) {\n throw new Error(`PLY: property declared before any element: \"${line}\"`);\n }\n const parts = line.split(/\\s+/);\n if (parts[1] === \"list\")\n continue;\n const type = parts[1];\n const name = parts[2];\n const size = TYPE_SIZES[type];\n if (size === void 0) {\n throw new Error(`PLY: unknown property type \"${type}\"`);\n }\n current.properties.push({ name, type, size, offset: current.recordSize });\n current.recordSize += size;\n continue;\n }\n }\n if (!format)\n throw new Error(\"PLY: missing `format` line in header\");\n if (!elements.some((e) => e.name === \"vertex\")) {\n throw new Error(\"PLY: missing `vertex` element\");\n }\n return { format, version, elements, bodyOffset };\n }\n function decodePly(buffer) {\n const header = parsePlyHeader(buffer);\n const vertex = header.elements.find((e) => e.name === \"vertex\");\n if (!vertex)\n throw new Error(\"PLY: no vertex element\");\n if (header.elements[0] !== vertex) {\n throw new Error(`PLY: vertex element must appear first; saw \"${header.elements[0]?.name}\" first`);\n }\n const xProp = vertex.properties.find((p) => p.name === \"x\");\n const yProp = vertex.properties.find((p) => p.name === \"y\");\n const zProp = vertex.properties.find((p) => p.name === \"z\");\n if (!xProp || !yProp || !zProp) {\n throw new Error(\"PLY: vertex element must define x, y, z properties\");\n }\n const rProp = vertex.properties.find((p) => p.name === \"red\" || p.name === \"r\");\n const gProp = vertex.properties.find((p) => p.name === \"green\" || p.name === \"g\");\n const bProp = vertex.properties.find((p) => p.name === \"blue\" || p.name === \"b\");\n const hasRgb = !!(rProp && gProp && bProp);\n const intensityProp = vertex.properties.find((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\");\n const count = vertex.count;\n const positions = new Float32Array(count * 3);\n const colors = hasRgb ? new Float32Array(count * 3) : void 0;\n const intensities = intensityProp ? new Uint16Array(count) : void 0;\n if (header.format === \"ascii\") {\n decodeAsciiBody(buffer, header, vertex, positions, colors, intensities);\n } else {\n decodeBinaryBody(buffer, header, vertex, positions, colors, intensities, header.format === \"binary_little_endian\");\n }\n return {\n positions,\n colors,\n intensities,\n pointCount: count,\n bbox: computeBBox(positions)\n };\n }\n function decodeAsciiBody(buffer, header, vertex, positions, colors, intensities) {\n const text = TEXT_DECODER.decode(buffer.subarray(header.bodyOffset));\n const xCol = vertex.properties.findIndex((p) => p.name === \"x\");\n const yCol = vertex.properties.findIndex((p) => p.name === \"y\");\n const zCol = vertex.properties.findIndex((p) => p.name === \"z\");\n const rCol = vertex.properties.findIndex((p) => p.name === \"red\" || p.name === \"r\");\n const gCol = vertex.properties.findIndex((p) => p.name === \"green\" || p.name === \"g\");\n const bCol = vertex.properties.findIndex((p) => p.name === \"blue\" || p.name === \"b\");\n const iCol = vertex.properties.findIndex((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\");\n let lineStart = 0;\n let written = 0;\n while (written < vertex.count && lineStart < text.length) {\n let lineEnd = text.indexOf(\"\\n\", lineStart);\n if (lineEnd < 0)\n lineEnd = text.length;\n const line = text.slice(lineStart, lineEnd).trim();\n lineStart = lineEnd + 1;\n if (!line)\n continue;\n const parts = line.split(/\\s+/);\n positions[written * 3] = Number(parts[xCol]);\n positions[written * 3 + 1] = Number(parts[yCol]);\n positions[written * 3 + 2] = Number(parts[zCol]);\n if (colors && rCol >= 0 && gCol >= 0 && bCol >= 0) {\n colors[written * 3] = clamp01(Number(parts[rCol]) / 255);\n colors[written * 3 + 1] = clamp01(Number(parts[gCol]) / 255);\n colors[written * 3 + 2] = clamp01(Number(parts[bCol]) / 255);\n }\n if (intensities && iCol >= 0) {\n intensities[written] = Math.min(65535, Math.max(0, Number(parts[iCol]) | 0));\n }\n written++;\n }\n if (written !== vertex.count) {\n throw new Error(`PLY ascii: expected ${vertex.count} vertex lines, got ${written}`);\n }\n }\n function decodeBinaryBody(buffer, header, vertex, positions, colors, intensities, littleEndian) {\n const stride = vertex.recordSize;\n const need = vertex.count * stride;\n if (buffer.length < header.bodyOffset + need) {\n throw new Error(`PLY binary: expected ${need} body bytes, got ${buffer.length - header.bodyOffset}`);\n }\n const view = new DataView(buffer.buffer, buffer.byteOffset + header.bodyOffset, need);\n const xProp = vertex.properties.find((p) => p.name === \"x\");\n const yProp = vertex.properties.find((p) => p.name === \"y\");\n const zProp = vertex.properties.find((p) => p.name === \"z\");\n const rProp = colors ? vertex.properties.find((p) => p.name === \"red\" || p.name === \"r\") : void 0;\n const gProp = colors ? vertex.properties.find((p) => p.name === \"green\" || p.name === \"g\") : void 0;\n const bProp = colors ? vertex.properties.find((p) => p.name === \"blue\" || p.name === \"b\") : void 0;\n const iProp = intensities ? vertex.properties.find((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\") : void 0;\n for (let i = 0; i < vertex.count; i++) {\n const base = i * stride;\n positions[i * 3] = readScalar(view, base + xProp.offset, xProp, littleEndian);\n positions[i * 3 + 1] = readScalar(view, base + yProp.offset, yProp, littleEndian);\n positions[i * 3 + 2] = readScalar(view, base + zProp.offset, zProp, littleEndian);\n if (colors && rProp && gProp && bProp) {\n colors[i * 3] = clamp01(readScalar(view, base + rProp.offset, rProp, littleEndian) / 255);\n colors[i * 3 + 1] = clamp01(readScalar(view, base + gProp.offset, gProp, littleEndian) / 255);\n colors[i * 3 + 2] = clamp01(readScalar(view, base + bProp.offset, bProp, littleEndian) / 255);\n }\n if (intensities && iProp) {\n intensities[i] = Math.min(65535, Math.max(0, readScalar(view, base + iProp.offset, iProp, littleEndian) | 0));\n }\n }\n }\n function readScalar(view, offset, prop, le) {\n switch (prop.type) {\n case \"char\":\n case \"int8\":\n return view.getInt8(offset);\n case \"uchar\":\n case \"uint8\":\n return view.getUint8(offset);\n case \"short\":\n case \"int16\":\n return view.getInt16(offset, le);\n case \"ushort\":\n case \"uint16\":\n return view.getUint16(offset, le);\n case \"int\":\n case \"int32\":\n return view.getInt32(offset, le);\n case \"uint\":\n case \"uint32\":\n return view.getUint32(offset, le);\n case \"float\":\n case \"float32\":\n return view.getFloat32(offset, le);\n case \"double\":\n case \"float64\":\n return view.getFloat64(offset, le);\n default:\n throw new Error(`PLY: cannot read scalar of type \"${prop.type}\"`);\n }\n }\n function clamp01(v) {\n return v < 0 ? 0 : v > 1 ? 1 : v;\n }\n function computeBBox(positions) {\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i < positions.length; i += 3) {\n const x = positions[i], y = positions[i + 1], z = positions[i + 2];\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n }\n return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };\n }\n var TYPE_SIZES, TEXT_DECODER;\n var init_ply = __esm({\n \"dist/formats/ply.js\"() {\n \"use strict\";\n TYPE_SIZES = {\n char: 1,\n int8: 1,\n uchar: 1,\n uint8: 1,\n short: 2,\n int16: 2,\n ushort: 2,\n uint16: 2,\n int: 4,\n int32: 4,\n uint: 4,\n uint32: 4,\n float: 4,\n float32: 4,\n double: 8,\n float64: 8\n };\n TEXT_DECODER = new TextDecoder();\n }\n });\n\n // dist/streaming/ply-source.js\n var ply_source_exports = {};\n __export(ply_source_exports, {\n PlyStreamingSource: () => PlyStreamingSource\n });\n function applyStride(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const classifications = chunk.classifications ? new Uint8Array(newCount) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (classifications && chunk.classifications) {\n classifications[dst] = chunk.classifications[i];\n }\n if (intensities && chunk.intensities) {\n intensities[dst] = chunk.intensities[i];\n }\n dst++;\n }\n return {\n positions,\n colors,\n classifications,\n intensities,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted3(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var PlyStreamingSource;\n var init_ply_source = __esm({\n \"dist/streaming/ply-source.js\"() {\n \"use strict\";\n init_ply();\n PlyStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted3(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted3(signal);\n const bytes = new Uint8Array(buf);\n const header = parsePlyHeader(bytes);\n const vertex = header.elements.find((e) => e.name === \"vertex\");\n if (!vertex)\n throw new Error(\"PLY: no vertex element\");\n const hasRgb = !!vertex.properties.find((p) => p.name === \"red\" || p.name === \"r\") && !!vertex.properties.find((p) => p.name === \"green\" || p.name === \"g\") && !!vertex.properties.find((p) => p.name === \"blue\" || p.name === \"b\");\n const hasIntensity = !!vertex.properties.find((p) => p.name === \"intensity\" || p.name === \"scalar_Intensity\");\n const fullChunk = decodePly(bytes);\n this.chunk = applyStride(fullChunk, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: hasRgb,\n hasClassification: false,\n hasIntensity,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted3(signal);\n if (!this.chunk || this.served)\n return null;\n void maxPoints;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/lzf.js\n function decompressLZF(input, outputSize) {\n const output = new Uint8Array(outputSize);\n let ip = 0;\n let op = 0;\n const ie = input.length;\n while (ip < ie) {\n let ctrl = input[ip++];\n if (ctrl < 32) {\n const run = ctrl + 1;\n if (ip + run > ie) {\n throw new Error(\"LZF: literal run exceeds input bounds\");\n }\n if (op + run > outputSize) {\n throw new Error(\"LZF: literal run exceeds output bounds\");\n }\n output.set(input.subarray(ip, ip + run), op);\n ip += run;\n op += run;\n } else {\n let len = ctrl >> 5;\n if (len === 7) {\n if (ip >= ie)\n throw new Error(\"LZF: truncated extended length\");\n len += input[ip++];\n }\n len += 2;\n if (ip >= ie)\n throw new Error(\"LZF: truncated back-reference offset\");\n const ref = op - ((ctrl & 31) << 8) - input[ip++] - 1;\n if (ref < 0) {\n throw new Error(\"LZF: back-reference points before output start\");\n }\n if (op + len > outputSize) {\n throw new Error(\"LZF: back-reference exceeds output bounds\");\n }\n for (let i = 0; i < len; i++) {\n output[op + i] = output[ref + i];\n }\n op += len;\n }\n }\n if (op !== outputSize) {\n throw new Error(`LZF: decompressed ${op} bytes, expected ${outputSize}`);\n }\n return output;\n }\n var init_lzf = __esm({\n \"dist/lzf.js\"() {\n \"use strict\";\n }\n });\n\n // dist/formats/pcd.js\n function decodePcd(buffer) {\n const header = parseHeader(buffer);\n let positions;\n let colors;\n if (header.data === \"ascii\") {\n ({ positions, colors } = decodeAscii(buffer, header));\n } else if (header.data === \"binary\") {\n ({ positions, colors } = decodeBinary(buffer, header));\n } else {\n ({ positions, colors } = decodeBinaryCompressed(buffer, header));\n }\n return {\n positions,\n colors,\n pointCount: header.pointCount,\n bbox: computeBBox2(positions)\n };\n }\n function parseHeader(buffer) {\n const probeLen = Math.min(65536, buffer.length);\n const probe = TEXT_DECODER2.decode(buffer.subarray(0, probeLen));\n const dataIdx = probe.search(/^DATA\\s+(\\S+)/m);\n if (dataIdx < 0) {\n throw new Error(\"PCD: missing DATA line in header (scanned first \" + probeLen + \" bytes)\");\n }\n const headerText = probe.slice(0, dataIdx);\n const dataLineMatch = probe.slice(dataIdx).match(/^DATA\\s+(\\S+)\\s*\\n/);\n if (!dataLineMatch) {\n throw new Error(\"PCD: malformed DATA line\");\n }\n const dataKind = dataLineMatch[1].toLowerCase();\n if (dataKind !== \"ascii\" && dataKind !== \"binary\" && dataKind !== \"binary_compressed\") {\n throw new Error(`PCD: unsupported DATA kind \"${dataKind}\"`);\n }\n const bodyOffset = dataIdx + dataLineMatch[0].length;\n const tokens = /* @__PURE__ */ new Map();\n for (const rawLine of headerText.split(\"\\n\")) {\n const line = rawLine.replace(/#.*$/, \"\").trim();\n if (!line)\n continue;\n const parts = line.split(/\\s+/);\n const key = parts[0].toUpperCase();\n tokens.set(key, parts.slice(1));\n }\n const fieldNames = tokens.get(\"FIELDS\") ?? [];\n const sizes = (tokens.get(\"SIZE\") ?? []).map(Number);\n const types = tokens.get(\"TYPE\") ?? [];\n const counts = (tokens.get(\"COUNT\") ?? []).map(Number);\n const widthRaw = tokens.get(\"WIDTH\")?.[0];\n const heightRaw = tokens.get(\"HEIGHT\")?.[0];\n const pointsRaw = tokens.get(\"POINTS\")?.[0];\n if (fieldNames.length === 0)\n throw new Error(\"PCD: missing FIELDS\");\n if (sizes.length !== fieldNames.length)\n throw new Error(\"PCD: SIZE/FIELDS length mismatch\");\n if (types.length !== fieldNames.length)\n throw new Error(\"PCD: TYPE/FIELDS length mismatch\");\n const fields = [];\n let stride = 0;\n for (let i = 0; i < fieldNames.length; i++) {\n const count = counts[i] ?? 1;\n const size = sizes[i];\n const type = types[i];\n if (type !== \"F\" && type !== \"I\" && type !== \"U\") {\n throw new Error(`PCD: unsupported field TYPE \"${type}\"`);\n }\n fields.push({ name: fieldNames[i], size, type, count, offset: stride });\n stride += size * count;\n }\n const width = widthRaw !== void 0 ? parseInt(widthRaw, 10) : 0;\n const height = heightRaw !== void 0 ? parseInt(heightRaw, 10) : 1;\n const pointCount = pointsRaw !== void 0 ? parseInt(pointsRaw, 10) : width * height;\n if (!Number.isFinite(pointCount) || pointCount <= 0) {\n throw new Error(\"PCD: invalid point count\");\n }\n return {\n version: tokens.get(\"VERSION\")?.[0] ?? \"0.7\",\n fields,\n width,\n height,\n pointCount,\n pointStride: stride,\n data: dataKind,\n bodyOffset\n };\n }\n function planChannels(header) {\n const plan = {};\n for (const field of header.fields) {\n const name = field.name.toLowerCase();\n if (name === \"x\")\n plan.xField = field;\n else if (name === \"y\")\n plan.yField = field;\n else if (name === \"z\")\n plan.zField = field;\n else if (name === \"rgb\" || name === \"rgba\")\n plan.rgbField = field;\n }\n if (!plan.xField || !plan.yField || !plan.zField) {\n throw new Error(\"PCD: x/y/z fields are required\");\n }\n return plan;\n }\n function decodeAscii(buffer, header) {\n const plan = planChannels(header);\n const text = TEXT_DECODER2.decode(buffer.subarray(header.bodyOffset));\n const positions = new Float32Array(header.pointCount * 3);\n const colors = plan.rgbField ? new Float32Array(header.pointCount * 3) : void 0;\n const colMap = buildAsciiColumnMap(header, plan);\n let writeIdx = 0;\n let lineStart = 0;\n let pointsRead = 0;\n while (pointsRead < header.pointCount && lineStart < text.length) {\n let lineEnd = text.indexOf(\"\\n\", lineStart);\n if (lineEnd < 0)\n lineEnd = text.length;\n const line = text.slice(lineStart, lineEnd).trim();\n lineStart = lineEnd + 1;\n if (!line)\n continue;\n const parts = line.split(/\\s+/);\n positions[writeIdx * 3] = Number(parts[colMap.xCol]);\n positions[writeIdx * 3 + 1] = Number(parts[colMap.yCol]);\n positions[writeIdx * 3 + 2] = Number(parts[colMap.zCol]);\n if (colors && colMap.rgbCol >= 0) {\n const packed = parsePackedRgb(parts[colMap.rgbCol], plan.rgbField);\n colors[writeIdx * 3] = (packed >> 16 & 255) / 255;\n colors[writeIdx * 3 + 1] = (packed >> 8 & 255) / 255;\n colors[writeIdx * 3 + 2] = (packed & 255) / 255;\n }\n writeIdx++;\n pointsRead++;\n }\n if (pointsRead !== header.pointCount) {\n throw new Error(`PCD ascii: expected ${header.pointCount} points, got ${pointsRead}`);\n }\n return { positions, colors };\n }\n function buildAsciiColumnMap(header, plan) {\n let col = 0;\n let xCol = -1;\n let yCol = -1;\n let zCol = -1;\n let rgbCol = -1;\n for (const field of header.fields) {\n if (field === plan.xField)\n xCol = col;\n if (field === plan.yField)\n yCol = col;\n if (field === plan.zField)\n zCol = col;\n if (field === plan.rgbField)\n rgbCol = col;\n col += field.count;\n }\n return { xCol, yCol, zCol, rgbCol };\n }\n function decodeBinary(buffer, header) {\n const plan = planChannels(header);\n const view = new DataView(buffer.buffer, buffer.byteOffset + header.bodyOffset, header.pointCount * header.pointStride);\n const positions = new Float32Array(header.pointCount * 3);\n const colors = plan.rgbField ? new Float32Array(header.pointCount * 3) : void 0;\n for (let i = 0; i < header.pointCount; i++) {\n const base = i * header.pointStride;\n positions[i * 3] = readScalar2(view, base + plan.xField.offset, plan.xField);\n positions[i * 3 + 1] = readScalar2(view, base + plan.yField.offset, plan.yField);\n positions[i * 3 + 2] = readScalar2(view, base + plan.zField.offset, plan.zField);\n if (colors && plan.rgbField) {\n const packed = view.getUint32(base + plan.rgbField.offset, true);\n colors[i * 3] = (packed >> 16 & 255) / 255;\n colors[i * 3 + 1] = (packed >> 8 & 255) / 255;\n colors[i * 3 + 2] = (packed & 255) / 255;\n }\n }\n return { positions, colors };\n }\n function decodeBinaryCompressed(buffer, header) {\n if (buffer.length < header.bodyOffset + 8) {\n throw new Error(\"PCD binary_compressed: truncated size header\");\n }\n const sizeView = new DataView(buffer.buffer, buffer.byteOffset + header.bodyOffset, 8);\n const compressedSize = sizeView.getUint32(0, true);\n const uncompressedSize = sizeView.getUint32(4, true);\n const expectedUncompressed = header.pointCount * header.pointStride;\n if (uncompressedSize !== expectedUncompressed) {\n throw new Error(`PCD binary_compressed: declared uncompressed=${uncompressedSize} does not match fields*points=${expectedUncompressed}`);\n }\n const compressed = buffer.subarray(header.bodyOffset + 8, header.bodyOffset + 8 + compressedSize);\n const raw = decompressLZF(compressed, uncompressedSize);\n const plan = planChannels(header);\n const fieldStart = /* @__PURE__ */ new Map();\n let cursor = 0;\n for (const field of header.fields) {\n fieldStart.set(field, cursor);\n cursor += header.pointCount * field.size * field.count;\n }\n const view = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);\n const positions = new Float32Array(header.pointCount * 3);\n const colors = plan.rgbField ? new Float32Array(header.pointCount * 3) : void 0;\n const xBase = fieldStart.get(plan.xField);\n const yBase = fieldStart.get(plan.yField);\n const zBase = fieldStart.get(plan.zField);\n const rgbBase = plan.rgbField ? fieldStart.get(plan.rgbField) : 0;\n for (let i = 0; i < header.pointCount; i++) {\n positions[i * 3] = readScalar2(view, xBase + i * plan.xField.size, plan.xField);\n positions[i * 3 + 1] = readScalar2(view, yBase + i * plan.yField.size, plan.yField);\n positions[i * 3 + 2] = readScalar2(view, zBase + i * plan.zField.size, plan.zField);\n if (colors && plan.rgbField) {\n const packed = view.getUint32(rgbBase + i * plan.rgbField.size, true);\n colors[i * 3] = (packed >> 16 & 255) / 255;\n colors[i * 3 + 1] = (packed >> 8 & 255) / 255;\n colors[i * 3 + 2] = (packed & 255) / 255;\n }\n }\n return { positions, colors };\n }\n function readScalar2(view, offset, field) {\n if (field.type === \"F\") {\n return field.size === 8 ? view.getFloat64(offset, true) : view.getFloat32(offset, true);\n }\n if (field.type === \"U\") {\n if (field.size === 1)\n return view.getUint8(offset);\n if (field.size === 2)\n return view.getUint16(offset, true);\n if (field.size === 4)\n return view.getUint32(offset, true);\n } else {\n if (field.size === 1)\n return view.getInt8(offset);\n if (field.size === 2)\n return view.getInt16(offset, true);\n if (field.size === 4)\n return view.getInt32(offset, true);\n }\n throw new Error(`PCD: unsupported field width ${field.size} for type ${field.type}`);\n }\n function parsePackedRgb(token, field) {\n if (field.type === \"F\") {\n PARSE_F32[0] = Number(token);\n return PARSE_U32[0];\n }\n return Number(token) >>> 0;\n }\n function computeBBox2(positions) {\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i < positions.length; i += 3) {\n const x = positions[i], y = positions[i + 1], z = positions[i + 2];\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n }\n return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };\n }\n var TEXT_DECODER2, PARSE_BUFFER, PARSE_F32, PARSE_U32;\n var init_pcd = __esm({\n \"dist/formats/pcd.js\"() {\n \"use strict\";\n init_lzf();\n TEXT_DECODER2 = new TextDecoder();\n PARSE_BUFFER = new ArrayBuffer(4);\n PARSE_F32 = new Float32Array(PARSE_BUFFER);\n PARSE_U32 = new Uint32Array(PARSE_BUFFER);\n }\n });\n\n // dist/streaming/pcd-source.js\n var pcd_source_exports = {};\n __export(pcd_source_exports, {\n PcdStreamingSource: () => PcdStreamingSource\n });\n function applyStride2(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const classifications = chunk.classifications ? new Uint8Array(newCount) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (classifications && chunk.classifications)\n classifications[dst] = chunk.classifications[i];\n if (intensities && chunk.intensities)\n intensities[dst] = chunk.intensities[i];\n dst++;\n }\n return {\n positions,\n colors,\n classifications,\n intensities,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted4(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var PcdStreamingSource;\n var init_pcd_source = __esm({\n \"dist/streaming/pcd-source.js\"() {\n \"use strict\";\n init_pcd();\n PcdStreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted4(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted4(signal);\n const decoded = decodePcd(new Uint8Array(buf));\n this.chunk = applyStride2(decoded, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: !!this.chunk.colors,\n hasClassification: !!this.chunk.classifications,\n hasIntensity: !!this.chunk.intensities,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted4(signal);\n if (!this.chunk || this.served)\n return null;\n void maxPoints;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/formats/e57-page.js\n function parseE57FileHeader(bytes) {\n if (bytes.length < 48)\n throw new Error(\"E57: header truncated (need 48 bytes)\");\n const magic = String.fromCharCode(...bytes.subarray(0, 8));\n if (magic !== E57_MAGIC) {\n throw new Error(`E57: bad magic \"${magic}\" (expected \"${E57_MAGIC}\")`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n return {\n majorVersion: view.getUint32(8, true),\n minorVersion: view.getUint32(12, true),\n fileLogicalSize: readU64LE2(view, 16),\n // Physical XML offset → we convert to logical below; xmlLogicalLength\n // is the byte length AFTER stripping page CRCs.\n xmlLogicalOffset: physicalToLogical(readU64LE2(view, 24), readU64LE2(view, 40)),\n xmlLogicalLength: readU64LE2(view, 32),\n pageSize: readU64LE2(view, 40)\n };\n }\n function stripPageCrc(bytes, pageSize) {\n if (pageSize <= 4)\n throw new Error(\"E57: pageSize too small\");\n const payloadPerPage = pageSize - 4;\n const fullPages = Math.floor(bytes.length / pageSize);\n const tail = bytes.length - fullPages * pageSize;\n const out = new Uint8Array(fullPages * payloadPerPage + Math.max(0, tail - 4));\n let dst = 0;\n for (let p = 0; p < fullPages; p++) {\n const src = p * pageSize;\n out.set(bytes.subarray(src, src + payloadPerPage), dst);\n dst += payloadPerPage;\n }\n if (tail > 4) {\n const src = fullPages * pageSize;\n out.set(bytes.subarray(src, src + tail - 4), dst);\n }\n return out;\n }\n function physicalToLogical(physical, pageSize) {\n const payloadPerPage = pageSize - 4;\n const pages = Math.floor(physical / pageSize);\n const within = physical - pages * pageSize;\n return pages * payloadPerPage + within;\n }\n function resolveCompressedVectorDataOffset(logical, physicalSectionOffset, pageSize) {\n const sectionLogical = physicalToLogical(physicalSectionOffset, pageSize);\n if (sectionLogical + 32 > logical.length) {\n throw new Error(`E57: CompressedVector section header at logical ${sectionLogical} runs past end of file (length ${logical.length})`);\n }\n const view = new DataView(logical.buffer, logical.byteOffset + sectionLogical, 32);\n const sectionId = view.getUint8(0);\n if (sectionId !== 1) {\n throw new Error(`E57: expected CompressedVector section (id=1) at physical ${physicalSectionOffset}, got id=${sectionId}`);\n }\n const dataPhysicalOffset = readU64LE2(view, 16);\n return physicalToLogical(dataPhysicalOffset, pageSize);\n }\n function readU64LE2(view, offset) {\n const lo = view.getUint32(offset, true);\n const hi = view.getUint32(offset + 4, true);\n return hi * 4294967296 + lo;\n }\n var E57_MAGIC;\n var init_e57_page = __esm({\n \"dist/formats/e57-page.js\"() {\n \"use strict\";\n E57_MAGIC = \"ASTM-E57\";\n }\n });\n\n // dist/xml-mini.js\n function parseXml(xml) {\n const root = { name: \"\", attrs: /* @__PURE__ */ new Map(), children: [], text: \"\" };\n const stack = [root];\n let i = 0;\n const n = xml.length;\n let textStart = -1;\n const flushText = (end) => {\n if (textStart < 0 || textStart >= end) {\n textStart = -1;\n return;\n }\n const slice = xml.slice(textStart, end).trim();\n if (slice.length > 0) {\n const top = stack[stack.length - 1];\n if (top.children.length === 0) {\n top.text = top.text + decodeEntities(slice);\n }\n }\n textStart = -1;\n };\n while (i < n) {\n const ch = xml.charCodeAt(i);\n if (ch !== 60) {\n if (textStart < 0)\n textStart = i;\n i++;\n continue;\n }\n flushText(i);\n if (xml.startsWith(\"<?\", i)) {\n const end = xml.indexOf(\"?>\", i + 2);\n i = end < 0 ? n : end + 2;\n continue;\n }\n if (xml.startsWith(\"<!--\", i)) {\n const end = xml.indexOf(\"-->\", i + 4);\n i = end < 0 ? n : end + 3;\n continue;\n }\n if (xml.startsWith(\"<![CDATA[\", i)) {\n const end = xml.indexOf(\"]]>\", i + 9);\n const cdata = xml.slice(i + 9, end < 0 ? n : end);\n const top = stack[stack.length - 1];\n if (top.children.length === 0)\n top.text = top.text + cdata;\n i = end < 0 ? n : end + 3;\n continue;\n }\n if (xml.startsWith(\"<!\", i)) {\n const end = xml.indexOf(\">\", i + 2);\n i = end < 0 ? n : end + 1;\n continue;\n }\n if (xml.charCodeAt(i + 1) === 47) {\n const end = xml.indexOf(\">\", i + 2);\n if (end < 0)\n throw new Error(\"XML: unterminated closing tag\");\n const name2 = xml.slice(i + 2, end).trim();\n const top = stack[stack.length - 1];\n if (top.name !== name2) {\n throw new Error(`XML: mismatched closing tag </${name2}> (expected </${top.name}>)`);\n }\n stack.pop();\n i = end + 1;\n continue;\n }\n const tagEnd = findTagEnd(xml, i + 1);\n if (tagEnd < 0)\n throw new Error(\"XML: unterminated tag\");\n let inner = xml.slice(i + 1, tagEnd).trim();\n let selfClosing = false;\n if (inner.endsWith(\"/\")) {\n selfClosing = true;\n inner = inner.slice(0, -1).trim();\n }\n const nameMatch = inner.match(/^([A-Za-z_][\\w:.\\-]*)/);\n if (!nameMatch) {\n i = tagEnd + 1;\n continue;\n }\n const name = nameMatch[1];\n const attrSpan = inner.slice(name.length).trim();\n const attrs = parseAttrs(attrSpan);\n const node = { name, attrs, children: [], text: \"\" };\n if (stack.length === 1 && root.name === \"\") {\n root.name = name;\n root.attrs = attrs;\n if (!selfClosing)\n stack.push(root);\n } else {\n stack[stack.length - 1].children.push(node);\n if (!selfClosing)\n stack.push(node);\n }\n i = tagEnd + 1;\n }\n flushText(n);\n if (stack.length !== 1) {\n throw new Error(`XML: unclosed tag <${stack[stack.length - 1].name}>`);\n }\n if (root.name === \"\") {\n throw new Error(\"XML: missing root element\");\n }\n return root;\n }\n function findTagEnd(xml, from) {\n let inAttr = false;\n for (let i = from; i < xml.length; i++) {\n const c = xml.charCodeAt(i);\n if (c === 34)\n inAttr = !inAttr;\n else if (c === 62 && !inAttr)\n return i;\n }\n return -1;\n }\n function parseAttrs(span) {\n const out = /* @__PURE__ */ new Map();\n if (!span)\n return out;\n let m;\n ATTR_RE.lastIndex = 0;\n while ((m = ATTR_RE.exec(span)) !== null) {\n out.set(m[1], decodeEntities(m[2]));\n }\n return out;\n }\n function decodeEntities(s) {\n if (s.indexOf(\"&\") < 0)\n return s;\n return s.replace(/</g, \"<\").replace(/>/g, \">\").replace(/"/g, '\"').replace(/'/g, \"'\").replace(/&#(\\d+);/g, (_, d) => String.fromCharCode(parseInt(d, 10))).replace(/&#x([0-9a-fA-F]+);/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/&/g, \"&\");\n }\n function childByName(parent, name) {\n for (const c of parent.children) {\n if (c.name === name)\n return c;\n }\n return null;\n }\n function childrenByName(parent, name) {\n return parent.children.filter((c) => c.name === name);\n }\n function textChild(parent, name) {\n const c = childByName(parent, name);\n if (!c)\n return null;\n const t = c.text.trim();\n return t.length > 0 ? t : null;\n }\n var ATTR_RE;\n var init_xml_mini = __esm({\n \"dist/xml-mini.js\"() {\n \"use strict\";\n ATTR_RE = /([A-Za-z_][\\w:.\\-]*)\\s*=\\s*\"([^\"]*)\"/g;\n }\n });\n\n // dist/formats/e57-xml.js\n function parseE57Xml(xmlText) {\n const root = parseXml(xmlText);\n if (root.name !== \"e57Root\") {\n throw new Error(`E57: XML root is not <e57Root> (saw <${root.name || \"?\"}>)`);\n }\n const data3D = childByName(root, \"data3D\");\n if (!data3D)\n return [];\n const entries = [];\n for (const scan of childrenByName(data3D, \"vectorChild\")) {\n const points = childByName(scan, \"points\");\n if (!points)\n continue;\n if (points.attrs.get(\"type\") !== \"CompressedVector\") {\n continue;\n }\n const fileOffsetAttr = points.attrs.get(\"fileOffset\");\n const recordCountAttr = points.attrs.get(\"recordCount\");\n if (!fileOffsetAttr || !recordCountAttr)\n continue;\n const binaryFileOffset = Number(fileOffsetAttr);\n const recordCount = Number(recordCountAttr);\n if (!Number.isFinite(binaryFileOffset) || binaryFileOffset < 0)\n continue;\n if (!Number.isFinite(recordCount) || recordCount < 0)\n continue;\n const proto = childByName(points, \"prototype\");\n if (!proto)\n continue;\n const fields = [];\n for (const f of proto.children) {\n const type = f.attrs.get(\"type\") ?? \"\";\n if (type === \"Float\") {\n fields.push({\n name: f.name,\n kind: \"Float\",\n precision: f.attrs.get(\"precision\") === \"single\" ? \"single\" : \"double\"\n });\n } else if (type === \"ScaledInteger\") {\n fields.push({\n name: f.name,\n kind: \"ScaledInteger\",\n scale: Number(f.attrs.get(\"scale\") ?? \"1\"),\n offset: Number(f.attrs.get(\"offset\") ?? \"0\"),\n minimum: Number(f.attrs.get(\"minimum\") ?? \"0\"),\n maximum: Number(f.attrs.get(\"maximum\") ?? \"0\")\n });\n } else if (type === \"Integer\") {\n fields.push({\n name: f.name,\n kind: \"Integer\",\n minimum: Number(f.attrs.get(\"minimum\") ?? \"0\"),\n maximum: Number(f.attrs.get(\"maximum\") ?? \"0\")\n });\n }\n }\n entries.push({\n guid: textChild(scan, \"guid\") ?? \"\",\n name: textChild(scan, \"name\") ?? void 0,\n recordCount,\n binaryFileOffset,\n prototype: fields,\n pose: parsePoseElement(childByName(scan, \"pose\")) ?? void 0\n });\n }\n return entries;\n }\n function parsePoseElement(poseEl) {\n if (!poseEl)\n return null;\n const rotation = childByName(poseEl, \"rotation\");\n const translation = childByName(poseEl, \"translation\");\n if (!rotation || !translation)\n return null;\n const qw = Number(textChild(rotation, \"w\") ?? \"1\");\n const qx = Number(textChild(rotation, \"x\") ?? \"0\");\n const qy = Number(textChild(rotation, \"y\") ?? \"0\");\n const qz = Number(textChild(rotation, \"z\") ?? \"0\");\n const tx = Number(textChild(translation, \"x\") ?? \"0\");\n const ty = Number(textChild(translation, \"y\") ?? \"0\");\n const tz = Number(textChild(translation, \"z\") ?? \"0\");\n if (![qw, qx, qy, qz, tx, ty, tz].every(Number.isFinite))\n return null;\n return {\n rotation: { w: qw, x: qx, y: qy, z: qz },\n translation: { x: tx, y: ty, z: tz }\n };\n }\n function findField(proto, name) {\n return proto.find((p) => p.name === name);\n }\n var init_e57_xml = __esm({\n \"dist/formats/e57-xml.js\"() {\n \"use strict\";\n init_xml_mini();\n }\n });\n\n // dist/formats/e57-decode.js\n function decodeE57Scan(logical, entry) {\n const xField = findField(entry.prototype, \"cartesianX\");\n const yField = findField(entry.prototype, \"cartesianY\");\n const zField = findField(entry.prototype, \"cartesianZ\");\n if (!xField || !yField || !zField) {\n throw new Error(\"E57: prototype missing cartesianX/Y/Z\");\n }\n for (const f of [xField, yField, zField]) {\n if (f.kind === \"Integer\") {\n throw new Error(`E57: cartesian${f.name.slice(-1)} encoded as plain Integer (only Float / ScaledInteger supported)`);\n }\n }\n const rField = findField(entry.prototype, \"colorRed\");\n const gField = findField(entry.prototype, \"colorGreen\");\n const bField = findField(entry.prototype, \"colorBlue\");\n const hasRgb = !!(rField && gField && bField);\n const iField = findField(entry.prototype, \"intensity\");\n const cField = findField(entry.prototype, \"classification\");\n const positions = new Float32Array(entry.recordCount * 3);\n const colors = hasRgb ? new Float32Array(entry.recordCount * 3) : void 0;\n const intensities = iField && (iField.kind === \"Float\" || iField.kind === \"Integer\" || iField.kind === \"ScaledInteger\") ? new Uint16Array(entry.recordCount) : void 0;\n const classifications = cField && (cField.kind === \"Integer\" || cField.kind === \"ScaledInteger\") ? new Uint8Array(entry.recordCount) : void 0;\n let offset = entry.binaryFileOffset;\n const view = new DataView(logical.buffer, logical.byteOffset, logical.byteLength);\n let written = 0;\n while (written < entry.recordCount && offset < logical.length) {\n if (offset + 4 > logical.length) {\n throw new Error(\"E57: truncated DataPacket header\");\n }\n const packetType = view.getUint8(offset);\n const packetLogicalLength = view.getUint16(offset + 2, true) + 1;\n if (packetType !== 1) {\n offset += packetLogicalLength;\n continue;\n }\n const packetEnd = offset + packetLogicalLength;\n if (packetEnd > logical.length) {\n throw new Error(\"E57: DataPacket runs past end of logical bytes\");\n }\n const payloadEnd = packetEnd;\n if (offset + 6 > payloadEnd) {\n throw new Error(\"E57: truncated DataPacket header\");\n }\n const bytestreamCount = view.getUint16(offset + 4, true);\n if (bytestreamCount !== entry.prototype.length) {\n throw new Error(`E57: packet bytestreamCount (${bytestreamCount}) \\u2260 prototype length (${entry.prototype.length})`);\n }\n const bytestreamLengths = [];\n let cursor = offset + 6;\n for (let i = 0; i < bytestreamCount; i++) {\n if (cursor + 2 > payloadEnd) {\n throw new Error(\"E57: truncated bytestream length table\");\n }\n bytestreamLengths.push(view.getUint16(cursor, true));\n cursor += 2;\n }\n const fieldOffsets = /* @__PURE__ */ new Map();\n let streamCursor = cursor;\n for (let i = 0; i < bytestreamCount; i++) {\n if (streamCursor + bytestreamLengths[i] > payloadEnd) {\n throw new Error(`E57: bytestream ${entry.prototype[i].name} (${bytestreamLengths[i]} bytes) runs past packet payload at offset ${streamCursor}`);\n }\n fieldOffsets.set(entry.prototype[i].name, { start: streamCursor, length: bytestreamLengths[i] });\n streamCursor += bytestreamLengths[i];\n }\n const xPos = fieldOffsets.get(\"cartesianX\");\n const yPos = fieldOffsets.get(\"cartesianY\");\n const zPos = fieldOffsets.get(\"cartesianZ\");\n const xCapacity = floatOrSiPointCapacity(xField, xPos.length);\n const yCapacity = floatOrSiPointCapacity(yField, yPos.length);\n const zCapacity = floatOrSiPointCapacity(zField, zPos.length);\n const pointsInPacket = Math.min(xCapacity, yCapacity, zCapacity);\n const take = Math.min(pointsInPacket, entry.recordCount - written);\n readCartesianStream(logical, view, xField, xPos.start, positions, written, take, 0);\n readCartesianStream(logical, view, yField, yPos.start, positions, written, take, 1);\n readCartesianStream(logical, view, zField, zPos.start, positions, written, take, 2);\n if (colors && rField && gField && bField) {\n writeColorChannel(view, fieldOffsets.get(\"colorRed\").start, rField, colors, written, take, 0, logical);\n writeColorChannel(view, fieldOffsets.get(\"colorGreen\").start, gField, colors, written, take, 1, logical);\n writeColorChannel(view, fieldOffsets.get(\"colorBlue\").start, bField, colors, written, take, 2, logical);\n }\n if (intensities && iField) {\n readIntensityStream(logical, view, iField, fieldOffsets.get(\"intensity\").start, intensities, written, take);\n }\n if (classifications && cField) {\n readClassificationStream(logical, view, cField, fieldOffsets.get(\"classification\").start, classifications, written, take);\n }\n written += take;\n offset = packetEnd;\n }\n if (written < entry.recordCount) {\n return finalize(positions.subarray(0, written * 3), colors?.subarray(0, written * 3), intensities?.subarray(0, written), classifications?.subarray(0, written), written);\n }\n return finalize(positions, colors, intensities, classifications, entry.recordCount);\n }\n function writeColorChannel(view, start, field, colors, written, take, channelOffset, bytes) {\n if (field.kind === \"Float\") {\n const stride = field.precision === \"single\" ? 4 : 8;\n for (let i = 0; i < take; i++) {\n const v = stride === 4 ? view.getFloat32(start + i * stride, true) : view.getFloat64(start + i * stride, true);\n colors[(written + i) * 3 + channelOffset] = clamp012(v);\n }\n } else if (field.kind === \"Integer\") {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 255;\n const span = max - min;\n const inv = span > 0 ? 1 / span : 1;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const stride = widest > 255 ? 2 : 1;\n const signed = min < 0;\n for (let i = 0; i < take; i++) {\n const off = start + i * stride;\n const raw = stride === 2 ? signed ? view.getInt16(off, true) : view.getUint16(off, true) : signed ? view.getInt8(off) : view.getUint8(off);\n colors[(written + i) * 3 + channelOffset] = clamp012((raw - min) * inv);\n }\n } else {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 1;\n const span = max - min;\n const inv = span > 0 ? 1 / span : 1;\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n colors[(written + i) * 3 + channelOffset] = clamp012(raw * inv);\n }\n }\n }\n function readCartesianStream(bytes, view, field, start, positions, written, take, axis) {\n if (field.kind === \"Float\") {\n const stride = field.precision === \"single\" ? 4 : 8;\n if (stride === 4) {\n for (let i = 0; i < take; i++) {\n positions[(written + i) * 3 + axis] = view.getFloat32(start + i * stride, true);\n }\n } else {\n for (let i = 0; i < take; i++) {\n positions[(written + i) * 3 + axis] = view.getFloat64(start + i * stride, true);\n }\n }\n return;\n }\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const minimum = field.minimum ?? 0;\n const scale = field.scale ?? 1;\n const offset = field.offset ?? 0;\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n positions[(written + i) * 3 + axis] = (raw + minimum) * scale + offset;\n }\n }\n function readIntensityStream(bytes, view, field, start, intensities, written, take) {\n if (field.kind === \"Float\") {\n const stride = field.precision === \"single\" ? 4 : 8;\n for (let i = 0; i < take; i++) {\n const v = stride === 4 ? view.getFloat32(start + i * stride, true) : view.getFloat64(start + i * stride, true);\n intensities[written + i] = Math.min(65535, Math.max(0, Math.round(v * 65535)));\n }\n return;\n }\n if (field.kind === \"Integer\") {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 65535;\n const span2 = max - min;\n const inv2 = span2 > 0 ? 1 / span2 : 1;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const stride = widest > 255 ? 2 : 1;\n const signed = min < 0;\n for (let i = 0; i < take; i++) {\n const off = start + i * stride;\n const raw = stride === 2 ? signed ? view.getInt16(off, true) : view.getUint16(off, true) : signed ? view.getInt8(off) : view.getUint8(off);\n const norm = (raw - min) * inv2;\n intensities[written + i] = Math.min(65535, Math.max(0, Math.round(norm * 65535)));\n }\n return;\n }\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const minimum = field.minimum ?? 0;\n const maximum = field.maximum ?? minimum;\n const span = maximum - minimum;\n const inv = span > 0 ? 1 / span : 1;\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n intensities[written + i] = Math.min(65535, Math.max(0, Math.round(raw * inv * 65535)));\n }\n }\n function scaledIntegerBitsPerRecord(field) {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? min;\n const span = Math.max(0, max - min);\n if (span === 0)\n return 1;\n const bits = Math.ceil(Math.log2(span + 1));\n if (bits > 53) {\n throw new Error(`E57: ScaledInteger field \"${field.name}\" needs ${bits} bits \\u2014 exceeds the 53-bit Number-precision limit`);\n }\n return Math.max(1, bits);\n }\n function floatOrSiPointCapacity(field, lengthBytes) {\n if (field.kind === \"Float\") {\n const byteSize2 = field.precision === \"single\" ? 4 : 8;\n return Math.floor(lengthBytes / byteSize2);\n }\n if (field.kind === \"ScaledInteger\") {\n const bits = scaledIntegerBitsPerRecord(field);\n return Math.floor(lengthBytes * 8 / bits);\n }\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 255;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const byteSize = widest > 255 ? 2 : 1;\n return Math.floor(lengthBytes / byteSize);\n }\n function readBitsLE(bytes, bitOffset, bitsPerRecord) {\n let value = 0;\n let bitsRead = 0;\n let cur = bitOffset >>> 3;\n let inByte = bitOffset & 7;\n while (bitsRead < bitsPerRecord) {\n const avail = 8 - inByte;\n const take = Math.min(avail, bitsPerRecord - bitsRead);\n const mask = (1 << take) - 1;\n const piece = bytes[cur] >>> inByte & mask;\n value += piece * Math.pow(2, bitsRead);\n bitsRead += take;\n inByte = 0;\n cur++;\n }\n return value;\n }\n function finalize(positions, colors, intensities, classifications, pointCount) {\n return {\n positions: new Float32Array(positions),\n colors: colors ? new Float32Array(colors) : void 0,\n intensities: intensities ? new Uint16Array(intensities) : void 0,\n classifications: classifications ? new Uint8Array(classifications) : void 0,\n pointCount,\n bbox: computeBBox3(positions)\n };\n }\n function readClassificationStream(bytes, view, field, start, classifications, written, take) {\n if (field.kind === \"Integer\") {\n const min = field.minimum ?? 0;\n const max = field.maximum ?? 255;\n const widest = Math.max(Math.abs(min), Math.abs(max));\n const stride = widest > 255 ? 2 : 1;\n const signed = min < 0;\n for (let i = 0; i < take; i++) {\n const off = start + i * stride;\n const raw = stride === 2 ? signed ? view.getInt16(off, true) : view.getUint16(off, true) : signed ? view.getInt8(off) : view.getUint8(off);\n classifications[written + i] = Math.max(0, Math.min(255, raw));\n }\n return;\n }\n const bitsPerRecord = scaledIntegerBitsPerRecord(field);\n const minimum = field.minimum ?? 0;\n const startBit = start * 8;\n for (let i = 0; i < take; i++) {\n const raw = readBitsLE(bytes, startBit + i * bitsPerRecord, bitsPerRecord);\n classifications[written + i] = Math.max(0, Math.min(255, raw + minimum));\n }\n }\n function clamp012(v) {\n return v < 0 ? 0 : v > 1 ? 1 : v;\n }\n function computeBBox3(positions) {\n if (positions.length < 3) {\n return { min: [0, 0, 0], max: [0, 0, 0] };\n }\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n let any = false;\n for (let i = 0; i + 2 < positions.length; i += 3) {\n const x = positions[i], y = positions[i + 1], z = positions[i + 2];\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))\n continue;\n any = true;\n if (x < minX)\n minX = x;\n if (x > maxX)\n maxX = x;\n if (y < minY)\n minY = y;\n if (y > maxY)\n maxY = y;\n if (z < minZ)\n minZ = z;\n if (z > maxZ)\n maxZ = z;\n }\n if (!any)\n return { min: [0, 0, 0], max: [0, 0, 0] };\n return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };\n }\n var init_e57_decode = __esm({\n \"dist/formats/e57-decode.js\"() {\n \"use strict\";\n init_e57_xml();\n }\n });\n\n // dist/formats/e57.js\n function decodeE57(bytes) {\n const header = parseE57FileHeader(bytes);\n const logical = stripPageCrc(bytes, header.pageSize);\n const xmlBytes = logical.subarray(header.xmlLogicalOffset, header.xmlLogicalOffset + header.xmlLogicalLength);\n const xmlText = TEXT_DECODER3.decode(xmlBytes);\n const entries = parseE57Xml(xmlText);\n if (entries.length === 0)\n return null;\n const chunks = entries.map((entry) => {\n const dataLogicalOffset = resolveCompressedVectorDataOffset(logical, entry.binaryFileOffset, header.pageSize);\n const chunk = decodeE57Scan(logical, { ...entry, binaryFileOffset: dataLogicalOffset });\n if (entry.pose) {\n applyPoseInPlace(chunk.positions, chunk.pointCount, entry.pose);\n chunk.bbox = computeBBox3(chunk.positions);\n }\n return chunk;\n });\n if (chunks.length === 1)\n return chunks[0];\n let total = 0;\n for (const c of chunks)\n total += c.pointCount;\n const positions = new Float32Array(total * 3);\n const hasColors = chunks.some((c) => c.colors);\n const hasIntensity = chunks.some((c) => c.intensities);\n const hasClass = chunks.some((c) => c.classifications);\n const colors = hasColors ? new Float32Array(total * 3) : void 0;\n const intensities = hasIntensity ? new Uint16Array(total) : void 0;\n const classifications = hasClass ? new Uint8Array(total) : void 0;\n let off = 0;\n for (const c of chunks) {\n positions.set(c.positions, off * 3);\n if (colors && c.colors)\n colors.set(c.colors, off * 3);\n if (intensities && c.intensities)\n intensities.set(c.intensities, off);\n if (classifications && c.classifications)\n classifications.set(c.classifications, off);\n off += c.pointCount;\n }\n return {\n positions,\n colors,\n intensities,\n classifications,\n pointCount: total,\n bbox: computeBBox3(positions)\n };\n }\n function applyPoseInPlace(positions, pointCount, pose) {\n const { w, x, y, z } = pose.rotation;\n const tx = pose.translation.x;\n const ty = pose.translation.y;\n const tz = pose.translation.z;\n const r00 = 1 - 2 * (y * y + z * z);\n const r01 = 2 * (x * y - w * z);\n const r02 = 2 * (x * z + w * y);\n const r10 = 2 * (x * y + w * z);\n const r11 = 1 - 2 * (x * x + z * z);\n const r12 = 2 * (y * z - w * x);\n const r20 = 2 * (x * z - w * y);\n const r21 = 2 * (y * z + w * x);\n const r22 = 1 - 2 * (x * x + y * y);\n for (let i = 0; i < pointCount; i++) {\n const px = positions[i * 3];\n const py = positions[i * 3 + 1];\n const pz = positions[i * 3 + 2];\n positions[i * 3] = r00 * px + r01 * py + r02 * pz + tx;\n positions[i * 3 + 1] = r10 * px + r11 * py + r12 * pz + ty;\n positions[i * 3 + 2] = r20 * px + r21 * py + r22 * pz + tz;\n }\n }\n var TEXT_DECODER3;\n var init_e57 = __esm({\n \"dist/formats/e57.js\"() {\n \"use strict\";\n init_e57_page();\n init_e57_xml();\n init_e57_decode();\n init_e57_page();\n init_e57_xml();\n init_e57_decode();\n TEXT_DECODER3 = new TextDecoder();\n }\n });\n\n // dist/streaming/e57-source.js\n var e57_source_exports = {};\n __export(e57_source_exports, {\n E57StreamingSource: () => E57StreamingSource\n });\n function applyStride3(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n const classifications = chunk.classifications ? new Uint8Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (intensities && chunk.intensities) {\n intensities[dst] = chunk.intensities[i];\n }\n if (classifications && chunk.classifications) {\n classifications[dst] = chunk.classifications[i];\n }\n dst++;\n }\n return {\n positions,\n colors,\n intensities,\n classifications,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted5(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var E57StreamingSource;\n var init_e57_source = __esm({\n \"dist/streaming/e57-source.js\"() {\n \"use strict\";\n init_e57();\n E57StreamingSource = class {\n constructor(blob, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted5(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted5(signal);\n const decoded = decodeE57(new Uint8Array(buf));\n if (!decoded) {\n throw new Error(\"E57: file contains no Data3D scans\");\n }\n this.chunk = applyStride3(decoded, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: !!this.chunk.colors,\n hasClassification: !!this.chunk.classifications,\n hasIntensity: !!this.chunk.intensities,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted5(signal);\n if (!this.chunk || this.served)\n return null;\n void maxPoints;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/formats/ascii-points.js\n function probeAsciiPointsLayout(buffer, format) {\n const probeLen = Math.min(16384, buffer.length);\n const text = TEXT_DECODER4.decode(buffer.subarray(0, probeLen));\n const lines = text.split(/\\r?\\n/);\n let firstDataLine = null;\n let hasHeaderCount = false;\n for (let i = 0; i < lines.length; i++) {\n const trimmed = lines[i].trim();\n if (trimmed.length === 0)\n continue;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"//\"))\n continue;\n if (i === 0 || !hasHeaderCount) {\n const tokens2 = trimmed.split(/\\s+/);\n if (tokens2.length === 1 && /^\\d+$/.test(tokens2[0])) {\n hasHeaderCount = true;\n continue;\n }\n }\n firstDataLine = trimmed;\n break;\n }\n if (firstDataLine === null)\n return null;\n const tokens = firstDataLine.split(/\\s+/);\n const columns = tokens.length;\n for (const t of tokens) {\n if (!Number.isFinite(Number(t)))\n return null;\n }\n const fields = layoutFromColumnCount(columns, format);\n if (!fields)\n return null;\n return { columns, hasHeaderCount, fields };\n }\n function layoutFromColumnCount(columns, format) {\n switch (columns) {\n case 3:\n return [\"x\", \"y\", \"z\"];\n case 4:\n return [\"x\", \"y\", \"z\", \"i\"];\n case 6:\n return [\"x\", \"y\", \"z\", \"r\", \"g\", \"b\"];\n case 7:\n return [\"x\", \"y\", \"z\", \"i\", \"r\", \"g\", \"b\"];\n case 9:\n return [\"x\", \"y\", \"z\", \"r\", \"g\", \"b\", \"skip\", \"skip\", \"skip\"];\n case 10:\n return [\"x\", \"y\", \"z\", \"i\", \"r\", \"g\", \"b\", \"skip\", \"skip\", \"skip\"];\n default:\n if (columns >= 3 && format === \"xyz\") {\n const fields = [\"x\", \"y\", \"z\"];\n for (let i = 3; i < columns; i++)\n fields.push(\"skip\");\n return fields;\n }\n return null;\n }\n }\n function decodeAsciiPoints(bytes, format) {\n const layout = probeAsciiPointsLayout(bytes, format);\n if (!layout) {\n throw new Error(`${format.toUpperCase()}: file does not look like ASCII point data`);\n }\n const text = TEXT_DECODER4.decode(bytes);\n return decodeAsciiPointsFromText(text, layout);\n }\n function decodeAsciiPointsFromText(text, layout) {\n const lines = text.split(/\\r?\\n/);\n let dataLineCount = 0;\n let headerSkipped = !layout.hasHeaderCount;\n for (const raw of lines) {\n const trimmed = raw.trim();\n if (trimmed.length === 0)\n continue;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"//\"))\n continue;\n if (!headerSkipped) {\n headerSkipped = true;\n continue;\n }\n dataLineCount++;\n }\n const xIdx = layout.fields.indexOf(\"x\");\n const yIdx = layout.fields.indexOf(\"y\");\n const zIdx = layout.fields.indexOf(\"z\");\n const iIdx = layout.fields.indexOf(\"i\");\n const rIdx = layout.fields.indexOf(\"r\");\n const gIdx = layout.fields.indexOf(\"g\");\n const bIdx = layout.fields.indexOf(\"b\");\n const hasIntensity = iIdx >= 0;\n const hasColor = rIdx >= 0 && gIdx >= 0 && bIdx >= 0;\n const positions = new Float32Array(dataLineCount * 3);\n const intensitiesRaw = hasIntensity ? new Float32Array(dataLineCount) : null;\n const colorsRaw = hasColor ? new Float32Array(dataLineCount * 3) : null;\n let written = 0;\n let intensityMax = 0;\n let colorMax = 0;\n let bboxMinX = Infinity, bboxMinY = Infinity, bboxMinZ = Infinity;\n let bboxMaxX = -Infinity, bboxMaxY = -Infinity, bboxMaxZ = -Infinity;\n headerSkipped = !layout.hasHeaderCount;\n for (const raw of lines) {\n const trimmed = raw.trim();\n if (trimmed.length === 0)\n continue;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"//\"))\n continue;\n if (!headerSkipped) {\n headerSkipped = true;\n continue;\n }\n const tokens = trimmed.split(/\\s+/);\n if (tokens.length < layout.columns)\n continue;\n const x = Number(tokens[xIdx]);\n const y = Number(tokens[yIdx]);\n const z = Number(tokens[zIdx]);\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))\n continue;\n positions[written * 3] = x;\n positions[written * 3 + 1] = y;\n positions[written * 3 + 2] = z;\n if (x < bboxMinX)\n bboxMinX = x;\n if (x > bboxMaxX)\n bboxMaxX = x;\n if (y < bboxMinY)\n bboxMinY = y;\n if (y > bboxMaxY)\n bboxMaxY = y;\n if (z < bboxMinZ)\n bboxMinZ = z;\n if (z > bboxMaxZ)\n bboxMaxZ = z;\n if (intensitiesRaw) {\n const v = Number(tokens[iIdx]);\n const f = Number.isFinite(v) ? v : 0;\n intensitiesRaw[written] = f;\n if (f > intensityMax)\n intensityMax = f;\n }\n if (colorsRaw) {\n const r = Number(tokens[rIdx]);\n const g = Number(tokens[gIdx]);\n const b = Number(tokens[bIdx]);\n const rf = Number.isFinite(r) ? r : 0;\n const gf = Number.isFinite(g) ? g : 0;\n const bf = Number.isFinite(b) ? b : 0;\n colorsRaw[written * 3] = rf;\n colorsRaw[written * 3 + 1] = gf;\n colorsRaw[written * 3 + 2] = bf;\n const m = Math.max(rf, gf, bf);\n if (m > colorMax)\n colorMax = m;\n }\n written++;\n }\n const trimmedPositions = written === dataLineCount ? positions : positions.subarray(0, written * 3);\n let intensities;\n if (intensitiesRaw) {\n intensities = new Uint16Array(written);\n const scale = intensityMax > 1 ? intensityMax > 255 ? 65535 / intensityMax : 65535 / 255 : 65535;\n for (let i = 0; i < written; i++) {\n const v = intensitiesRaw[i] * scale;\n intensities[i] = v < 0 ? 0 : v > 65535 ? 65535 : Math.round(v);\n }\n }\n let colors;\n if (colorsRaw) {\n colors = new Float32Array(written * 3);\n const scale = colorMax > 1 ? 1 / 255 : 1;\n for (let i = 0; i < written * 3; i++) {\n const v = colorsRaw[i] * scale;\n colors[i] = v < 0 ? 0 : v > 1 ? 1 : v;\n }\n }\n const bbox = written === 0 ? { min: [0, 0, 0], max: [0, 0, 0] } : { min: [bboxMinX, bboxMinY, bboxMinZ], max: [bboxMaxX, bboxMaxY, bboxMaxZ] };\n return {\n positions: written === dataLineCount ? positions : new Float32Array(trimmedPositions),\n colors,\n intensities,\n pointCount: written,\n bbox\n };\n }\n var TEXT_DECODER4;\n var init_ascii_points = __esm({\n \"dist/formats/ascii-points.js\"() {\n \"use strict\";\n TEXT_DECODER4 = new TextDecoder();\n }\n });\n\n // dist/streaming/ascii-points-source.js\n var ascii_points_source_exports = {};\n __export(ascii_points_source_exports, {\n AsciiPointsStreamingSource: () => AsciiPointsStreamingSource\n });\n function applyStride4(chunk, stride) {\n const s = Math.max(1, stride | 0);\n if (s === 1)\n return chunk;\n const newCount = Math.ceil(chunk.pointCount / s);\n const positions = new Float32Array(newCount * 3);\n const colors = chunk.colors ? new Float32Array(newCount * 3) : void 0;\n const intensities = chunk.intensities ? new Uint16Array(newCount) : void 0;\n let dst = 0;\n for (let i = 0; i < chunk.pointCount; i += s) {\n positions[dst * 3] = chunk.positions[i * 3];\n positions[dst * 3 + 1] = chunk.positions[i * 3 + 1];\n positions[dst * 3 + 2] = chunk.positions[i * 3 + 2];\n if (colors && chunk.colors) {\n colors[dst * 3] = chunk.colors[i * 3];\n colors[dst * 3 + 1] = chunk.colors[i * 3 + 1];\n colors[dst * 3 + 2] = chunk.colors[i * 3 + 2];\n }\n if (intensities && chunk.intensities) {\n intensities[dst] = chunk.intensities[i];\n }\n dst++;\n }\n return {\n positions,\n colors,\n intensities,\n pointCount: newCount,\n bbox: chunk.bbox\n };\n }\n function abortIfAborted6(signal) {\n if (signal?.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n }\n var AsciiPointsStreamingSource;\n var init_ascii_points_source = __esm({\n \"dist/streaming/ascii-points-source.js\"() {\n \"use strict\";\n init_ascii_points();\n AsciiPointsStreamingSource = class {\n constructor(blob, format, options = {}) {\n __publicField(this, \"blob\");\n __publicField(this, \"format\");\n __publicField(this, \"downsample\");\n __publicField(this, \"label\");\n __publicField(this, \"chunk\", null);\n __publicField(this, \"served\", false);\n this.blob = blob;\n this.format = format;\n this.downsample = options.downsample ?? { stride: 1 };\n this.label = options.label;\n }\n async open(signal) {\n abortIfAborted6(signal);\n const buf = await this.blob.arrayBuffer();\n abortIfAborted6(signal);\n const bytes = new Uint8Array(buf);\n const fullChunk = decodeAsciiPoints(bytes, this.format);\n this.chunk = applyStride4(fullChunk, this.downsample.stride);\n return {\n totalPointCount: this.chunk.pointCount,\n bbox: this.chunk.bbox,\n hasColor: !!this.chunk.colors,\n hasClassification: false,\n hasIntensity: !!this.chunk.intensities,\n label: this.label\n };\n }\n async next(maxPoints, signal) {\n abortIfAborted6(signal);\n if (!this.chunk || this.served)\n return null;\n void maxPoints;\n this.served = true;\n return this.chunk;\n }\n close() {\n this.chunk = null;\n this.served = false;\n }\n };\n }\n });\n\n // dist/streaming/protocol.js\n function chunkToWire(chunk) {\n const positions = chunk.positions.buffer;\n const transfer = [positions];\n const payload = {\n positions,\n pointCount: chunk.pointCount,\n bbox: chunk.bbox\n };\n if (chunk.colors) {\n const buf = chunk.colors.buffer;\n payload.colors = buf;\n transfer.push(buf);\n }\n if (chunk.classifications) {\n const buf = chunk.classifications.buffer;\n payload.classifications = buf;\n transfer.push(buf);\n }\n if (chunk.intensities) {\n const buf = chunk.intensities.buffer;\n payload.intensities = buf;\n transfer.push(buf);\n }\n return { payload, transfer };\n }\n function chunkFromWire(payload) {\n return {\n positions: new Float32Array(payload.positions),\n colors: payload.colors ? new Float32Array(payload.colors) : void 0,\n classifications: payload.classifications ? new Uint8Array(payload.classifications) : void 0,\n intensities: payload.intensities ? new Uint16Array(payload.intensities) : void 0,\n pointCount: payload.pointCount,\n bbox: payload.bbox\n };\n }\n\n // dist/streaming/decode-worker.js\n var sources = /* @__PURE__ */ new Map();\n var nextSourceId = 1;\n self.onmessage = (event) => {\n const msg = event.data;\n switch (msg.kind) {\n case \"open\":\n void handleOpen(msg);\n return;\n case \"next\":\n void handleNext(msg);\n return;\n case \"close\":\n handleClose(msg.sourceId);\n return;\n case \"abort\":\n handleAbort(msg.sourceId);\n return;\n }\n };\n async function handleOpen(msg) {\n try {\n const source = await createSource(msg.format, msg.blob, {\n label: msg.label,\n downsample: { stride: Math.max(1, msg.stride | 0) }\n });\n const abort = new AbortController();\n const info = await source.open(abort.signal);\n const sourceId = nextSourceId++;\n sources.set(sourceId, { source, abort });\n post({\n kind: \"opened\",\n requestId: msg.requestId,\n sourceId,\n info\n });\n } catch (err) {\n post({\n kind: \"error\",\n requestId: msg.requestId,\n message: errMessage(err)\n });\n }\n }\n async function handleNext(msg) {\n const open = sources.get(msg.sourceId);\n if (!open) {\n post({\n kind: \"error\",\n requestId: msg.requestId,\n message: `Unknown sourceId ${msg.sourceId}`\n });\n return;\n }\n try {\n const chunk = await open.source.next(msg.maxPoints, open.abort.signal);\n if (!chunk) {\n post({\n kind: \"chunk\",\n requestId: msg.requestId,\n sourceId: msg.sourceId,\n chunk: null\n });\n return;\n }\n const { payload, transfer } = chunkToWire(chunk);\n post({\n kind: \"chunk\",\n requestId: msg.requestId,\n sourceId: msg.sourceId,\n chunk: payload\n }, transfer);\n } catch (err) {\n post({\n kind: \"error\",\n requestId: msg.requestId,\n message: errMessage(err)\n });\n }\n }\n function handleClose(sourceId) {\n const open = sources.get(sourceId);\n if (!open)\n return;\n try {\n open.abort.abort();\n open.source.close();\n } catch (err) {\n console.warn(\"[decode-worker] close failed:\", errMessage(err));\n }\n sources.delete(sourceId);\n }\n function handleAbort(sourceId) {\n const open = sources.get(sourceId);\n if (!open)\n return;\n open.abort.abort();\n }\n async function createSource(format, blob, opts) {\n switch (format) {\n case \"las\": {\n const { LasStreamingSource: LasStreamingSource2 } = await Promise.resolve().then(() => (init_las_source(), las_source_exports));\n return new LasStreamingSource2(blob, opts);\n }\n case \"laz\": {\n const { LazStreamingSource: LazStreamingSource2 } = await Promise.resolve().then(() => (init_laz_source(), laz_source_exports));\n return new LazStreamingSource2(blob, opts);\n }\n case \"ply\": {\n const { PlyStreamingSource: PlyStreamingSource2 } = await Promise.resolve().then(() => (init_ply_source(), ply_source_exports));\n return new PlyStreamingSource2(blob, opts);\n }\n case \"pcd\": {\n const { PcdStreamingSource: PcdStreamingSource2 } = await Promise.resolve().then(() => (init_pcd_source(), pcd_source_exports));\n return new PcdStreamingSource2(blob, opts);\n }\n case \"e57\": {\n const { E57StreamingSource: E57StreamingSource2 } = await Promise.resolve().then(() => (init_e57_source(), e57_source_exports));\n return new E57StreamingSource2(blob, opts);\n }\n case \"pts\": {\n const { AsciiPointsStreamingSource: AsciiPointsStreamingSource2 } = await Promise.resolve().then(() => (init_ascii_points_source(), ascii_points_source_exports));\n return new AsciiPointsStreamingSource2(blob, \"pts\", opts);\n }\n case \"xyz\": {\n const { AsciiPointsStreamingSource: AsciiPointsStreamingSource2 } = await Promise.resolve().then(() => (init_ascii_points_source(), ascii_points_source_exports));\n return new AsciiPointsStreamingSource2(blob, \"xyz\", opts);\n }\n default:\n throw new Error(`decode-worker: unknown format \"${format}\"`);\n }\n }\n function post(msg, transfer = []) {\n self.postMessage(msg, transfer);\n }\n function errMessage(err) {\n if (err instanceof Error)\n return err.message;\n return String(err);\n }\n})();\n";
|