From 3d403f0c2ce7941c1741211b34ea3a67944ad1b6 Mon Sep 17 00:00:00 2001 From: David Altenburg Date: Wed, 13 Nov 2024 20:03:01 -0800 Subject: [PATCH 1/3] Add an endType parameter to CrossSection::Offset --- bindings/c/conv.cpp | 21 +++ bindings/c/cross.cpp | 6 +- bindings/c/include/manifold/types.h | 8 + bindings/wasm/bindings.js | 229 ++++++++++++++-------------- bindings/wasm/helpers.cpp | 9 +- bindings/wasm/manifold.js | 14 +- bindings/wasm/manifold.wasm | Bin 766642 -> 766695 bytes include/manifold/cross_section.h | 6 +- src/cross_section/cross_section.cpp | 28 +++- test/cross_section_test.cpp | 3 +- 10 files changed, 194 insertions(+), 130 deletions(-) diff --git a/bindings/c/conv.cpp b/bindings/c/conv.cpp index 78115ff3cd..2b9a9784a1 100644 --- a/bindings/c/conv.cpp +++ b/bindings/c/conv.cpp @@ -200,6 +200,27 @@ CrossSection::JoinType from_c(ManifoldJoinType join_type) { return jt; } +CrossSection::EndType from_c(ManifoldEndType end_type) { + auto et = CrossSection::EndType::Polygon; + switch (end_type) { + case MANIFOLD_END_TYPE_POLYGON: + break; + case MANIFOLD_END_TYPE_JOINED: + et = CrossSection::EndType::Joined; + break; + case MANIFOLD_END_TYPE_BUTT: + et = CrossSection::EndType::Butt; + break; + case MANIFOLD_END_TYPE_SQUARE: + et = CrossSection::EndType::Square; + break; + case MANIFOLD_END_TYPE_ROUND: + et = CrossSection::EndType::Round; + break; + }; + return et; +} + const manifold::Box *from_c(ManifoldBox *m) { return reinterpret_cast(m); } diff --git a/bindings/c/cross.cpp b/bindings/c/cross.cpp index d05e07e46a..6b0068ea3b 100644 --- a/bindings/c/cross.cpp +++ b/bindings/c/cross.cpp @@ -203,9 +203,9 @@ ManifoldCrossSection *manifold_cross_section_simplify(void *mem, ManifoldCrossSection *manifold_cross_section_offset( void *mem, ManifoldCrossSection *cs, double delta, ManifoldJoinType jt, - double miter_limit, int circular_segments) { - auto offset = - from_c(cs)->Offset(delta, from_c(jt), miter_limit, circular_segments); + ManifoldEndType et, double miter_limit, int circular_segments) { + auto offset = from_c(cs)->Offset(delta, from_c(jt), from_c(et), miter_limit, + circular_segments); return to_c(new (mem) CrossSection(offset)); } diff --git a/bindings/c/include/manifold/types.h b/bindings/c/include/manifold/types.h index 1aa9ae2fdd..ea031c8f6d 100644 --- a/bindings/c/include/manifold/types.h +++ b/bindings/c/include/manifold/types.h @@ -103,3 +103,11 @@ typedef enum ManifoldJoinType { MANIFOLD_JOIN_TYPE_ROUND, MANIFOLD_JOIN_TYPE_MITER, } ManifoldJoinType; + +typedef enum ManifoldEndType { + MANIFOLD_END_TYPE_POLYGON, + MANIFOLD_END_TYPE_JOINED, + MANIFOLD_END_TYPE_BUTT, + MANIFOLD_END_TYPE_SQUARE, + MANIFOLD_END_TYPE_ROUND, +} ManifoldEndType; diff --git a/bindings/wasm/bindings.js b/bindings/wasm/bindings.js index 479b15d40b..845cd30158 100644 --- a/bindings/wasm/bindings.js +++ b/bindings/wasm/bindings.js @@ -13,7 +13,7 @@ // limitations under the License. var _ManifoldInitialized = false; -Module.setup = function() { +Module.setup = function () { if (_ManifoldInitialized) return; _ManifoldInitialized = true; @@ -55,11 +55,11 @@ Module.setup = function() { polygons = [polygons]; } return toVec( - new Module.Vector2_vec2(), polygons, - poly => toVec(new Module.Vector_vec2(), poly, p => { - if (p instanceof Array) return {x: p[0], y: p[1]}; - return p; - })); + new Module.Vector2_vec2(), polygons, + poly => toVec(new Module.Vector_vec2(), poly, p => { + if (p instanceof Array) return { x: p[0], y: p[1] }; + return p; + })); } function disposePolygons(polygonsVec) { @@ -68,26 +68,26 @@ Module.setup = function() { } function vararg2vec2(vec) { - if (vec[0] instanceof Array) return {x: vec[0][0], y: vec[0][1]}; + if (vec[0] instanceof Array) return { x: vec[0][0], y: vec[0][1] }; if (typeof (vec[0]) == 'number') // default to 0 - return {x: vec[0] || 0, y: vec[1] || 0}; + return { x: vec[0] || 0, y: vec[1] || 0 }; return vec[0]; } function vararg2vec3(vec) { if (vec[0] instanceof Array) - return {x: vec[0][0], y: vec[0][1], z: vec[0][2]}; + return { x: vec[0][0], y: vec[0][1], z: vec[0][2] }; if (typeof (vec[0]) == 'number') // default to 0 - return {x: vec[0] || 0, y: vec[1] || 0, z: vec[2] || 0}; + return { x: vec[0] || 0, y: vec[1] || 0, z: vec[2] || 0 }; return vec[0]; } function fillRuleToInt(fillRule) { return fillRule == 'EvenOdd' ? 0 : - fillRule == 'NonZero' ? 1 : - fillRule == 'Negative' ? 3 : + fillRule == 'NonZero' ? 1 : + fillRule == 'Negative' ? 3 : /* Positive */ 2; } @@ -95,6 +95,11 @@ Module.setup = function() { return joinType == 'Round' ? 1 : joinType == 'Miter' ? 2 : /* Square */ 0; } + function endTypeToInt(endType) { + return endType == 'Polygon' ? 0 : endType == 'Joined' ? 1 : + endType == 'Butt' ? 2 : endType == 'Square' ? 3 : /* Round */ 4; + } + // CrossSection methods const CrossSectionCtor = Module.CrossSection; @@ -110,24 +115,24 @@ Module.setup = function() { } }; - Module.CrossSection.prototype.translate = function(...vec) { + Module.CrossSection.prototype.translate = function (...vec) { return this._Translate(vararg2vec2(vec)); }; - Module.CrossSection.prototype.scale = function(vec) { + Module.CrossSection.prototype.scale = function (vec) { // if only one factor provided, scale both x and y with it if (typeof vec == 'number') { - return this._Scale({x: vec, y: vec}); + return this._Scale({ x: vec, y: vec }); } return this._Scale(vararg2vec2([vec])); }; - Module.CrossSection.prototype.mirror = function(vec) { + Module.CrossSection.prototype.mirror = function (vec) { return this._Mirror(vararg2vec2([vec])); }; - Module.CrossSection.prototype.warp = function(func) { - const wasmFuncPtr = addFunction(function(vec2Ptr) { + Module.CrossSection.prototype.warp = function (func) { + const wasmFuncPtr = addFunction(function (vec2Ptr) { const x = getValue(vec2Ptr, 'double'); const y = getValue(vec2Ptr + 8, 'double'); const vert = [x, y]; @@ -140,14 +145,14 @@ Module.setup = function() { return out; }; - Module.CrossSection.prototype.decompose = function() { + Module.CrossSection.prototype.decompose = function () { const vec = this._Decompose(); const result = fromVec(vec); vec.delete(); return result; }; - Module.CrossSection.prototype.bounds = function() { + Module.CrossSection.prototype.bounds = function () { const result = this._Bounds(); return { min: ['x', 'y'].map(f => result.min[f]), @@ -155,40 +160,42 @@ Module.setup = function() { }; }; - Module.CrossSection.prototype.offset = function( - delta, joinType = 'Square', miterLimit = 2.0, circularSegments = 0) { + Module.CrossSection.prototype.offset = function ( + delta, joinType = 'Square', endType = 'Polygon', miterLimit = 2.0, + circularSegments = 0) { return this._Offset( - delta, joinTypeToInt(joinType), miterLimit, circularSegments); + delta, joinTypeToInt(joinType), endTypeToInt(endType), miterLimit, + circularSegments); }; - Module.CrossSection.prototype.extrude = function( - height, nDivisions = 0, twistDegrees = 0.0, scaleTop = [1.0, 1.0], - center = false) { + Module.CrossSection.prototype.extrude = function ( + height, nDivisions = 0, twistDegrees = 0.0, scaleTop = [1.0, 1.0], + center = false) { scaleTop = vararg2vec2([scaleTop]); const man = Module._Extrude( - this._ToPolygons(), height, nDivisions, twistDegrees, scaleTop); + this._ToPolygons(), height, nDivisions, twistDegrees, scaleTop); return (center ? man.translate([0., 0., -height / 2.]) : man); }; - Module.CrossSection.prototype.revolve = function( - circularSegments = 0, revolveDegrees = 360.0) { + Module.CrossSection.prototype.revolve = function ( + circularSegments = 0, revolveDegrees = 360.0) { return Module._Revolve( - this._ToPolygons(), circularSegments, revolveDegrees); + this._ToPolygons(), circularSegments, revolveDegrees); }; - Module.CrossSection.prototype.add = function(other) { + Module.CrossSection.prototype.add = function (other) { return this._add(cross(other)); }; - Module.CrossSection.prototype.subtract = function(other) { + Module.CrossSection.prototype.subtract = function (other) { return this._subtract(cross(other)); }; - Module.CrossSection.prototype.intersect = function(other) { + Module.CrossSection.prototype.intersect = function (other) { return this._intersect(cross(other)); }; - Module.CrossSection.prototype.toPolygons = function() { + Module.CrossSection.prototype.toPolygons = function () { const vec = this._ToPolygons(); const result = vec2polygons(vec, v => [v.x, v.y]); vec.delete(); @@ -197,13 +204,13 @@ Module.setup = function() { // Manifold methods - Module.Manifold.prototype.smoothOut = function( - minSharpAngle = 60, minSmoothness = 0) { + Module.Manifold.prototype.smoothOut = function ( + minSharpAngle = 60, minSmoothness = 0) { return this._SmoothOut(minSharpAngle, minSmoothness); }; - Module.Manifold.prototype.warp = function(func) { - const wasmFuncPtr = addFunction(function(vec3Ptr) { + Module.Manifold.prototype.warp = function (func) { + const wasmFuncPtr = addFunction(function (vec3Ptr) { const x = getValue(vec3Ptr, 'double'); const y = getValue(vec3Ptr + 8, 'double'); const z = getValue(vec3Ptr + 16, 'double'); @@ -223,14 +230,14 @@ Module.setup = function() { return out; }; - Module.Manifold.prototype.calculateNormals = function( - normalIdx, minSharpAngle = 60) { + Module.Manifold.prototype.calculateNormals = function ( + normalIdx, minSharpAngle = 60) { return this._CalculateNormals(normalIdx, minSharpAngle); }; - Module.Manifold.prototype.setProperties = function(numProp, func) { + Module.Manifold.prototype.setProperties = function (numProp, func) { const oldNumProp = this.numProp(); - const wasmFuncPtr = addFunction(function(newPtr, vec3Ptr, oldPtr) { + const wasmFuncPtr = addFunction(function (newPtr, vec3Ptr, oldPtr) { const newProp = []; for (let i = 0; i < numProp; ++i) { newProp[i] = getValue(newPtr + 8 * i, 'double'); @@ -255,11 +262,11 @@ Module.setup = function() { return out; }; - Module.Manifold.prototype.translate = function(...vec) { + Module.Manifold.prototype.translate = function (...vec) { return this._Translate(vararg2vec3(vec)); }; - Module.Manifold.prototype.rotate = function(xOrVec, y, z) { + Module.Manifold.prototype.rotate = function (xOrVec, y, z) { if (Array.isArray(xOrVec)) { return this._Rotate(...xOrVec); } else { @@ -267,58 +274,58 @@ Module.setup = function() { } }; - Module.Manifold.prototype.scale = function(vec) { + Module.Manifold.prototype.scale = function (vec) { // if only one factor provided, scale all three dimensions (xyz) with it if (typeof vec == 'number') { - return this._Scale({x: vec, y: vec, z: vec}); + return this._Scale({ x: vec, y: vec, z: vec }); } return this._Scale(vararg2vec3([vec])); }; - Module.Manifold.prototype.mirror = function(vec) { + Module.Manifold.prototype.mirror = function (vec) { return this._Mirror(vararg2vec3([vec])); }; - Module.Manifold.prototype.trimByPlane = function(normal, offset = 0.) { + Module.Manifold.prototype.trimByPlane = function (normal, offset = 0.) { return this._TrimByPlane(vararg2vec3([normal]), offset); }; - Module.Manifold.prototype.slice = function(height = 0.) { + Module.Manifold.prototype.slice = function (height = 0.) { const polygonsVec = this._Slice(height); const result = new CrossSectionCtor(polygonsVec, fillRuleToInt('Positive')); disposePolygons(polygonsVec); return result; }; - Module.Manifold.prototype.project = function() { + Module.Manifold.prototype.project = function () { const polygonsVec = this._Project(); const result = new CrossSectionCtor(polygonsVec, fillRuleToInt('Positive')); disposePolygons(polygonsVec); return result.simplify(this.tolerance); }; - Module.Manifold.prototype.split = function(manifold) { + Module.Manifold.prototype.split = function (manifold) { const vec = this._Split(manifold); const result = fromVec(vec); vec.delete(); return result; }; - Module.Manifold.prototype.splitByPlane = function(normal, offset = 0.) { + Module.Manifold.prototype.splitByPlane = function (normal, offset = 0.) { const vec = this._SplitByPlane(vararg2vec3([normal]), offset); const result = fromVec(vec); vec.delete(); return result; }; - Module.Manifold.prototype.decompose = function() { + Module.Manifold.prototype.decompose = function () { const vec = this._Decompose(); const result = fromVec(vec); vec.delete(); return result; }; - Module.Manifold.prototype.boundingBox = function() { + Module.Manifold.prototype.boundingBox = function () { const result = this._boundingBox(); return { min: ['x', 'y', 'z'].map(f => result.min[f]), @@ -364,8 +371,8 @@ Module.setup = function() { } merge() { - const {changed, mesh} = Module._Merge(this); - Object.assign(this, {...mesh}); + const { changed, mesh } = Module._Merge(this); + Object.assign(this, { ...mesh }); return changed; } @@ -375,12 +382,12 @@ Module.setup = function() { position(vert) { return this.vertProperties.subarray( - this.numProp * vert, this.numProp * vert + 3); + this.numProp * vert, this.numProp * vert + 3); } extras(vert) { return this.vertProperties.subarray( - this.numProp * vert + 3, this.numProp * (vert + 1)); + this.numProp * vert + 3, this.numProp * (vert + 1)); } tangent(halfedge) { @@ -401,9 +408,9 @@ Module.setup = function() { Module.Mesh = Mesh; - Module.Manifold.prototype.getMesh = function(normalIdx = [0, 0, 0]) { + Module.Manifold.prototype.getMesh = function (normalIdx = [0, 0, 0]) { if (normalIdx instanceof Array) - normalIdx = {0: normalIdx[0], 1: normalIdx[1], 2: normalIdx[2]}; + normalIdx = { 0: normalIdx[0], 1: normalIdx[1], 2: normalIdx[2] }; return new Mesh(this._GetMeshJS(normalIdx)); }; @@ -452,42 +459,42 @@ Module.setup = function() { Module.ManifoldError.prototype = Object.create(Error.prototype, { constructor: - {value: Module.ManifoldError, writable: true, configurable: true} + { value: Module.ManifoldError, writable: true, configurable: true } }); // CrossSection Constructors - Module.CrossSection = function(polygons, fillRule = 'Positive') { + Module.CrossSection = function (polygons, fillRule = 'Positive') { const polygonsVec = polygons2vec(polygons); const cs = new CrossSectionCtor(polygonsVec, fillRuleToInt(fillRule)); disposePolygons(polygonsVec); return cs; }; - Module.CrossSection.ofPolygons = function(polygons, fillRule = 'Positive') { + Module.CrossSection.ofPolygons = function (polygons, fillRule = 'Positive') { return new Module.CrossSection(polygons, fillRule); }; - Module.CrossSection.square = function(...args) { + Module.CrossSection.square = function (...args) { let size = undefined; if (args.length == 0) - size = {x: 1, y: 1}; + size = { x: 1, y: 1 }; else if (typeof args[0] == 'number') - size = {x: args[0], y: args[0]}; + size = { x: args[0], y: args[0] }; else size = vararg2vec2(args); const center = args[1] || false; return Module._Square(size, center); }; - Module.CrossSection.circle = function(radius, circularSegments = 0) { + Module.CrossSection.circle = function (radius, circularSegments = 0) { return Module._Circle(radius, circularSegments); }; // allows args to be either CrossSection or polygons (constructed with // Positive fill) function crossSectionBatchbool(name) { - return function(...args) { + return function (...args) { if (args.length == 1) args = args[0]; const v = new Module.Vector_crossSection(); for (const cs of args) v.push_back(cross(cs)); @@ -504,25 +511,25 @@ Module.setup = function() { function pushVec2(vec, ps) { toVec(vec, ps, p => { - if (p instanceof Array) return {x: p[0], y: p[1]}; + if (p instanceof Array) return { x: p[0], y: p[1] }; return p; - }) + }); } - Module.CrossSection.hull = function(...args) { + Module.CrossSection.hull = function (...args) { if (args.length == 1) args = args[0]; let pts = new Module.Vector_vec2(); for (const cs of args) { if (cs instanceof CrossSectionCtor) { Module._crossSectionCollectVertices(pts, cs); } else if ( - cs instanceof Array && cs.length == 2 && typeof cs[0] == 'number') { - pts.push_back({x: cs[0], y: cs[1]}); + cs instanceof Array && cs.length == 2 && typeof cs[0] == 'number') { + pts.push_back({ x: cs[0], y: cs[1] }); } else if (cs.x) { pts.push_back(cs); } else { const wrap = - ((cs[0].length == 2 && typeof cs[0][0] == 'number') || cs[0].x); + ((cs[0].length == 2 && typeof cs[0][0] == 'number') || cs[0].x); const polys = wrap ? [cs] : cs; for (const poly of polys) pushVec2(pts, poly); } @@ -545,7 +552,7 @@ Module.setup = function() { // Manifold Constructors const ManifoldCtor = Module.Manifold; - Module.Manifold = function(mesh) { + Module.Manifold = function (mesh) { const manifold = new ManifoldCtor(mesh); const status = manifold.status(); @@ -556,38 +563,38 @@ Module.setup = function() { return manifold; }; - Module.Manifold.ofMesh = function(mesh) { + Module.Manifold.ofMesh = function (mesh) { return new Module.Manifold(mesh); }; - Module.Manifold.tetrahedron = function() { + Module.Manifold.tetrahedron = function () { return Module._Tetrahedron(); }; - Module.Manifold.cube = function(...args) { + Module.Manifold.cube = function (...args) { let size = undefined; if (args.length == 0) - size = {x: 1, y: 1, z: 1}; + size = { x: 1, y: 1, z: 1 }; else if (typeof args[0] == 'number') - size = {x: args[0], y: args[0], z: args[0]}; + size = { x: args[0], y: args[0], z: args[0] }; else size = vararg2vec3(args); const center = args[1] || false; return Module._Cube(size, center); }; - Module.Manifold.cylinder = function( - height, radiusLow, radiusHigh = -1.0, circularSegments = 0, - center = false) { + Module.Manifold.cylinder = function ( + height, radiusLow, radiusHigh = -1.0, circularSegments = 0, + center = false) { return Module._Cylinder( - height, radiusLow, radiusHigh, circularSegments, center); + height, radiusLow, radiusHigh, circularSegments, center); }; - Module.Manifold.sphere = function(radius, circularSegments = 0) { + Module.Manifold.sphere = function (radius, circularSegments = 0) { return Module._Sphere(radius, circularSegments); }; - Module.Manifold.smooth = function(mesh, sharpenedEdges = []) { + Module.Manifold.smooth = function (mesh, sharpenedEdges = []) { const sharp = new Module.Vector_smoothness(); toVec(sharp, sharpenedEdges); const result = Module._Smooth(mesh, sharp); @@ -595,28 +602,28 @@ Module.setup = function() { return result; }; - Module.Manifold.extrude = function( - polygons, height, nDivisions = 0, twistDegrees = 0.0, - scaleTop = [1.0, 1.0], center = false) { + Module.Manifold.extrude = function ( + polygons, height, nDivisions = 0, twistDegrees = 0.0, + scaleTop = [1.0, 1.0], center = false) { const cs = (polygons instanceof CrossSectionCtor) ? - polygons : - Module.CrossSection(polygons, 'Positive'); + polygons : + Module.CrossSection(polygons, 'Positive'); return cs.extrude(height, nDivisions, twistDegrees, scaleTop, center); }; - Module.Manifold.revolve = function( - polygons, circularSegments = 0, revolveDegrees = 360.0) { + Module.Manifold.revolve = function ( + polygons, circularSegments = 0, revolveDegrees = 360.0) { const cs = (polygons instanceof CrossSectionCtor) ? - polygons : - Module.CrossSection(polygons, 'Positive'); + polygons : + Module.CrossSection(polygons, 'Positive'); return cs.revolve(circularSegments, revolveDegrees); }; - Module.Manifold.reserveIDs = function(n) { + Module.Manifold.reserveIDs = function (n) { return Module._ReserveIDs(n); }; - Module.Manifold.compose = function(manifolds) { + Module.Manifold.compose = function (manifolds) { const vec = new Module.Vector_manifold(); toVec(vec, manifolds); const result = Module._manifoldCompose(vec); @@ -625,7 +632,7 @@ Module.setup = function() { }; function manifoldBatchbool(name) { - return function(...args) { + return function (...args) { if (args.length == 1) args = args[0]; const v = new Module.Vector_manifold(); for (const m of args) v.push_back(m); @@ -639,13 +646,13 @@ Module.setup = function() { Module.Manifold.difference = manifoldBatchbool('Difference'); Module.Manifold.intersection = manifoldBatchbool('Intersection'); - Module.Manifold.levelSet = function( - sdf, bounds, edgeLength, level = 0, tolerance = -1) { + Module.Manifold.levelSet = function ( + sdf, bounds, edgeLength, level = 0, tolerance = -1) { const bounds2 = { - min: {x: bounds.min[0], y: bounds.min[1], z: bounds.min[2]}, - max: {x: bounds.max[0], y: bounds.max[1], z: bounds.max[2]}, + min: { x: bounds.min[0], y: bounds.min[1], z: bounds.min[2] }, + max: { x: bounds.max[0], y: bounds.max[1], z: bounds.max[2] }, }; - const wasmFuncPtr = addFunction(function(vec3Ptr) { + const wasmFuncPtr = addFunction(function (vec3Ptr) { const x = getValue(vec3Ptr, 'double'); const y = getValue(vec3Ptr + 8, 'double'); const z = getValue(vec3Ptr + 16, 'double'); @@ -653,27 +660,27 @@ Module.setup = function() { return sdf(vert); }, 'di'); const out = - Module._LevelSet(wasmFuncPtr, bounds2, edgeLength, level, tolerance); + Module._LevelSet(wasmFuncPtr, bounds2, edgeLength, level, tolerance); removeFunction(wasmFuncPtr); return out; }; function pushVec3(vec, ps) { toVec(vec, ps, p => { - if (p instanceof Array) return {x: p[0], y: p[1], z: p[2]}; + if (p instanceof Array) return { x: p[0], y: p[1], z: p[2] }; return p; - }) + }); } - Module.Manifold.hull = function(...args) { + Module.Manifold.hull = function (...args) { if (args.length == 1) args = args[0]; let pts = new Module.Vector_vec3(); for (const m of args) { if (m instanceof ManifoldCtor) { Module._manifoldCollectVertices(pts, m); } else if ( - m instanceof Array && m.length == 3 && typeof m[0] == 'number') { - pts.push_back({x: m[0], y: m[1], z: m[2]}); + m instanceof Array && m.length == 3 && typeof m[0] == 'number') { + pts.push_back({ x: m[0], y: m[1], z: m[2] }); } else if (m.x) { pts.push_back(m); } else { @@ -697,10 +704,10 @@ Module.setup = function() { // Top-level functions - Module.triangulate = function(polygons, epsilon = -1) { + Module.triangulate = function (polygons, epsilon = -1) { const polygonsVec = polygons2vec(polygons); const result = fromVec( - Module._Triangulate(polygonsVec, epsilon), (x) => [x[0], x[1], x[2]]); + Module._Triangulate(polygonsVec, epsilon), (x) => [x[0], x[1], x[2]]); disposePolygons(polygonsVec); return result; }; diff --git a/bindings/wasm/helpers.cpp b/bindings/wasm/helpers.cpp index 16c99c62c2..95a55f8495 100644 --- a/bindings/wasm/helpers.cpp +++ b/bindings/wasm/helpers.cpp @@ -152,11 +152,16 @@ CrossSection Warp(CrossSection& cross_section, uintptr_t funcPtr) { } CrossSection Offset(CrossSection& cross_section, double delta, int join_type, - double miter_limit, double arc_tolerance) { + int end_type, double miter_limit, double arc_tolerance) { auto jt = join_type == 0 ? CrossSection::JoinType::Square : join_type == 1 ? CrossSection::JoinType::Round : CrossSection::JoinType::Miter; - return cross_section.Offset(delta, jt, miter_limit, arc_tolerance); + auto et = end_type == 0 ? CrossSection::EndType::Polygon + : end_type == 1 ? CrossSection::EndType::Joined + : end_type == 2 ? CrossSection::EndType::Butt + : end_type == 3 ? CrossSection::EndType::Square + : CrossSection::EndType::Round; + return cross_section.Offset(delta, jt, et, miter_limit, arc_tolerance); } void CollectVertices(std::vector& verts, const CrossSection& cs) { diff --git a/bindings/wasm/manifold.js b/bindings/wasm/manifold.js index cab93ae998..3ecbe53a70 100644 --- a/bindings/wasm/manifold.js +++ b/bindings/wasm/manifold.js @@ -1,16 +1,16 @@ var Module = (() => { var _scriptName = import.meta.url; - + return ( - async function (moduleArg = {}) { - var moduleRtn; +async function(moduleArg = {}) { + var moduleRtn; - var Module = moduleArg; var readyPromiseResolve, readyPromiseReject; var readyPromise = new Promise((resolve, reject) => { readyPromiseResolve = resolve; readyPromiseReject = reject; }); var ENVIRONMENT_IS_WEB = typeof window == "object"; var ENVIRONMENT_IS_WORKER = typeof importScripts == "function"; var _ManifoldInitialized = false; Module.setup = function () { if (_ManifoldInitialized) return; _ManifoldInitialized = true; function toVec(vec, list, f = (x => x)) { if (list) { for (let x of list) { vec.push_back(f(x)); } } return vec; } function fromVec(vec, f = (x => x)) { const result = []; const size = vec.size(); for (let i = 0; i < size; i++)result.push(f(vec.get(i))); return result; } function vec2polygons(vec, f = (x => x)) { const result = []; const nPoly = vec.size(); for (let i = 0; i < nPoly; i++) { const v = vec.get(i); const nPts = v.size(); const poly = []; for (let j = 0; j < nPts; j++) { poly.push(f(v.get(j))); } result.push(poly); } return result; } function polygons2vec(polygons) { if (polygons[0].length < 3) { polygons = [polygons]; } return toVec(new Module.Vector2_vec2, polygons, poly => toVec(new Module.Vector_vec2, poly, p => { if (p instanceof Array) return { x: p[0], y: p[1] }; return p; })); } function disposePolygons(polygonsVec) { for (let i = 0; i < polygonsVec.size(); i++)polygonsVec.get(i).delete(); polygonsVec.delete(); } function vararg2vec2(vec) { if (vec[0] instanceof Array) return { x: vec[0][0], y: vec[0][1] }; if (typeof vec[0] == "number") return { x: vec[0] || 0, y: vec[1] || 0 }; return vec[0]; } function vararg2vec3(vec) { if (vec[0] instanceof Array) return { x: vec[0][0], y: vec[0][1], z: vec[0][2] }; if (typeof vec[0] == "number") return { x: vec[0] || 0, y: vec[1] || 0, z: vec[2] || 0 }; return vec[0]; } function fillRuleToInt(fillRule) { return fillRule == "EvenOdd" ? 0 : fillRule == "NonZero" ? 1 : fillRule == "Negative" ? 3 : 2; } function joinTypeToInt(joinType) { return joinType == "Round" ? 1 : joinType == "Miter" ? 2 : 0; } const CrossSectionCtor = Module.CrossSection; function cross(polygons, fillRule = "Positive") { if (polygons instanceof CrossSectionCtor) { return polygons; } else { const polygonsVec = polygons2vec(polygons); const cs = new CrossSectionCtor(polygonsVec, fillRuleToInt(fillRule)); disposePolygons(polygonsVec); return cs; } } Module.CrossSection.prototype.translate = function (...vec) { return this._Translate(vararg2vec2(vec)); }; Module.CrossSection.prototype.scale = function (vec) { if (typeof vec == "number") { return this._Scale({ x: vec, y: vec }); } return this._Scale(vararg2vec2([vec])); }; Module.CrossSection.prototype.mirror = function (vec) { return this._Mirror(vararg2vec2([vec])); }; Module.CrossSection.prototype.warp = function (func) { const wasmFuncPtr = addFunction(function (vec2Ptr) { const x = getValue(vec2Ptr, "double"); const y = getValue(vec2Ptr + 8, "double"); const vert = [x, y]; func(vert); setValue(vec2Ptr, vert[0], "double"); setValue(vec2Ptr + 8, vert[1], "double"); }, "vi"); const out = this._Warp(wasmFuncPtr); removeFunction(wasmFuncPtr); return out; }; Module.CrossSection.prototype.decompose = function () { const vec = this._Decompose(); const result = fromVec(vec); vec.delete(); return result; }; Module.CrossSection.prototype.bounds = function () { const result = this._Bounds(); return { min: ["x", "y"].map(f => result.min[f]), max: ["x", "y"].map(f => result.max[f]) }; }; Module.CrossSection.prototype.offset = function (delta, joinType = "Square", miterLimit = 2, circularSegments = 0) { return this._Offset(delta, joinTypeToInt(joinType), miterLimit, circularSegments); }; Module.CrossSection.prototype.extrude = function (height, nDivisions = 0, twistDegrees = 0, scaleTop = [1, 1], center = false) { scaleTop = vararg2vec2([scaleTop]); const man = Module._Extrude(this._ToPolygons(), height, nDivisions, twistDegrees, scaleTop); return center ? man.translate([0, 0, -height / 2]) : man; }; Module.CrossSection.prototype.revolve = function (circularSegments = 0, revolveDegrees = 360) { return Module._Revolve(this._ToPolygons(), circularSegments, revolveDegrees); }; Module.CrossSection.prototype.add = function (other) { return this._add(cross(other)); }; Module.CrossSection.prototype.subtract = function (other) { return this._subtract(cross(other)); }; Module.CrossSection.prototype.intersect = function (other) { return this._intersect(cross(other)); }; Module.CrossSection.prototype.toPolygons = function () { const vec = this._ToPolygons(); const result = vec2polygons(vec, v => [v.x, v.y]); vec.delete(); return result; }; Module.Manifold.prototype.smoothOut = function (minSharpAngle = 60, minSmoothness = 0) { return this._SmoothOut(minSharpAngle, minSmoothness); }; Module.Manifold.prototype.warp = function (func) { const wasmFuncPtr = addFunction(function (vec3Ptr) { const x = getValue(vec3Ptr, "double"); const y = getValue(vec3Ptr + 8, "double"); const z = getValue(vec3Ptr + 16, "double"); const vert = [x, y, z]; func(vert); setValue(vec3Ptr, vert[0], "double"); setValue(vec3Ptr + 8, vert[1], "double"); setValue(vec3Ptr + 16, vert[2], "double"); }, "vi"); const out = this._Warp(wasmFuncPtr); removeFunction(wasmFuncPtr); const status = out.status(); if (status.value !== 0) { throw new Module.ManifoldError(status.value); } return out; }; Module.Manifold.prototype.calculateNormals = function (normalIdx, minSharpAngle = 60) { return this._CalculateNormals(normalIdx, minSharpAngle); }; Module.Manifold.prototype.setProperties = function (numProp, func) { const oldNumProp = this.numProp(); const wasmFuncPtr = addFunction(function (newPtr, vec3Ptr, oldPtr) { const newProp = []; for (let i = 0; i < numProp; ++i) { newProp[i] = getValue(newPtr + 8 * i, "double"); } const pos = []; for (let i = 0; i < 3; ++i) { pos[i] = getValue(vec3Ptr + 8 * i, "double"); } const oldProp = []; for (let i = 0; i < oldNumProp; ++i) { oldProp[i] = getValue(oldPtr + 8 * i, "double"); } func(newProp, pos, oldProp); for (let i = 0; i < numProp; ++i) { setValue(newPtr + 8 * i, newProp[i], "double"); } }, "viii"); const out = this._SetProperties(numProp, wasmFuncPtr); removeFunction(wasmFuncPtr); return out; }; Module.Manifold.prototype.translate = function (...vec) { return this._Translate(vararg2vec3(vec)); }; Module.Manifold.prototype.rotate = function (xOrVec, y, z) { if (Array.isArray(xOrVec)) { return this._Rotate(...xOrVec); } else { return this._Rotate(xOrVec, y || 0, z || 0); } }; Module.Manifold.prototype.scale = function (vec) { if (typeof vec == "number") { return this._Scale({ x: vec, y: vec, z: vec }); } return this._Scale(vararg2vec3([vec])); }; Module.Manifold.prototype.mirror = function (vec) { return this._Mirror(vararg2vec3([vec])); }; Module.Manifold.prototype.trimByPlane = function (normal, offset = 0) { return this._TrimByPlane(vararg2vec3([normal]), offset); }; Module.Manifold.prototype.slice = function (height = 0) { const polygonsVec = this._Slice(height); const result = new CrossSectionCtor(polygonsVec, fillRuleToInt("Positive")); disposePolygons(polygonsVec); return result; }; Module.Manifold.prototype.project = function () { const polygonsVec = this._Project(); const result = new CrossSectionCtor(polygonsVec, fillRuleToInt("Positive")); disposePolygons(polygonsVec); return result.simplify(this.tolerance); }; Module.Manifold.prototype.split = function (manifold) { const vec = this._Split(manifold); const result = fromVec(vec); vec.delete(); return result; }; Module.Manifold.prototype.splitByPlane = function (normal, offset = 0) { const vec = this._SplitByPlane(vararg2vec3([normal]), offset); const result = fromVec(vec); vec.delete(); return result; }; Module.Manifold.prototype.decompose = function () { const vec = this._Decompose(); const result = fromVec(vec); vec.delete(); return result; }; Module.Manifold.prototype.boundingBox = function () { const result = this._boundingBox(); return { min: ["x", "y", "z"].map(f => result.min[f]), max: ["x", "y", "z"].map(f => result.max[f]) }; }; class Mesh { constructor({ numProp = 3, triVerts = new Uint32Array, vertProperties = new Float32Array, mergeFromVert, mergeToVert, runIndex, runOriginalID, faceID, halfedgeTangent, runTransform } = {}) { this.numProp = numProp; this.triVerts = triVerts; this.vertProperties = vertProperties; this.mergeFromVert = mergeFromVert; this.mergeToVert = mergeToVert; this.runIndex = runIndex; this.runOriginalID = runOriginalID; this.faceID = faceID; this.halfedgeTangent = halfedgeTangent; this.runTransform = runTransform; } get numTri() { return this.triVerts.length / 3; } get numVert() { return this.vertProperties.length / this.numProp; } get numRun() { return this.runOriginalID.length; } merge() { const { changed, mesh } = Module._Merge(this); Object.assign(this, { ...mesh }); return changed; } verts(tri) { return this.triVerts.subarray(3 * tri, 3 * (tri + 1)); } position(vert) { return this.vertProperties.subarray(this.numProp * vert, this.numProp * vert + 3); } extras(vert) { return this.vertProperties.subarray(this.numProp * vert + 3, this.numProp * (vert + 1)); } tangent(halfedge) { return this.halfedgeTangent.subarray(4 * halfedge, 4 * (halfedge + 1)); } transform(run) { const mat4 = new Array(16); for (const col of [0, 1, 2, 3]) { for (const row of [0, 1, 2]) { mat4[4 * col + row] = this.runTransform[12 * run + 3 * col + row]; } } mat4[15] = 1; return mat4; } } Module.Mesh = Mesh; Module.Manifold.prototype.getMesh = function (normalIdx = [0, 0, 0]) { if (normalIdx instanceof Array) normalIdx = { 0: normalIdx[0], 1: normalIdx[1], 2: normalIdx[2] }; return new Mesh(this._GetMeshJS(normalIdx)); }; Module.ManifoldError = function ManifoldError(code, ...args) { let message = "Unknown error"; switch (code) { case Module.status.NonFiniteVertex.value: message = "Non-finite vertex"; break; case Module.status.NotManifold.value: message = "Not manifold"; break; case Module.status.VertexOutOfBounds.value: message = "Vertex index out of bounds"; break; case Module.status.PropertiesWrongLength.value: message = "Properties have wrong length"; break; case Module.status.MissingPositionProperties.value: message = "Less than three properties"; break; case Module.status.MergeVectorsDifferentLengths.value: message = "Merge vectors have different lengths"; break; case Module.status.MergeIndexOutOfBounds.value: message = "Merge index out of bounds"; break; case Module.status.TransformWrongLength.value: message = "Transform vector has wrong length"; break; case Module.status.RunIndexWrongLength.value: message = "Run index vector has wrong length"; break; case Module.status.FaceIDWrongLength.value: message = "Face ID vector has wrong length"; case Module.status.InvalidConstruction.value: message = "Manifold constructed with invalid parameters"; }const base = Error.apply(this, [message, ...args]); base.name = this.name = "ManifoldError"; this.message = base.message; this.stack = base.stack; this.code = code; }; Module.ManifoldError.prototype = Object.create(Error.prototype, { constructor: { value: Module.ManifoldError, writable: true, configurable: true } }); Module.CrossSection = function (polygons, fillRule = "Positive") { const polygonsVec = polygons2vec(polygons); const cs = new CrossSectionCtor(polygonsVec, fillRuleToInt(fillRule)); disposePolygons(polygonsVec); return cs; }; Module.CrossSection.ofPolygons = function (polygons, fillRule = "Positive") { return new Module.CrossSection(polygons, fillRule); }; Module.CrossSection.square = function (...args) { let size = undefined; if (args.length == 0) size = { x: 1, y: 1 }; else if (typeof args[0] == "number") size = { x: args[0], y: args[0] }; else size = vararg2vec2(args); const center = args[1] || false; return Module._Square(size, center); }; Module.CrossSection.circle = function (radius, circularSegments = 0) { return Module._Circle(radius, circularSegments); }; function crossSectionBatchbool(name) { return function (...args) { if (args.length == 1) args = args[0]; const v = new Module.Vector_crossSection; for (const cs of args) v.push_back(cross(cs)); const result = Module["_crossSection" + name](v); v.delete(); return result; }; } Module.CrossSection.compose = crossSectionBatchbool("Compose"); Module.CrossSection.union = crossSectionBatchbool("UnionN"); Module.CrossSection.difference = crossSectionBatchbool("DifferenceN"); Module.CrossSection.intersection = crossSectionBatchbool("IntersectionN"); function pushVec2(vec, ps) { toVec(vec, ps, p => { if (p instanceof Array) return { x: p[0], y: p[1] }; return p; }); } Module.CrossSection.hull = function (...args) { if (args.length == 1) args = args[0]; let pts = new Module.Vector_vec2; for (const cs of args) { if (cs instanceof CrossSectionCtor) { Module._crossSectionCollectVertices(pts, cs); } else if (cs instanceof Array && cs.length == 2 && typeof cs[0] == "number") { pts.push_back({ x: cs[0], y: cs[1] }); } else if (cs.x) { pts.push_back(cs); } else { const wrap = cs[0].length == 2 && typeof cs[0][0] == "number" || cs[0].x; const polys = wrap ? [cs] : cs; for (const poly of polys) pushVec2(pts, poly); } } const result = Module._crossSectionHullPoints(pts); pts.delete(); return result; }; Module.CrossSection.prototype = Object.create(CrossSectionCtor.prototype); Object.defineProperty(Module.CrossSection, Symbol.hasInstance, { get: () => t => t instanceof CrossSectionCtor }); const ManifoldCtor = Module.Manifold; Module.Manifold = function (mesh) { const manifold = new ManifoldCtor(mesh); const status = manifold.status(); if (status.value !== 0) { throw new Module.ManifoldError(status.value); } return manifold; }; Module.Manifold.ofMesh = function (mesh) { return new Module.Manifold(mesh); }; Module.Manifold.tetrahedron = function () { return Module._Tetrahedron(); }; Module.Manifold.cube = function (...args) { let size = undefined; if (args.length == 0) size = { x: 1, y: 1, z: 1 }; else if (typeof args[0] == "number") size = { x: args[0], y: args[0], z: args[0] }; else size = vararg2vec3(args); const center = args[1] || false; return Module._Cube(size, center); }; Module.Manifold.cylinder = function (height, radiusLow, radiusHigh = -1, circularSegments = 0, center = false) { return Module._Cylinder(height, radiusLow, radiusHigh, circularSegments, center); }; Module.Manifold.sphere = function (radius, circularSegments = 0) { return Module._Sphere(radius, circularSegments); }; Module.Manifold.smooth = function (mesh, sharpenedEdges = []) { const sharp = new Module.Vector_smoothness; toVec(sharp, sharpenedEdges); const result = Module._Smooth(mesh, sharp); sharp.delete(); return result; }; Module.Manifold.extrude = function (polygons, height, nDivisions = 0, twistDegrees = 0, scaleTop = [1, 1], center = false) { const cs = polygons instanceof CrossSectionCtor ? polygons : Module.CrossSection(polygons, "Positive"); return cs.extrude(height, nDivisions, twistDegrees, scaleTop, center); }; Module.Manifold.revolve = function (polygons, circularSegments = 0, revolveDegrees = 360) { const cs = polygons instanceof CrossSectionCtor ? polygons : Module.CrossSection(polygons, "Positive"); return cs.revolve(circularSegments, revolveDegrees); }; Module.Manifold.reserveIDs = function (n) { return Module._ReserveIDs(n); }; Module.Manifold.compose = function (manifolds) { const vec = new Module.Vector_manifold; toVec(vec, manifolds); const result = Module._manifoldCompose(vec); vec.delete(); return result; }; function manifoldBatchbool(name) { return function (...args) { if (args.length == 1) args = args[0]; const v = new Module.Vector_manifold; for (const m of args) v.push_back(m); const result = Module["_manifold" + name + "N"](v); v.delete(); return result; }; } Module.Manifold.union = manifoldBatchbool("Union"); Module.Manifold.difference = manifoldBatchbool("Difference"); Module.Manifold.intersection = manifoldBatchbool("Intersection"); Module.Manifold.levelSet = function (sdf, bounds, edgeLength, level = 0, tolerance = -1) { const bounds2 = { min: { x: bounds.min[0], y: bounds.min[1], z: bounds.min[2] }, max: { x: bounds.max[0], y: bounds.max[1], z: bounds.max[2] } }; const wasmFuncPtr = addFunction(function (vec3Ptr) { const x = getValue(vec3Ptr, "double"); const y = getValue(vec3Ptr + 8, "double"); const z = getValue(vec3Ptr + 16, "double"); const vert = [x, y, z]; return sdf(vert); }, "di"); const out = Module._LevelSet(wasmFuncPtr, bounds2, edgeLength, level, tolerance); removeFunction(wasmFuncPtr); return out; }; function pushVec3(vec, ps) { toVec(vec, ps, p => { if (p instanceof Array) return { x: p[0], y: p[1], z: p[2] }; return p; }); } Module.Manifold.hull = function (...args) { if (args.length == 1) args = args[0]; let pts = new Module.Vector_vec3; for (const m of args) { if (m instanceof ManifoldCtor) { Module._manifoldCollectVertices(pts, m); } else if (m instanceof Array && m.length == 3 && typeof m[0] == "number") { pts.push_back({ x: m[0], y: m[1], z: m[2] }); } else if (m.x) { pts.push_back(m); } else { pushVec3(pts, m); } } const result = Module._manifoldHullPoints(pts); pts.delete(); return result; }; Module.Manifold.prototype = Object.create(ManifoldCtor.prototype); Object.defineProperty(Module.Manifold, Symbol.hasInstance, { get: () => t => t instanceof ManifoldCtor }); Module.triangulate = function (polygons, epsilon = -1) { const polygonsVec = polygons2vec(polygons); const result = fromVec(Module._Triangulate(polygonsVec, epsilon), x => [x[0], x[1], x[2]]); disposePolygons(polygonsVec); return result; }; }; var moduleOverrides = Object.assign({}, Module); var arguments_ = []; var thisProgram = "./this.program"; var quit_ = (status, toThrow) => { throw toThrow; }; var scriptDirectory = ""; function locateFile(path) { if (Module["locateFile"]) { return Module["locateFile"](path, scriptDirectory); } return scriptDirectory + path; } var readAsync, readBinary; if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) { scriptDirectory = self.location.href; } else if (typeof document != "undefined" && document.currentScript) { scriptDirectory = document.currentScript.src; } if (_scriptName) { scriptDirectory = _scriptName; } if (scriptDirectory.startsWith("blob:")) { scriptDirectory = ""; } else { scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1); } { if (ENVIRONMENT_IS_WORKER) { readBinary = url => { var xhr = new XMLHttpRequest; xhr.open("GET", url, false); xhr.responseType = "arraybuffer"; xhr.send(null); return new Uint8Array(xhr.response); }; } readAsync = url => { if (isFileURI(url)) { return new Promise((resolve, reject) => { var xhr = new XMLHttpRequest; xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; xhr.onload = () => { if (xhr.status == 200 || xhr.status == 0 && xhr.response) { resolve(xhr.response); return; } reject(xhr.status); }; xhr.onerror = reject; xhr.send(null); }); } return fetch(url, { credentials: "same-origin" }).then(response => { if (response.ok) { return response.arrayBuffer(); } return Promise.reject(new Error(response.status + " : " + response.url)); }); }; } } else { } var out = Module["print"] || console.log.bind(console); var err = Module["printErr"] || console.error.bind(console); Object.assign(Module, moduleOverrides); moduleOverrides = null; if (Module["arguments"]) arguments_ = Module["arguments"]; if (Module["thisProgram"]) thisProgram = Module["thisProgram"]; var wasmBinary = Module["wasmBinary"]; var wasmMemory; var ABORT = false; var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; function updateMemoryViews() { var b = wasmMemory.buffer; Module["HEAP8"] = HEAP8 = new Int8Array(b); Module["HEAP16"] = HEAP16 = new Int16Array(b); Module["HEAPU8"] = HEAPU8 = new Uint8Array(b); Module["HEAPU16"] = HEAPU16 = new Uint16Array(b); Module["HEAP32"] = HEAP32 = new Int32Array(b); Module["HEAPU32"] = HEAPU32 = new Uint32Array(b); Module["HEAPF32"] = HEAPF32 = new Float32Array(b); Module["HEAPF64"] = HEAPF64 = new Float64Array(b); } var __ATPRERUN__ = []; var __ATINIT__ = []; var __ATPOSTRUN__ = []; var runtimeInitialized = false; function preRun() { var preRuns = Module["preRun"]; if (preRuns) { if (typeof preRuns == "function") preRuns = [preRuns]; preRuns.forEach(addOnPreRun); } callRuntimeCallbacks(__ATPRERUN__); } function initRuntime() { runtimeInitialized = true; callRuntimeCallbacks(__ATINIT__); } function postRun() { var postRuns = Module["postRun"]; if (postRuns) { if (typeof postRuns == "function") postRuns = [postRuns]; postRuns.forEach(addOnPostRun); } callRuntimeCallbacks(__ATPOSTRUN__); } function addOnPreRun(cb) { __ATPRERUN__.unshift(cb); } function addOnInit(cb) { __ATINIT__.unshift(cb); } function addOnPostRun(cb) { __ATPOSTRUN__.unshift(cb); } var runDependencies = 0; var runDependencyWatcher = null; var dependenciesFulfilled = null; function addRunDependency(id) { runDependencies++; Module["monitorRunDependencies"]?.(runDependencies); } function removeRunDependency(id) { runDependencies--; Module["monitorRunDependencies"]?.(runDependencies); if (runDependencies == 0) { if (runDependencyWatcher !== null) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; } if (dependenciesFulfilled) { var callback = dependenciesFulfilled; dependenciesFulfilled = null; callback(); } } } function abort(what) { Module["onAbort"]?.(what); what = "Aborted(" + what + ")"; err(what); ABORT = true; what += ". Build with -sASSERTIONS for more info."; var e = new WebAssembly.RuntimeError(what); readyPromiseReject(e); throw e; } var dataURIPrefix = "data:application/octet-stream;base64,"; var isDataURI = filename => filename.startsWith(dataURIPrefix); var isFileURI = filename => filename.startsWith("file://"); function findWasmBinary() { if (Module["locateFile"]) { var f = "manifold.wasm"; if (!isDataURI(f)) { return locateFile(f); } return f; } return new URL("manifold.wasm", import.meta.url).href; } var wasmBinaryFile; function getBinarySync(file) { if (file == wasmBinaryFile && wasmBinary) { return new Uint8Array(wasmBinary); } if (readBinary) { return readBinary(file); } throw "both async and sync fetching of the wasm failed"; } function getBinaryPromise(binaryFile) { if (!wasmBinary) { return readAsync(binaryFile).then(response => new Uint8Array(response), () => getBinarySync(binaryFile)); } return Promise.resolve().then(() => getBinarySync(binaryFile)); } function instantiateArrayBuffer(binaryFile, imports, receiver) { return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(receiver, reason => { err(`failed to asynchronously prepare wasm: ${reason}`); abort(reason); }); } function instantiateAsync(binary, binaryFile, imports, callback) { if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && !isFileURI(binaryFile) && typeof fetch == "function") { return fetch(binaryFile, { credentials: "same-origin" }).then(response => { var result = WebAssembly.instantiateStreaming(response, imports); return result.then(callback, function (reason) { err(`wasm streaming compile failed: ${reason}`); err("falling back to ArrayBuffer instantiation"); return instantiateArrayBuffer(binaryFile, imports, callback); }); }); } return instantiateArrayBuffer(binaryFile, imports, callback); } function getWasmImports() { return { a: wasmImports }; } function createWasm() { var info = getWasmImports(); function receiveInstance(instance, module) { wasmExports = instance.exports; wasmMemory = wasmExports["za"]; updateMemoryViews(); wasmTable = wasmExports["Ca"]; addOnInit(wasmExports["Aa"]); removeRunDependency("wasm-instantiate"); return wasmExports; } addRunDependency("wasm-instantiate"); function receiveInstantiationResult(result) { receiveInstance(result["instance"]); } if (Module["instantiateWasm"]) { try { return Module["instantiateWasm"](info, receiveInstance); } catch (e) { err(`Module.instantiateWasm callback failed with error: ${e}`); readyPromiseReject(e); } } wasmBinaryFile ??= findWasmBinary(); instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject); return {}; } var callRuntimeCallbacks = callbacks => { callbacks.forEach(f => f(Module)); }; function getValue(ptr, type = "i8") { if (type.endsWith("*")) type = "*"; switch (type) { case "i1": return HEAP8[ptr]; case "i8": return HEAP8[ptr]; case "i16": return HEAP16[ptr >> 1]; case "i32": return HEAP32[ptr >> 2]; case "i64": abort("to do getValue(i64) use WASM_BIGINT"); case "float": return HEAPF32[ptr >> 2]; case "double": return HEAPF64[ptr >> 3]; case "*": return HEAPU32[ptr >> 2]; default: abort(`invalid type for getValue: ${type}`); } } var noExitRuntime = Module["noExitRuntime"] || true; function setValue(ptr, value, type = "i8") { if (type.endsWith("*")) type = "*"; switch (type) { case "i1": HEAP8[ptr] = value; break; case "i8": HEAP8[ptr] = value; break; case "i16": HEAP16[ptr >> 1] = value; break; case "i32": HEAP32[ptr >> 2] = value; break; case "i64": abort("to do setValue(i64) use WASM_BIGINT"); case "float": HEAPF32[ptr >> 2] = value; break; case "double": HEAPF64[ptr >> 3] = value; break; case "*": HEAPU32[ptr >> 2] = value; break; default: abort(`invalid type for setValue: ${type}`); } } var stackRestore = val => __emscripten_stack_restore(val); var stackSave = () => _emscripten_stack_get_current(); var exceptionCaught = []; var uncaughtExceptionCount = 0; var ___cxa_begin_catch = ptr => { var info = new ExceptionInfo(ptr); if (!info.get_caught()) { info.set_caught(true); uncaughtExceptionCount--; } info.set_rethrown(false); exceptionCaught.push(info); ___cxa_increment_exception_refcount(ptr); return ___cxa_get_exception_ptr(ptr); }; var exceptionLast = 0; var ___cxa_end_catch = () => { _setThrew(0, 0); var info = exceptionCaught.pop(); ___cxa_decrement_exception_refcount(info.excPtr); exceptionLast = 0; }; class ExceptionInfo { constructor(excPtr) { this.excPtr = excPtr; this.ptr = excPtr - 24; } set_type(type) { HEAPU32[this.ptr + 4 >> 2] = type; } get_type() { return HEAPU32[this.ptr + 4 >> 2]; } set_destructor(destructor) { HEAPU32[this.ptr + 8 >> 2] = destructor; } get_destructor() { return HEAPU32[this.ptr + 8 >> 2]; } set_caught(caught) { caught = caught ? 1 : 0; HEAP8[this.ptr + 12] = caught; } get_caught() { return HEAP8[this.ptr + 12] != 0; } set_rethrown(rethrown) { rethrown = rethrown ? 1 : 0; HEAP8[this.ptr + 13] = rethrown; } get_rethrown() { return HEAP8[this.ptr + 13] != 0; } init(type, destructor) { this.set_adjusted_ptr(0); this.set_type(type); this.set_destructor(destructor); } set_adjusted_ptr(adjustedPtr) { HEAPU32[this.ptr + 16 >> 2] = adjustedPtr; } get_adjusted_ptr() { return HEAPU32[this.ptr + 16 >> 2]; } } var ___resumeException = ptr => { if (!exceptionLast) { exceptionLast = ptr; } throw exceptionLast; }; var setTempRet0 = val => __emscripten_tempret_set(val); var findMatchingCatch = args => { var thrown = exceptionLast; if (!thrown) { setTempRet0(0); return 0; } var info = new ExceptionInfo(thrown); info.set_adjusted_ptr(thrown); var thrownType = info.get_type(); if (!thrownType) { setTempRet0(0); return thrown; } for (var caughtType of args) { if (caughtType === 0 || caughtType === thrownType) { break; } var adjusted_ptr_addr = info.ptr + 16; if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { setTempRet0(caughtType); return thrown; } } setTempRet0(thrownType); return thrown; }; var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]); var ___cxa_find_matching_catch_3 = arg0 => findMatchingCatch([arg0]); var ___cxa_throw = (ptr, type, destructor) => { var info = new ExceptionInfo(ptr); info.init(type, destructor); exceptionLast = ptr; uncaughtExceptionCount++; throw exceptionLast; }; var __abort_js = () => { abort(""); }; var structRegistrations = {}; var runDestructors = destructors => { while (destructors.length) { var ptr = destructors.pop(); var del = destructors.pop(); del(ptr); } }; function readPointer(pointer) { return this["fromWireType"](HEAPU32[pointer >> 2]); } var awaitingDependencies = {}; var registeredTypes = {}; var typeDependencies = {}; var InternalError; var throwInternalError = message => { throw new InternalError(message); }; var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => { myTypes.forEach(type => typeDependencies[type] = dependentTypes); function onComplete(typeConverters) { var myTypeConverters = getTypeConverters(typeConverters); if (myTypeConverters.length !== myTypes.length) { throwInternalError("Mismatched type converter count"); } for (var i = 0; i < myTypes.length; ++i) { registerType(myTypes[i], myTypeConverters[i]); } } var typeConverters = new Array(dependentTypes.length); var unregisteredTypes = []; var registered = 0; dependentTypes.forEach((dt, i) => { if (registeredTypes.hasOwnProperty(dt)) { typeConverters[i] = registeredTypes[dt]; } else { unregisteredTypes.push(dt); if (!awaitingDependencies.hasOwnProperty(dt)) { awaitingDependencies[dt] = []; } awaitingDependencies[dt].push(() => { typeConverters[i] = registeredTypes[dt]; ++registered; if (registered === unregisteredTypes.length) { onComplete(typeConverters); } }); } }); if (0 === unregisteredTypes.length) { onComplete(typeConverters); } }; var __embind_finalize_value_object = structType => { var reg = structRegistrations[structType]; delete structRegistrations[structType]; var rawConstructor = reg.rawConstructor; var rawDestructor = reg.rawDestructor; var fieldRecords = reg.fields; var fieldTypes = fieldRecords.map(field => field.getterReturnType).concat(fieldRecords.map(field => field.setterArgumentType)); whenDependentTypesAreResolved([structType], fieldTypes, fieldTypes => { var fields = {}; fieldRecords.forEach((field, i) => { var fieldName = field.fieldName; var getterReturnType = fieldTypes[i]; var getter = field.getter; var getterContext = field.getterContext; var setterArgumentType = fieldTypes[i + fieldRecords.length]; var setter = field.setter; var setterContext = field.setterContext; fields[fieldName] = { read: ptr => getterReturnType["fromWireType"](getter(getterContext, ptr)), write: (ptr, o) => { var destructors = []; setter(setterContext, ptr, setterArgumentType["toWireType"](destructors, o)); runDestructors(destructors); } }; }); return [{ name: reg.name, fromWireType: ptr => { var rv = {}; for (var i in fields) { rv[i] = fields[i].read(ptr); } rawDestructor(ptr); return rv; }, toWireType: (destructors, o) => { for (var fieldName in fields) { if (!(fieldName in o)) { throw new TypeError(`Missing field: "${fieldName}"`); } } var ptr = rawConstructor(); for (fieldName in fields) { fields[fieldName].write(ptr, o[fieldName]); } if (destructors !== null) { destructors.push(rawDestructor, ptr); } return ptr; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction: rawDestructor }]; }); }; var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => { }; var embind_init_charCodes = () => { var codes = new Array(256); for (var i = 0; i < 256; ++i) { codes[i] = String.fromCharCode(i); } embind_charCodes = codes; }; var embind_charCodes; var readLatin1String = ptr => { var ret = ""; var c = ptr; while (HEAPU8[c]) { ret += embind_charCodes[HEAPU8[c++]]; } return ret; }; var BindingError; var throwBindingError = message => { throw new BindingError(message); }; function sharedRegisterType(rawType, registeredInstance, options = {}) { var name = registeredInstance.name; if (!rawType) { throwBindingError(`type "${name}" must have a positive integer typeid pointer`); } if (registeredTypes.hasOwnProperty(rawType)) { if (options.ignoreDuplicateRegistrations) { return; } else { throwBindingError(`Cannot register type '${name}' twice`); } } registeredTypes[rawType] = registeredInstance; delete typeDependencies[rawType]; if (awaitingDependencies.hasOwnProperty(rawType)) { var callbacks = awaitingDependencies[rawType]; delete awaitingDependencies[rawType]; callbacks.forEach(cb => cb()); } } function registerType(rawType, registeredInstance, options = {}) { return sharedRegisterType(rawType, registeredInstance, options); } var GenericWireTypeSize = 8; var __embind_register_bool = (rawType, name, trueValue, falseValue) => { name = readLatin1String(name); registerType(rawType, { name, fromWireType: function (wt) { return !!wt; }, toWireType: function (destructors, o) { return o ? trueValue : falseValue; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: function (pointer) { return this["fromWireType"](HEAPU8[pointer]); }, destructorFunction: null }); }; var shallowCopyInternalPointer = o => ({ count: o.count, deleteScheduled: o.deleteScheduled, preservePointerOnDelete: o.preservePointerOnDelete, ptr: o.ptr, ptrType: o.ptrType, smartPtr: o.smartPtr, smartPtrType: o.smartPtrType }); var throwInstanceAlreadyDeleted = obj => { function getInstanceTypeName(handle) { return handle.$$.ptrType.registeredClass.name; } throwBindingError(getInstanceTypeName(obj) + " instance already deleted"); }; var finalizationRegistry = false; var detachFinalizer = handle => { }; var runDestructor = $$ => { if ($$.smartPtr) { $$.smartPtrType.rawDestructor($$.smartPtr); } else { $$.ptrType.registeredClass.rawDestructor($$.ptr); } }; var releaseClassHandle = $$ => { $$.count.value -= 1; var toDelete = 0 === $$.count.value; if (toDelete) { runDestructor($$); } }; var downcastPointer = (ptr, ptrClass, desiredClass) => { if (ptrClass === desiredClass) { return ptr; } if (undefined === desiredClass.baseClass) { return null; } var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass); if (rv === null) { return null; } return desiredClass.downcast(rv); }; var registeredPointers = {}; var registeredInstances = {}; var getBasestPointer = (class_, ptr) => { if (ptr === undefined) { throwBindingError("ptr should not be undefined"); } while (class_.baseClass) { ptr = class_.upcast(ptr); class_ = class_.baseClass; } return ptr; }; var getInheritedInstance = (class_, ptr) => { ptr = getBasestPointer(class_, ptr); return registeredInstances[ptr]; }; var makeClassHandle = (prototype, record) => { if (!record.ptrType || !record.ptr) { throwInternalError("makeClassHandle requires ptr and ptrType"); } var hasSmartPtrType = !!record.smartPtrType; var hasSmartPtr = !!record.smartPtr; if (hasSmartPtrType !== hasSmartPtr) { throwInternalError("Both smartPtrType and smartPtr must be specified"); } record.count = { value: 1 }; return attachFinalizer(Object.create(prototype, { $$: { value: record, writable: true } })); }; function RegisteredPointer_fromWireType(ptr) { var rawPointer = this.getPointee(ptr); if (!rawPointer) { this.destructor(ptr); return null; } var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer); if (undefined !== registeredInstance) { if (0 === registeredInstance.$$.count.value) { registeredInstance.$$.ptr = rawPointer; registeredInstance.$$.smartPtr = ptr; return registeredInstance["clone"](); } else { var rv = registeredInstance["clone"](); this.destructor(ptr); return rv; } } function makeDefaultHandle() { if (this.isSmartPointer) { return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: rawPointer, smartPtrType: this, smartPtr: ptr }); } else { return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this, ptr }); } } var actualType = this.registeredClass.getActualType(rawPointer); var registeredPointerRecord = registeredPointers[actualType]; if (!registeredPointerRecord) { return makeDefaultHandle.call(this); } var toType; if (this.isConst) { toType = registeredPointerRecord.constPointerType; } else { toType = registeredPointerRecord.pointerType; } var dp = downcastPointer(rawPointer, this.registeredClass, toType.registeredClass); if (dp === null) { return makeDefaultHandle.call(this); } if (this.isSmartPointer) { return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp, smartPtrType: this, smartPtr: ptr }); } else { return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp }); } } var attachFinalizer = handle => { if ("undefined" === typeof FinalizationRegistry) { attachFinalizer = handle => handle; return handle; } finalizationRegistry = new FinalizationRegistry(info => { releaseClassHandle(info.$$); }); attachFinalizer = handle => { var $$ = handle.$$; var hasSmartPtr = !!$$.smartPtr; if (hasSmartPtr) { var info = { $$ }; finalizationRegistry.register(handle, info, handle); } return handle; }; detachFinalizer = handle => finalizationRegistry.unregister(handle); return attachFinalizer(handle); }; var deletionQueue = []; var flushPendingDeletes = () => { while (deletionQueue.length) { var obj = deletionQueue.pop(); obj.$$.deleteScheduled = false; obj["delete"](); } }; var delayFunction; var init_ClassHandle = () => { Object.assign(ClassHandle.prototype, { isAliasOf(other) { if (!(this instanceof ClassHandle)) { return false; } if (!(other instanceof ClassHandle)) { return false; } var leftClass = this.$$.ptrType.registeredClass; var left = this.$$.ptr; other.$$ = other.$$; var rightClass = other.$$.ptrType.registeredClass; var right = other.$$.ptr; while (leftClass.baseClass) { left = leftClass.upcast(left); leftClass = leftClass.baseClass; } while (rightClass.baseClass) { right = rightClass.upcast(right); rightClass = rightClass.baseClass; } return leftClass === rightClass && left === right; }, clone() { if (!this.$$.ptr) { throwInstanceAlreadyDeleted(this); } if (this.$$.preservePointerOnDelete) { this.$$.count.value += 1; return this; } else { var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), { $$: { value: shallowCopyInternalPointer(this.$$) } })); clone.$$.count.value += 1; clone.$$.deleteScheduled = false; return clone; } }, delete() { if (!this.$$.ptr) { throwInstanceAlreadyDeleted(this); } if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) { throwBindingError("Object already scheduled for deletion"); } detachFinalizer(this); releaseClassHandle(this.$$); if (!this.$$.preservePointerOnDelete) { this.$$.smartPtr = undefined; this.$$.ptr = undefined; } }, isDeleted() { return !this.$$.ptr; }, deleteLater() { if (!this.$$.ptr) { throwInstanceAlreadyDeleted(this); } if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) { throwBindingError("Object already scheduled for deletion"); } deletionQueue.push(this); if (deletionQueue.length === 1 && delayFunction) { delayFunction(flushPendingDeletes); } this.$$.deleteScheduled = true; return this; } }); }; function ClassHandle() { } var createNamedFunction = (name, body) => Object.defineProperty(body, "name", { value: name }); var ensureOverloadTable = (proto, methodName, humanName) => { if (undefined === proto[methodName].overloadTable) { var prevFunc = proto[methodName]; proto[methodName] = function (...args) { if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) { throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`); } return proto[methodName].overloadTable[args.length].apply(this, args); }; proto[methodName].overloadTable = []; proto[methodName].overloadTable[prevFunc.argCount] = prevFunc; } }; var exposePublicSymbol = (name, value, numArguments) => { if (Module.hasOwnProperty(name)) { if (undefined === numArguments || undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments]) { throwBindingError(`Cannot register public name '${name}' twice`); } ensureOverloadTable(Module, name, name); if (Module.hasOwnProperty(numArguments)) { throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`); } Module[name].overloadTable[numArguments] = value; } else { Module[name] = value; if (undefined !== numArguments) { Module[name].numArguments = numArguments; } } }; var char_0 = 48; var char_9 = 57; var makeLegalFunctionName = name => { name = name.replace(/[^a-zA-Z0-9_]/g, "$"); var f = name.charCodeAt(0); if (f >= char_0 && f <= char_9) { return `_${name}`; } return name; }; function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) { this.name = name; this.constructor = constructor; this.instancePrototype = instancePrototype; this.rawDestructor = rawDestructor; this.baseClass = baseClass; this.getActualType = getActualType; this.upcast = upcast; this.downcast = downcast; this.pureVirtualFunctions = []; } var upcastPointer = (ptr, ptrClass, desiredClass) => { while (ptrClass !== desiredClass) { if (!ptrClass.upcast) { throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`); } ptr = ptrClass.upcast(ptr); ptrClass = ptrClass.baseClass; } return ptr; }; function constNoSmartPtrRawPointerToWireType(destructors, handle) { if (handle === null) { if (this.isReference) { throwBindingError(`null is not a valid ${this.name}`); } return 0; } if (!handle.$$) { throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`); } if (!handle.$$.ptr) { throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`); } var handleClass = handle.$$.ptrType.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); return ptr; } function genericPointerToWireType(destructors, handle) { var ptr; if (handle === null) { if (this.isReference) { throwBindingError(`null is not a valid ${this.name}`); } if (this.isSmartPointer) { ptr = this.rawConstructor(); if (destructors !== null) { destructors.push(this.rawDestructor, ptr); } return ptr; } else { return 0; } } if (!handle || !handle.$$) { throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`); } if (!handle.$$.ptr) { throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`); } if (!this.isConst && handle.$$.ptrType.isConst) { throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name} to parameter type ${this.name}`); } var handleClass = handle.$$.ptrType.registeredClass; ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); if (this.isSmartPointer) { if (undefined === handle.$$.smartPtr) { throwBindingError("Passing raw pointer to smart pointer is illegal"); } switch (this.sharingPolicy) { case 0: if (handle.$$.smartPtrType === this) { ptr = handle.$$.smartPtr; } else { throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name} to parameter type ${this.name}`); } break; case 1: ptr = handle.$$.smartPtr; break; case 2: if (handle.$$.smartPtrType === this) { ptr = handle.$$.smartPtr; } else { var clonedHandle = handle["clone"](); ptr = this.rawShare(ptr, Emval.toHandle(() => clonedHandle["delete"]())); if (destructors !== null) { destructors.push(this.rawDestructor, ptr); } } break; default: throwBindingError("Unsupporting sharing policy"); } } return ptr; } function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) { if (handle === null) { if (this.isReference) { throwBindingError(`null is not a valid ${this.name}`); } return 0; } if (!handle.$$) { throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`); } if (!handle.$$.ptr) { throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`); } if (handle.$$.ptrType.isConst) { throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`); } var handleClass = handle.$$.ptrType.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); return ptr; } var init_RegisteredPointer = () => { Object.assign(RegisteredPointer.prototype, { getPointee(ptr) { if (this.rawGetPointee) { ptr = this.rawGetPointee(ptr); } return ptr; }, destructor(ptr) { this.rawDestructor?.(ptr); }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, fromWireType: RegisteredPointer_fromWireType }); }; function RegisteredPointer(name, registeredClass, isReference, isConst, isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) { this.name = name; this.registeredClass = registeredClass; this.isReference = isReference; this.isConst = isConst; this.isSmartPointer = isSmartPointer; this.pointeeType = pointeeType; this.sharingPolicy = sharingPolicy; this.rawGetPointee = rawGetPointee; this.rawConstructor = rawConstructor; this.rawShare = rawShare; this.rawDestructor = rawDestructor; if (!isSmartPointer && registeredClass.baseClass === undefined) { if (isConst) { this["toWireType"] = constNoSmartPtrRawPointerToWireType; this.destructorFunction = null; } else { this["toWireType"] = nonConstNoSmartPtrRawPointerToWireType; this.destructorFunction = null; } } else { this["toWireType"] = genericPointerToWireType; } } var replacePublicSymbol = (name, value, numArguments) => { if (!Module.hasOwnProperty(name)) { throwInternalError("Replacing nonexistent public symbol"); } if (undefined !== Module[name].overloadTable && undefined !== numArguments) { Module[name].overloadTable[numArguments] = value; } else { Module[name] = value; Module[name].argCount = numArguments; } }; var dynCallLegacy = (sig, ptr, args) => { sig = sig.replace(/p/g, "i"); var f = Module["dynCall_" + sig]; return f(ptr, ...args); }; var wasmTableMirror = []; var wasmTable; var getWasmTableEntry = funcPtr => { var func = wasmTableMirror[funcPtr]; if (!func) { if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1; wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr); } return func; }; var dynCall = (sig, ptr, args = []) => { if (sig.includes("j")) { return dynCallLegacy(sig, ptr, args); } var rtn = getWasmTableEntry(ptr)(...args); return rtn; }; var getDynCaller = (sig, ptr) => (...args) => dynCall(sig, ptr, args); var embind__requireFunction = (signature, rawFunction) => { signature = readLatin1String(signature); function makeDynCaller() { if (signature.includes("j")) { return getDynCaller(signature, rawFunction); } return getWasmTableEntry(rawFunction); } var fp = makeDynCaller(); if (typeof fp != "function") { throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`); } return fp; }; var extendError = (baseErrorType, errorName) => { var errorClass = createNamedFunction(errorName, function (message) { this.name = errorName; this.message = message; var stack = new Error(message).stack; if (stack !== undefined) { this.stack = this.toString() + "\n" + stack.replace(/^Error(:[^\n]*)?\n/, ""); } }); errorClass.prototype = Object.create(baseErrorType.prototype); errorClass.prototype.constructor = errorClass; errorClass.prototype.toString = function () { if (this.message === undefined) { return this.name; } else { return `${this.name}: ${this.message}`; } }; return errorClass; }; var UnboundTypeError; var getTypeName = type => { var ptr = ___getTypeName(type); var rv = readLatin1String(ptr); _free(ptr); return rv; }; var throwUnboundTypeError = (message, types) => { var unboundTypes = []; var seen = {}; function visit(type) { if (seen[type]) { return; } if (registeredTypes[type]) { return; } if (typeDependencies[type]) { typeDependencies[type].forEach(visit); return; } unboundTypes.push(type); seen[type] = true; } types.forEach(visit); throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([", "])); }; var __embind_register_class = (rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) => { name = readLatin1String(name); getActualType = embind__requireFunction(getActualTypeSignature, getActualType); upcast &&= embind__requireFunction(upcastSignature, upcast); downcast &&= embind__requireFunction(downcastSignature, downcast); rawDestructor = embind__requireFunction(destructorSignature, rawDestructor); var legalFunctionName = makeLegalFunctionName(name); exposePublicSymbol(legalFunctionName, function () { throwUnboundTypeError(`Cannot construct ${name} due to unbound types`, [baseClassRawType]); }); whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], base => { base = base[0]; var baseClass; var basePrototype; if (baseClassRawType) { baseClass = base.registeredClass; basePrototype = baseClass.instancePrototype; } else { basePrototype = ClassHandle.prototype; } var constructor = createNamedFunction(name, function (...args) { if (Object.getPrototypeOf(this) !== instancePrototype) { throw new BindingError("Use 'new' to construct " + name); } if (undefined === registeredClass.constructor_body) { throw new BindingError(name + " has no accessible constructor"); } var body = registeredClass.constructor_body[args.length]; if (undefined === body) { throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`); } return body.apply(this, args); }); var instancePrototype = Object.create(basePrototype, { constructor: { value: constructor } }); constructor.prototype = instancePrototype; var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast); if (registeredClass.baseClass) { registeredClass.baseClass.__derivedClasses ??= []; registeredClass.baseClass.__derivedClasses.push(registeredClass); } var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false); var pointerConverter = new RegisteredPointer(name + "*", registeredClass, false, false, false); var constPointerConverter = new RegisteredPointer(name + " const*", registeredClass, false, true, false); registeredPointers[rawType] = { pointerType: pointerConverter, constPointerType: constPointerConverter }; replacePublicSymbol(legalFunctionName, constructor); return [referenceConverter, pointerConverter, constPointerConverter]; }); }; var heap32VectorToArray = (count, firstElement) => { var array = []; for (var i = 0; i < count; i++) { array.push(HEAPU32[firstElement + i * 4 >> 2]); } return array; }; function usesDestructorStack(argTypes) { for (var i = 1; i < argTypes.length; ++i) { if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { return true; } } return false; } function newFunc(constructor, argumentList) { if (!(constructor instanceof Function)) { throw new TypeError(`new_ called with constructor type ${typeof constructor} which is not a function`); } var dummy = createNamedFunction(constructor.name || "unknownFunctionName", function () { }); dummy.prototype = constructor.prototype; var obj = new dummy; var r = constructor.apply(obj, argumentList); return r instanceof Object ? r : obj; } function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) { var needsDestructorStack = usesDestructorStack(argTypes); var argCount = argTypes.length - 2; var argsList = []; var argsListWired = ["fn"]; if (isClassMethodFunc) { argsListWired.push("thisWired"); } for (var i = 0; i < argCount; ++i) { argsList.push(`arg${i}`); argsListWired.push(`arg${i}Wired`); } argsList = argsList.join(","); argsListWired = argsListWired.join(","); var invokerFnBody = `return function (${argsList}) {\n`; if (needsDestructorStack) { invokerFnBody += "var destructors = [];\n"; } var dtorStack = needsDestructorStack ? "destructors" : "null"; var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"]; if (isClassMethodFunc) { invokerFnBody += `var thisWired = classParam['toWireType'](${dtorStack}, this);\n`; } for (var i = 0; i < argCount; ++i) { invokerFnBody += `var arg${i}Wired = argType${i}['toWireType'](${dtorStack}, arg${i});\n`; args1.push(`argType${i}`); } invokerFnBody += (returns || isAsync ? "var rv = " : "") + `invoker(${argsListWired});\n`; if (needsDestructorStack) { invokerFnBody += "runDestructors(destructors);\n"; } else { for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { var paramName = i === 1 ? "thisWired" : "arg" + (i - 2) + "Wired"; if (argTypes[i].destructorFunction !== null) { invokerFnBody += `${paramName}_dtor(${paramName});\n`; args1.push(`${paramName}_dtor`); } } } if (returns) { invokerFnBody += "var ret = retType['fromWireType'](rv);\n" + "return ret;\n"; } else { } invokerFnBody += "}\n"; return [args1, invokerFnBody]; } function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, isAsync) { var argCount = argTypes.length; if (argCount < 2) { throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!"); } var isClassMethodFunc = argTypes[1] !== null && classType !== null; var needsDestructorStack = usesDestructorStack(argTypes); var returns = argTypes[0].name !== "void"; var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]]; for (var i = 0; i < argCount - 2; ++i) { closureArgs.push(argTypes[i + 2]); } if (!needsDestructorStack) { for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { if (argTypes[i].destructorFunction !== null) { closureArgs.push(argTypes[i].destructorFunction); } } } let [args, invokerFnBody] = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync); args.push(invokerFnBody); var invokerFn = newFunc(Function, args)(...closureArgs); return createNamedFunction(humanName, invokerFn); } var __embind_register_class_constructor = (rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) => { var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); invoker = embind__requireFunction(invokerSignature, invoker); whenDependentTypesAreResolved([], [rawClassType], classType => { classType = classType[0]; var humanName = `constructor ${classType.name}`; if (undefined === classType.registeredClass.constructor_body) { classType.registeredClass.constructor_body = []; } if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) { 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!`); } classType.registeredClass.constructor_body[argCount - 1] = () => { throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`, rawArgTypes); }; whenDependentTypesAreResolved([], rawArgTypes, argTypes => { argTypes.splice(1, 0, null); classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor); return []; }); return []; }); }; var getFunctionName = signature => { signature = signature.trim(); const argsIndex = signature.indexOf("("); if (argsIndex !== -1) { return signature.substr(0, argsIndex); } else { return signature; } }; var __embind_register_class_function = (rawClassType, methodName, argCount, rawArgTypesAddr, invokerSignature, rawInvoker, context, isPureVirtual, isAsync, isNonnullReturn) => { var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); methodName = readLatin1String(methodName); methodName = getFunctionName(methodName); rawInvoker = embind__requireFunction(invokerSignature, rawInvoker); whenDependentTypesAreResolved([], [rawClassType], classType => { classType = classType[0]; var humanName = `${classType.name}.${methodName}`; if (methodName.startsWith("@@")) { methodName = Symbol[methodName.substring(2)]; } if (isPureVirtual) { classType.registeredClass.pureVirtualFunctions.push(methodName); } function unboundTypesHandler() { throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`, rawArgTypes); } var proto = classType.registeredClass.instancePrototype; var method = proto[methodName]; if (undefined === method || undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2) { unboundTypesHandler.argCount = argCount - 2; unboundTypesHandler.className = classType.name; proto[methodName] = unboundTypesHandler; } else { ensureOverloadTable(proto, methodName, humanName); proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler; } whenDependentTypesAreResolved([], rawArgTypes, argTypes => { var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync); if (undefined === proto[methodName].overloadTable) { memberFunction.argCount = argCount - 2; proto[methodName] = memberFunction; } else { proto[methodName].overloadTable[argCount - 2] = memberFunction; } return []; }); return []; }); }; var emval_freelist = []; var emval_handles = []; var __emval_decref = handle => { if (handle > 9 && 0 === --emval_handles[handle + 1]) { emval_handles[handle] = undefined; emval_freelist.push(handle); } }; var count_emval_handles = () => emval_handles.length / 2 - 5 - emval_freelist.length; var init_emval = () => { emval_handles.push(0, 1, undefined, 1, null, 1, true, 1, false, 1); Module["count_emval_handles"] = count_emval_handles; }; var Emval = { toValue: handle => { if (!handle) { throwBindingError("Cannot use deleted val. handle = " + handle); } return emval_handles[handle]; }, toHandle: value => { switch (value) { case undefined: return 2; case null: return 4; case true: return 6; case false: return 8; default: { const handle = emval_freelist.pop() || emval_handles.length; emval_handles[handle] = value; emval_handles[handle + 1] = 1; return handle; } } } }; var EmValType = { name: "emscripten::val", fromWireType: handle => { var rv = Emval.toValue(handle); __emval_decref(handle); return rv; }, toWireType: (destructors, value) => Emval.toHandle(value), argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction: null }; var __embind_register_emval = rawType => registerType(rawType, EmValType); var enumReadValueFromPointer = (name, width, signed) => { switch (width) { case 1: return signed ? function (pointer) { return this["fromWireType"](HEAP8[pointer]); } : function (pointer) { return this["fromWireType"](HEAPU8[pointer]); }; case 2: return signed ? function (pointer) { return this["fromWireType"](HEAP16[pointer >> 1]); } : function (pointer) { return this["fromWireType"](HEAPU16[pointer >> 1]); }; case 4: return signed ? function (pointer) { return this["fromWireType"](HEAP32[pointer >> 2]); } : function (pointer) { return this["fromWireType"](HEAPU32[pointer >> 2]); }; default: throw new TypeError(`invalid integer width (${width}): ${name}`); } }; var __embind_register_enum = (rawType, name, size, isSigned) => { name = readLatin1String(name); function ctor() { } ctor.values = {}; registerType(rawType, { name, constructor: ctor, fromWireType: function (c) { return this.constructor.values[c]; }, toWireType: (destructors, c) => c.value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: enumReadValueFromPointer(name, size, isSigned), destructorFunction: null }); exposePublicSymbol(name, ctor); }; var requireRegisteredType = (rawType, humanName) => { var impl = registeredTypes[rawType]; if (undefined === impl) { throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`); } return impl; }; var __embind_register_enum_value = (rawEnumType, name, enumValue) => { var enumType = requireRegisteredType(rawEnumType, "enum"); name = readLatin1String(name); var Enum = enumType.constructor; var Value = Object.create(enumType.constructor.prototype, { value: { value: enumValue }, constructor: { value: createNamedFunction(`${enumType.name}_${name}`, function () { }) } }); Enum.values[enumValue] = Value; Enum[name] = Value; }; var embindRepr = v => { if (v === null) { return "null"; } var t = typeof v; if (t === "object" || t === "array" || t === "function") { return v.toString(); } else { return "" + v; } }; var floatReadValueFromPointer = (name, width) => { switch (width) { case 4: return function (pointer) { return this["fromWireType"](HEAPF32[pointer >> 2]); }; case 8: return function (pointer) { return this["fromWireType"](HEAPF64[pointer >> 3]); }; default: throw new TypeError(`invalid float width (${width}): ${name}`); } }; var __embind_register_float = (rawType, name, size) => { name = readLatin1String(name); registerType(rawType, { name, fromWireType: value => value, toWireType: (destructors, value) => value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: floatReadValueFromPointer(name, size), destructorFunction: null }); }; var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync, isNonnullReturn) => { var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr); name = readLatin1String(name); name = getFunctionName(name); rawInvoker = embind__requireFunction(signature, rawInvoker); exposePublicSymbol(name, function () { throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes); }, argCount - 1); whenDependentTypesAreResolved([], argTypes, argTypes => { var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)); replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn, isAsync), argCount - 1); return []; }); }; var integerReadValueFromPointer = (name, width, signed) => { switch (width) { case 1: return signed ? pointer => HEAP8[pointer] : pointer => HEAPU8[pointer]; case 2: return signed ? pointer => HEAP16[pointer >> 1] : pointer => HEAPU16[pointer >> 1]; case 4: return signed ? pointer => HEAP32[pointer >> 2] : pointer => HEAPU32[pointer >> 2]; default: throw new TypeError(`invalid integer width (${width}): ${name}`); } }; var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => { name = readLatin1String(name); if (maxRange === -1) { maxRange = 4294967295; } var fromWireType = value => value; if (minRange === 0) { var bitshift = 32 - 8 * size; fromWireType = value => value << bitshift >>> bitshift; } var isUnsignedType = name.includes("unsigned"); var checkAssertions = (value, toTypeName) => { }; var toWireType; if (isUnsignedType) { toWireType = function (destructors, value) { checkAssertions(value, this.name); return value >>> 0; }; } else { toWireType = function (destructors, value) { checkAssertions(value, this.name); return value; }; } registerType(primitiveType, { name, fromWireType, toWireType, argPackAdvance: GenericWireTypeSize, readValueFromPointer: integerReadValueFromPointer(name, size, minRange !== 0), destructorFunction: null }); }; var __embind_register_memory_view = (rawType, dataTypeIndex, name) => { var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; var TA = typeMapping[dataTypeIndex]; function decodeMemoryView(handle) { var size = HEAPU32[handle >> 2]; var data = HEAPU32[handle + 4 >> 2]; return new TA(HEAP8.buffer, data, size); } name = readLatin1String(name); registerType(rawType, { name, fromWireType: decodeMemoryView, argPackAdvance: GenericWireTypeSize, readValueFromPointer: decodeMemoryView }, { ignoreDuplicateRegistrations: true }); }; var EmValOptionalType = Object.assign({ optional: true }, EmValType); var __embind_register_optional = (rawOptionalType, rawType) => { registerType(rawOptionalType, EmValOptionalType); }; var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => { if (!(maxBytesToWrite > 0)) return 0; var startIdx = outIdx; var endIdx = outIdx + maxBytesToWrite - 1; for (var i = 0; i < str.length; ++i) { var u = str.charCodeAt(i); if (u >= 55296 && u <= 57343) { var u1 = str.charCodeAt(++i); u = 65536 + ((u & 1023) << 10) | u1 & 1023; } if (u <= 127) { if (outIdx >= endIdx) break; heap[outIdx++] = u; } else if (u <= 2047) { if (outIdx + 1 >= endIdx) break; heap[outIdx++] = 192 | u >> 6; heap[outIdx++] = 128 | u & 63; } else if (u <= 65535) { if (outIdx + 2 >= endIdx) break; heap[outIdx++] = 224 | u >> 12; heap[outIdx++] = 128 | u >> 6 & 63; heap[outIdx++] = 128 | u & 63; } else { if (outIdx + 3 >= endIdx) break; heap[outIdx++] = 240 | u >> 18; heap[outIdx++] = 128 | u >> 12 & 63; heap[outIdx++] = 128 | u >> 6 & 63; heap[outIdx++] = 128 | u & 63; } } heap[outIdx] = 0; return outIdx - startIdx; }; var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); var lengthBytesUTF8 = str => { var len = 0; for (var i = 0; i < str.length; ++i) { var c = str.charCodeAt(i); if (c <= 127) { len++; } else if (c <= 2047) { len += 2; } else if (c >= 55296 && c <= 57343) { len += 4; ++i; } else { len += 3; } } return len; }; var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined; var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => { var endIdx = idx + maxBytesToRead; var endPtr = idx; while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr; if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); } var str = ""; while (idx < endPtr) { var u0 = heapOrArray[idx++]; if (!(u0 & 128)) { str += String.fromCharCode(u0); continue; } var u1 = heapOrArray[idx++] & 63; if ((u0 & 224) == 192) { str += String.fromCharCode((u0 & 31) << 6 | u1); continue; } var u2 = heapOrArray[idx++] & 63; if ((u0 & 240) == 224) { u0 = (u0 & 15) << 12 | u1 << 6 | u2; } else { u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63; } if (u0 < 65536) { str += String.fromCharCode(u0); } else { var ch = u0 - 65536; str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); } } return str; }; var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""; var __embind_register_std_string = (rawType, name) => { name = readLatin1String(name); var stdStringIsUTF8 = name === "std::string"; registerType(rawType, { name, fromWireType(value) { var length = HEAPU32[value >> 2]; var payload = value + 4; var str; if (stdStringIsUTF8) { var decodeStartPtr = payload; for (var i = 0; i <= length; ++i) { var currentBytePtr = payload + i; if (i == length || HEAPU8[currentBytePtr] == 0) { var maxRead = currentBytePtr - decodeStartPtr; var stringSegment = UTF8ToString(decodeStartPtr, maxRead); if (str === undefined) { str = stringSegment; } else { str += String.fromCharCode(0); str += stringSegment; } decodeStartPtr = currentBytePtr + 1; } } } else { var a = new Array(length); for (var i = 0; i < length; ++i) { a[i] = String.fromCharCode(HEAPU8[payload + i]); } str = a.join(""); } _free(value); return str; }, toWireType(destructors, value) { if (value instanceof ArrayBuffer) { value = new Uint8Array(value); } var length; var valueIsOfTypeString = typeof value == "string"; if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) { throwBindingError("Cannot pass non-string to std::string"); } if (stdStringIsUTF8 && valueIsOfTypeString) { length = lengthBytesUTF8(value); } else { length = value.length; } var base = _malloc(4 + length + 1); var ptr = base + 4; HEAPU32[base >> 2] = length; if (stdStringIsUTF8 && valueIsOfTypeString) { stringToUTF8(value, ptr, length + 1); } else { if (valueIsOfTypeString) { for (var i = 0; i < length; ++i) { var charCode = value.charCodeAt(i); if (charCode > 255) { _free(ptr); throwBindingError("String has UTF-16 code units that do not fit in 8 bits"); } HEAPU8[ptr + i] = charCode; } } else { for (var i = 0; i < length; ++i) { HEAPU8[ptr + i] = value[i]; } } } if (destructors !== null) { destructors.push(_free, base); } return base; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction(ptr) { _free(ptr); } }); }; var UTF16Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : undefined; var UTF16ToString = (ptr, maxBytesToRead) => { var endPtr = ptr; var idx = endPtr >> 1; var maxIdx = idx + maxBytesToRead / 2; while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx; endPtr = idx << 1; if (endPtr - ptr > 32 && UTF16Decoder) return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)); var str = ""; for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { var codeUnit = HEAP16[ptr + i * 2 >> 1]; if (codeUnit == 0) break; str += String.fromCharCode(codeUnit); } return str; }; var stringToUTF16 = (str, outPtr, maxBytesToWrite) => { maxBytesToWrite ??= 2147483647; if (maxBytesToWrite < 2) return 0; maxBytesToWrite -= 2; var startPtr = outPtr; var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length; for (var i = 0; i < numCharsToWrite; ++i) { var codeUnit = str.charCodeAt(i); HEAP16[outPtr >> 1] = codeUnit; outPtr += 2; } HEAP16[outPtr >> 1] = 0; return outPtr - startPtr; }; var lengthBytesUTF16 = str => str.length * 2; var UTF32ToString = (ptr, maxBytesToRead) => { var i = 0; var str = ""; while (!(i >= maxBytesToRead / 4)) { var utf32 = HEAP32[ptr + i * 4 >> 2]; if (utf32 == 0) break; ++i; if (utf32 >= 65536) { var ch = utf32 - 65536; str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); } else { str += String.fromCharCode(utf32); } } return str; }; var stringToUTF32 = (str, outPtr, maxBytesToWrite) => { maxBytesToWrite ??= 2147483647; if (maxBytesToWrite < 4) return 0; var startPtr = outPtr; var endPtr = startPtr + maxBytesToWrite - 4; for (var i = 0; i < str.length; ++i) { var codeUnit = str.charCodeAt(i); if (codeUnit >= 55296 && codeUnit <= 57343) { var trailSurrogate = str.charCodeAt(++i); codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023; } HEAP32[outPtr >> 2] = codeUnit; outPtr += 4; if (outPtr + 4 > endPtr) break; } HEAP32[outPtr >> 2] = 0; return outPtr - startPtr; }; var lengthBytesUTF32 = str => { var len = 0; for (var i = 0; i < str.length; ++i) { var codeUnit = str.charCodeAt(i); if (codeUnit >= 55296 && codeUnit <= 57343) ++i; len += 4; } return len; }; var __embind_register_std_wstring = (rawType, charSize, name) => { name = readLatin1String(name); var decodeString, encodeString, readCharAt, lengthBytesUTF; if (charSize === 2) { decodeString = UTF16ToString; encodeString = stringToUTF16; lengthBytesUTF = lengthBytesUTF16; readCharAt = pointer => HEAPU16[pointer >> 1]; } else if (charSize === 4) { decodeString = UTF32ToString; encodeString = stringToUTF32; lengthBytesUTF = lengthBytesUTF32; readCharAt = pointer => HEAPU32[pointer >> 2]; } registerType(rawType, { name, fromWireType: value => { var length = HEAPU32[value >> 2]; var str; var decodeStartPtr = value + 4; for (var i = 0; i <= length; ++i) { var currentBytePtr = value + 4 + i * charSize; if (i == length || readCharAt(currentBytePtr) == 0) { var maxReadBytes = currentBytePtr - decodeStartPtr; var stringSegment = decodeString(decodeStartPtr, maxReadBytes); if (str === undefined) { str = stringSegment; } else { str += String.fromCharCode(0); str += stringSegment; } decodeStartPtr = currentBytePtr + charSize; } } _free(value); return str; }, toWireType: (destructors, value) => { if (!(typeof value == "string")) { throwBindingError(`Cannot pass non-string to C++ string type ${name}`); } var length = lengthBytesUTF(value); var ptr = _malloc(4 + length + charSize); HEAPU32[ptr >> 2] = length / charSize; encodeString(value, ptr + 4, length + charSize); if (destructors !== null) { destructors.push(_free, ptr); } return ptr; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction(ptr) { _free(ptr); } }); }; var __embind_register_value_object = (rawType, name, constructorSignature, rawConstructor, destructorSignature, rawDestructor) => { structRegistrations[rawType] = { name: readLatin1String(name), rawConstructor: embind__requireFunction(constructorSignature, rawConstructor), rawDestructor: embind__requireFunction(destructorSignature, rawDestructor), fields: [] }; }; var __embind_register_value_object_field = (structType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) => { structRegistrations[structType].fields.push({ fieldName: readLatin1String(fieldName), getterReturnType, getter: embind__requireFunction(getterSignature, getter), getterContext, setterArgumentType, setter: embind__requireFunction(setterSignature, setter), setterContext }); }; var __embind_register_void = (rawType, name) => { name = readLatin1String(name); registerType(rawType, { isVoid: true, name, argPackAdvance: 0, fromWireType: () => undefined, toWireType: (destructors, o) => undefined }); }; var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num); var emval_returnValue = (returnType, destructorsRef, handle) => { var destructors = []; var result = returnType["toWireType"](destructors, handle); if (destructors.length) { HEAPU32[destructorsRef >> 2] = Emval.toHandle(destructors); } return result; }; var __emval_as = (handle, returnType, destructorsRef) => { handle = Emval.toValue(handle); returnType = requireRegisteredType(returnType, "emval::as"); return emval_returnValue(returnType, destructorsRef, handle); }; var emval_symbols = {}; var getStringOrSymbol = address => { var symbol = emval_symbols[address]; if (symbol === undefined) { return readLatin1String(address); } return symbol; }; var emval_methodCallers = []; var __emval_call_method = (caller, objHandle, methodName, destructorsRef, args) => { caller = emval_methodCallers[caller]; objHandle = Emval.toValue(objHandle); methodName = getStringOrSymbol(methodName); return caller(objHandle, objHandle[methodName], destructorsRef, args); }; var __emval_equals = (first, second) => { first = Emval.toValue(first); second = Emval.toValue(second); return first == second; }; var emval_addMethodCaller = caller => { var id = emval_methodCallers.length; emval_methodCallers.push(caller); return id; }; var emval_lookupTypes = (argCount, argTypes) => { var a = new Array(argCount); for (var i = 0; i < argCount; ++i) { a[i] = requireRegisteredType(HEAPU32[argTypes + i * 4 >> 2], "parameter " + i); } return a; }; var reflectConstruct = Reflect.construct; var __emval_get_method_caller = (argCount, argTypes, kind) => { var types = emval_lookupTypes(argCount, argTypes); var retType = types.shift(); argCount--; var functionBody = `return function (obj, func, destructorsRef, args) {\n`; var offset = 0; var argsList = []; if (kind === 0) { argsList.push("obj"); } var params = ["retType"]; var args = [retType]; for (var i = 0; i < argCount; ++i) { argsList.push("arg" + i); params.push("argType" + i); args.push(types[i]); functionBody += ` var arg${i} = argType${i}.readValueFromPointer(args${offset ? "+" + offset : ""});\n`; offset += types[i].argPackAdvance; } var invoker = kind === 1 ? "new func" : "func.call"; functionBody += ` var rv = ${invoker}(${argsList.join(", ")});\n`; if (!retType.isVoid) { params.push("emval_returnValue"); args.push(emval_returnValue); functionBody += " return emval_returnValue(retType, destructorsRef, rv);\n"; } functionBody += "};\n"; params.push(functionBody); var invokerFunction = newFunc(Function, params)(...args); var functionName = `methodCaller<(${types.map(t => t.name).join(", ")}) => ${retType.name}>`; return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction)); }; var __emval_get_property = (handle, key) => { handle = Emval.toValue(handle); key = Emval.toValue(key); return Emval.toHandle(handle[key]); }; var __emval_incref = handle => { if (handle > 9) { emval_handles[handle + 1] += 1; } }; var __emval_new_cstring = v => Emval.toHandle(getStringOrSymbol(v)); var __emval_new_object = () => Emval.toHandle({}); var __emval_run_destructors = handle => { var destructors = Emval.toValue(handle); runDestructors(destructors); __emval_decref(handle); }; var __emval_set_property = (handle, key, value) => { handle = Emval.toValue(handle); key = Emval.toValue(key); value = Emval.toValue(value); handle[key] = value; }; var __emval_take_value = (type, arg) => { type = requireRegisteredType(type, "_emval_take_value"); var v = type["readValueFromPointer"](arg); return Emval.toHandle(v); }; var getHeapMax = () => 2147483648; var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment; var growMemory = size => { var b = wasmMemory.buffer; var pages = (size - b.byteLength + 65535) / 65536 | 0; try { wasmMemory.grow(pages); updateMemoryViews(); return 1; } catch (e) { } }; var _emscripten_resize_heap = requestedSize => { var oldSize = HEAPU8.length; requestedSize >>>= 0; var maxHeapSize = getHeapMax(); if (requestedSize > maxHeapSize) { return false; } for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { var overGrownHeapSize = oldSize * (1 + .2 / cutDown); overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296); var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536)); var replacement = growMemory(newSize); if (replacement) { return true; } } return false; }; var _llvm_eh_typeid_for = type => type; var uleb128Encode = (n, target) => { if (n < 128) { target.push(n); } else { target.push(n % 128 | 128, n >> 7); } }; var sigToWasmTypes = sig => { var typeNames = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" }; var type = { parameters: [], results: sig[0] == "v" ? [] : [typeNames[sig[0]]] }; for (var i = 1; i < sig.length; ++i) { type.parameters.push(typeNames[sig[i]]); } return type; }; var generateFuncType = (sig, target) => { var sigRet = sig.slice(0, 1); var sigParam = sig.slice(1); var typeCodes = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }; target.push(96); uleb128Encode(sigParam.length, target); for (var i = 0; i < sigParam.length; ++i) { target.push(typeCodes[sigParam[i]]); } if (sigRet == "v") { target.push(0); } else { target.push(1, typeCodes[sigRet]); } }; var convertJsFunctionToWasm = (func, sig) => { if (typeof WebAssembly.Function == "function") { return new WebAssembly.Function(sigToWasmTypes(sig), func); } var typeSectionBody = [1]; generateFuncType(sig, typeSectionBody); var bytes = [0, 97, 115, 109, 1, 0, 0, 0, 1]; uleb128Encode(typeSectionBody.length, bytes); bytes.push(...typeSectionBody); bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0); var module = new WebAssembly.Module(new Uint8Array(bytes)); var instance = new WebAssembly.Instance(module, { e: { f: func } }); var wrappedFunc = instance.exports["f"]; return wrappedFunc; }; var updateTableMap = (offset, count) => { if (functionsInTableMap) { for (var i = offset; i < offset + count; i++) { var item = getWasmTableEntry(i); if (item) { functionsInTableMap.set(item, i); } } } }; var functionsInTableMap; var getFunctionAddress = func => { if (!functionsInTableMap) { functionsInTableMap = new WeakMap; updateTableMap(0, wasmTable.length); } return functionsInTableMap.get(func) || 0; }; var freeTableIndexes = []; var getEmptyTableSlot = () => { if (freeTableIndexes.length) { return freeTableIndexes.pop(); } try { wasmTable.grow(1); } catch (err) { if (!(err instanceof RangeError)) { throw err; } throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."; } return wasmTable.length - 1; }; var setWasmTableEntry = (idx, func) => { wasmTable.set(idx, func); wasmTableMirror[idx] = wasmTable.get(idx); }; var addFunction = (func, sig) => { var rtn = getFunctionAddress(func); if (rtn) { return rtn; } var ret = getEmptyTableSlot(); try { setWasmTableEntry(ret, func); } catch (err) { if (!(err instanceof TypeError)) { throw err; } var wrapped = convertJsFunctionToWasm(func, sig); setWasmTableEntry(ret, wrapped); } functionsInTableMap.set(func, ret); return ret; }; var removeFunction = index => { functionsInTableMap.delete(getWasmTableEntry(index)); setWasmTableEntry(index, null); freeTableIndexes.push(index); }; InternalError = Module["InternalError"] = class InternalError extends Error { constructor(message) { super(message); this.name = "InternalError"; } }; embind_init_charCodes(); BindingError = Module["BindingError"] = class BindingError extends Error { constructor(message) { super(message); this.name = "BindingError"; } }; init_ClassHandle(); init_RegisteredPointer(); UnboundTypeError = Module["UnboundTypeError"] = extendError(Error, "UnboundTypeError"); init_emval(); var wasmImports = { J: ___cxa_begin_catch, fa: ___cxa_end_catch, a: ___cxa_find_matching_catch_2, k: ___cxa_find_matching_catch_3, h: ___cxa_throw, e: ___resumeException, $: __abort_js, qa: __embind_finalize_value_object, _: __embind_register_bigint, na: __embind_register_bool, x: __embind_register_class, w: __embind_register_class_constructor, i: __embind_register_class_function, ma: __embind_register_emval, M: __embind_register_enum, t: __embind_register_enum_value, V: __embind_register_float, o: __embind_register_function, z: __embind_register_integer, s: __embind_register_memory_view, A: __embind_register_optional, U: __embind_register_std_string, L: __embind_register_std_wstring, B: __embind_register_value_object, ra: __embind_register_value_object_field, oa: __embind_register_void, ba: __emscripten_memcpy_js, va: __emval_as, ka: __emval_call_method, xa: __emval_decref, ua: __emval_equals, pa: __emval_get_method_caller, wa: __emval_get_property, ta: __emval_incref, E: __emval_new_cstring, X: __emval_new_object, Y: __emval_run_destructors, ya: __emval_set_property, D: __emval_take_value, aa: _emscripten_resize_heap, y: invoke_dd, G: invoke_dii, ha: invoke_diid, I: invoke_diii, v: invoke_diiiii, H: invoke_i, d: invoke_ii, b: invoke_iii, m: invoke_iiii, n: invoke_iiiii, W: invoke_iiiiii, Z: invoke_iiij, j: invoke_v, f: invoke_vi, T: invoke_vid, ca: invoke_vidi, g: invoke_vii, r: invoke_viid, ja: invoke_viidd, ia: invoke_viiddd, F: invoke_viiddi, N: invoke_viidi, la: invoke_viididi, da: invoke_viidiidid, c: invoke_viii, K: invoke_viiid, sa: invoke_viiidddi, l: invoke_viiii, O: invoke_viiiiddi, ea: invoke_viiiidi, u: invoke_viiiii, S: invoke_viiiiid, p: invoke_viiiiii, Q: invoke_viiiiiii, P: invoke_viiiiiiiii, C: invoke_viiiiiiiiidiii, q: invoke_viiiiiiiiii, R: invoke_viiiiiiiiiiiiiiiiii, ga: _llvm_eh_typeid_for }; var wasmExports = createWasm(); var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["Aa"])(); var ___getTypeName = a0 => (___getTypeName = wasmExports["Ba"])(a0); var _malloc = a0 => (_malloc = wasmExports["Da"])(a0); var _free = a0 => (_free = wasmExports["Ea"])(a0); var _setThrew = (a0, a1) => (_setThrew = wasmExports["Fa"])(a0, a1); var __emscripten_tempret_set = a0 => (__emscripten_tempret_set = wasmExports["Ga"])(a0); var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["Ha"])(a0); var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports["Ia"])(); var ___cxa_decrement_exception_refcount = a0 => (___cxa_decrement_exception_refcount = wasmExports["Ja"])(a0); var ___cxa_increment_exception_refcount = a0 => (___cxa_increment_exception_refcount = wasmExports["Ka"])(a0); var ___cxa_can_catch = (a0, a1, a2) => (___cxa_can_catch = wasmExports["La"])(a0, a1, a2); var ___cxa_get_exception_ptr = a0 => (___cxa_get_exception_ptr = wasmExports["Ma"])(a0); var dynCall_iiij = Module["dynCall_iiij"] = (a0, a1, a2, a3, a4) => (dynCall_iiij = Module["dynCall_iiij"] = wasmExports["Na"])(a0, a1, a2, a3, a4); function invoke_viii(index, a1, a2, a3) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iii(index, a1, a2) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiii(index, a1, a2, a3) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_diiiii(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vi(index, a1) { var sp = stackSave(); try { getWasmTableEntry(index)(a1); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_ii(index, a1) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_diii(index, a1, a2, a3) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vii(index, a1, a2) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiiiii(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiii(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiidddi(index, a1, a2, a3, a4, a5, a6, a7) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_v(index) { var sp = stackSave(); try { getWasmTableEntry(index)(); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiiii(index, a1, a2, a3, a4) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_dd(index, a1) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viididi(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viid(index, a1, a2, a3) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vid(index, a1, a2) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiii(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiiidiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiid(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiiiiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiii(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiii(index, a1, a2, a3, a4, a5, a6, a7) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_i(index) { var sp = stackSave(); try { return getWasmTableEntry(index)(); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiid(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viidd(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiddd(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_diid(index, a1, a2, a3) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_dii(index, a1, a2) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiidi(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiddi(index, a1, a2, a3, a4, a5, a6, a7) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viidi(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viidiidid(index, a1, a2, a3, a4, a5, a6, a7, a8) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiddi(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vidi(index, a1, a2, a3) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiij(index, a1, a2, a3, a4) { var sp = stackSave(); try { return dynCall_iiij(index, a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } Module["addFunction"] = addFunction; Module["removeFunction"] = removeFunction; var calledRun; var calledPrerun; dependenciesFulfilled = function runCaller() { if (!calledRun) run(); if (!calledRun) dependenciesFulfilled = runCaller; }; function run() { if (runDependencies > 0) { return; } if (!calledPrerun) { calledPrerun = 1; preRun(); if (runDependencies > 0) { return; } } function doRun() { if (calledRun) return; calledRun = 1; Module["calledRun"] = 1; if (ABORT) return; initRuntime(); readyPromiseResolve(Module); Module["onRuntimeInitialized"]?.(); postRun(); } if (Module["setStatus"]) { Module["setStatus"]("Running..."); setTimeout(() => { setTimeout(() => Module["setStatus"](""), 1); doRun(); }, 1); } else { doRun(); } } if (Module["preInit"]) { if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]]; while (Module["preInit"].length > 0) { Module["preInit"].pop()(); } } run(); moduleRtn = readyPromise; +var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");let dirname=import.meta.url;if(dirname.startsWith("data:")){dirname="/"}var require=createRequire(dirname)}var _ManifoldInitialized=false;Module.setup=function(){if(_ManifoldInitialized)return;_ManifoldInitialized=true;function toVec(vec,list,f=(x=>x)){if(list){for(let x of list){vec.push_back(f(x))}}return vec}function fromVec(vec,f=(x=>x)){const result=[];const size=vec.size();for(let i=0;ix)){const result=[];const nPoly=vec.size();for(let i=0;itoVec(new Module.Vector_vec2,poly,p=>{if(p instanceof Array)return{x:p[0],y:p[1]};return p}))}function disposePolygons(polygonsVec){for(let i=0;iresult.min[f]),max:["x","y"].map(f=>result.max[f])}};Module.CrossSection.prototype.offset=function(delta,joinType="Square",endType="Polygon",miterLimit=2,circularSegments=0){return this._Offset(delta,joinTypeToInt(joinType),endTypeToInt(endType),miterLimit,circularSegments)};Module.CrossSection.prototype.extrude=function(height,nDivisions=0,twistDegrees=0,scaleTop=[1,1],center=false){scaleTop=vararg2vec2([scaleTop]);const man=Module._Extrude(this._ToPolygons(),height,nDivisions,twistDegrees,scaleTop);return center?man.translate([0,0,-height/2]):man};Module.CrossSection.prototype.revolve=function(circularSegments=0,revolveDegrees=360){return Module._Revolve(this._ToPolygons(),circularSegments,revolveDegrees)};Module.CrossSection.prototype.add=function(other){return this._add(cross(other))};Module.CrossSection.prototype.subtract=function(other){return this._subtract(cross(other))};Module.CrossSection.prototype.intersect=function(other){return this._intersect(cross(other))};Module.CrossSection.prototype.toPolygons=function(){const vec=this._ToPolygons();const result=vec2polygons(vec,v=>[v.x,v.y]);vec.delete();return result};Module.Manifold.prototype.smoothOut=function(minSharpAngle=60,minSmoothness=0){return this._SmoothOut(minSharpAngle,minSmoothness)};Module.Manifold.prototype.warp=function(func){const wasmFuncPtr=addFunction(function(vec3Ptr){const x=getValue(vec3Ptr,"double");const y=getValue(vec3Ptr+8,"double");const z=getValue(vec3Ptr+16,"double");const vert=[x,y,z];func(vert);setValue(vec3Ptr,vert[0],"double");setValue(vec3Ptr+8,vert[1],"double");setValue(vec3Ptr+16,vert[2],"double")},"vi");const out=this._Warp(wasmFuncPtr);removeFunction(wasmFuncPtr);const status=out.status();if(status.value!==0){throw new Module.ManifoldError(status.value)}return out};Module.Manifold.prototype.calculateNormals=function(normalIdx,minSharpAngle=60){return this._CalculateNormals(normalIdx,minSharpAngle)};Module.Manifold.prototype.setProperties=function(numProp,func){const oldNumProp=this.numProp();const wasmFuncPtr=addFunction(function(newPtr,vec3Ptr,oldPtr){const newProp=[];for(let i=0;iresult.min[f]),max:["x","y","z"].map(f=>result.max[f])}};class Mesh{constructor({numProp=3,triVerts=new Uint32Array,vertProperties=new Float32Array,mergeFromVert,mergeToVert,runIndex,runOriginalID,faceID,halfedgeTangent,runTransform}={}){this.numProp=numProp;this.triVerts=triVerts;this.vertProperties=vertProperties;this.mergeFromVert=mergeFromVert;this.mergeToVert=mergeToVert;this.runIndex=runIndex;this.runOriginalID=runOriginalID;this.faceID=faceID;this.halfedgeTangent=halfedgeTangent;this.runTransform=runTransform}get numTri(){return this.triVerts.length/3}get numVert(){return this.vertProperties.length/this.numProp}get numRun(){return this.runOriginalID.length}merge(){const{changed,mesh}=Module._Merge(this);Object.assign(this,{...mesh});return changed}verts(tri){return this.triVerts.subarray(3*tri,3*(tri+1))}position(vert){return this.vertProperties.subarray(this.numProp*vert,this.numProp*vert+3)}extras(vert){return this.vertProperties.subarray(this.numProp*vert+3,this.numProp*(vert+1))}tangent(halfedge){return this.halfedgeTangent.subarray(4*halfedge,4*(halfedge+1))}transform(run){const mat4=new Array(16);for(const col of[0,1,2,3]){for(const row of[0,1,2]){mat4[4*col+row]=this.runTransform[12*run+3*col+row]}}mat4[15]=1;return mat4}}Module.Mesh=Mesh;Module.Manifold.prototype.getMesh=function(normalIdx=[0,0,0]){if(normalIdx instanceof Array)normalIdx={0:normalIdx[0],1:normalIdx[1],2:normalIdx[2]};return new Mesh(this._GetMeshJS(normalIdx))};Module.ManifoldError=function ManifoldError(code,...args){let message="Unknown error";switch(code){case Module.status.NonFiniteVertex.value:message="Non-finite vertex";break;case Module.status.NotManifold.value:message="Not manifold";break;case Module.status.VertexOutOfBounds.value:message="Vertex index out of bounds";break;case Module.status.PropertiesWrongLength.value:message="Properties have wrong length";break;case Module.status.MissingPositionProperties.value:message="Less than three properties";break;case Module.status.MergeVectorsDifferentLengths.value:message="Merge vectors have different lengths";break;case Module.status.MergeIndexOutOfBounds.value:message="Merge index out of bounds";break;case Module.status.TransformWrongLength.value:message="Transform vector has wrong length";break;case Module.status.RunIndexWrongLength.value:message="Run index vector has wrong length";break;case Module.status.FaceIDWrongLength.value:message="Face ID vector has wrong length";case Module.status.InvalidConstruction.value:message="Manifold constructed with invalid parameters"}const base=Error.apply(this,[message,...args]);base.name=this.name="ManifoldError";this.message=base.message;this.stack=base.stack;this.code=code};Module.ManifoldError.prototype=Object.create(Error.prototype,{constructor:{value:Module.ManifoldError,writable:true,configurable:true}});Module.CrossSection=function(polygons,fillRule="Positive"){const polygonsVec=polygons2vec(polygons);const cs=new CrossSectionCtor(polygonsVec,fillRuleToInt(fillRule));disposePolygons(polygonsVec);return cs};Module.CrossSection.ofPolygons=function(polygons,fillRule="Positive"){return new Module.CrossSection(polygons,fillRule)};Module.CrossSection.square=function(...args){let size=undefined;if(args.length==0)size={x:1,y:1};else if(typeof args[0]=="number")size={x:args[0],y:args[0]};else size=vararg2vec2(args);const center=args[1]||false;return Module._Square(size,center)};Module.CrossSection.circle=function(radius,circularSegments=0){return Module._Circle(radius,circularSegments)};function crossSectionBatchbool(name){return function(...args){if(args.length==1)args=args[0];const v=new Module.Vector_crossSection;for(const cs of args)v.push_back(cross(cs));const result=Module["_crossSection"+name](v);v.delete();return result}}Module.CrossSection.compose=crossSectionBatchbool("Compose");Module.CrossSection.union=crossSectionBatchbool("UnionN");Module.CrossSection.difference=crossSectionBatchbool("DifferenceN");Module.CrossSection.intersection=crossSectionBatchbool("IntersectionN");function pushVec2(vec,ps){toVec(vec,ps,p=>{if(p instanceof Array)return{x:p[0],y:p[1]};return p})}Module.CrossSection.hull=function(...args){if(args.length==1)args=args[0];let pts=new Module.Vector_vec2;for(const cs of args){if(cs instanceof CrossSectionCtor){Module._crossSectionCollectVertices(pts,cs)}else if(cs instanceof Array&&cs.length==2&&typeof cs[0]=="number"){pts.push_back({x:cs[0],y:cs[1]})}else if(cs.x){pts.push_back(cs)}else{const wrap=cs[0].length==2&&typeof cs[0][0]=="number"||cs[0].x;const polys=wrap?[cs]:cs;for(const poly of polys)pushVec2(pts,poly)}}const result=Module._crossSectionHullPoints(pts);pts.delete();return result};Module.CrossSection.prototype=Object.create(CrossSectionCtor.prototype);Object.defineProperty(Module.CrossSection,Symbol.hasInstance,{get:()=>t=>t instanceof CrossSectionCtor});const ManifoldCtor=Module.Manifold;Module.Manifold=function(mesh){const manifold=new ManifoldCtor(mesh);const status=manifold.status();if(status.value!==0){throw new Module.ManifoldError(status.value)}return manifold};Module.Manifold.ofMesh=function(mesh){return new Module.Manifold(mesh)};Module.Manifold.tetrahedron=function(){return Module._Tetrahedron()};Module.Manifold.cube=function(...args){let size=undefined;if(args.length==0)size={x:1,y:1,z:1};else if(typeof args[0]=="number")size={x:args[0],y:args[0],z:args[0]};else size=vararg2vec3(args);const center=args[1]||false;return Module._Cube(size,center)};Module.Manifold.cylinder=function(height,radiusLow,radiusHigh=-1,circularSegments=0,center=false){return Module._Cylinder(height,radiusLow,radiusHigh,circularSegments,center)};Module.Manifold.sphere=function(radius,circularSegments=0){return Module._Sphere(radius,circularSegments)};Module.Manifold.smooth=function(mesh,sharpenedEdges=[]){const sharp=new Module.Vector_smoothness;toVec(sharp,sharpenedEdges);const result=Module._Smooth(mesh,sharp);sharp.delete();return result};Module.Manifold.extrude=function(polygons,height,nDivisions=0,twistDegrees=0,scaleTop=[1,1],center=false){const cs=polygons instanceof CrossSectionCtor?polygons:Module.CrossSection(polygons,"Positive");return cs.extrude(height,nDivisions,twistDegrees,scaleTop,center)};Module.Manifold.revolve=function(polygons,circularSegments=0,revolveDegrees=360){const cs=polygons instanceof CrossSectionCtor?polygons:Module.CrossSection(polygons,"Positive");return cs.revolve(circularSegments,revolveDegrees)};Module.Manifold.reserveIDs=function(n){return Module._ReserveIDs(n)};Module.Manifold.compose=function(manifolds){const vec=new Module.Vector_manifold;toVec(vec,manifolds);const result=Module._manifoldCompose(vec);vec.delete();return result};function manifoldBatchbool(name){return function(...args){if(args.length==1)args=args[0];const v=new Module.Vector_manifold;for(const m of args)v.push_back(m);const result=Module["_manifold"+name+"N"](v);v.delete();return result}}Module.Manifold.union=manifoldBatchbool("Union");Module.Manifold.difference=manifoldBatchbool("Difference");Module.Manifold.intersection=manifoldBatchbool("Intersection");Module.Manifold.levelSet=function(sdf,bounds,edgeLength,level=0,tolerance=-1){const bounds2={min:{x:bounds.min[0],y:bounds.min[1],z:bounds.min[2]},max:{x:bounds.max[0],y:bounds.max[1],z:bounds.max[2]}};const wasmFuncPtr=addFunction(function(vec3Ptr){const x=getValue(vec3Ptr,"double");const y=getValue(vec3Ptr+8,"double");const z=getValue(vec3Ptr+16,"double");const vert=[x,y,z];return sdf(vert)},"di");const out=Module._LevelSet(wasmFuncPtr,bounds2,edgeLength,level,tolerance);removeFunction(wasmFuncPtr);return out};function pushVec3(vec,ps){toVec(vec,ps,p=>{if(p instanceof Array)return{x:p[0],y:p[1],z:p[2]};return p})}Module.Manifold.hull=function(...args){if(args.length==1)args=args[0];let pts=new Module.Vector_vec3;for(const m of args){if(m instanceof ManifoldCtor){Module._manifoldCollectVertices(pts,m)}else if(m instanceof Array&&m.length==3&&typeof m[0]=="number"){pts.push_back({x:m[0],y:m[1],z:m[2]})}else if(m.x){pts.push_back(m)}else{pushVec3(pts,m)}}const result=Module._manifoldHullPoints(pts);pts.delete();return result};Module.Manifold.prototype=Object.create(ManifoldCtor.prototype);Object.defineProperty(Module.Manifold,Symbol.hasInstance,{get:()=>t=>t instanceof ManifoldCtor});Module.triangulate=function(polygons,epsilon=-1){const polygonsVec=polygons2vec(polygons);const result=fromVec(Module._Triangulate(polygonsVec,epsilon),x=>[x[0],x[1],x[2]]);disposePolygons(polygonsVec);return result}};var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(!import.meta.url.startsWith("data:")){scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);var ret=fs.readFileSync(filename);return ret};readAsync=(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return new Promise((resolve,reject)=>{fs.readFile(filename,binary?undefined:"utf8",(err,data)=>{if(err)reject(err);else resolve(binary?data.buffer:data)})})};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}return fetch(url,{credentials:"same-origin"}).then(response=>{if(response.ok){return response.arrayBuffer()}return Promise.reject(new Error(response.status+" : "+response.url))})}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){var preRuns=Module["preRun"];if(preRuns){if(typeof preRuns=="function")preRuns=[preRuns];preRuns.forEach(addOnPreRun)}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){var postRuns=Module["postRun"];if(postRuns){if(typeof postRuns=="function")postRuns=[postRuns];postRuns.forEach(addOnPostRun)}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");function findWasmBinary(){if(Module["locateFile"]){var f="manifold.wasm";if(!isDataURI(f)){return locateFile(f)}return f}return new URL("manifold.wasm",import.meta.url).href}var wasmBinaryFile;function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary){return readAsync(binaryFile).then(response=>new Uint8Array(response),()=>getBinarySync(binaryFile))}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function getWasmImports(){return{a:wasmImports}}function createWasm(){var info=getWasmImports();function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["za"];updateMemoryViews();wasmTable=wasmExports["Ca"];addOnInit(wasmExports["Aa"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}wasmBinaryFile??=findWasmBinary();instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{callbacks.forEach(f=>f(Module))};function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":abort("to do getValue(i64) use WASM_BIGINT");case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=Module["noExitRuntime"]||true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":abort("to do setValue(i64) use WASM_BIGINT");case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionCaught=[];var uncaughtExceptionCount=0;var ___cxa_begin_catch=ptr=>{var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);___cxa_increment_exception_refcount(ptr);return ___cxa_get_exception_ptr(ptr)};var exceptionLast=0;var ___cxa_end_catch=()=>{_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=0};class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var ___cxa_find_matching_catch_3=arg0=>findMatchingCatch([arg0]);var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var __abort_js=()=>{abort("")};var structRegistrations={};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function readPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var InternalError;var throwInternalError=message=>{throw new InternalError(message)};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(type=>typeDependencies[type]=dependentTypes);function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i{if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}});if(0===unregisteredTypes.length){onComplete(typeConverters)}};var __embind_finalize_value_object=structType=>{var reg=structRegistrations[structType];delete structRegistrations[structType];var rawConstructor=reg.rawConstructor;var rawDestructor=reg.rawDestructor;var fieldRecords=reg.fields;var fieldTypes=fieldRecords.map(field=>field.getterReturnType).concat(fieldRecords.map(field=>field.setterArgumentType));whenDependentTypesAreResolved([structType],fieldTypes,fieldTypes=>{var fields={};fieldRecords.forEach((field,i)=>{var fieldName=field.fieldName;var getterReturnType=fieldTypes[i];var getter=field.getter;var getterContext=field.getterContext;var setterArgumentType=fieldTypes[i+fieldRecords.length];var setter=field.setter;var setterContext=field.setterContext;fields[fieldName]={read:ptr=>getterReturnType["fromWireType"](getter(getterContext,ptr)),write:(ptr,o)=>{var destructors=[];setter(setterContext,ptr,setterArgumentType["toWireType"](destructors,o));runDestructors(destructors)}}});return[{name:reg.name,fromWireType:ptr=>{var rv={};for(var i in fields){rv[i]=fields[i].read(ptr)}rawDestructor(ptr);return rv},toWireType:(destructors,o)=>{for(var fieldName in fields){if(!(fieldName in o)){throw new TypeError(`Missing field: "${fieldName}"`)}}var ptr=rawConstructor();for(fieldName in fields){fields[fieldName].write(ptr,o[fieldName])}if(destructors!==null){destructors.push(rawDestructor,ptr)}return ptr},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction:rawDestructor}]})};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{};var embind_init_charCodes=()=>{var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes};var embind_charCodes;var readLatin1String=ptr=>{var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret};var BindingError;var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var GenericWireTypeSize=8;var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=readLatin1String(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},argPackAdvance:GenericWireTypeSize,readValueFromPointer:function(pointer){return this["fromWireType"](HEAPU8[pointer])},destructorFunction:null})};var shallowCopyInternalPointer=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType});var throwInstanceAlreadyDeleted=obj=>{function getInstanceTypeName(handle){return handle.$$.ptrType.registeredClass.name}throwBindingError(getInstanceTypeName(obj)+" instance already deleted")};var finalizationRegistry=false;var detachFinalizer=handle=>{};var runDestructor=$$=>{if($$.smartPtr){$$.smartPtrType.rawDestructor($$.smartPtr)}else{$$.ptrType.registeredClass.rawDestructor($$.ptr)}};var releaseClassHandle=$$=>{$$.count.value-=1;var toDelete=0===$$.count.value;if(toDelete){runDestructor($$)}};var downcastPointer=(ptr,ptrClass,desiredClass)=>{if(ptrClass===desiredClass){return ptr}if(undefined===desiredClass.baseClass){return null}var rv=downcastPointer(ptr,ptrClass,desiredClass.baseClass);if(rv===null){return null}return desiredClass.downcast(rv)};var registeredPointers={};var registeredInstances={};var getBasestPointer=(class_,ptr)=>{if(ptr===undefined){throwBindingError("ptr should not be undefined")}while(class_.baseClass){ptr=class_.upcast(ptr);class_=class_.baseClass}return ptr};var getInheritedInstance=(class_,ptr)=>{ptr=getBasestPointer(class_,ptr);return registeredInstances[ptr]};var makeClassHandle=(prototype,record)=>{if(!record.ptrType||!record.ptr){throwInternalError("makeClassHandle requires ptr and ptrType")}var hasSmartPtrType=!!record.smartPtrType;var hasSmartPtr=!!record.smartPtr;if(hasSmartPtrType!==hasSmartPtr){throwInternalError("Both smartPtrType and smartPtr must be specified")}record.count={value:1};return attachFinalizer(Object.create(prototype,{$$:{value:record,writable:true}}))};function RegisteredPointer_fromWireType(ptr){var rawPointer=this.getPointee(ptr);if(!rawPointer){this.destructor(ptr);return null}var registeredInstance=getInheritedInstance(this.registeredClass,rawPointer);if(undefined!==registeredInstance){if(0===registeredInstance.$$.count.value){registeredInstance.$$.ptr=rawPointer;registeredInstance.$$.smartPtr=ptr;return registeredInstance["clone"]()}else{var rv=registeredInstance["clone"]();this.destructor(ptr);return rv}}function makeDefaultHandle(){if(this.isSmartPointer){return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:rawPointer,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr})}}var actualType=this.registeredClass.getActualType(rawPointer);var registeredPointerRecord=registeredPointers[actualType];if(!registeredPointerRecord){return makeDefaultHandle.call(this)}var toType;if(this.isConst){toType=registeredPointerRecord.constPointerType}else{toType=registeredPointerRecord.pointerType}var dp=downcastPointer(rawPointer,this.registeredClass,toType.registeredClass);if(dp===null){return makeDefaultHandle.call(this)}if(this.isSmartPointer){return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp})}}var attachFinalizer=handle=>{if("undefined"===typeof FinalizationRegistry){attachFinalizer=handle=>handle;return handle}finalizationRegistry=new FinalizationRegistry(info=>{releaseClassHandle(info.$$)});attachFinalizer=handle=>{var $$=handle.$$;var hasSmartPtr=!!$$.smartPtr;if(hasSmartPtr){var info={$$};finalizationRegistry.register(handle,info,handle)}return handle};detachFinalizer=handle=>finalizationRegistry.unregister(handle);return attachFinalizer(handle)};var deletionQueue=[];var flushPendingDeletes=()=>{while(deletionQueue.length){var obj=deletionQueue.pop();obj.$$.deleteScheduled=false;obj["delete"]()}};var delayFunction;var init_ClassHandle=()=>{Object.assign(ClassHandle.prototype,{isAliasOf(other){if(!(this instanceof ClassHandle)){return false}if(!(other instanceof ClassHandle)){return false}var leftClass=this.$$.ptrType.registeredClass;var left=this.$$.ptr;other.$$=other.$$;var rightClass=other.$$.ptrType.registeredClass;var right=other.$$.ptr;while(leftClass.baseClass){left=leftClass.upcast(left);leftClass=leftClass.baseClass}while(rightClass.baseClass){right=rightClass.upcast(right);rightClass=rightClass.baseClass}return leftClass===rightClass&&left===right},clone(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.preservePointerOnDelete){this.$$.count.value+=1;return this}else{var clone=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));clone.$$.count.value+=1;clone.$$.deleteScheduled=false;return clone}},delete(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}detachFinalizer(this);releaseClassHandle(this.$$);if(!this.$$.preservePointerOnDelete){this.$$.smartPtr=undefined;this.$$.ptr=undefined}},isDeleted(){return!this.$$.ptr},deleteLater(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}deletionQueue.push(this);if(deletionQueue.length===1&&delayFunction){delayFunction(flushPendingDeletes)}this.$$.deleteScheduled=true;return this}})};function ClassHandle(){}var createNamedFunction=(name,body)=>Object.defineProperty(body,"name",{value:name});var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(...args){if(!proto[methodName].overloadTable.hasOwnProperty(args.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[args.length].apply(this,args)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;if(undefined!==numArguments){Module[name].numArguments=numArguments}}};var char_0=48;var char_9=57;var makeLegalFunctionName=name=>{name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return`_${name}`}return name};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]}var upcastPointer=(ptr,ptrClass,desiredClass)=>{while(ptrClass!==desiredClass){if(!ptrClass.upcast){throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`)}ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr};function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null){destructors.push(this.rawDestructor,ptr)}return ptr}else{return 0}}if(!handle||!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(!this.isConst&&handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr){throwBindingError("Passing raw pointer to smart pointer is illegal")}switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(()=>clonedHandle["delete"]()));if(destructors!==null){destructors.push(this.rawDestructor,ptr)}}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr}function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(ptr){if(this.rawGetPointee){ptr=this.rawGetPointee(ptr)}return ptr},destructor(ptr){this.rawDestructor?.(ptr)},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,fromWireType:RegisteredPointer_fromWireType})};function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&®isteredClass.baseClass===undefined){if(isConst){this["toWireType"]=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this["toWireType"]=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}}else{this["toWireType"]=genericPointerToWireType}}var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistent public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var dynCallLegacy=(sig,ptr,args)=>{sig=sig.replace(/p/g,"i");var f=Module["dynCall_"+sig];return f(ptr,...args)};var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var dynCall=(sig,ptr,args=[])=>{if(sig.includes("j")){return dynCallLegacy(sig,ptr,args)}var rtn=getWasmTableEntry(ptr)(...args);return rtn};var getDynCaller=(sig,ptr)=>(...args)=>dynCall(sig,ptr,args);var embind__requireFunction=(signature,rawFunction)=>{signature=readLatin1String(signature);function makeDynCaller(){if(signature.includes("j")){return getDynCaller(signature,rawFunction)}return getWasmTableEntry(rawFunction)}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};var extendError=(baseErrorType,errorName)=>{var errorClass=createNamedFunction(errorName,function(message){this.name=errorName;this.message=message;var stack=new Error(message).stack;if(stack!==undefined){this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")}});errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=function(){if(this.message===undefined){return this.name}else{return`${this.name}: ${this.message}`}};return errorClass};var UnboundTypeError;var getTypeName=type=>{var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv};var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var __embind_register_class=(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor)=>{name=readLatin1String(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);upcast&&=embind__requireFunction(upcastSignature,upcast);downcast&&=embind__requireFunction(downcastSignature,downcast);rawDestructor=embind__requireFunction(destructorSignature,rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError(`Cannot construct ${name} due to unbound types`,[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],base=>{base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else{basePrototype=ClassHandle.prototype}var constructor=createNamedFunction(name,function(...args){if(Object.getPrototypeOf(this)!==instancePrototype){throw new BindingError("Use 'new' to construct "+name)}if(undefined===registeredClass.constructor_body){throw new BindingError(name+" has no accessible constructor")}var body=registeredClass.constructor_body[args.length];if(undefined===body){throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`)}return body.apply(this,args)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){registeredClass.baseClass.__derivedClasses??=[];registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter=new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})};var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i>2])}return array};function usesDestructorStack(argTypes){for(var i=1;i{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);invoker=embind__requireFunction(invokerSignature,invoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`constructor ${classType.name}`;if(undefined===classType.registeredClass.constructor_body){classType.registeredClass.constructor_body=[]}if(undefined!==classType.registeredClass.constructor_body[argCount-1]){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!`)}classType.registeredClass.constructor_body[argCount-1]=()=>{throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`,rawArgTypes)};whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{argTypes.splice(1,0,null);classType.registeredClass.constructor_body[argCount-1]=craftInvokerFunction(humanName,argTypes,null,invoker,rawConstructor);return[]});return[]})};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex!==-1){return signature.substr(0,argsIndex)}else{return signature}};var __embind_register_class_function=(rawClassType,methodName,argCount,rawArgTypesAddr,invokerSignature,rawInvoker,context,isPureVirtual,isAsync,isNonnullReturn)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);methodName=readLatin1String(methodName);methodName=getFunctionName(methodName);rawInvoker=embind__requireFunction(invokerSignature,rawInvoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`${classType.name}.${methodName}`;if(methodName.startsWith("@@")){methodName=Symbol[methodName.substring(2)]}if(isPureVirtual){classType.registeredClass.pureVirtualFunctions.push(methodName)}function unboundTypesHandler(){throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`,rawArgTypes)}var proto=classType.registeredClass.instancePrototype;var method=proto[methodName];if(undefined===method||undefined===method.overloadTable&&method.className!==classType.name&&method.argCount===argCount-2){unboundTypesHandler.argCount=argCount-2;unboundTypesHandler.className=classType.name;proto[methodName]=unboundTypesHandler}else{ensureOverloadTable(proto,methodName,humanName);proto[methodName].overloadTable[argCount-2]=unboundTypesHandler}whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{var memberFunction=craftInvokerFunction(humanName,argTypes,classType,rawInvoker,context,isAsync);if(undefined===proto[methodName].overloadTable){memberFunction.argCount=argCount-2;proto[methodName]=memberFunction}else{proto[methodName].overloadTable[argCount-2]=memberFunction}return[]});return[]})};var emval_freelist=[];var emval_handles=[];var __emval_decref=handle=>{if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}};var count_emval_handles=()=>emval_handles.length/2-5-emval_freelist.length;var init_emval=()=>{emval_handles.push(0,1,undefined,1,null,1,true,1,false,1);Module["count_emval_handles"]=count_emval_handles};var Emval={toValue:handle=>{if(!handle){throwBindingError("Cannot use deleted val. handle = "+handle)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction:null};var __embind_register_emval=rawType=>registerType(rawType,EmValType);var enumReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?function(pointer){return this["fromWireType"](HEAP8[pointer])}:function(pointer){return this["fromWireType"](HEAPU8[pointer])};case 2:return signed?function(pointer){return this["fromWireType"](HEAP16[pointer>>1])}:function(pointer){return this["fromWireType"](HEAPU16[pointer>>1])};case 4:return signed?function(pointer){return this["fromWireType"](HEAP32[pointer>>2])}:function(pointer){return this["fromWireType"](HEAPU32[pointer>>2])};default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_enum=(rawType,name,size,isSigned)=>{name=readLatin1String(name);function ctor(){}ctor.values={};registerType(rawType,{name,constructor:ctor,fromWireType:function(c){return this.constructor.values[c]},toWireType:(destructors,c)=>c.value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor)};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};var __embind_register_enum_value=(rawEnumType,name,enumValue)=>{var enumType=requireRegisteredType(rawEnumType,"enum");name=readLatin1String(name);var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(`${enumType.name}_${name}`,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value};var embindRepr=v=>{if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}};var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 8:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=readLatin1String(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_function=(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync,isNonnullReturn)=>{var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=readLatin1String(name);name=getFunctionName(name);rawInvoker=embind__requireFunction(signature,rawInvoker);exposePublicSymbol(name,function(){throwUnboundTypeError(`Cannot call ${name} due to unbound types`,argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,argTypes=>{var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})};var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer]:pointer=>HEAPU8[pointer];case 2:return signed?pointer=>HEAP16[pointer>>1]:pointer=>HEAPU16[pointer>>1];case 4:return signed?pointer=>HEAP32[pointer>>2]:pointer=>HEAPU32[pointer>>2];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_integer=(primitiveType,name,size,minRange,maxRange)=>{name=readLatin1String(name);if(maxRange===-1){maxRange=4294967295}var fromWireType=value=>value;if(minRange===0){var bitshift=32-8*size;fromWireType=value=>value<>>bitshift}var isUnsignedType=name.includes("unsigned");var checkAssertions=(value,toTypeName)=>{};var toWireType;if(isUnsignedType){toWireType=function(destructors,value){checkAssertions(value,this.name);return value>>>0}}else{toWireType=function(destructors,value){checkAssertions(value,this.name);return value}}registerType(primitiveType,{name,fromWireType,toWireType,argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=readLatin1String(name);registerType(rawType,{name,fromWireType:decodeMemoryView,argPackAdvance:GenericWireTypeSize,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})};var EmValOptionalType=Object.assign({optional:true},EmValType);var __embind_register_optional=(rawOptionalType,rawType)=>{registerType(rawOptionalType,EmValOptionalType)};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var __embind_register_std_string=(rawType,name)=>{name=readLatin1String(name);var stdStringIsUTF8=name==="std::string";registerType(rawType,{name,fromWireType(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment=UTF8ToString(decodeStartPtr,maxRead);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i>2]=length;if(stdStringIsUTF8&&valueIsOfTypeString){stringToUTF8(value,ptr,length+1)}else{if(valueIsOfTypeString){for(var i=0;i255){_free(ptr);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}else{for(var i=0;i{var endPtr=ptr;var idx=endPtr>>1;var maxIdx=idx+maxBytesToRead/2;while(!(idx>=maxIdx)&&HEAPU16[idx])++idx;endPtr=idx<<1;if(endPtr-ptr>32&&UTF16Decoder)return UTF16Decoder.decode(HEAPU8.subarray(ptr,endPtr));var str="";for(var i=0;!(i>=maxBytesToRead/2);++i){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead)=>{var i=0;var str="";while(!(i>=maxBytesToRead/4)){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)break;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=readLatin1String(name);var decodeString,encodeString,readCharAt,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;readCharAt=pointer=>HEAPU16[pointer>>1]}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;readCharAt=pointer=>HEAPU32[pointer>>2]}registerType(rawType,{name,fromWireType:value=>{var length=HEAPU32[value>>2];var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||readCharAt(currentBytePtr)==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length/charSize;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_value_object=(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor)=>{structRegistrations[rawType]={name:readLatin1String(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}};var __embind_register_value_object_field=(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext)=>{structRegistrations[structType].fields.push({fieldName:readLatin1String(fieldName),getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext,setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext})};var __embind_register_void=(rawType,name)=>{name=readLatin1String(name);registerType(rawType,{isVoid:true,name,argPackAdvance:0,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var __emscripten_memcpy_js=(dest,src,num)=>HEAPU8.copyWithin(dest,src,src+num);var emval_returnValue=(returnType,destructorsRef,handle)=>{var destructors=[];var result=returnType["toWireType"](destructors,handle);if(destructors.length){HEAPU32[destructorsRef>>2]=Emval.toHandle(destructors)}return result};var __emval_as=(handle,returnType,destructorsRef)=>{handle=Emval.toValue(handle);returnType=requireRegisteredType(returnType,"emval::as");return emval_returnValue(returnType,destructorsRef,handle)};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return readLatin1String(address)}return symbol};var emval_methodCallers=[];var __emval_call_method=(caller,objHandle,methodName,destructorsRef,args)=>{caller=emval_methodCallers[caller];objHandle=Emval.toValue(objHandle);methodName=getStringOrSymbol(methodName);return caller(objHandle,objHandle[methodName],destructorsRef,args)};var __emval_equals=(first,second)=>{first=Emval.toValue(first);second=Emval.toValue(second);return first==second};var emval_addMethodCaller=caller=>{var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var emval_lookupTypes=(argCount,argTypes)=>{var a=new Array(argCount);for(var i=0;i>2],"parameter "+i)}return a};var reflectConstruct=Reflect.construct;var __emval_get_method_caller=(argCount,argTypes,kind)=>{var types=emval_lookupTypes(argCount,argTypes);var retType=types.shift();argCount--;var functionBody=`return function (obj, func, destructorsRef, args) {\n`;var offset=0;var argsList=[];if(kind===0){argsList.push("obj")}var params=["retType"];var args=[retType];for(var i=0;it.name).join(", ")}) => ${retType.name}>`;return emval_addMethodCaller(createNamedFunction(functionName,invokerFunction))};var __emval_get_property=(handle,key)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);return Emval.toHandle(handle[key])};var __emval_incref=handle=>{if(handle>9){emval_handles[handle+1]+=1}};var __emval_new_cstring=v=>Emval.toHandle(getStringOrSymbol(v));var __emval_new_object=()=>Emval.toHandle({});var __emval_run_destructors=handle=>{var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var __emval_set_property=(handle,key,value)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);value=Emval.toValue(value);handle[key]=value};var __emval_take_value=(type,arg)=>{type=requireRegisteredType(type,"_emval_take_value");var v=type["readValueFromPointer"](arg);return Emval.toHandle(v)};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var _llvm_eh_typeid_for=type=>type;var uleb128Encode=(n,target)=>{if(n<128){target.push(n)}else{target.push(n%128|128,n>>7)}};var sigToWasmTypes=sig=>{var typeNames={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"};var type={parameters:[],results:sig[0]=="v"?[]:[typeNames[sig[0]]]};for(var i=1;i{var sigRet=sig.slice(0,1);var sigParam=sig.slice(1);var typeCodes={i:127,p:127,j:126,f:125,d:124,e:111};target.push(96);uleb128Encode(sigParam.length,target);for(var i=0;i{if(typeof WebAssembly.Function=="function"){return new WebAssembly.Function(sigToWasmTypes(sig),func)}var typeSectionBody=[1];generateFuncType(sig,typeSectionBody);var bytes=[0,97,115,109,1,0,0,0,1];uleb128Encode(typeSectionBody.length,bytes);bytes.push(...typeSectionBody);bytes.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module=new WebAssembly.Module(new Uint8Array(bytes));var instance=new WebAssembly.Instance(module,{e:{f:func}});var wrappedFunc=instance.exports["f"];return wrappedFunc};var updateTableMap=(offset,count)=>{if(functionsInTableMap){for(var i=offset;i{if(!functionsInTableMap){functionsInTableMap=new WeakMap;updateTableMap(0,wasmTable.length)}return functionsInTableMap.get(func)||0};var freeTableIndexes=[];var getEmptyTableSlot=()=>{if(freeTableIndexes.length){return freeTableIndexes.pop()}try{wasmTable.grow(1)}catch(err){if(!(err instanceof RangeError)){throw err}throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return wasmTable.length-1};var setWasmTableEntry=(idx,func)=>{wasmTable.set(idx,func);wasmTableMirror[idx]=wasmTable.get(idx)};var addFunction=(func,sig)=>{var rtn=getFunctionAddress(func);if(rtn){return rtn}var ret=getEmptyTableSlot();try{setWasmTableEntry(ret,func)}catch(err){if(!(err instanceof TypeError)){throw err}var wrapped=convertJsFunctionToWasm(func,sig);setWasmTableEntry(ret,wrapped)}functionsInTableMap.set(func,ret);return ret};var removeFunction=index=>{functionsInTableMap.delete(getWasmTableEntry(index));setWasmTableEntry(index,null);freeTableIndexes.push(index)};InternalError=Module["InternalError"]=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};embind_init_charCodes();BindingError=Module["BindingError"]=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};init_ClassHandle();init_RegisteredPointer();UnboundTypeError=Module["UnboundTypeError"]=extendError(Error,"UnboundTypeError");init_emval();var wasmImports={J:___cxa_begin_catch,fa:___cxa_end_catch,a:___cxa_find_matching_catch_2,k:___cxa_find_matching_catch_3,h:___cxa_throw,e:___resumeException,$:__abort_js,qa:__embind_finalize_value_object,_:__embind_register_bigint,na:__embind_register_bool,x:__embind_register_class,w:__embind_register_class_constructor,i:__embind_register_class_function,ma:__embind_register_emval,M:__embind_register_enum,t:__embind_register_enum_value,V:__embind_register_float,o:__embind_register_function,z:__embind_register_integer,s:__embind_register_memory_view,A:__embind_register_optional,U:__embind_register_std_string,L:__embind_register_std_wstring,B:__embind_register_value_object,ra:__embind_register_value_object_field,oa:__embind_register_void,ba:__emscripten_memcpy_js,va:__emval_as,ka:__emval_call_method,xa:__emval_decref,ua:__emval_equals,pa:__emval_get_method_caller,wa:__emval_get_property,ta:__emval_incref,E:__emval_new_cstring,X:__emval_new_object,Y:__emval_run_destructors,ya:__emval_set_property,D:__emval_take_value,aa:_emscripten_resize_heap,y:invoke_dd,G:invoke_dii,ha:invoke_diid,I:invoke_diii,v:invoke_diiiii,H:invoke_i,d:invoke_ii,b:invoke_iii,m:invoke_iiii,n:invoke_iiiii,W:invoke_iiiiii,Z:invoke_iiij,j:invoke_v,f:invoke_vi,T:invoke_vid,ca:invoke_vidi,g:invoke_vii,r:invoke_viid,ja:invoke_viidd,ia:invoke_viiddd,F:invoke_viiddi,N:invoke_viidi,la:invoke_viididi,da:invoke_viidiidid,c:invoke_viii,K:invoke_viiid,sa:invoke_viiidddi,l:invoke_viiii,O:invoke_viiiiddi,ea:invoke_viiiidi,u:invoke_viiiii,S:invoke_viiiiid,p:invoke_viiiiii,Q:invoke_viiiiiii,P:invoke_viiiiiiiii,C:invoke_viiiiiiiiidiii,q:invoke_viiiiiiiiii,R:invoke_viiiiiiiiiiiiiiiiii,ga:_llvm_eh_typeid_for};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["Aa"])();var ___getTypeName=a0=>(___getTypeName=wasmExports["Ba"])(a0);var _malloc=a0=>(_malloc=wasmExports["Da"])(a0);var _free=a0=>(_free=wasmExports["Ea"])(a0);var _setThrew=(a0,a1)=>(_setThrew=wasmExports["Fa"])(a0,a1);var __emscripten_tempret_set=a0=>(__emscripten_tempret_set=wasmExports["Ga"])(a0);var __emscripten_stack_restore=a0=>(__emscripten_stack_restore=wasmExports["Ha"])(a0);var _emscripten_stack_get_current=()=>(_emscripten_stack_get_current=wasmExports["Ia"])();var ___cxa_decrement_exception_refcount=a0=>(___cxa_decrement_exception_refcount=wasmExports["Ja"])(a0);var ___cxa_increment_exception_refcount=a0=>(___cxa_increment_exception_refcount=wasmExports["Ka"])(a0);var ___cxa_can_catch=(a0,a1,a2)=>(___cxa_can_catch=wasmExports["La"])(a0,a1,a2);var ___cxa_get_exception_ptr=a0=>(___cxa_get_exception_ptr=wasmExports["Ma"])(a0);var dynCall_iiij=Module["dynCall_iiij"]=(a0,a1,a2,a3,a4)=>(dynCall_iiij=Module["dynCall_iiij"]=wasmExports["Na"])(a0,a1,a2,a3,a4);function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiidddi(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_dd(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viididi(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viid(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vid(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiidiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiid(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiid(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidd(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiddd(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diid(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_dii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiidi(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiddi(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidi(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidiidid(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiddi(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vidi(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiij(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiij(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}Module["addFunction"]=addFunction;Module["removeFunction"]=removeFunction;var calledRun;var calledPrerun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}if(!calledPrerun){calledPrerun=1;preRun();if(runDependencies>0){return}}function doRun(){if(calledRun)return;calledRun=1;Module["calledRun"]=1;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise; - return moduleRtn; - } - ); + return moduleRtn; +} +); })(); export default Module; diff --git a/bindings/wasm/manifold.wasm b/bindings/wasm/manifold.wasm index 93b023ed21f8f27f047633668d7ad00cd6ef30ad..b6c5b4cfc032d415a11e8852e8b018bf9d94388d 100755 GIT binary patch delta 2091 zcmYLJYiv|S6rM9P_p$fx!mVtf^r5rcLR&3;5kLWBCl(b!D^RMzh$X@g+YnLF5NTXO z8weByTcBJ}X>5 z;)sCC8l?GlKm>%dTR0l!cnx`maNKm9U9&?a255dPYT}aondYQrv-2XRD`+Zv+i7)V zS8dLO+WMhL04w|WUGL>|c%pB|u1LTYmdtMw;H?6=>L)76WJ+X@h2EkjVU^H)K_wG5 zZjj!WC%7aypjq;ndBTvk2zYl%b?zxMpX0tQ6*@3E+Sl^hqT z3o_hedKqB}m`rofu*o!x#ww-ZDa@8TEkQ6caVN|5@T`^4qA0-*ktjzmoTu3xySb<( z_lF2pk8Fga6*W(0HQjNRw77Fgabe{IT4VId^ znpMNFTDqE5K%3gWn&r&e@EMiAo+9!Zk=KdDpEpAGXGvnB1Os4W05D-&E8!W0Cr za#jgZi$EuV;;{UNF8kU(Sf^&x z2e!aZ{`d8Pq33A-}B48Mgq6{JG2>rcmnF znXYL;q2Ca4M+1E6FCF0)6#MHYxi1BLevf-}iMJQ7Y$HUEM>Z2Oyh)wh?Jms9yF-7n z2>Ia+LONd~q)Oep$DJ|fv9}3X^?FJg+)9YXIxI8Sa_!r+Jr%kFwHe>=rvK+UCh1pa z_qfwy>9n%{bL!5`=(Q#@E~N7w#2m@|m{(hY8f|;hSnD;`YiZk`^2;54)O{{P>IL*X zv(Ru5)&EuJzq8i`D0mYapm%W$g`eR3E!1T2S#|h5cVfYeGC~qa-$c4-Cn1eE--15f zuazp)=}s#cN=pu)ZAnXJO~|x#iIyBfsIx3adonEvm8T@v)nP4JiBL;!M_aZlwa`~- zNsr3za_@kPN_M$ZviDb{l+|eWqf%F&P_J~k6SJpRrKoTvA%CQ)h3XVip+(jIyVm*H I``qpJzfDjjod5s; delta 2011 zcmY*ZeN0wW7(dVXxc7bE`=XZsMG(913n-)r2>FqvoQ9g@7l!?jQ*oAm;F?)x>Xv&ij1)e$U5w?m74O zp0S_zjP;YH@4N|w5a<@KHu(QAjf#qLd>Z<5BWn54d8^MoKgc;TC^fy*O9c&*s%1J4w;W# zrl&gquf!#lP{A@5h&b=aqps(X38$)EyVkYAb!~d)yR6N)u?kwAN@UK8ppix#CSf`+ zkThV@0!K(%6hq{eD>Q?WpintId6~`GRMfE!yPJ_ zV`4XSda@)AmmbGsPtsiMBoGQx_H`P^k?g4MgEU{AuY_dP(aT4~gmX)OS&%t~YPn8R zas<|z>u1*EYL4N+c$$cUji>P_j7%Cofq7($=@1>Y&zBSjx|g&d;ROzEUmF?ftv!6= z6z$ggH5}|bLjz-y9AVGZ`^qUxBZDm)li(KZ1xYq1Xoc9gJA1Js+=d&pa~Bw@xQdPQ z-akp@)lB&pQA^jc#LV8%EP9Vpc`#N|S=kXn|0WKRp~v>fKjS5no79CWmYB2^@ohg6 z*+=9*VSJEmi^ss->QNONI;<@me}~AsQMfu8;Wm|B{Xh6#6y6kr*^j6t2oLWFM-LGB zAPQeQPURVNUs8?LY$V)NC#qR0^s3w%mZa`gv%wMFuEzNisp*@2m@&l2g!^h?4a*YW zV#~FvxQ-1|`)XKR$bLU$yO(QNBfte!wvo+;AJmr{S-rT5^gUsCc`Z9mMK?N5hT|vI zu{iim&8}lPSb9SpM)#}OdX@;=)HC&LCJd<6^(;537eg+B{2ufi?Lo52Ck@%%MP-%h ztjE|o)mP8jW_@^>$X`KTkJ7rI!fAbSn#u@pBMLNI2y`LPh!HnI_C$e08aRu6|^ zy;I_S@Dtp2`?7tj=#&{mg2W8kS)~np+!V4FUMt-8INc z8Rd37YpwIT`BSZL-tf0V?+!xrn%AJbd#%N>Nu%}0gpg~^gtRphlB3q{wWbx9>>{Lc ztELg+|A-K6|5w*^?c1_59J&^{QQyNYPjnp<@~c7ntjQITw6g0IwdP0pniE|&BYBTu zj!=HgtEGb+EssQO&DXZBrDa#xFL!rR>+LA03urxB=%F9kkGpd(?Xv(7O5qs%rXqX~;j|V)N>Sg6K0UAX>cuu|a>_u2@)^qV2&E`1I?`rM zIfkarvJB;=2*p1(Ou41{HDx`Tnv#ifOl!E%xd`R3Dr&bzh5o=uiCA=gvq&KC@zPPI}vD+@*S}9VoJw7acy#o4p=)q{{q?74x#`6 diff --git a/include/manifold/cross_section.h b/include/manifold/cross_section.h index dab68146c9..0a759c7d09 100644 --- a/include/manifold/cross_section.h +++ b/include/manifold/cross_section.h @@ -122,8 +122,10 @@ class CrossSection { (relative to the offset distance), these are 'squared' instead. */ }; - CrossSection Offset(double delta, JoinType jt, double miter_limit = 2.0, - int circularSegments = 0) const; + enum class EndType { Polygon, Joined, Butt, Square, Round }; + + CrossSection Offset(double delta, JoinType jt, EndType et, + double miter_limit = 2.0, int circularSegments = 0) const; ///@} /** @name Boolean diff --git a/src/cross_section/cross_section.cpp b/src/cross_section/cross_section.cpp index f46013433c..3278bf6635 100644 --- a/src/cross_section/cross_section.cpp +++ b/src/cross_section/cross_section.cpp @@ -82,6 +82,27 @@ C2::JoinType jt(CrossSection::JoinType jointype) { return jt; } +C2::EndType et(CrossSection::EndType endtype) { + C2::EndType et = C2::EndType::Polygon; + switch (endtype) { + case CrossSection::EndType::Polygon: + break; + case CrossSection::EndType::Joined: + et = C2::EndType::Joined; + break; + case CrossSection::EndType::Butt: + et = C2::EndType::Butt; + break; + case CrossSection::EndType::Square: + et = C2::EndType::Square; + break; + case CrossSection::EndType::Round: + et = C2::EndType::Round; + break; + }; + return et; +} + vec2 v2_of_pd(const C2::PointD p) { return {p.x, p.y}; } C2::PointD v2_to_pd(const vec2 v) { return C2::PointD(v.x, v.y); } @@ -654,7 +675,7 @@ CrossSection CrossSection::Simplify(double epsilon) const { * defaults according to the radius. */ CrossSection CrossSection::Offset(double delta, JoinType jointype, - double miter_limit, + EndType endtype, double miter_limit, int circularSegments) const { double arc_tol = 0.; if (jointype == JoinType::Round) { @@ -667,9 +688,8 @@ CrossSection CrossSection::Offset(double delta, JoinType jointype, const double scaled_delta = abs_delta * std::pow(10, precision_); arc_tol = (std::cos(Clipper2Lib::PI / n) - 1) * -scaled_delta; } - auto ps = - C2::InflatePaths(GetPaths()->paths_, delta, jt(jointype), - C2::EndType::Polygon, miter_limit, precision_, arc_tol); + auto ps = C2::InflatePaths(GetPaths()->paths_, delta, jt(jointype), + et(endtype), miter_limit, precision_, arc_tol); return CrossSection(shared_paths(ps)); } diff --git a/test/cross_section_test.cpp b/test/cross_section_test.cpp index 7ff81a6df0..28c82e070d 100644 --- a/test/cross_section_test.cpp +++ b/test/cross_section_test.cpp @@ -49,7 +49,8 @@ TEST(CrossSection, MirrorUnion) { TEST(CrossSection, RoundOffset) { auto a = CrossSection::Square({20., 20.}, true); int segments = 20; - auto rounded = a.Offset(5., CrossSection::JoinType::Round, 2, segments); + auto rounded = a.Offset(5., CrossSection::JoinType::Round, + CrossSection::EndType::Polygon, 2, segments); auto result = Manifold::Extrude(rounded.ToPolygons(), 5.); #ifdef MANIFOLD_EXPORT From cca493aa51e4ff1e7e49712a6c76e6a328b386f3 Mon Sep 17 00:00:00 2001 From: David Altenburg Date: Fri, 15 Nov 2024 13:11:43 -0800 Subject: [PATCH 2/3] Remove `if (ENVIRONMENT_IS_NODE) {...}` block that messes up esbuild --- bindings/wasm/manifold.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/wasm/manifold.js b/bindings/wasm/manifold.js index 3ecbe53a70..d20d820b56 100644 --- a/bindings/wasm/manifold.js +++ b/bindings/wasm/manifold.js @@ -1,16 +1,16 @@ var Module = (() => { var _scriptName = import.meta.url; - + return ( -async function(moduleArg = {}) { - var moduleRtn; + async function (moduleArg = {}) { + var moduleRtn; -var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;var readyPromise=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");let dirname=import.meta.url;if(dirname.startsWith("data:")){dirname="/"}var require=createRequire(dirname)}var _ManifoldInitialized=false;Module.setup=function(){if(_ManifoldInitialized)return;_ManifoldInitialized=true;function toVec(vec,list,f=(x=>x)){if(list){for(let x of list){vec.push_back(f(x))}}return vec}function fromVec(vec,f=(x=>x)){const result=[];const size=vec.size();for(let i=0;ix)){const result=[];const nPoly=vec.size();for(let i=0;itoVec(new Module.Vector_vec2,poly,p=>{if(p instanceof Array)return{x:p[0],y:p[1]};return p}))}function disposePolygons(polygonsVec){for(let i=0;iresult.min[f]),max:["x","y"].map(f=>result.max[f])}};Module.CrossSection.prototype.offset=function(delta,joinType="Square",endType="Polygon",miterLimit=2,circularSegments=0){return this._Offset(delta,joinTypeToInt(joinType),endTypeToInt(endType),miterLimit,circularSegments)};Module.CrossSection.prototype.extrude=function(height,nDivisions=0,twistDegrees=0,scaleTop=[1,1],center=false){scaleTop=vararg2vec2([scaleTop]);const man=Module._Extrude(this._ToPolygons(),height,nDivisions,twistDegrees,scaleTop);return center?man.translate([0,0,-height/2]):man};Module.CrossSection.prototype.revolve=function(circularSegments=0,revolveDegrees=360){return Module._Revolve(this._ToPolygons(),circularSegments,revolveDegrees)};Module.CrossSection.prototype.add=function(other){return this._add(cross(other))};Module.CrossSection.prototype.subtract=function(other){return this._subtract(cross(other))};Module.CrossSection.prototype.intersect=function(other){return this._intersect(cross(other))};Module.CrossSection.prototype.toPolygons=function(){const vec=this._ToPolygons();const result=vec2polygons(vec,v=>[v.x,v.y]);vec.delete();return result};Module.Manifold.prototype.smoothOut=function(minSharpAngle=60,minSmoothness=0){return this._SmoothOut(minSharpAngle,minSmoothness)};Module.Manifold.prototype.warp=function(func){const wasmFuncPtr=addFunction(function(vec3Ptr){const x=getValue(vec3Ptr,"double");const y=getValue(vec3Ptr+8,"double");const z=getValue(vec3Ptr+16,"double");const vert=[x,y,z];func(vert);setValue(vec3Ptr,vert[0],"double");setValue(vec3Ptr+8,vert[1],"double");setValue(vec3Ptr+16,vert[2],"double")},"vi");const out=this._Warp(wasmFuncPtr);removeFunction(wasmFuncPtr);const status=out.status();if(status.value!==0){throw new Module.ManifoldError(status.value)}return out};Module.Manifold.prototype.calculateNormals=function(normalIdx,minSharpAngle=60){return this._CalculateNormals(normalIdx,minSharpAngle)};Module.Manifold.prototype.setProperties=function(numProp,func){const oldNumProp=this.numProp();const wasmFuncPtr=addFunction(function(newPtr,vec3Ptr,oldPtr){const newProp=[];for(let i=0;iresult.min[f]),max:["x","y","z"].map(f=>result.max[f])}};class Mesh{constructor({numProp=3,triVerts=new Uint32Array,vertProperties=new Float32Array,mergeFromVert,mergeToVert,runIndex,runOriginalID,faceID,halfedgeTangent,runTransform}={}){this.numProp=numProp;this.triVerts=triVerts;this.vertProperties=vertProperties;this.mergeFromVert=mergeFromVert;this.mergeToVert=mergeToVert;this.runIndex=runIndex;this.runOriginalID=runOriginalID;this.faceID=faceID;this.halfedgeTangent=halfedgeTangent;this.runTransform=runTransform}get numTri(){return this.triVerts.length/3}get numVert(){return this.vertProperties.length/this.numProp}get numRun(){return this.runOriginalID.length}merge(){const{changed,mesh}=Module._Merge(this);Object.assign(this,{...mesh});return changed}verts(tri){return this.triVerts.subarray(3*tri,3*(tri+1))}position(vert){return this.vertProperties.subarray(this.numProp*vert,this.numProp*vert+3)}extras(vert){return this.vertProperties.subarray(this.numProp*vert+3,this.numProp*(vert+1))}tangent(halfedge){return this.halfedgeTangent.subarray(4*halfedge,4*(halfedge+1))}transform(run){const mat4=new Array(16);for(const col of[0,1,2,3]){for(const row of[0,1,2]){mat4[4*col+row]=this.runTransform[12*run+3*col+row]}}mat4[15]=1;return mat4}}Module.Mesh=Mesh;Module.Manifold.prototype.getMesh=function(normalIdx=[0,0,0]){if(normalIdx instanceof Array)normalIdx={0:normalIdx[0],1:normalIdx[1],2:normalIdx[2]};return new Mesh(this._GetMeshJS(normalIdx))};Module.ManifoldError=function ManifoldError(code,...args){let message="Unknown error";switch(code){case Module.status.NonFiniteVertex.value:message="Non-finite vertex";break;case Module.status.NotManifold.value:message="Not manifold";break;case Module.status.VertexOutOfBounds.value:message="Vertex index out of bounds";break;case Module.status.PropertiesWrongLength.value:message="Properties have wrong length";break;case Module.status.MissingPositionProperties.value:message="Less than three properties";break;case Module.status.MergeVectorsDifferentLengths.value:message="Merge vectors have different lengths";break;case Module.status.MergeIndexOutOfBounds.value:message="Merge index out of bounds";break;case Module.status.TransformWrongLength.value:message="Transform vector has wrong length";break;case Module.status.RunIndexWrongLength.value:message="Run index vector has wrong length";break;case Module.status.FaceIDWrongLength.value:message="Face ID vector has wrong length";case Module.status.InvalidConstruction.value:message="Manifold constructed with invalid parameters"}const base=Error.apply(this,[message,...args]);base.name=this.name="ManifoldError";this.message=base.message;this.stack=base.stack;this.code=code};Module.ManifoldError.prototype=Object.create(Error.prototype,{constructor:{value:Module.ManifoldError,writable:true,configurable:true}});Module.CrossSection=function(polygons,fillRule="Positive"){const polygonsVec=polygons2vec(polygons);const cs=new CrossSectionCtor(polygonsVec,fillRuleToInt(fillRule));disposePolygons(polygonsVec);return cs};Module.CrossSection.ofPolygons=function(polygons,fillRule="Positive"){return new Module.CrossSection(polygons,fillRule)};Module.CrossSection.square=function(...args){let size=undefined;if(args.length==0)size={x:1,y:1};else if(typeof args[0]=="number")size={x:args[0],y:args[0]};else size=vararg2vec2(args);const center=args[1]||false;return Module._Square(size,center)};Module.CrossSection.circle=function(radius,circularSegments=0){return Module._Circle(radius,circularSegments)};function crossSectionBatchbool(name){return function(...args){if(args.length==1)args=args[0];const v=new Module.Vector_crossSection;for(const cs of args)v.push_back(cross(cs));const result=Module["_crossSection"+name](v);v.delete();return result}}Module.CrossSection.compose=crossSectionBatchbool("Compose");Module.CrossSection.union=crossSectionBatchbool("UnionN");Module.CrossSection.difference=crossSectionBatchbool("DifferenceN");Module.CrossSection.intersection=crossSectionBatchbool("IntersectionN");function pushVec2(vec,ps){toVec(vec,ps,p=>{if(p instanceof Array)return{x:p[0],y:p[1]};return p})}Module.CrossSection.hull=function(...args){if(args.length==1)args=args[0];let pts=new Module.Vector_vec2;for(const cs of args){if(cs instanceof CrossSectionCtor){Module._crossSectionCollectVertices(pts,cs)}else if(cs instanceof Array&&cs.length==2&&typeof cs[0]=="number"){pts.push_back({x:cs[0],y:cs[1]})}else if(cs.x){pts.push_back(cs)}else{const wrap=cs[0].length==2&&typeof cs[0][0]=="number"||cs[0].x;const polys=wrap?[cs]:cs;for(const poly of polys)pushVec2(pts,poly)}}const result=Module._crossSectionHullPoints(pts);pts.delete();return result};Module.CrossSection.prototype=Object.create(CrossSectionCtor.prototype);Object.defineProperty(Module.CrossSection,Symbol.hasInstance,{get:()=>t=>t instanceof CrossSectionCtor});const ManifoldCtor=Module.Manifold;Module.Manifold=function(mesh){const manifold=new ManifoldCtor(mesh);const status=manifold.status();if(status.value!==0){throw new Module.ManifoldError(status.value)}return manifold};Module.Manifold.ofMesh=function(mesh){return new Module.Manifold(mesh)};Module.Manifold.tetrahedron=function(){return Module._Tetrahedron()};Module.Manifold.cube=function(...args){let size=undefined;if(args.length==0)size={x:1,y:1,z:1};else if(typeof args[0]=="number")size={x:args[0],y:args[0],z:args[0]};else size=vararg2vec3(args);const center=args[1]||false;return Module._Cube(size,center)};Module.Manifold.cylinder=function(height,radiusLow,radiusHigh=-1,circularSegments=0,center=false){return Module._Cylinder(height,radiusLow,radiusHigh,circularSegments,center)};Module.Manifold.sphere=function(radius,circularSegments=0){return Module._Sphere(radius,circularSegments)};Module.Manifold.smooth=function(mesh,sharpenedEdges=[]){const sharp=new Module.Vector_smoothness;toVec(sharp,sharpenedEdges);const result=Module._Smooth(mesh,sharp);sharp.delete();return result};Module.Manifold.extrude=function(polygons,height,nDivisions=0,twistDegrees=0,scaleTop=[1,1],center=false){const cs=polygons instanceof CrossSectionCtor?polygons:Module.CrossSection(polygons,"Positive");return cs.extrude(height,nDivisions,twistDegrees,scaleTop,center)};Module.Manifold.revolve=function(polygons,circularSegments=0,revolveDegrees=360){const cs=polygons instanceof CrossSectionCtor?polygons:Module.CrossSection(polygons,"Positive");return cs.revolve(circularSegments,revolveDegrees)};Module.Manifold.reserveIDs=function(n){return Module._ReserveIDs(n)};Module.Manifold.compose=function(manifolds){const vec=new Module.Vector_manifold;toVec(vec,manifolds);const result=Module._manifoldCompose(vec);vec.delete();return result};function manifoldBatchbool(name){return function(...args){if(args.length==1)args=args[0];const v=new Module.Vector_manifold;for(const m of args)v.push_back(m);const result=Module["_manifold"+name+"N"](v);v.delete();return result}}Module.Manifold.union=manifoldBatchbool("Union");Module.Manifold.difference=manifoldBatchbool("Difference");Module.Manifold.intersection=manifoldBatchbool("Intersection");Module.Manifold.levelSet=function(sdf,bounds,edgeLength,level=0,tolerance=-1){const bounds2={min:{x:bounds.min[0],y:bounds.min[1],z:bounds.min[2]},max:{x:bounds.max[0],y:bounds.max[1],z:bounds.max[2]}};const wasmFuncPtr=addFunction(function(vec3Ptr){const x=getValue(vec3Ptr,"double");const y=getValue(vec3Ptr+8,"double");const z=getValue(vec3Ptr+16,"double");const vert=[x,y,z];return sdf(vert)},"di");const out=Module._LevelSet(wasmFuncPtr,bounds2,edgeLength,level,tolerance);removeFunction(wasmFuncPtr);return out};function pushVec3(vec,ps){toVec(vec,ps,p=>{if(p instanceof Array)return{x:p[0],y:p[1],z:p[2]};return p})}Module.Manifold.hull=function(...args){if(args.length==1)args=args[0];let pts=new Module.Vector_vec3;for(const m of args){if(m instanceof ManifoldCtor){Module._manifoldCollectVertices(pts,m)}else if(m instanceof Array&&m.length==3&&typeof m[0]=="number"){pts.push_back({x:m[0],y:m[1],z:m[2]})}else if(m.x){pts.push_back(m)}else{pushVec3(pts,m)}}const result=Module._manifoldHullPoints(pts);pts.delete();return result};Module.Manifold.prototype=Object.create(ManifoldCtor.prototype);Object.defineProperty(Module.Manifold,Symbol.hasInstance,{get:()=>t=>t instanceof ManifoldCtor});Module.triangulate=function(polygons,epsilon=-1){const polygonsVec=polygons2vec(polygons);const result=fromVec(Module._Triangulate(polygonsVec,epsilon),x=>[x[0],x[1],x[2]]);disposePolygons(polygonsVec);return result}};var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(!import.meta.url.startsWith("data:")){scriptDirectory=nodePath.dirname(require("url").fileURLToPath(import.meta.url))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);var ret=fs.readFileSync(filename);return ret};readAsync=(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return new Promise((resolve,reject)=>{fs.readFile(filename,binary?undefined:"utf8",(err,data)=>{if(err)reject(err);else resolve(binary?data.buffer:data)})})};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptName){scriptDirectory=_scriptName}if(scriptDirectory.startsWith("blob:")){scriptDirectory=""}else{scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=url=>{if(isFileURI(url)){return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)})}return fetch(url,{credentials:"same-origin"}).then(response=>{if(response.ok){return response.arrayBuffer()}return Promise.reject(new Error(response.status+" : "+response.url))})}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var wasmBinary=Module["wasmBinary"];var wasmMemory;var ABORT=false;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){var preRuns=Module["preRun"];if(preRuns){if(typeof preRuns=="function")preRuns=[preRuns];preRuns.forEach(addOnPreRun)}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){var postRuns=Module["postRun"];if(postRuns){if(typeof postRuns=="function")postRuns=[postRuns];postRuns.forEach(addOnPostRun)}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)}function removeRunDependency(id){runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";var isDataURI=filename=>filename.startsWith(dataURIPrefix);var isFileURI=filename=>filename.startsWith("file://");function findWasmBinary(){if(Module["locateFile"]){var f="manifold.wasm";if(!isDataURI(f)){return locateFile(f)}return f}return new URL("manifold.wasm",import.meta.url).href}var wasmBinaryFile;function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary){return readAsync(binaryFile).then(response=>new Uint8Array(response),()=>getBinarySync(binaryFile))}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function getWasmImports(){return{a:wasmImports}}function createWasm(){var info=getWasmImports();function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["za"];updateMemoryViews();wasmTable=wasmExports["Ca"];addOnInit(wasmExports["Aa"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}wasmBinaryFile??=findWasmBinary();instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{callbacks.forEach(f=>f(Module))};function getValue(ptr,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":abort("to do getValue(i64) use WASM_BIGINT");case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];case"*":return HEAPU32[ptr>>2];default:abort(`invalid type for getValue: ${type}`)}}var noExitRuntime=Module["noExitRuntime"]||true;function setValue(ptr,value,type="i8"){if(type.endsWith("*"))type="*";switch(type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":abort("to do setValue(i64) use WASM_BIGINT");case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;case"*":HEAPU32[ptr>>2]=value;break;default:abort(`invalid type for setValue: ${type}`)}}var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionCaught=[];var uncaughtExceptionCount=0;var ___cxa_begin_catch=ptr=>{var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);___cxa_increment_exception_refcount(ptr);return ___cxa_get_exception_ptr(ptr)};var exceptionLast=0;var ___cxa_end_catch=()=>{_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=0};class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var ___cxa_find_matching_catch_3=arg0=>findMatchingCatch([arg0]);var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var __abort_js=()=>{abort("")};var structRegistrations={};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function readPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var InternalError;var throwInternalError=message=>{throw new InternalError(message)};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(type=>typeDependencies[type]=dependentTypes);function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i{if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}});if(0===unregisteredTypes.length){onComplete(typeConverters)}};var __embind_finalize_value_object=structType=>{var reg=structRegistrations[structType];delete structRegistrations[structType];var rawConstructor=reg.rawConstructor;var rawDestructor=reg.rawDestructor;var fieldRecords=reg.fields;var fieldTypes=fieldRecords.map(field=>field.getterReturnType).concat(fieldRecords.map(field=>field.setterArgumentType));whenDependentTypesAreResolved([structType],fieldTypes,fieldTypes=>{var fields={};fieldRecords.forEach((field,i)=>{var fieldName=field.fieldName;var getterReturnType=fieldTypes[i];var getter=field.getter;var getterContext=field.getterContext;var setterArgumentType=fieldTypes[i+fieldRecords.length];var setter=field.setter;var setterContext=field.setterContext;fields[fieldName]={read:ptr=>getterReturnType["fromWireType"](getter(getterContext,ptr)),write:(ptr,o)=>{var destructors=[];setter(setterContext,ptr,setterArgumentType["toWireType"](destructors,o));runDestructors(destructors)}}});return[{name:reg.name,fromWireType:ptr=>{var rv={};for(var i in fields){rv[i]=fields[i].read(ptr)}rawDestructor(ptr);return rv},toWireType:(destructors,o)=>{for(var fieldName in fields){if(!(fieldName in o)){throw new TypeError(`Missing field: "${fieldName}"`)}}var ptr=rawConstructor();for(fieldName in fields){fields[fieldName].write(ptr,o[fieldName])}if(destructors!==null){destructors.push(rawDestructor,ptr)}return ptr},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction:rawDestructor}]})};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{};var embind_init_charCodes=()=>{var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes};var embind_charCodes;var readLatin1String=ptr=>{var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret};var BindingError;var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){return sharedRegisterType(rawType,registeredInstance,options)}var GenericWireTypeSize=8;var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=readLatin1String(name);registerType(rawType,{name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},argPackAdvance:GenericWireTypeSize,readValueFromPointer:function(pointer){return this["fromWireType"](HEAPU8[pointer])},destructorFunction:null})};var shallowCopyInternalPointer=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType});var throwInstanceAlreadyDeleted=obj=>{function getInstanceTypeName(handle){return handle.$$.ptrType.registeredClass.name}throwBindingError(getInstanceTypeName(obj)+" instance already deleted")};var finalizationRegistry=false;var detachFinalizer=handle=>{};var runDestructor=$$=>{if($$.smartPtr){$$.smartPtrType.rawDestructor($$.smartPtr)}else{$$.ptrType.registeredClass.rawDestructor($$.ptr)}};var releaseClassHandle=$$=>{$$.count.value-=1;var toDelete=0===$$.count.value;if(toDelete){runDestructor($$)}};var downcastPointer=(ptr,ptrClass,desiredClass)=>{if(ptrClass===desiredClass){return ptr}if(undefined===desiredClass.baseClass){return null}var rv=downcastPointer(ptr,ptrClass,desiredClass.baseClass);if(rv===null){return null}return desiredClass.downcast(rv)};var registeredPointers={};var registeredInstances={};var getBasestPointer=(class_,ptr)=>{if(ptr===undefined){throwBindingError("ptr should not be undefined")}while(class_.baseClass){ptr=class_.upcast(ptr);class_=class_.baseClass}return ptr};var getInheritedInstance=(class_,ptr)=>{ptr=getBasestPointer(class_,ptr);return registeredInstances[ptr]};var makeClassHandle=(prototype,record)=>{if(!record.ptrType||!record.ptr){throwInternalError("makeClassHandle requires ptr and ptrType")}var hasSmartPtrType=!!record.smartPtrType;var hasSmartPtr=!!record.smartPtr;if(hasSmartPtrType!==hasSmartPtr){throwInternalError("Both smartPtrType and smartPtr must be specified")}record.count={value:1};return attachFinalizer(Object.create(prototype,{$$:{value:record,writable:true}}))};function RegisteredPointer_fromWireType(ptr){var rawPointer=this.getPointee(ptr);if(!rawPointer){this.destructor(ptr);return null}var registeredInstance=getInheritedInstance(this.registeredClass,rawPointer);if(undefined!==registeredInstance){if(0===registeredInstance.$$.count.value){registeredInstance.$$.ptr=rawPointer;registeredInstance.$$.smartPtr=ptr;return registeredInstance["clone"]()}else{var rv=registeredInstance["clone"]();this.destructor(ptr);return rv}}function makeDefaultHandle(){if(this.isSmartPointer){return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:rawPointer,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr})}}var actualType=this.registeredClass.getActualType(rawPointer);var registeredPointerRecord=registeredPointers[actualType];if(!registeredPointerRecord){return makeDefaultHandle.call(this)}var toType;if(this.isConst){toType=registeredPointerRecord.constPointerType}else{toType=registeredPointerRecord.pointerType}var dp=downcastPointer(rawPointer,this.registeredClass,toType.registeredClass);if(dp===null){return makeDefaultHandle.call(this)}if(this.isSmartPointer){return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp})}}var attachFinalizer=handle=>{if("undefined"===typeof FinalizationRegistry){attachFinalizer=handle=>handle;return handle}finalizationRegistry=new FinalizationRegistry(info=>{releaseClassHandle(info.$$)});attachFinalizer=handle=>{var $$=handle.$$;var hasSmartPtr=!!$$.smartPtr;if(hasSmartPtr){var info={$$};finalizationRegistry.register(handle,info,handle)}return handle};detachFinalizer=handle=>finalizationRegistry.unregister(handle);return attachFinalizer(handle)};var deletionQueue=[];var flushPendingDeletes=()=>{while(deletionQueue.length){var obj=deletionQueue.pop();obj.$$.deleteScheduled=false;obj["delete"]()}};var delayFunction;var init_ClassHandle=()=>{Object.assign(ClassHandle.prototype,{isAliasOf(other){if(!(this instanceof ClassHandle)){return false}if(!(other instanceof ClassHandle)){return false}var leftClass=this.$$.ptrType.registeredClass;var left=this.$$.ptr;other.$$=other.$$;var rightClass=other.$$.ptrType.registeredClass;var right=other.$$.ptr;while(leftClass.baseClass){left=leftClass.upcast(left);leftClass=leftClass.baseClass}while(rightClass.baseClass){right=rightClass.upcast(right);rightClass=rightClass.baseClass}return leftClass===rightClass&&left===right},clone(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.preservePointerOnDelete){this.$$.count.value+=1;return this}else{var clone=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));clone.$$.count.value+=1;clone.$$.deleteScheduled=false;return clone}},delete(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}detachFinalizer(this);releaseClassHandle(this.$$);if(!this.$$.preservePointerOnDelete){this.$$.smartPtr=undefined;this.$$.ptr=undefined}},isDeleted(){return!this.$$.ptr},deleteLater(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}deletionQueue.push(this);if(deletionQueue.length===1&&delayFunction){delayFunction(flushPendingDeletes)}this.$$.deleteScheduled=true;return this}})};function ClassHandle(){}var createNamedFunction=(name,body)=>Object.defineProperty(body,"name",{value:name});var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(...args){if(!proto[methodName].overloadTable.hasOwnProperty(args.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[args.length].apply(this,args)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;if(undefined!==numArguments){Module[name].numArguments=numArguments}}};var char_0=48;var char_9=57;var makeLegalFunctionName=name=>{name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return`_${name}`}return name};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]}var upcastPointer=(ptr,ptrClass,desiredClass)=>{while(ptrClass!==desiredClass){if(!ptrClass.upcast){throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`)}ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr};function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null){destructors.push(this.rawDestructor,ptr)}return ptr}else{return 0}}if(!handle||!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(!this.isConst&&handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr){throwBindingError("Passing raw pointer to smart pointer is illegal")}switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(()=>clonedHandle["delete"]()));if(destructors!==null){destructors.push(this.rawDestructor,ptr)}}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr}function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(ptr){if(this.rawGetPointee){ptr=this.rawGetPointee(ptr)}return ptr},destructor(ptr){this.rawDestructor?.(ptr)},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,fromWireType:RegisteredPointer_fromWireType})};function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&®isteredClass.baseClass===undefined){if(isConst){this["toWireType"]=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this["toWireType"]=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}}else{this["toWireType"]=genericPointerToWireType}}var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistent public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var dynCallLegacy=(sig,ptr,args)=>{sig=sig.replace(/p/g,"i");var f=Module["dynCall_"+sig];return f(ptr,...args)};var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var dynCall=(sig,ptr,args=[])=>{if(sig.includes("j")){return dynCallLegacy(sig,ptr,args)}var rtn=getWasmTableEntry(ptr)(...args);return rtn};var getDynCaller=(sig,ptr)=>(...args)=>dynCall(sig,ptr,args);var embind__requireFunction=(signature,rawFunction)=>{signature=readLatin1String(signature);function makeDynCaller(){if(signature.includes("j")){return getDynCaller(signature,rawFunction)}return getWasmTableEntry(rawFunction)}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};var extendError=(baseErrorType,errorName)=>{var errorClass=createNamedFunction(errorName,function(message){this.name=errorName;this.message=message;var stack=new Error(message).stack;if(stack!==undefined){this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")}});errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=function(){if(this.message===undefined){return this.name}else{return`${this.name}: ${this.message}`}};return errorClass};var UnboundTypeError;var getTypeName=type=>{var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv};var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var __embind_register_class=(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor)=>{name=readLatin1String(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);upcast&&=embind__requireFunction(upcastSignature,upcast);downcast&&=embind__requireFunction(downcastSignature,downcast);rawDestructor=embind__requireFunction(destructorSignature,rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError(`Cannot construct ${name} due to unbound types`,[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],base=>{base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else{basePrototype=ClassHandle.prototype}var constructor=createNamedFunction(name,function(...args){if(Object.getPrototypeOf(this)!==instancePrototype){throw new BindingError("Use 'new' to construct "+name)}if(undefined===registeredClass.constructor_body){throw new BindingError(name+" has no accessible constructor")}var body=registeredClass.constructor_body[args.length];if(undefined===body){throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`)}return body.apply(this,args)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){registeredClass.baseClass.__derivedClasses??=[];registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter=new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})};var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i>2])}return array};function usesDestructorStack(argTypes){for(var i=1;i{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);invoker=embind__requireFunction(invokerSignature,invoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`constructor ${classType.name}`;if(undefined===classType.registeredClass.constructor_body){classType.registeredClass.constructor_body=[]}if(undefined!==classType.registeredClass.constructor_body[argCount-1]){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!`)}classType.registeredClass.constructor_body[argCount-1]=()=>{throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`,rawArgTypes)};whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{argTypes.splice(1,0,null);classType.registeredClass.constructor_body[argCount-1]=craftInvokerFunction(humanName,argTypes,null,invoker,rawConstructor);return[]});return[]})};var getFunctionName=signature=>{signature=signature.trim();const argsIndex=signature.indexOf("(");if(argsIndex!==-1){return signature.substr(0,argsIndex)}else{return signature}};var __embind_register_class_function=(rawClassType,methodName,argCount,rawArgTypesAddr,invokerSignature,rawInvoker,context,isPureVirtual,isAsync,isNonnullReturn)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);methodName=readLatin1String(methodName);methodName=getFunctionName(methodName);rawInvoker=embind__requireFunction(invokerSignature,rawInvoker);whenDependentTypesAreResolved([],[rawClassType],classType=>{classType=classType[0];var humanName=`${classType.name}.${methodName}`;if(methodName.startsWith("@@")){methodName=Symbol[methodName.substring(2)]}if(isPureVirtual){classType.registeredClass.pureVirtualFunctions.push(methodName)}function unboundTypesHandler(){throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`,rawArgTypes)}var proto=classType.registeredClass.instancePrototype;var method=proto[methodName];if(undefined===method||undefined===method.overloadTable&&method.className!==classType.name&&method.argCount===argCount-2){unboundTypesHandler.argCount=argCount-2;unboundTypesHandler.className=classType.name;proto[methodName]=unboundTypesHandler}else{ensureOverloadTable(proto,methodName,humanName);proto[methodName].overloadTable[argCount-2]=unboundTypesHandler}whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{var memberFunction=craftInvokerFunction(humanName,argTypes,classType,rawInvoker,context,isAsync);if(undefined===proto[methodName].overloadTable){memberFunction.argCount=argCount-2;proto[methodName]=memberFunction}else{proto[methodName].overloadTable[argCount-2]=memberFunction}return[]});return[]})};var emval_freelist=[];var emval_handles=[];var __emval_decref=handle=>{if(handle>9&&0===--emval_handles[handle+1]){emval_handles[handle]=undefined;emval_freelist.push(handle)}};var count_emval_handles=()=>emval_handles.length/2-5-emval_freelist.length;var init_emval=()=>{emval_handles.push(0,1,undefined,1,null,1,true,1,false,1);Module["count_emval_handles"]=count_emval_handles};var Emval={toValue:handle=>{if(!handle){throwBindingError("Cannot use deleted val. handle = "+handle)}return emval_handles[handle]},toHandle:value=>{switch(value){case undefined:return 2;case null:return 4;case true:return 6;case false:return 8;default:{const handle=emval_freelist.pop()||emval_handles.length;emval_handles[handle]=value;emval_handles[handle+1]=1;return handle}}}};var EmValType={name:"emscripten::val",fromWireType:handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},toWireType:(destructors,value)=>Emval.toHandle(value),argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction:null};var __embind_register_emval=rawType=>registerType(rawType,EmValType);var enumReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?function(pointer){return this["fromWireType"](HEAP8[pointer])}:function(pointer){return this["fromWireType"](HEAPU8[pointer])};case 2:return signed?function(pointer){return this["fromWireType"](HEAP16[pointer>>1])}:function(pointer){return this["fromWireType"](HEAPU16[pointer>>1])};case 4:return signed?function(pointer){return this["fromWireType"](HEAP32[pointer>>2])}:function(pointer){return this["fromWireType"](HEAPU32[pointer>>2])};default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_enum=(rawType,name,size,isSigned)=>{name=readLatin1String(name);function ctor(){}ctor.values={};registerType(rawType,{name,constructor:ctor,fromWireType:function(c){return this.constructor.values[c]},toWireType:(destructors,c)=>c.value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor)};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`)}return impl};var __embind_register_enum_value=(rawEnumType,name,enumValue)=>{var enumType=requireRegisteredType(rawEnumType,"enum");name=readLatin1String(name);var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(`${enumType.name}_${name}`,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value};var embindRepr=v=>{if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}};var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 8:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=readLatin1String(name);registerType(rawType,{name,fromWireType:value=>value,toWireType:(destructors,value)=>value,argPackAdvance:GenericWireTypeSize,readValueFromPointer:floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_function=(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync,isNonnullReturn)=>{var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=readLatin1String(name);name=getFunctionName(name);rawInvoker=embind__requireFunction(signature,rawInvoker);exposePublicSymbol(name,function(){throwUnboundTypeError(`Cannot call ${name} due to unbound types`,argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,argTypes=>{var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})};var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer]:pointer=>HEAPU8[pointer];case 2:return signed?pointer=>HEAP16[pointer>>1]:pointer=>HEAPU16[pointer>>1];case 4:return signed?pointer=>HEAP32[pointer>>2]:pointer=>HEAPU32[pointer>>2];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_integer=(primitiveType,name,size,minRange,maxRange)=>{name=readLatin1String(name);if(maxRange===-1){maxRange=4294967295}var fromWireType=value=>value;if(minRange===0){var bitshift=32-8*size;fromWireType=value=>value<>>bitshift}var isUnsignedType=name.includes("unsigned");var checkAssertions=(value,toTypeName)=>{};var toWireType;if(isUnsignedType){toWireType=function(destructors,value){checkAssertions(value,this.name);return value>>>0}}else{toWireType=function(destructors,value){checkAssertions(value,this.name);return value}}registerType(primitiveType,{name,fromWireType,toWireType,argPackAdvance:GenericWireTypeSize,readValueFromPointer:integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=readLatin1String(name);registerType(rawType,{name,fromWireType:decodeMemoryView,argPackAdvance:GenericWireTypeSize,readValueFromPointer:decodeMemoryView},{ignoreDuplicateRegistrations:true})};var EmValOptionalType=Object.assign({optional:true},EmValType);var __embind_register_optional=(rawOptionalType,rawType)=>{registerType(rawOptionalType,EmValOptionalType)};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder:undefined;var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead=NaN)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var __embind_register_std_string=(rawType,name)=>{name=readLatin1String(name);var stdStringIsUTF8=name==="std::string";registerType(rawType,{name,fromWireType(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment=UTF8ToString(decodeStartPtr,maxRead);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i>2]=length;if(stdStringIsUTF8&&valueIsOfTypeString){stringToUTF8(value,ptr,length+1)}else{if(valueIsOfTypeString){for(var i=0;i255){_free(ptr);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}else{for(var i=0;i{var endPtr=ptr;var idx=endPtr>>1;var maxIdx=idx+maxBytesToRead/2;while(!(idx>=maxIdx)&&HEAPU16[idx])++idx;endPtr=idx<<1;if(endPtr-ptr>32&&UTF16Decoder)return UTF16Decoder.decode(HEAPU8.subarray(ptr,endPtr));var str="";for(var i=0;!(i>=maxBytesToRead/2);++i){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead)=>{var i=0;var str="";while(!(i>=maxBytesToRead/4)){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)break;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{maxBytesToWrite??=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=readLatin1String(name);var decodeString,encodeString,readCharAt,lengthBytesUTF;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;readCharAt=pointer=>HEAPU16[pointer>>1]}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;readCharAt=pointer=>HEAPU32[pointer>>2]}registerType(rawType,{name,fromWireType:value=>{var length=HEAPU32[value>>2];var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||readCharAt(currentBytePtr)==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_free(value);return str},toWireType:(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length/charSize;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},argPackAdvance:GenericWireTypeSize,readValueFromPointer:readPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_value_object=(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor)=>{structRegistrations[rawType]={name:readLatin1String(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}};var __embind_register_value_object_field=(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext)=>{structRegistrations[structType].fields.push({fieldName:readLatin1String(fieldName),getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext,setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext})};var __embind_register_void=(rawType,name)=>{name=readLatin1String(name);registerType(rawType,{isVoid:true,name,argPackAdvance:0,fromWireType:()=>undefined,toWireType:(destructors,o)=>undefined})};var __emscripten_memcpy_js=(dest,src,num)=>HEAPU8.copyWithin(dest,src,src+num);var emval_returnValue=(returnType,destructorsRef,handle)=>{var destructors=[];var result=returnType["toWireType"](destructors,handle);if(destructors.length){HEAPU32[destructorsRef>>2]=Emval.toHandle(destructors)}return result};var __emval_as=(handle,returnType,destructorsRef)=>{handle=Emval.toValue(handle);returnType=requireRegisteredType(returnType,"emval::as");return emval_returnValue(returnType,destructorsRef,handle)};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return readLatin1String(address)}return symbol};var emval_methodCallers=[];var __emval_call_method=(caller,objHandle,methodName,destructorsRef,args)=>{caller=emval_methodCallers[caller];objHandle=Emval.toValue(objHandle);methodName=getStringOrSymbol(methodName);return caller(objHandle,objHandle[methodName],destructorsRef,args)};var __emval_equals=(first,second)=>{first=Emval.toValue(first);second=Emval.toValue(second);return first==second};var emval_addMethodCaller=caller=>{var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var emval_lookupTypes=(argCount,argTypes)=>{var a=new Array(argCount);for(var i=0;i>2],"parameter "+i)}return a};var reflectConstruct=Reflect.construct;var __emval_get_method_caller=(argCount,argTypes,kind)=>{var types=emval_lookupTypes(argCount,argTypes);var retType=types.shift();argCount--;var functionBody=`return function (obj, func, destructorsRef, args) {\n`;var offset=0;var argsList=[];if(kind===0){argsList.push("obj")}var params=["retType"];var args=[retType];for(var i=0;it.name).join(", ")}) => ${retType.name}>`;return emval_addMethodCaller(createNamedFunction(functionName,invokerFunction))};var __emval_get_property=(handle,key)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);return Emval.toHandle(handle[key])};var __emval_incref=handle=>{if(handle>9){emval_handles[handle+1]+=1}};var __emval_new_cstring=v=>Emval.toHandle(getStringOrSymbol(v));var __emval_new_object=()=>Emval.toHandle({});var __emval_run_destructors=handle=>{var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var __emval_set_property=(handle,key,value)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);value=Emval.toValue(value);handle[key]=value};var __emval_take_value=(type,arg)=>{type=requireRegisteredType(type,"_emval_take_value");var v=type["readValueFromPointer"](arg);return Emval.toHandle(v)};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var _llvm_eh_typeid_for=type=>type;var uleb128Encode=(n,target)=>{if(n<128){target.push(n)}else{target.push(n%128|128,n>>7)}};var sigToWasmTypes=sig=>{var typeNames={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"};var type={parameters:[],results:sig[0]=="v"?[]:[typeNames[sig[0]]]};for(var i=1;i{var sigRet=sig.slice(0,1);var sigParam=sig.slice(1);var typeCodes={i:127,p:127,j:126,f:125,d:124,e:111};target.push(96);uleb128Encode(sigParam.length,target);for(var i=0;i{if(typeof WebAssembly.Function=="function"){return new WebAssembly.Function(sigToWasmTypes(sig),func)}var typeSectionBody=[1];generateFuncType(sig,typeSectionBody);var bytes=[0,97,115,109,1,0,0,0,1];uleb128Encode(typeSectionBody.length,bytes);bytes.push(...typeSectionBody);bytes.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var module=new WebAssembly.Module(new Uint8Array(bytes));var instance=new WebAssembly.Instance(module,{e:{f:func}});var wrappedFunc=instance.exports["f"];return wrappedFunc};var updateTableMap=(offset,count)=>{if(functionsInTableMap){for(var i=offset;i{if(!functionsInTableMap){functionsInTableMap=new WeakMap;updateTableMap(0,wasmTable.length)}return functionsInTableMap.get(func)||0};var freeTableIndexes=[];var getEmptyTableSlot=()=>{if(freeTableIndexes.length){return freeTableIndexes.pop()}try{wasmTable.grow(1)}catch(err){if(!(err instanceof RangeError)){throw err}throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return wasmTable.length-1};var setWasmTableEntry=(idx,func)=>{wasmTable.set(idx,func);wasmTableMirror[idx]=wasmTable.get(idx)};var addFunction=(func,sig)=>{var rtn=getFunctionAddress(func);if(rtn){return rtn}var ret=getEmptyTableSlot();try{setWasmTableEntry(ret,func)}catch(err){if(!(err instanceof TypeError)){throw err}var wrapped=convertJsFunctionToWasm(func,sig);setWasmTableEntry(ret,wrapped)}functionsInTableMap.set(func,ret);return ret};var removeFunction=index=>{functionsInTableMap.delete(getWasmTableEntry(index));setWasmTableEntry(index,null);freeTableIndexes.push(index)};InternalError=Module["InternalError"]=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};embind_init_charCodes();BindingError=Module["BindingError"]=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};init_ClassHandle();init_RegisteredPointer();UnboundTypeError=Module["UnboundTypeError"]=extendError(Error,"UnboundTypeError");init_emval();var wasmImports={J:___cxa_begin_catch,fa:___cxa_end_catch,a:___cxa_find_matching_catch_2,k:___cxa_find_matching_catch_3,h:___cxa_throw,e:___resumeException,$:__abort_js,qa:__embind_finalize_value_object,_:__embind_register_bigint,na:__embind_register_bool,x:__embind_register_class,w:__embind_register_class_constructor,i:__embind_register_class_function,ma:__embind_register_emval,M:__embind_register_enum,t:__embind_register_enum_value,V:__embind_register_float,o:__embind_register_function,z:__embind_register_integer,s:__embind_register_memory_view,A:__embind_register_optional,U:__embind_register_std_string,L:__embind_register_std_wstring,B:__embind_register_value_object,ra:__embind_register_value_object_field,oa:__embind_register_void,ba:__emscripten_memcpy_js,va:__emval_as,ka:__emval_call_method,xa:__emval_decref,ua:__emval_equals,pa:__emval_get_method_caller,wa:__emval_get_property,ta:__emval_incref,E:__emval_new_cstring,X:__emval_new_object,Y:__emval_run_destructors,ya:__emval_set_property,D:__emval_take_value,aa:_emscripten_resize_heap,y:invoke_dd,G:invoke_dii,ha:invoke_diid,I:invoke_diii,v:invoke_diiiii,H:invoke_i,d:invoke_ii,b:invoke_iii,m:invoke_iiii,n:invoke_iiiii,W:invoke_iiiiii,Z:invoke_iiij,j:invoke_v,f:invoke_vi,T:invoke_vid,ca:invoke_vidi,g:invoke_vii,r:invoke_viid,ja:invoke_viidd,ia:invoke_viiddd,F:invoke_viiddi,N:invoke_viidi,la:invoke_viididi,da:invoke_viidiidid,c:invoke_viii,K:invoke_viiid,sa:invoke_viiidddi,l:invoke_viiii,O:invoke_viiiiddi,ea:invoke_viiiidi,u:invoke_viiiii,S:invoke_viiiiid,p:invoke_viiiiii,Q:invoke_viiiiiii,P:invoke_viiiiiiiii,C:invoke_viiiiiiiiidiii,q:invoke_viiiiiiiiii,R:invoke_viiiiiiiiiiiiiiiiii,ga:_llvm_eh_typeid_for};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["Aa"])();var ___getTypeName=a0=>(___getTypeName=wasmExports["Ba"])(a0);var _malloc=a0=>(_malloc=wasmExports["Da"])(a0);var _free=a0=>(_free=wasmExports["Ea"])(a0);var _setThrew=(a0,a1)=>(_setThrew=wasmExports["Fa"])(a0,a1);var __emscripten_tempret_set=a0=>(__emscripten_tempret_set=wasmExports["Ga"])(a0);var __emscripten_stack_restore=a0=>(__emscripten_stack_restore=wasmExports["Ha"])(a0);var _emscripten_stack_get_current=()=>(_emscripten_stack_get_current=wasmExports["Ia"])();var ___cxa_decrement_exception_refcount=a0=>(___cxa_decrement_exception_refcount=wasmExports["Ja"])(a0);var ___cxa_increment_exception_refcount=a0=>(___cxa_increment_exception_refcount=wasmExports["Ka"])(a0);var ___cxa_can_catch=(a0,a1,a2)=>(___cxa_can_catch=wasmExports["La"])(a0,a1,a2);var ___cxa_get_exception_ptr=a0=>(___cxa_get_exception_ptr=wasmExports["Ma"])(a0);var dynCall_iiij=Module["dynCall_iiij"]=(a0,a1,a2,a3,a4)=>(dynCall_iiij=Module["dynCall_iiij"]=wasmExports["Na"])(a0,a1,a2,a3,a4);function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiidddi(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_dd(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viididi(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viid(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vid(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiidiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiid(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_i(index){var sp=stackSave();try{return getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiid(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidd(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiddd(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_diid(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_dii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiidi(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiddi(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidi(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viidiidid(index,a1,a2,a3,a4,a5,a6,a7,a8){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiddi(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vidi(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiij(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiij(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}Module["addFunction"]=addFunction;Module["removeFunction"]=removeFunction;var calledRun;var calledPrerun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}if(!calledPrerun){calledPrerun=1;preRun();if(runDependencies>0){return}}function doRun(){if(calledRun)return;calledRun=1;Module["calledRun"]=1;if(ABORT)return;initRuntime();readyPromiseResolve(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();moduleRtn=readyPromise; + var Module = moduleArg; var readyPromiseResolve, readyPromiseReject; var readyPromise = new Promise((resolve, reject) => { readyPromiseResolve = resolve; readyPromiseReject = reject; }); var ENVIRONMENT_IS_WEB = typeof window == "object"; var ENVIRONMENT_IS_WORKER = typeof importScripts == "function"; var _ManifoldInitialized = false; Module.setup = function () { if (_ManifoldInitialized) return; _ManifoldInitialized = true; function toVec(vec, list, f = (x => x)) { if (list) { for (let x of list) { vec.push_back(f(x)); } } return vec; } function fromVec(vec, f = (x => x)) { const result = []; const size = vec.size(); for (let i = 0; i < size; i++)result.push(f(vec.get(i))); return result; } function vec2polygons(vec, f = (x => x)) { const result = []; const nPoly = vec.size(); for (let i = 0; i < nPoly; i++) { const v = vec.get(i); const nPts = v.size(); const poly = []; for (let j = 0; j < nPts; j++) { poly.push(f(v.get(j))); } result.push(poly); } return result; } function polygons2vec(polygons) { if (polygons[0].length < 3) { polygons = [polygons]; } return toVec(new Module.Vector2_vec2, polygons, poly => toVec(new Module.Vector_vec2, poly, p => { if (p instanceof Array) return { x: p[0], y: p[1] }; return p; })); } function disposePolygons(polygonsVec) { for (let i = 0; i < polygonsVec.size(); i++)polygonsVec.get(i).delete(); polygonsVec.delete(); } function vararg2vec2(vec) { if (vec[0] instanceof Array) return { x: vec[0][0], y: vec[0][1] }; if (typeof vec[0] == "number") return { x: vec[0] || 0, y: vec[1] || 0 }; return vec[0]; } function vararg2vec3(vec) { if (vec[0] instanceof Array) return { x: vec[0][0], y: vec[0][1], z: vec[0][2] }; if (typeof vec[0] == "number") return { x: vec[0] || 0, y: vec[1] || 0, z: vec[2] || 0 }; return vec[0]; } function fillRuleToInt(fillRule) { return fillRule == "EvenOdd" ? 0 : fillRule == "NonZero" ? 1 : fillRule == "Negative" ? 3 : 2; } function joinTypeToInt(joinType) { return joinType == "Round" ? 1 : joinType == "Miter" ? 2 : 0; } function endTypeToInt(endType) { return endType == "Polygon" ? 0 : endType == "Joined" ? 1 : endType == "Butt" ? 2 : endType == "Square" ? 3 : 4; } const CrossSectionCtor = Module.CrossSection; function cross(polygons, fillRule = "Positive") { if (polygons instanceof CrossSectionCtor) { return polygons; } else { const polygonsVec = polygons2vec(polygons); const cs = new CrossSectionCtor(polygonsVec, fillRuleToInt(fillRule)); disposePolygons(polygonsVec); return cs; } } Module.CrossSection.prototype.translate = function (...vec) { return this._Translate(vararg2vec2(vec)); }; Module.CrossSection.prototype.scale = function (vec) { if (typeof vec == "number") { return this._Scale({ x: vec, y: vec }); } return this._Scale(vararg2vec2([vec])); }; Module.CrossSection.prototype.mirror = function (vec) { return this._Mirror(vararg2vec2([vec])); }; Module.CrossSection.prototype.warp = function (func) { const wasmFuncPtr = addFunction(function (vec2Ptr) { const x = getValue(vec2Ptr, "double"); const y = getValue(vec2Ptr + 8, "double"); const vert = [x, y]; func(vert); setValue(vec2Ptr, vert[0], "double"); setValue(vec2Ptr + 8, vert[1], "double"); }, "vi"); const out = this._Warp(wasmFuncPtr); removeFunction(wasmFuncPtr); return out; }; Module.CrossSection.prototype.decompose = function () { const vec = this._Decompose(); const result = fromVec(vec); vec.delete(); return result; }; Module.CrossSection.prototype.bounds = function () { const result = this._Bounds(); return { min: ["x", "y"].map(f => result.min[f]), max: ["x", "y"].map(f => result.max[f]) }; }; Module.CrossSection.prototype.offset = function (delta, joinType = "Square", endType = "Polygon", miterLimit = 2, circularSegments = 0) { return this._Offset(delta, joinTypeToInt(joinType), endTypeToInt(endType), miterLimit, circularSegments); }; Module.CrossSection.prototype.extrude = function (height, nDivisions = 0, twistDegrees = 0, scaleTop = [1, 1], center = false) { scaleTop = vararg2vec2([scaleTop]); const man = Module._Extrude(this._ToPolygons(), height, nDivisions, twistDegrees, scaleTop); return center ? man.translate([0, 0, -height / 2]) : man; }; Module.CrossSection.prototype.revolve = function (circularSegments = 0, revolveDegrees = 360) { return Module._Revolve(this._ToPolygons(), circularSegments, revolveDegrees); }; Module.CrossSection.prototype.add = function (other) { return this._add(cross(other)); }; Module.CrossSection.prototype.subtract = function (other) { return this._subtract(cross(other)); }; Module.CrossSection.prototype.intersect = function (other) { return this._intersect(cross(other)); }; Module.CrossSection.prototype.toPolygons = function () { const vec = this._ToPolygons(); const result = vec2polygons(vec, v => [v.x, v.y]); vec.delete(); return result; }; Module.Manifold.prototype.smoothOut = function (minSharpAngle = 60, minSmoothness = 0) { return this._SmoothOut(minSharpAngle, minSmoothness); }; Module.Manifold.prototype.warp = function (func) { const wasmFuncPtr = addFunction(function (vec3Ptr) { const x = getValue(vec3Ptr, "double"); const y = getValue(vec3Ptr + 8, "double"); const z = getValue(vec3Ptr + 16, "double"); const vert = [x, y, z]; func(vert); setValue(vec3Ptr, vert[0], "double"); setValue(vec3Ptr + 8, vert[1], "double"); setValue(vec3Ptr + 16, vert[2], "double"); }, "vi"); const out = this._Warp(wasmFuncPtr); removeFunction(wasmFuncPtr); const status = out.status(); if (status.value !== 0) { throw new Module.ManifoldError(status.value); } return out; }; Module.Manifold.prototype.calculateNormals = function (normalIdx, minSharpAngle = 60) { return this._CalculateNormals(normalIdx, minSharpAngle); }; Module.Manifold.prototype.setProperties = function (numProp, func) { const oldNumProp = this.numProp(); const wasmFuncPtr = addFunction(function (newPtr, vec3Ptr, oldPtr) { const newProp = []; for (let i = 0; i < numProp; ++i) { newProp[i] = getValue(newPtr + 8 * i, "double"); } const pos = []; for (let i = 0; i < 3; ++i) { pos[i] = getValue(vec3Ptr + 8 * i, "double"); } const oldProp = []; for (let i = 0; i < oldNumProp; ++i) { oldProp[i] = getValue(oldPtr + 8 * i, "double"); } func(newProp, pos, oldProp); for (let i = 0; i < numProp; ++i) { setValue(newPtr + 8 * i, newProp[i], "double"); } }, "viii"); const out = this._SetProperties(numProp, wasmFuncPtr); removeFunction(wasmFuncPtr); return out; }; Module.Manifold.prototype.translate = function (...vec) { return this._Translate(vararg2vec3(vec)); }; Module.Manifold.prototype.rotate = function (xOrVec, y, z) { if (Array.isArray(xOrVec)) { return this._Rotate(...xOrVec); } else { return this._Rotate(xOrVec, y || 0, z || 0); } }; Module.Manifold.prototype.scale = function (vec) { if (typeof vec == "number") { return this._Scale({ x: vec, y: vec, z: vec }); } return this._Scale(vararg2vec3([vec])); }; Module.Manifold.prototype.mirror = function (vec) { return this._Mirror(vararg2vec3([vec])); }; Module.Manifold.prototype.trimByPlane = function (normal, offset = 0) { return this._TrimByPlane(vararg2vec3([normal]), offset); }; Module.Manifold.prototype.slice = function (height = 0) { const polygonsVec = this._Slice(height); const result = new CrossSectionCtor(polygonsVec, fillRuleToInt("Positive")); disposePolygons(polygonsVec); return result; }; Module.Manifold.prototype.project = function () { const polygonsVec = this._Project(); const result = new CrossSectionCtor(polygonsVec, fillRuleToInt("Positive")); disposePolygons(polygonsVec); return result.simplify(this.tolerance); }; Module.Manifold.prototype.split = function (manifold) { const vec = this._Split(manifold); const result = fromVec(vec); vec.delete(); return result; }; Module.Manifold.prototype.splitByPlane = function (normal, offset = 0) { const vec = this._SplitByPlane(vararg2vec3([normal]), offset); const result = fromVec(vec); vec.delete(); return result; }; Module.Manifold.prototype.decompose = function () { const vec = this._Decompose(); const result = fromVec(vec); vec.delete(); return result; }; Module.Manifold.prototype.boundingBox = function () { const result = this._boundingBox(); return { min: ["x", "y", "z"].map(f => result.min[f]), max: ["x", "y", "z"].map(f => result.max[f]) }; }; class Mesh { constructor({ numProp = 3, triVerts = new Uint32Array, vertProperties = new Float32Array, mergeFromVert, mergeToVert, runIndex, runOriginalID, faceID, halfedgeTangent, runTransform } = {}) { this.numProp = numProp; this.triVerts = triVerts; this.vertProperties = vertProperties; this.mergeFromVert = mergeFromVert; this.mergeToVert = mergeToVert; this.runIndex = runIndex; this.runOriginalID = runOriginalID; this.faceID = faceID; this.halfedgeTangent = halfedgeTangent; this.runTransform = runTransform; } get numTri() { return this.triVerts.length / 3; } get numVert() { return this.vertProperties.length / this.numProp; } get numRun() { return this.runOriginalID.length; } merge() { const { changed, mesh } = Module._Merge(this); Object.assign(this, { ...mesh }); return changed; } verts(tri) { return this.triVerts.subarray(3 * tri, 3 * (tri + 1)); } position(vert) { return this.vertProperties.subarray(this.numProp * vert, this.numProp * vert + 3); } extras(vert) { return this.vertProperties.subarray(this.numProp * vert + 3, this.numProp * (vert + 1)); } tangent(halfedge) { return this.halfedgeTangent.subarray(4 * halfedge, 4 * (halfedge + 1)); } transform(run) { const mat4 = new Array(16); for (const col of [0, 1, 2, 3]) { for (const row of [0, 1, 2]) { mat4[4 * col + row] = this.runTransform[12 * run + 3 * col + row]; } } mat4[15] = 1; return mat4; } } Module.Mesh = Mesh; Module.Manifold.prototype.getMesh = function (normalIdx = [0, 0, 0]) { if (normalIdx instanceof Array) normalIdx = { 0: normalIdx[0], 1: normalIdx[1], 2: normalIdx[2] }; return new Mesh(this._GetMeshJS(normalIdx)); }; Module.ManifoldError = function ManifoldError(code, ...args) { let message = "Unknown error"; switch (code) { case Module.status.NonFiniteVertex.value: message = "Non-finite vertex"; break; case Module.status.NotManifold.value: message = "Not manifold"; break; case Module.status.VertexOutOfBounds.value: message = "Vertex index out of bounds"; break; case Module.status.PropertiesWrongLength.value: message = "Properties have wrong length"; break; case Module.status.MissingPositionProperties.value: message = "Less than three properties"; break; case Module.status.MergeVectorsDifferentLengths.value: message = "Merge vectors have different lengths"; break; case Module.status.MergeIndexOutOfBounds.value: message = "Merge index out of bounds"; break; case Module.status.TransformWrongLength.value: message = "Transform vector has wrong length"; break; case Module.status.RunIndexWrongLength.value: message = "Run index vector has wrong length"; break; case Module.status.FaceIDWrongLength.value: message = "Face ID vector has wrong length"; case Module.status.InvalidConstruction.value: message = "Manifold constructed with invalid parameters"; }const base = Error.apply(this, [message, ...args]); base.name = this.name = "ManifoldError"; this.message = base.message; this.stack = base.stack; this.code = code; }; Module.ManifoldError.prototype = Object.create(Error.prototype, { constructor: { value: Module.ManifoldError, writable: true, configurable: true } }); Module.CrossSection = function (polygons, fillRule = "Positive") { const polygonsVec = polygons2vec(polygons); const cs = new CrossSectionCtor(polygonsVec, fillRuleToInt(fillRule)); disposePolygons(polygonsVec); return cs; }; Module.CrossSection.ofPolygons = function (polygons, fillRule = "Positive") { return new Module.CrossSection(polygons, fillRule); }; Module.CrossSection.square = function (...args) { let size = undefined; if (args.length == 0) size = { x: 1, y: 1 }; else if (typeof args[0] == "number") size = { x: args[0], y: args[0] }; else size = vararg2vec2(args); const center = args[1] || false; return Module._Square(size, center); }; Module.CrossSection.circle = function (radius, circularSegments = 0) { return Module._Circle(radius, circularSegments); }; function crossSectionBatchbool(name) { return function (...args) { if (args.length == 1) args = args[0]; const v = new Module.Vector_crossSection; for (const cs of args) v.push_back(cross(cs)); const result = Module["_crossSection" + name](v); v.delete(); return result; }; } Module.CrossSection.compose = crossSectionBatchbool("Compose"); Module.CrossSection.union = crossSectionBatchbool("UnionN"); Module.CrossSection.difference = crossSectionBatchbool("DifferenceN"); Module.CrossSection.intersection = crossSectionBatchbool("IntersectionN"); function pushVec2(vec, ps) { toVec(vec, ps, p => { if (p instanceof Array) return { x: p[0], y: p[1] }; return p; }); } Module.CrossSection.hull = function (...args) { if (args.length == 1) args = args[0]; let pts = new Module.Vector_vec2; for (const cs of args) { if (cs instanceof CrossSectionCtor) { Module._crossSectionCollectVertices(pts, cs); } else if (cs instanceof Array && cs.length == 2 && typeof cs[0] == "number") { pts.push_back({ x: cs[0], y: cs[1] }); } else if (cs.x) { pts.push_back(cs); } else { const wrap = cs[0].length == 2 && typeof cs[0][0] == "number" || cs[0].x; const polys = wrap ? [cs] : cs; for (const poly of polys) pushVec2(pts, poly); } } const result = Module._crossSectionHullPoints(pts); pts.delete(); return result; }; Module.CrossSection.prototype = Object.create(CrossSectionCtor.prototype); Object.defineProperty(Module.CrossSection, Symbol.hasInstance, { get: () => t => t instanceof CrossSectionCtor }); const ManifoldCtor = Module.Manifold; Module.Manifold = function (mesh) { const manifold = new ManifoldCtor(mesh); const status = manifold.status(); if (status.value !== 0) { throw new Module.ManifoldError(status.value); } return manifold; }; Module.Manifold.ofMesh = function (mesh) { return new Module.Manifold(mesh); }; Module.Manifold.tetrahedron = function () { return Module._Tetrahedron(); }; Module.Manifold.cube = function (...args) { let size = undefined; if (args.length == 0) size = { x: 1, y: 1, z: 1 }; else if (typeof args[0] == "number") size = { x: args[0], y: args[0], z: args[0] }; else size = vararg2vec3(args); const center = args[1] || false; return Module._Cube(size, center); }; Module.Manifold.cylinder = function (height, radiusLow, radiusHigh = -1, circularSegments = 0, center = false) { return Module._Cylinder(height, radiusLow, radiusHigh, circularSegments, center); }; Module.Manifold.sphere = function (radius, circularSegments = 0) { return Module._Sphere(radius, circularSegments); }; Module.Manifold.smooth = function (mesh, sharpenedEdges = []) { const sharp = new Module.Vector_smoothness; toVec(sharp, sharpenedEdges); const result = Module._Smooth(mesh, sharp); sharp.delete(); return result; }; Module.Manifold.extrude = function (polygons, height, nDivisions = 0, twistDegrees = 0, scaleTop = [1, 1], center = false) { const cs = polygons instanceof CrossSectionCtor ? polygons : Module.CrossSection(polygons, "Positive"); return cs.extrude(height, nDivisions, twistDegrees, scaleTop, center); }; Module.Manifold.revolve = function (polygons, circularSegments = 0, revolveDegrees = 360) { const cs = polygons instanceof CrossSectionCtor ? polygons : Module.CrossSection(polygons, "Positive"); return cs.revolve(circularSegments, revolveDegrees); }; Module.Manifold.reserveIDs = function (n) { return Module._ReserveIDs(n); }; Module.Manifold.compose = function (manifolds) { const vec = new Module.Vector_manifold; toVec(vec, manifolds); const result = Module._manifoldCompose(vec); vec.delete(); return result; }; function manifoldBatchbool(name) { return function (...args) { if (args.length == 1) args = args[0]; const v = new Module.Vector_manifold; for (const m of args) v.push_back(m); const result = Module["_manifold" + name + "N"](v); v.delete(); return result; }; } Module.Manifold.union = manifoldBatchbool("Union"); Module.Manifold.difference = manifoldBatchbool("Difference"); Module.Manifold.intersection = manifoldBatchbool("Intersection"); Module.Manifold.levelSet = function (sdf, bounds, edgeLength, level = 0, tolerance = -1) { const bounds2 = { min: { x: bounds.min[0], y: bounds.min[1], z: bounds.min[2] }, max: { x: bounds.max[0], y: bounds.max[1], z: bounds.max[2] } }; const wasmFuncPtr = addFunction(function (vec3Ptr) { const x = getValue(vec3Ptr, "double"); const y = getValue(vec3Ptr + 8, "double"); const z = getValue(vec3Ptr + 16, "double"); const vert = [x, y, z]; return sdf(vert); }, "di"); const out = Module._LevelSet(wasmFuncPtr, bounds2, edgeLength, level, tolerance); removeFunction(wasmFuncPtr); return out; }; function pushVec3(vec, ps) { toVec(vec, ps, p => { if (p instanceof Array) return { x: p[0], y: p[1], z: p[2] }; return p; }); } Module.Manifold.hull = function (...args) { if (args.length == 1) args = args[0]; let pts = new Module.Vector_vec3; for (const m of args) { if (m instanceof ManifoldCtor) { Module._manifoldCollectVertices(pts, m); } else if (m instanceof Array && m.length == 3 && typeof m[0] == "number") { pts.push_back({ x: m[0], y: m[1], z: m[2] }); } else if (m.x) { pts.push_back(m); } else { pushVec3(pts, m); } } const result = Module._manifoldHullPoints(pts); pts.delete(); return result; }; Module.Manifold.prototype = Object.create(ManifoldCtor.prototype); Object.defineProperty(Module.Manifold, Symbol.hasInstance, { get: () => t => t instanceof ManifoldCtor }); Module.triangulate = function (polygons, epsilon = -1) { const polygonsVec = polygons2vec(polygons); const result = fromVec(Module._Triangulate(polygonsVec, epsilon), x => [x[0], x[1], x[2]]); disposePolygons(polygonsVec); return result; }; }; var moduleOverrides = Object.assign({}, Module); var arguments_ = []; var thisProgram = "./this.program"; var quit_ = (status, toThrow) => { throw toThrow; }; var scriptDirectory = ""; function locateFile(path) { if (Module["locateFile"]) { return Module["locateFile"](path, scriptDirectory); } return scriptDirectory + path; } var readAsync, readBinary; if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { if (ENVIRONMENT_IS_WORKER) { scriptDirectory = self.location.href; } else if (typeof document != "undefined" && document.currentScript) { scriptDirectory = document.currentScript.src; } if (_scriptName) { scriptDirectory = _scriptName; } if (scriptDirectory.startsWith("blob:")) { scriptDirectory = ""; } else { scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1); } { if (ENVIRONMENT_IS_WORKER) { readBinary = url => { var xhr = new XMLHttpRequest; xhr.open("GET", url, false); xhr.responseType = "arraybuffer"; xhr.send(null); return new Uint8Array(xhr.response); }; } readAsync = url => { if (isFileURI(url)) { return new Promise((resolve, reject) => { var xhr = new XMLHttpRequest; xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; xhr.onload = () => { if (xhr.status == 200 || xhr.status == 0 && xhr.response) { resolve(xhr.response); return; } reject(xhr.status); }; xhr.onerror = reject; xhr.send(null); }); } return fetch(url, { credentials: "same-origin" }).then(response => { if (response.ok) { return response.arrayBuffer(); } return Promise.reject(new Error(response.status + " : " + response.url)); }); }; } } else { } var out = Module["print"] || console.log.bind(console); var err = Module["printErr"] || console.error.bind(console); Object.assign(Module, moduleOverrides); moduleOverrides = null; if (Module["arguments"]) arguments_ = Module["arguments"]; if (Module["thisProgram"]) thisProgram = Module["thisProgram"]; var wasmBinary = Module["wasmBinary"]; var wasmMemory; var ABORT = false; var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64; function updateMemoryViews() { var b = wasmMemory.buffer; Module["HEAP8"] = HEAP8 = new Int8Array(b); Module["HEAP16"] = HEAP16 = new Int16Array(b); Module["HEAPU8"] = HEAPU8 = new Uint8Array(b); Module["HEAPU16"] = HEAPU16 = new Uint16Array(b); Module["HEAP32"] = HEAP32 = new Int32Array(b); Module["HEAPU32"] = HEAPU32 = new Uint32Array(b); Module["HEAPF32"] = HEAPF32 = new Float32Array(b); Module["HEAPF64"] = HEAPF64 = new Float64Array(b); } var __ATPRERUN__ = []; var __ATINIT__ = []; var __ATPOSTRUN__ = []; var runtimeInitialized = false; function preRun() { var preRuns = Module["preRun"]; if (preRuns) { if (typeof preRuns == "function") preRuns = [preRuns]; preRuns.forEach(addOnPreRun); } callRuntimeCallbacks(__ATPRERUN__); } function initRuntime() { runtimeInitialized = true; callRuntimeCallbacks(__ATINIT__); } function postRun() { var postRuns = Module["postRun"]; if (postRuns) { if (typeof postRuns == "function") postRuns = [postRuns]; postRuns.forEach(addOnPostRun); } callRuntimeCallbacks(__ATPOSTRUN__); } function addOnPreRun(cb) { __ATPRERUN__.unshift(cb); } function addOnInit(cb) { __ATINIT__.unshift(cb); } function addOnPostRun(cb) { __ATPOSTRUN__.unshift(cb); } var runDependencies = 0; var runDependencyWatcher = null; var dependenciesFulfilled = null; function addRunDependency(id) { runDependencies++; Module["monitorRunDependencies"]?.(runDependencies); } function removeRunDependency(id) { runDependencies--; Module["monitorRunDependencies"]?.(runDependencies); if (runDependencies == 0) { if (runDependencyWatcher !== null) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; } if (dependenciesFulfilled) { var callback = dependenciesFulfilled; dependenciesFulfilled = null; callback(); } } } function abort(what) { Module["onAbort"]?.(what); what = "Aborted(" + what + ")"; err(what); ABORT = true; what += ". Build with -sASSERTIONS for more info."; var e = new WebAssembly.RuntimeError(what); readyPromiseReject(e); throw e; } var dataURIPrefix = "data:application/octet-stream;base64,"; var isDataURI = filename => filename.startsWith(dataURIPrefix); var isFileURI = filename => filename.startsWith("file://"); function findWasmBinary() { if (Module["locateFile"]) { var f = "manifold.wasm"; if (!isDataURI(f)) { return locateFile(f); } return f; } return new URL("manifold.wasm", import.meta.url).href; } var wasmBinaryFile; function getBinarySync(file) { if (file == wasmBinaryFile && wasmBinary) { return new Uint8Array(wasmBinary); } if (readBinary) { return readBinary(file); } throw "both async and sync fetching of the wasm failed"; } function getBinaryPromise(binaryFile) { if (!wasmBinary) { return readAsync(binaryFile).then(response => new Uint8Array(response), () => getBinarySync(binaryFile)); } return Promise.resolve().then(() => getBinarySync(binaryFile)); } function instantiateArrayBuffer(binaryFile, imports, receiver) { return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(receiver, reason => { err(`failed to asynchronously prepare wasm: ${reason}`); abort(reason); }); } function instantiateAsync(binary, binaryFile, imports, callback) { if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && !isFileURI(binaryFile) && typeof fetch == "function") { return fetch(binaryFile, { credentials: "same-origin" }).then(response => { var result = WebAssembly.instantiateStreaming(response, imports); return result.then(callback, function (reason) { err(`wasm streaming compile failed: ${reason}`); err("falling back to ArrayBuffer instantiation"); return instantiateArrayBuffer(binaryFile, imports, callback); }); }); } return instantiateArrayBuffer(binaryFile, imports, callback); } function getWasmImports() { return { a: wasmImports }; } function createWasm() { var info = getWasmImports(); function receiveInstance(instance, module) { wasmExports = instance.exports; wasmMemory = wasmExports["za"]; updateMemoryViews(); wasmTable = wasmExports["Ca"]; addOnInit(wasmExports["Aa"]); removeRunDependency("wasm-instantiate"); return wasmExports; } addRunDependency("wasm-instantiate"); function receiveInstantiationResult(result) { receiveInstance(result["instance"]); } if (Module["instantiateWasm"]) { try { return Module["instantiateWasm"](info, receiveInstance); } catch (e) { err(`Module.instantiateWasm callback failed with error: ${e}`); readyPromiseReject(e); } } wasmBinaryFile ??= findWasmBinary(); instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject); return {}; } var callRuntimeCallbacks = callbacks => { callbacks.forEach(f => f(Module)); }; function getValue(ptr, type = "i8") { if (type.endsWith("*")) type = "*"; switch (type) { case "i1": return HEAP8[ptr]; case "i8": return HEAP8[ptr]; case "i16": return HEAP16[ptr >> 1]; case "i32": return HEAP32[ptr >> 2]; case "i64": abort("to do getValue(i64) use WASM_BIGINT"); case "float": return HEAPF32[ptr >> 2]; case "double": return HEAPF64[ptr >> 3]; case "*": return HEAPU32[ptr >> 2]; default: abort(`invalid type for getValue: ${type}`); } } var noExitRuntime = Module["noExitRuntime"] || true; function setValue(ptr, value, type = "i8") { if (type.endsWith("*")) type = "*"; switch (type) { case "i1": HEAP8[ptr] = value; break; case "i8": HEAP8[ptr] = value; break; case "i16": HEAP16[ptr >> 1] = value; break; case "i32": HEAP32[ptr >> 2] = value; break; case "i64": abort("to do setValue(i64) use WASM_BIGINT"); case "float": HEAPF32[ptr >> 2] = value; break; case "double": HEAPF64[ptr >> 3] = value; break; case "*": HEAPU32[ptr >> 2] = value; break; default: abort(`invalid type for setValue: ${type}`); } } var stackRestore = val => __emscripten_stack_restore(val); var stackSave = () => _emscripten_stack_get_current(); var exceptionCaught = []; var uncaughtExceptionCount = 0; var ___cxa_begin_catch = ptr => { var info = new ExceptionInfo(ptr); if (!info.get_caught()) { info.set_caught(true); uncaughtExceptionCount--; } info.set_rethrown(false); exceptionCaught.push(info); ___cxa_increment_exception_refcount(ptr); return ___cxa_get_exception_ptr(ptr); }; var exceptionLast = 0; var ___cxa_end_catch = () => { _setThrew(0, 0); var info = exceptionCaught.pop(); ___cxa_decrement_exception_refcount(info.excPtr); exceptionLast = 0; }; class ExceptionInfo { constructor(excPtr) { this.excPtr = excPtr; this.ptr = excPtr - 24; } set_type(type) { HEAPU32[this.ptr + 4 >> 2] = type; } get_type() { return HEAPU32[this.ptr + 4 >> 2]; } set_destructor(destructor) { HEAPU32[this.ptr + 8 >> 2] = destructor; } get_destructor() { return HEAPU32[this.ptr + 8 >> 2]; } set_caught(caught) { caught = caught ? 1 : 0; HEAP8[this.ptr + 12] = caught; } get_caught() { return HEAP8[this.ptr + 12] != 0; } set_rethrown(rethrown) { rethrown = rethrown ? 1 : 0; HEAP8[this.ptr + 13] = rethrown; } get_rethrown() { return HEAP8[this.ptr + 13] != 0; } init(type, destructor) { this.set_adjusted_ptr(0); this.set_type(type); this.set_destructor(destructor); } set_adjusted_ptr(adjustedPtr) { HEAPU32[this.ptr + 16 >> 2] = adjustedPtr; } get_adjusted_ptr() { return HEAPU32[this.ptr + 16 >> 2]; } } var ___resumeException = ptr => { if (!exceptionLast) { exceptionLast = ptr; } throw exceptionLast; }; var setTempRet0 = val => __emscripten_tempret_set(val); var findMatchingCatch = args => { var thrown = exceptionLast; if (!thrown) { setTempRet0(0); return 0; } var info = new ExceptionInfo(thrown); info.set_adjusted_ptr(thrown); var thrownType = info.get_type(); if (!thrownType) { setTempRet0(0); return thrown; } for (var caughtType of args) { if (caughtType === 0 || caughtType === thrownType) { break; } var adjusted_ptr_addr = info.ptr + 16; if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { setTempRet0(caughtType); return thrown; } } setTempRet0(thrownType); return thrown; }; var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]); var ___cxa_find_matching_catch_3 = arg0 => findMatchingCatch([arg0]); var ___cxa_throw = (ptr, type, destructor) => { var info = new ExceptionInfo(ptr); info.init(type, destructor); exceptionLast = ptr; uncaughtExceptionCount++; throw exceptionLast; }; var __abort_js = () => { abort(""); }; var structRegistrations = {}; var runDestructors = destructors => { while (destructors.length) { var ptr = destructors.pop(); var del = destructors.pop(); del(ptr); } }; function readPointer(pointer) { return this["fromWireType"](HEAPU32[pointer >> 2]); } var awaitingDependencies = {}; var registeredTypes = {}; var typeDependencies = {}; var InternalError; var throwInternalError = message => { throw new InternalError(message); }; var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => { myTypes.forEach(type => typeDependencies[type] = dependentTypes); function onComplete(typeConverters) { var myTypeConverters = getTypeConverters(typeConverters); if (myTypeConverters.length !== myTypes.length) { throwInternalError("Mismatched type converter count"); } for (var i = 0; i < myTypes.length; ++i) { registerType(myTypes[i], myTypeConverters[i]); } } var typeConverters = new Array(dependentTypes.length); var unregisteredTypes = []; var registered = 0; dependentTypes.forEach((dt, i) => { if (registeredTypes.hasOwnProperty(dt)) { typeConverters[i] = registeredTypes[dt]; } else { unregisteredTypes.push(dt); if (!awaitingDependencies.hasOwnProperty(dt)) { awaitingDependencies[dt] = []; } awaitingDependencies[dt].push(() => { typeConverters[i] = registeredTypes[dt]; ++registered; if (registered === unregisteredTypes.length) { onComplete(typeConverters); } }); } }); if (0 === unregisteredTypes.length) { onComplete(typeConverters); } }; var __embind_finalize_value_object = structType => { var reg = structRegistrations[structType]; delete structRegistrations[structType]; var rawConstructor = reg.rawConstructor; var rawDestructor = reg.rawDestructor; var fieldRecords = reg.fields; var fieldTypes = fieldRecords.map(field => field.getterReturnType).concat(fieldRecords.map(field => field.setterArgumentType)); whenDependentTypesAreResolved([structType], fieldTypes, fieldTypes => { var fields = {}; fieldRecords.forEach((field, i) => { var fieldName = field.fieldName; var getterReturnType = fieldTypes[i]; var getter = field.getter; var getterContext = field.getterContext; var setterArgumentType = fieldTypes[i + fieldRecords.length]; var setter = field.setter; var setterContext = field.setterContext; fields[fieldName] = { read: ptr => getterReturnType["fromWireType"](getter(getterContext, ptr)), write: (ptr, o) => { var destructors = []; setter(setterContext, ptr, setterArgumentType["toWireType"](destructors, o)); runDestructors(destructors); } }; }); return [{ name: reg.name, fromWireType: ptr => { var rv = {}; for (var i in fields) { rv[i] = fields[i].read(ptr); } rawDestructor(ptr); return rv; }, toWireType: (destructors, o) => { for (var fieldName in fields) { if (!(fieldName in o)) { throw new TypeError(`Missing field: "${fieldName}"`); } } var ptr = rawConstructor(); for (fieldName in fields) { fields[fieldName].write(ptr, o[fieldName]); } if (destructors !== null) { destructors.push(rawDestructor, ptr); } return ptr; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction: rawDestructor }]; }); }; var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => { }; var embind_init_charCodes = () => { var codes = new Array(256); for (var i = 0; i < 256; ++i) { codes[i] = String.fromCharCode(i); } embind_charCodes = codes; }; var embind_charCodes; var readLatin1String = ptr => { var ret = ""; var c = ptr; while (HEAPU8[c]) { ret += embind_charCodes[HEAPU8[c++]]; } return ret; }; var BindingError; var throwBindingError = message => { throw new BindingError(message); }; function sharedRegisterType(rawType, registeredInstance, options = {}) { var name = registeredInstance.name; if (!rawType) { throwBindingError(`type "${name}" must have a positive integer typeid pointer`); } if (registeredTypes.hasOwnProperty(rawType)) { if (options.ignoreDuplicateRegistrations) { return; } else { throwBindingError(`Cannot register type '${name}' twice`); } } registeredTypes[rawType] = registeredInstance; delete typeDependencies[rawType]; if (awaitingDependencies.hasOwnProperty(rawType)) { var callbacks = awaitingDependencies[rawType]; delete awaitingDependencies[rawType]; callbacks.forEach(cb => cb()); } } function registerType(rawType, registeredInstance, options = {}) { return sharedRegisterType(rawType, registeredInstance, options); } var GenericWireTypeSize = 8; var __embind_register_bool = (rawType, name, trueValue, falseValue) => { name = readLatin1String(name); registerType(rawType, { name, fromWireType: function (wt) { return !!wt; }, toWireType: function (destructors, o) { return o ? trueValue : falseValue; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: function (pointer) { return this["fromWireType"](HEAPU8[pointer]); }, destructorFunction: null }); }; var shallowCopyInternalPointer = o => ({ count: o.count, deleteScheduled: o.deleteScheduled, preservePointerOnDelete: o.preservePointerOnDelete, ptr: o.ptr, ptrType: o.ptrType, smartPtr: o.smartPtr, smartPtrType: o.smartPtrType }); var throwInstanceAlreadyDeleted = obj => { function getInstanceTypeName(handle) { return handle.$$.ptrType.registeredClass.name; } throwBindingError(getInstanceTypeName(obj) + " instance already deleted"); }; var finalizationRegistry = false; var detachFinalizer = handle => { }; var runDestructor = $$ => { if ($$.smartPtr) { $$.smartPtrType.rawDestructor($$.smartPtr); } else { $$.ptrType.registeredClass.rawDestructor($$.ptr); } }; var releaseClassHandle = $$ => { $$.count.value -= 1; var toDelete = 0 === $$.count.value; if (toDelete) { runDestructor($$); } }; var downcastPointer = (ptr, ptrClass, desiredClass) => { if (ptrClass === desiredClass) { return ptr; } if (undefined === desiredClass.baseClass) { return null; } var rv = downcastPointer(ptr, ptrClass, desiredClass.baseClass); if (rv === null) { return null; } return desiredClass.downcast(rv); }; var registeredPointers = {}; var registeredInstances = {}; var getBasestPointer = (class_, ptr) => { if (ptr === undefined) { throwBindingError("ptr should not be undefined"); } while (class_.baseClass) { ptr = class_.upcast(ptr); class_ = class_.baseClass; } return ptr; }; var getInheritedInstance = (class_, ptr) => { ptr = getBasestPointer(class_, ptr); return registeredInstances[ptr]; }; var makeClassHandle = (prototype, record) => { if (!record.ptrType || !record.ptr) { throwInternalError("makeClassHandle requires ptr and ptrType"); } var hasSmartPtrType = !!record.smartPtrType; var hasSmartPtr = !!record.smartPtr; if (hasSmartPtrType !== hasSmartPtr) { throwInternalError("Both smartPtrType and smartPtr must be specified"); } record.count = { value: 1 }; return attachFinalizer(Object.create(prototype, { $$: { value: record, writable: true } })); }; function RegisteredPointer_fromWireType(ptr) { var rawPointer = this.getPointee(ptr); if (!rawPointer) { this.destructor(ptr); return null; } var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer); if (undefined !== registeredInstance) { if (0 === registeredInstance.$$.count.value) { registeredInstance.$$.ptr = rawPointer; registeredInstance.$$.smartPtr = ptr; return registeredInstance["clone"](); } else { var rv = registeredInstance["clone"](); this.destructor(ptr); return rv; } } function makeDefaultHandle() { if (this.isSmartPointer) { return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this.pointeeType, ptr: rawPointer, smartPtrType: this, smartPtr: ptr }); } else { return makeClassHandle(this.registeredClass.instancePrototype, { ptrType: this, ptr }); } } var actualType = this.registeredClass.getActualType(rawPointer); var registeredPointerRecord = registeredPointers[actualType]; if (!registeredPointerRecord) { return makeDefaultHandle.call(this); } var toType; if (this.isConst) { toType = registeredPointerRecord.constPointerType; } else { toType = registeredPointerRecord.pointerType; } var dp = downcastPointer(rawPointer, this.registeredClass, toType.registeredClass); if (dp === null) { return makeDefaultHandle.call(this); } if (this.isSmartPointer) { return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp, smartPtrType: this, smartPtr: ptr }); } else { return makeClassHandle(toType.registeredClass.instancePrototype, { ptrType: toType, ptr: dp }); } } var attachFinalizer = handle => { if ("undefined" === typeof FinalizationRegistry) { attachFinalizer = handle => handle; return handle; } finalizationRegistry = new FinalizationRegistry(info => { releaseClassHandle(info.$$); }); attachFinalizer = handle => { var $$ = handle.$$; var hasSmartPtr = !!$$.smartPtr; if (hasSmartPtr) { var info = { $$ }; finalizationRegistry.register(handle, info, handle); } return handle; }; detachFinalizer = handle => finalizationRegistry.unregister(handle); return attachFinalizer(handle); }; var deletionQueue = []; var flushPendingDeletes = () => { while (deletionQueue.length) { var obj = deletionQueue.pop(); obj.$$.deleteScheduled = false; obj["delete"](); } }; var delayFunction; var init_ClassHandle = () => { Object.assign(ClassHandle.prototype, { isAliasOf(other) { if (!(this instanceof ClassHandle)) { return false; } if (!(other instanceof ClassHandle)) { return false; } var leftClass = this.$$.ptrType.registeredClass; var left = this.$$.ptr; other.$$ = other.$$; var rightClass = other.$$.ptrType.registeredClass; var right = other.$$.ptr; while (leftClass.baseClass) { left = leftClass.upcast(left); leftClass = leftClass.baseClass; } while (rightClass.baseClass) { right = rightClass.upcast(right); rightClass = rightClass.baseClass; } return leftClass === rightClass && left === right; }, clone() { if (!this.$$.ptr) { throwInstanceAlreadyDeleted(this); } if (this.$$.preservePointerOnDelete) { this.$$.count.value += 1; return this; } else { var clone = attachFinalizer(Object.create(Object.getPrototypeOf(this), { $$: { value: shallowCopyInternalPointer(this.$$) } })); clone.$$.count.value += 1; clone.$$.deleteScheduled = false; return clone; } }, delete() { if (!this.$$.ptr) { throwInstanceAlreadyDeleted(this); } if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) { throwBindingError("Object already scheduled for deletion"); } detachFinalizer(this); releaseClassHandle(this.$$); if (!this.$$.preservePointerOnDelete) { this.$$.smartPtr = undefined; this.$$.ptr = undefined; } }, isDeleted() { return !this.$$.ptr; }, deleteLater() { if (!this.$$.ptr) { throwInstanceAlreadyDeleted(this); } if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) { throwBindingError("Object already scheduled for deletion"); } deletionQueue.push(this); if (deletionQueue.length === 1 && delayFunction) { delayFunction(flushPendingDeletes); } this.$$.deleteScheduled = true; return this; } }); }; function ClassHandle() { } var createNamedFunction = (name, body) => Object.defineProperty(body, "name", { value: name }); var ensureOverloadTable = (proto, methodName, humanName) => { if (undefined === proto[methodName].overloadTable) { var prevFunc = proto[methodName]; proto[methodName] = function (...args) { if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) { throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`); } return proto[methodName].overloadTable[args.length].apply(this, args); }; proto[methodName].overloadTable = []; proto[methodName].overloadTable[prevFunc.argCount] = prevFunc; } }; var exposePublicSymbol = (name, value, numArguments) => { if (Module.hasOwnProperty(name)) { if (undefined === numArguments || undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments]) { throwBindingError(`Cannot register public name '${name}' twice`); } ensureOverloadTable(Module, name, name); if (Module.hasOwnProperty(numArguments)) { throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`); } Module[name].overloadTable[numArguments] = value; } else { Module[name] = value; if (undefined !== numArguments) { Module[name].numArguments = numArguments; } } }; var char_0 = 48; var char_9 = 57; var makeLegalFunctionName = name => { name = name.replace(/[^a-zA-Z0-9_]/g, "$"); var f = name.charCodeAt(0); if (f >= char_0 && f <= char_9) { return `_${name}`; } return name; }; function RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) { this.name = name; this.constructor = constructor; this.instancePrototype = instancePrototype; this.rawDestructor = rawDestructor; this.baseClass = baseClass; this.getActualType = getActualType; this.upcast = upcast; this.downcast = downcast; this.pureVirtualFunctions = []; } var upcastPointer = (ptr, ptrClass, desiredClass) => { while (ptrClass !== desiredClass) { if (!ptrClass.upcast) { throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`); } ptr = ptrClass.upcast(ptr); ptrClass = ptrClass.baseClass; } return ptr; }; function constNoSmartPtrRawPointerToWireType(destructors, handle) { if (handle === null) { if (this.isReference) { throwBindingError(`null is not a valid ${this.name}`); } return 0; } if (!handle.$$) { throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`); } if (!handle.$$.ptr) { throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`); } var handleClass = handle.$$.ptrType.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); return ptr; } function genericPointerToWireType(destructors, handle) { var ptr; if (handle === null) { if (this.isReference) { throwBindingError(`null is not a valid ${this.name}`); } if (this.isSmartPointer) { ptr = this.rawConstructor(); if (destructors !== null) { destructors.push(this.rawDestructor, ptr); } return ptr; } else { return 0; } } if (!handle || !handle.$$) { throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`); } if (!handle.$$.ptr) { throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`); } if (!this.isConst && handle.$$.ptrType.isConst) { throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name} to parameter type ${this.name}`); } var handleClass = handle.$$.ptrType.registeredClass; ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); if (this.isSmartPointer) { if (undefined === handle.$$.smartPtr) { throwBindingError("Passing raw pointer to smart pointer is illegal"); } switch (this.sharingPolicy) { case 0: if (handle.$$.smartPtrType === this) { ptr = handle.$$.smartPtr; } else { throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name} to parameter type ${this.name}`); } break; case 1: ptr = handle.$$.smartPtr; break; case 2: if (handle.$$.smartPtrType === this) { ptr = handle.$$.smartPtr; } else { var clonedHandle = handle["clone"](); ptr = this.rawShare(ptr, Emval.toHandle(() => clonedHandle["delete"]())); if (destructors !== null) { destructors.push(this.rawDestructor, ptr); } } break; default: throwBindingError("Unsupporting sharing policy"); } } return ptr; } function nonConstNoSmartPtrRawPointerToWireType(destructors, handle) { if (handle === null) { if (this.isReference) { throwBindingError(`null is not a valid ${this.name}`); } return 0; } if (!handle.$$) { throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`); } if (!handle.$$.ptr) { throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`); } if (handle.$$.ptrType.isConst) { throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`); } var handleClass = handle.$$.ptrType.registeredClass; var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass); return ptr; } var init_RegisteredPointer = () => { Object.assign(RegisteredPointer.prototype, { getPointee(ptr) { if (this.rawGetPointee) { ptr = this.rawGetPointee(ptr); } return ptr; }, destructor(ptr) { this.rawDestructor?.(ptr); }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, fromWireType: RegisteredPointer_fromWireType }); }; function RegisteredPointer(name, registeredClass, isReference, isConst, isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) { this.name = name; this.registeredClass = registeredClass; this.isReference = isReference; this.isConst = isConst; this.isSmartPointer = isSmartPointer; this.pointeeType = pointeeType; this.sharingPolicy = sharingPolicy; this.rawGetPointee = rawGetPointee; this.rawConstructor = rawConstructor; this.rawShare = rawShare; this.rawDestructor = rawDestructor; if (!isSmartPointer && registeredClass.baseClass === undefined) { if (isConst) { this["toWireType"] = constNoSmartPtrRawPointerToWireType; this.destructorFunction = null; } else { this["toWireType"] = nonConstNoSmartPtrRawPointerToWireType; this.destructorFunction = null; } } else { this["toWireType"] = genericPointerToWireType; } } var replacePublicSymbol = (name, value, numArguments) => { if (!Module.hasOwnProperty(name)) { throwInternalError("Replacing nonexistent public symbol"); } if (undefined !== Module[name].overloadTable && undefined !== numArguments) { Module[name].overloadTable[numArguments] = value; } else { Module[name] = value; Module[name].argCount = numArguments; } }; var dynCallLegacy = (sig, ptr, args) => { sig = sig.replace(/p/g, "i"); var f = Module["dynCall_" + sig]; return f(ptr, ...args); }; var wasmTableMirror = []; var wasmTable; var getWasmTableEntry = funcPtr => { var func = wasmTableMirror[funcPtr]; if (!func) { if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1; wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr); } return func; }; var dynCall = (sig, ptr, args = []) => { if (sig.includes("j")) { return dynCallLegacy(sig, ptr, args); } var rtn = getWasmTableEntry(ptr)(...args); return rtn; }; var getDynCaller = (sig, ptr) => (...args) => dynCall(sig, ptr, args); var embind__requireFunction = (signature, rawFunction) => { signature = readLatin1String(signature); function makeDynCaller() { if (signature.includes("j")) { return getDynCaller(signature, rawFunction); } return getWasmTableEntry(rawFunction); } var fp = makeDynCaller(); if (typeof fp != "function") { throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`); } return fp; }; var extendError = (baseErrorType, errorName) => { var errorClass = createNamedFunction(errorName, function (message) { this.name = errorName; this.message = message; var stack = new Error(message).stack; if (stack !== undefined) { this.stack = this.toString() + "\n" + stack.replace(/^Error(:[^\n]*)?\n/, ""); } }); errorClass.prototype = Object.create(baseErrorType.prototype); errorClass.prototype.constructor = errorClass; errorClass.prototype.toString = function () { if (this.message === undefined) { return this.name; } else { return `${this.name}: ${this.message}`; } }; return errorClass; }; var UnboundTypeError; var getTypeName = type => { var ptr = ___getTypeName(type); var rv = readLatin1String(ptr); _free(ptr); return rv; }; var throwUnboundTypeError = (message, types) => { var unboundTypes = []; var seen = {}; function visit(type) { if (seen[type]) { return; } if (registeredTypes[type]) { return; } if (typeDependencies[type]) { typeDependencies[type].forEach(visit); return; } unboundTypes.push(type); seen[type] = true; } types.forEach(visit); throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([", "])); }; var __embind_register_class = (rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) => { name = readLatin1String(name); getActualType = embind__requireFunction(getActualTypeSignature, getActualType); upcast &&= embind__requireFunction(upcastSignature, upcast); downcast &&= embind__requireFunction(downcastSignature, downcast); rawDestructor = embind__requireFunction(destructorSignature, rawDestructor); var legalFunctionName = makeLegalFunctionName(name); exposePublicSymbol(legalFunctionName, function () { throwUnboundTypeError(`Cannot construct ${name} due to unbound types`, [baseClassRawType]); }); whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], base => { base = base[0]; var baseClass; var basePrototype; if (baseClassRawType) { baseClass = base.registeredClass; basePrototype = baseClass.instancePrototype; } else { basePrototype = ClassHandle.prototype; } var constructor = createNamedFunction(name, function (...args) { if (Object.getPrototypeOf(this) !== instancePrototype) { throw new BindingError("Use 'new' to construct " + name); } if (undefined === registeredClass.constructor_body) { throw new BindingError(name + " has no accessible constructor"); } var body = registeredClass.constructor_body[args.length]; if (undefined === body) { throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${args.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`); } return body.apply(this, args); }); var instancePrototype = Object.create(basePrototype, { constructor: { value: constructor } }); constructor.prototype = instancePrototype; var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast); if (registeredClass.baseClass) { registeredClass.baseClass.__derivedClasses ??= []; registeredClass.baseClass.__derivedClasses.push(registeredClass); } var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false); var pointerConverter = new RegisteredPointer(name + "*", registeredClass, false, false, false); var constPointerConverter = new RegisteredPointer(name + " const*", registeredClass, false, true, false); registeredPointers[rawType] = { pointerType: pointerConverter, constPointerType: constPointerConverter }; replacePublicSymbol(legalFunctionName, constructor); return [referenceConverter, pointerConverter, constPointerConverter]; }); }; var heap32VectorToArray = (count, firstElement) => { var array = []; for (var i = 0; i < count; i++) { array.push(HEAPU32[firstElement + i * 4 >> 2]); } return array; }; function usesDestructorStack(argTypes) { for (var i = 1; i < argTypes.length; ++i) { if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) { return true; } } return false; } function newFunc(constructor, argumentList) { if (!(constructor instanceof Function)) { throw new TypeError(`new_ called with constructor type ${typeof constructor} which is not a function`); } var dummy = createNamedFunction(constructor.name || "unknownFunctionName", function () { }); dummy.prototype = constructor.prototype; var obj = new dummy; var r = constructor.apply(obj, argumentList); return r instanceof Object ? r : obj; } function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) { var needsDestructorStack = usesDestructorStack(argTypes); var argCount = argTypes.length - 2; var argsList = []; var argsListWired = ["fn"]; if (isClassMethodFunc) { argsListWired.push("thisWired"); } for (var i = 0; i < argCount; ++i) { argsList.push(`arg${i}`); argsListWired.push(`arg${i}Wired`); } argsList = argsList.join(","); argsListWired = argsListWired.join(","); var invokerFnBody = `return function (${argsList}) {\n`; if (needsDestructorStack) { invokerFnBody += "var destructors = [];\n"; } var dtorStack = needsDestructorStack ? "destructors" : "null"; var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"]; if (isClassMethodFunc) { invokerFnBody += `var thisWired = classParam['toWireType'](${dtorStack}, this);\n`; } for (var i = 0; i < argCount; ++i) { invokerFnBody += `var arg${i}Wired = argType${i}['toWireType'](${dtorStack}, arg${i});\n`; args1.push(`argType${i}`); } invokerFnBody += (returns || isAsync ? "var rv = " : "") + `invoker(${argsListWired});\n`; if (needsDestructorStack) { invokerFnBody += "runDestructors(destructors);\n"; } else { for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { var paramName = i === 1 ? "thisWired" : "arg" + (i - 2) + "Wired"; if (argTypes[i].destructorFunction !== null) { invokerFnBody += `${paramName}_dtor(${paramName});\n`; args1.push(`${paramName}_dtor`); } } } if (returns) { invokerFnBody += "var ret = retType['fromWireType'](rv);\n" + "return ret;\n"; } else { } invokerFnBody += "}\n"; return [args1, invokerFnBody]; } function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, isAsync) { var argCount = argTypes.length; if (argCount < 2) { throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!"); } var isClassMethodFunc = argTypes[1] !== null && classType !== null; var needsDestructorStack = usesDestructorStack(argTypes); var returns = argTypes[0].name !== "void"; var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]]; for (var i = 0; i < argCount - 2; ++i) { closureArgs.push(argTypes[i + 2]); } if (!needsDestructorStack) { for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) { if (argTypes[i].destructorFunction !== null) { closureArgs.push(argTypes[i].destructorFunction); } } } let [args, invokerFnBody] = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync); args.push(invokerFnBody); var invokerFn = newFunc(Function, args)(...closureArgs); return createNamedFunction(humanName, invokerFn); } var __embind_register_class_constructor = (rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) => { var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); invoker = embind__requireFunction(invokerSignature, invoker); whenDependentTypesAreResolved([], [rawClassType], classType => { classType = classType[0]; var humanName = `constructor ${classType.name}`; if (undefined === classType.registeredClass.constructor_body) { classType.registeredClass.constructor_body = []; } if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) { 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!`); } classType.registeredClass.constructor_body[argCount - 1] = () => { throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`, rawArgTypes); }; whenDependentTypesAreResolved([], rawArgTypes, argTypes => { argTypes.splice(1, 0, null); classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor); return []; }); return []; }); }; var getFunctionName = signature => { signature = signature.trim(); const argsIndex = signature.indexOf("("); if (argsIndex !== -1) { return signature.substr(0, argsIndex); } else { return signature; } }; var __embind_register_class_function = (rawClassType, methodName, argCount, rawArgTypesAddr, invokerSignature, rawInvoker, context, isPureVirtual, isAsync, isNonnullReturn) => { var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr); methodName = readLatin1String(methodName); methodName = getFunctionName(methodName); rawInvoker = embind__requireFunction(invokerSignature, rawInvoker); whenDependentTypesAreResolved([], [rawClassType], classType => { classType = classType[0]; var humanName = `${classType.name}.${methodName}`; if (methodName.startsWith("@@")) { methodName = Symbol[methodName.substring(2)]; } if (isPureVirtual) { classType.registeredClass.pureVirtualFunctions.push(methodName); } function unboundTypesHandler() { throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`, rawArgTypes); } var proto = classType.registeredClass.instancePrototype; var method = proto[methodName]; if (undefined === method || undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2) { unboundTypesHandler.argCount = argCount - 2; unboundTypesHandler.className = classType.name; proto[methodName] = unboundTypesHandler; } else { ensureOverloadTable(proto, methodName, humanName); proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler; } whenDependentTypesAreResolved([], rawArgTypes, argTypes => { var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync); if (undefined === proto[methodName].overloadTable) { memberFunction.argCount = argCount - 2; proto[methodName] = memberFunction; } else { proto[methodName].overloadTable[argCount - 2] = memberFunction; } return []; }); return []; }); }; var emval_freelist = []; var emval_handles = []; var __emval_decref = handle => { if (handle > 9 && 0 === --emval_handles[handle + 1]) { emval_handles[handle] = undefined; emval_freelist.push(handle); } }; var count_emval_handles = () => emval_handles.length / 2 - 5 - emval_freelist.length; var init_emval = () => { emval_handles.push(0, 1, undefined, 1, null, 1, true, 1, false, 1); Module["count_emval_handles"] = count_emval_handles; }; var Emval = { toValue: handle => { if (!handle) { throwBindingError("Cannot use deleted val. handle = " + handle); } return emval_handles[handle]; }, toHandle: value => { switch (value) { case undefined: return 2; case null: return 4; case true: return 6; case false: return 8; default: { const handle = emval_freelist.pop() || emval_handles.length; emval_handles[handle] = value; emval_handles[handle + 1] = 1; return handle; } } } }; var EmValType = { name: "emscripten::val", fromWireType: handle => { var rv = Emval.toValue(handle); __emval_decref(handle); return rv; }, toWireType: (destructors, value) => Emval.toHandle(value), argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction: null }; var __embind_register_emval = rawType => registerType(rawType, EmValType); var enumReadValueFromPointer = (name, width, signed) => { switch (width) { case 1: return signed ? function (pointer) { return this["fromWireType"](HEAP8[pointer]); } : function (pointer) { return this["fromWireType"](HEAPU8[pointer]); }; case 2: return signed ? function (pointer) { return this["fromWireType"](HEAP16[pointer >> 1]); } : function (pointer) { return this["fromWireType"](HEAPU16[pointer >> 1]); }; case 4: return signed ? function (pointer) { return this["fromWireType"](HEAP32[pointer >> 2]); } : function (pointer) { return this["fromWireType"](HEAPU32[pointer >> 2]); }; default: throw new TypeError(`invalid integer width (${width}): ${name}`); } }; var __embind_register_enum = (rawType, name, size, isSigned) => { name = readLatin1String(name); function ctor() { } ctor.values = {}; registerType(rawType, { name, constructor: ctor, fromWireType: function (c) { return this.constructor.values[c]; }, toWireType: (destructors, c) => c.value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: enumReadValueFromPointer(name, size, isSigned), destructorFunction: null }); exposePublicSymbol(name, ctor); }; var requireRegisteredType = (rawType, humanName) => { var impl = registeredTypes[rawType]; if (undefined === impl) { throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`); } return impl; }; var __embind_register_enum_value = (rawEnumType, name, enumValue) => { var enumType = requireRegisteredType(rawEnumType, "enum"); name = readLatin1String(name); var Enum = enumType.constructor; var Value = Object.create(enumType.constructor.prototype, { value: { value: enumValue }, constructor: { value: createNamedFunction(`${enumType.name}_${name}`, function () { }) } }); Enum.values[enumValue] = Value; Enum[name] = Value; }; var embindRepr = v => { if (v === null) { return "null"; } var t = typeof v; if (t === "object" || t === "array" || t === "function") { return v.toString(); } else { return "" + v; } }; var floatReadValueFromPointer = (name, width) => { switch (width) { case 4: return function (pointer) { return this["fromWireType"](HEAPF32[pointer >> 2]); }; case 8: return function (pointer) { return this["fromWireType"](HEAPF64[pointer >> 3]); }; default: throw new TypeError(`invalid float width (${width}): ${name}`); } }; var __embind_register_float = (rawType, name, size) => { name = readLatin1String(name); registerType(rawType, { name, fromWireType: value => value, toWireType: (destructors, value) => value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: floatReadValueFromPointer(name, size), destructorFunction: null }); }; var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync, isNonnullReturn) => { var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr); name = readLatin1String(name); name = getFunctionName(name); rawInvoker = embind__requireFunction(signature, rawInvoker); exposePublicSymbol(name, function () { throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes); }, argCount - 1); whenDependentTypesAreResolved([], argTypes, argTypes => { var invokerArgsArray = [argTypes[0], null].concat(argTypes.slice(1)); replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null, rawInvoker, fn, isAsync), argCount - 1); return []; }); }; var integerReadValueFromPointer = (name, width, signed) => { switch (width) { case 1: return signed ? pointer => HEAP8[pointer] : pointer => HEAPU8[pointer]; case 2: return signed ? pointer => HEAP16[pointer >> 1] : pointer => HEAPU16[pointer >> 1]; case 4: return signed ? pointer => HEAP32[pointer >> 2] : pointer => HEAPU32[pointer >> 2]; default: throw new TypeError(`invalid integer width (${width}): ${name}`); } }; var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => { name = readLatin1String(name); if (maxRange === -1) { maxRange = 4294967295; } var fromWireType = value => value; if (minRange === 0) { var bitshift = 32 - 8 * size; fromWireType = value => value << bitshift >>> bitshift; } var isUnsignedType = name.includes("unsigned"); var checkAssertions = (value, toTypeName) => { }; var toWireType; if (isUnsignedType) { toWireType = function (destructors, value) { checkAssertions(value, this.name); return value >>> 0; }; } else { toWireType = function (destructors, value) { checkAssertions(value, this.name); return value; }; } registerType(primitiveType, { name, fromWireType, toWireType, argPackAdvance: GenericWireTypeSize, readValueFromPointer: integerReadValueFromPointer(name, size, minRange !== 0), destructorFunction: null }); }; var __embind_register_memory_view = (rawType, dataTypeIndex, name) => { var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]; var TA = typeMapping[dataTypeIndex]; function decodeMemoryView(handle) { var size = HEAPU32[handle >> 2]; var data = HEAPU32[handle + 4 >> 2]; return new TA(HEAP8.buffer, data, size); } name = readLatin1String(name); registerType(rawType, { name, fromWireType: decodeMemoryView, argPackAdvance: GenericWireTypeSize, readValueFromPointer: decodeMemoryView }, { ignoreDuplicateRegistrations: true }); }; var EmValOptionalType = Object.assign({ optional: true }, EmValType); var __embind_register_optional = (rawOptionalType, rawType) => { registerType(rawOptionalType, EmValOptionalType); }; var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => { if (!(maxBytesToWrite > 0)) return 0; var startIdx = outIdx; var endIdx = outIdx + maxBytesToWrite - 1; for (var i = 0; i < str.length; ++i) { var u = str.charCodeAt(i); if (u >= 55296 && u <= 57343) { var u1 = str.charCodeAt(++i); u = 65536 + ((u & 1023) << 10) | u1 & 1023; } if (u <= 127) { if (outIdx >= endIdx) break; heap[outIdx++] = u; } else if (u <= 2047) { if (outIdx + 1 >= endIdx) break; heap[outIdx++] = 192 | u >> 6; heap[outIdx++] = 128 | u & 63; } else if (u <= 65535) { if (outIdx + 2 >= endIdx) break; heap[outIdx++] = 224 | u >> 12; heap[outIdx++] = 128 | u >> 6 & 63; heap[outIdx++] = 128 | u & 63; } else { if (outIdx + 3 >= endIdx) break; heap[outIdx++] = 240 | u >> 18; heap[outIdx++] = 128 | u >> 12 & 63; heap[outIdx++] = 128 | u >> 6 & 63; heap[outIdx++] = 128 | u & 63; } } heap[outIdx] = 0; return outIdx - startIdx; }; var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); var lengthBytesUTF8 = str => { var len = 0; for (var i = 0; i < str.length; ++i) { var c = str.charCodeAt(i); if (c <= 127) { len++; } else if (c <= 2047) { len += 2; } else if (c >= 55296 && c <= 57343) { len += 4; ++i; } else { len += 3; } } return len; }; var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined; var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => { var endIdx = idx + maxBytesToRead; var endPtr = idx; while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr; if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); } var str = ""; while (idx < endPtr) { var u0 = heapOrArray[idx++]; if (!(u0 & 128)) { str += String.fromCharCode(u0); continue; } var u1 = heapOrArray[idx++] & 63; if ((u0 & 224) == 192) { str += String.fromCharCode((u0 & 31) << 6 | u1); continue; } var u2 = heapOrArray[idx++] & 63; if ((u0 & 240) == 224) { u0 = (u0 & 15) << 12 | u1 << 6 | u2; } else { u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63; } if (u0 < 65536) { str += String.fromCharCode(u0); } else { var ch = u0 - 65536; str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); } } return str; }; var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ""; var __embind_register_std_string = (rawType, name) => { name = readLatin1String(name); var stdStringIsUTF8 = name === "std::string"; registerType(rawType, { name, fromWireType(value) { var length = HEAPU32[value >> 2]; var payload = value + 4; var str; if (stdStringIsUTF8) { var decodeStartPtr = payload; for (var i = 0; i <= length; ++i) { var currentBytePtr = payload + i; if (i == length || HEAPU8[currentBytePtr] == 0) { var maxRead = currentBytePtr - decodeStartPtr; var stringSegment = UTF8ToString(decodeStartPtr, maxRead); if (str === undefined) { str = stringSegment; } else { str += String.fromCharCode(0); str += stringSegment; } decodeStartPtr = currentBytePtr + 1; } } } else { var a = new Array(length); for (var i = 0; i < length; ++i) { a[i] = String.fromCharCode(HEAPU8[payload + i]); } str = a.join(""); } _free(value); return str; }, toWireType(destructors, value) { if (value instanceof ArrayBuffer) { value = new Uint8Array(value); } var length; var valueIsOfTypeString = typeof value == "string"; if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) { throwBindingError("Cannot pass non-string to std::string"); } if (stdStringIsUTF8 && valueIsOfTypeString) { length = lengthBytesUTF8(value); } else { length = value.length; } var base = _malloc(4 + length + 1); var ptr = base + 4; HEAPU32[base >> 2] = length; if (stdStringIsUTF8 && valueIsOfTypeString) { stringToUTF8(value, ptr, length + 1); } else { if (valueIsOfTypeString) { for (var i = 0; i < length; ++i) { var charCode = value.charCodeAt(i); if (charCode > 255) { _free(ptr); throwBindingError("String has UTF-16 code units that do not fit in 8 bits"); } HEAPU8[ptr + i] = charCode; } } else { for (var i = 0; i < length; ++i) { HEAPU8[ptr + i] = value[i]; } } } if (destructors !== null) { destructors.push(_free, base); } return base; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction(ptr) { _free(ptr); } }); }; var UTF16Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : undefined; var UTF16ToString = (ptr, maxBytesToRead) => { var endPtr = ptr; var idx = endPtr >> 1; var maxIdx = idx + maxBytesToRead / 2; while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx; endPtr = idx << 1; if (endPtr - ptr > 32 && UTF16Decoder) return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)); var str = ""; for (var i = 0; !(i >= maxBytesToRead / 2); ++i) { var codeUnit = HEAP16[ptr + i * 2 >> 1]; if (codeUnit == 0) break; str += String.fromCharCode(codeUnit); } return str; }; var stringToUTF16 = (str, outPtr, maxBytesToWrite) => { maxBytesToWrite ??= 2147483647; if (maxBytesToWrite < 2) return 0; maxBytesToWrite -= 2; var startPtr = outPtr; var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length; for (var i = 0; i < numCharsToWrite; ++i) { var codeUnit = str.charCodeAt(i); HEAP16[outPtr >> 1] = codeUnit; outPtr += 2; } HEAP16[outPtr >> 1] = 0; return outPtr - startPtr; }; var lengthBytesUTF16 = str => str.length * 2; var UTF32ToString = (ptr, maxBytesToRead) => { var i = 0; var str = ""; while (!(i >= maxBytesToRead / 4)) { var utf32 = HEAP32[ptr + i * 4 >> 2]; if (utf32 == 0) break; ++i; if (utf32 >= 65536) { var ch = utf32 - 65536; str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023); } else { str += String.fromCharCode(utf32); } } return str; }; var stringToUTF32 = (str, outPtr, maxBytesToWrite) => { maxBytesToWrite ??= 2147483647; if (maxBytesToWrite < 4) return 0; var startPtr = outPtr; var endPtr = startPtr + maxBytesToWrite - 4; for (var i = 0; i < str.length; ++i) { var codeUnit = str.charCodeAt(i); if (codeUnit >= 55296 && codeUnit <= 57343) { var trailSurrogate = str.charCodeAt(++i); codeUnit = 65536 + ((codeUnit & 1023) << 10) | trailSurrogate & 1023; } HEAP32[outPtr >> 2] = codeUnit; outPtr += 4; if (outPtr + 4 > endPtr) break; } HEAP32[outPtr >> 2] = 0; return outPtr - startPtr; }; var lengthBytesUTF32 = str => { var len = 0; for (var i = 0; i < str.length; ++i) { var codeUnit = str.charCodeAt(i); if (codeUnit >= 55296 && codeUnit <= 57343) ++i; len += 4; } return len; }; var __embind_register_std_wstring = (rawType, charSize, name) => { name = readLatin1String(name); var decodeString, encodeString, readCharAt, lengthBytesUTF; if (charSize === 2) { decodeString = UTF16ToString; encodeString = stringToUTF16; lengthBytesUTF = lengthBytesUTF16; readCharAt = pointer => HEAPU16[pointer >> 1]; } else if (charSize === 4) { decodeString = UTF32ToString; encodeString = stringToUTF32; lengthBytesUTF = lengthBytesUTF32; readCharAt = pointer => HEAPU32[pointer >> 2]; } registerType(rawType, { name, fromWireType: value => { var length = HEAPU32[value >> 2]; var str; var decodeStartPtr = value + 4; for (var i = 0; i <= length; ++i) { var currentBytePtr = value + 4 + i * charSize; if (i == length || readCharAt(currentBytePtr) == 0) { var maxReadBytes = currentBytePtr - decodeStartPtr; var stringSegment = decodeString(decodeStartPtr, maxReadBytes); if (str === undefined) { str = stringSegment; } else { str += String.fromCharCode(0); str += stringSegment; } decodeStartPtr = currentBytePtr + charSize; } } _free(value); return str; }, toWireType: (destructors, value) => { if (!(typeof value == "string")) { throwBindingError(`Cannot pass non-string to C++ string type ${name}`); } var length = lengthBytesUTF(value); var ptr = _malloc(4 + length + charSize); HEAPU32[ptr >> 2] = length / charSize; encodeString(value, ptr + 4, length + charSize); if (destructors !== null) { destructors.push(_free, ptr); } return ptr; }, argPackAdvance: GenericWireTypeSize, readValueFromPointer: readPointer, destructorFunction(ptr) { _free(ptr); } }); }; var __embind_register_value_object = (rawType, name, constructorSignature, rawConstructor, destructorSignature, rawDestructor) => { structRegistrations[rawType] = { name: readLatin1String(name), rawConstructor: embind__requireFunction(constructorSignature, rawConstructor), rawDestructor: embind__requireFunction(destructorSignature, rawDestructor), fields: [] }; }; var __embind_register_value_object_field = (structType, fieldName, getterReturnType, getterSignature, getter, getterContext, setterArgumentType, setterSignature, setter, setterContext) => { structRegistrations[structType].fields.push({ fieldName: readLatin1String(fieldName), getterReturnType, getter: embind__requireFunction(getterSignature, getter), getterContext, setterArgumentType, setter: embind__requireFunction(setterSignature, setter), setterContext }); }; var __embind_register_void = (rawType, name) => { name = readLatin1String(name); registerType(rawType, { isVoid: true, name, argPackAdvance: 0, fromWireType: () => undefined, toWireType: (destructors, o) => undefined }); }; var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num); var emval_returnValue = (returnType, destructorsRef, handle) => { var destructors = []; var result = returnType["toWireType"](destructors, handle); if (destructors.length) { HEAPU32[destructorsRef >> 2] = Emval.toHandle(destructors); } return result; }; var __emval_as = (handle, returnType, destructorsRef) => { handle = Emval.toValue(handle); returnType = requireRegisteredType(returnType, "emval::as"); return emval_returnValue(returnType, destructorsRef, handle); }; var emval_symbols = {}; var getStringOrSymbol = address => { var symbol = emval_symbols[address]; if (symbol === undefined) { return readLatin1String(address); } return symbol; }; var emval_methodCallers = []; var __emval_call_method = (caller, objHandle, methodName, destructorsRef, args) => { caller = emval_methodCallers[caller]; objHandle = Emval.toValue(objHandle); methodName = getStringOrSymbol(methodName); return caller(objHandle, objHandle[methodName], destructorsRef, args); }; var __emval_equals = (first, second) => { first = Emval.toValue(first); second = Emval.toValue(second); return first == second; }; var emval_addMethodCaller = caller => { var id = emval_methodCallers.length; emval_methodCallers.push(caller); return id; }; var emval_lookupTypes = (argCount, argTypes) => { var a = new Array(argCount); for (var i = 0; i < argCount; ++i) { a[i] = requireRegisteredType(HEAPU32[argTypes + i * 4 >> 2], "parameter " + i); } return a; }; var reflectConstruct = Reflect.construct; var __emval_get_method_caller = (argCount, argTypes, kind) => { var types = emval_lookupTypes(argCount, argTypes); var retType = types.shift(); argCount--; var functionBody = `return function (obj, func, destructorsRef, args) {\n`; var offset = 0; var argsList = []; if (kind === 0) { argsList.push("obj"); } var params = ["retType"]; var args = [retType]; for (var i = 0; i < argCount; ++i) { argsList.push("arg" + i); params.push("argType" + i); args.push(types[i]); functionBody += ` var arg${i} = argType${i}.readValueFromPointer(args${offset ? "+" + offset : ""});\n`; offset += types[i].argPackAdvance; } var invoker = kind === 1 ? "new func" : "func.call"; functionBody += ` var rv = ${invoker}(${argsList.join(", ")});\n`; if (!retType.isVoid) { params.push("emval_returnValue"); args.push(emval_returnValue); functionBody += " return emval_returnValue(retType, destructorsRef, rv);\n"; } functionBody += "};\n"; params.push(functionBody); var invokerFunction = newFunc(Function, params)(...args); var functionName = `methodCaller<(${types.map(t => t.name).join(", ")}) => ${retType.name}>`; return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction)); }; var __emval_get_property = (handle, key) => { handle = Emval.toValue(handle); key = Emval.toValue(key); return Emval.toHandle(handle[key]); }; var __emval_incref = handle => { if (handle > 9) { emval_handles[handle + 1] += 1; } }; var __emval_new_cstring = v => Emval.toHandle(getStringOrSymbol(v)); var __emval_new_object = () => Emval.toHandle({}); var __emval_run_destructors = handle => { var destructors = Emval.toValue(handle); runDestructors(destructors); __emval_decref(handle); }; var __emval_set_property = (handle, key, value) => { handle = Emval.toValue(handle); key = Emval.toValue(key); value = Emval.toValue(value); handle[key] = value; }; var __emval_take_value = (type, arg) => { type = requireRegisteredType(type, "_emval_take_value"); var v = type["readValueFromPointer"](arg); return Emval.toHandle(v); }; var getHeapMax = () => 2147483648; var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment; var growMemory = size => { var b = wasmMemory.buffer; var pages = (size - b.byteLength + 65535) / 65536 | 0; try { wasmMemory.grow(pages); updateMemoryViews(); return 1; } catch (e) { } }; var _emscripten_resize_heap = requestedSize => { var oldSize = HEAPU8.length; requestedSize >>>= 0; var maxHeapSize = getHeapMax(); if (requestedSize > maxHeapSize) { return false; } for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { var overGrownHeapSize = oldSize * (1 + .2 / cutDown); overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296); var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536)); var replacement = growMemory(newSize); if (replacement) { return true; } } return false; }; var _llvm_eh_typeid_for = type => type; var uleb128Encode = (n, target) => { if (n < 128) { target.push(n); } else { target.push(n % 128 | 128, n >> 7); } }; var sigToWasmTypes = sig => { var typeNames = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" }; var type = { parameters: [], results: sig[0] == "v" ? [] : [typeNames[sig[0]]] }; for (var i = 1; i < sig.length; ++i) { type.parameters.push(typeNames[sig[i]]); } return type; }; var generateFuncType = (sig, target) => { var sigRet = sig.slice(0, 1); var sigParam = sig.slice(1); var typeCodes = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 }; target.push(96); uleb128Encode(sigParam.length, target); for (var i = 0; i < sigParam.length; ++i) { target.push(typeCodes[sigParam[i]]); } if (sigRet == "v") { target.push(0); } else { target.push(1, typeCodes[sigRet]); } }; var convertJsFunctionToWasm = (func, sig) => { if (typeof WebAssembly.Function == "function") { return new WebAssembly.Function(sigToWasmTypes(sig), func); } var typeSectionBody = [1]; generateFuncType(sig, typeSectionBody); var bytes = [0, 97, 115, 109, 1, 0, 0, 0, 1]; uleb128Encode(typeSectionBody.length, bytes); bytes.push(...typeSectionBody); bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0); var module = new WebAssembly.Module(new Uint8Array(bytes)); var instance = new WebAssembly.Instance(module, { e: { f: func } }); var wrappedFunc = instance.exports["f"]; return wrappedFunc; }; var updateTableMap = (offset, count) => { if (functionsInTableMap) { for (var i = offset; i < offset + count; i++) { var item = getWasmTableEntry(i); if (item) { functionsInTableMap.set(item, i); } } } }; var functionsInTableMap; var getFunctionAddress = func => { if (!functionsInTableMap) { functionsInTableMap = new WeakMap; updateTableMap(0, wasmTable.length); } return functionsInTableMap.get(func) || 0; }; var freeTableIndexes = []; var getEmptyTableSlot = () => { if (freeTableIndexes.length) { return freeTableIndexes.pop(); } try { wasmTable.grow(1); } catch (err) { if (!(err instanceof RangeError)) { throw err; } throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."; } return wasmTable.length - 1; }; var setWasmTableEntry = (idx, func) => { wasmTable.set(idx, func); wasmTableMirror[idx] = wasmTable.get(idx); }; var addFunction = (func, sig) => { var rtn = getFunctionAddress(func); if (rtn) { return rtn; } var ret = getEmptyTableSlot(); try { setWasmTableEntry(ret, func); } catch (err) { if (!(err instanceof TypeError)) { throw err; } var wrapped = convertJsFunctionToWasm(func, sig); setWasmTableEntry(ret, wrapped); } functionsInTableMap.set(func, ret); return ret; }; var removeFunction = index => { functionsInTableMap.delete(getWasmTableEntry(index)); setWasmTableEntry(index, null); freeTableIndexes.push(index); }; InternalError = Module["InternalError"] = class InternalError extends Error { constructor(message) { super(message); this.name = "InternalError"; } }; embind_init_charCodes(); BindingError = Module["BindingError"] = class BindingError extends Error { constructor(message) { super(message); this.name = "BindingError"; } }; init_ClassHandle(); init_RegisteredPointer(); UnboundTypeError = Module["UnboundTypeError"] = extendError(Error, "UnboundTypeError"); init_emval(); var wasmImports = { J: ___cxa_begin_catch, fa: ___cxa_end_catch, a: ___cxa_find_matching_catch_2, k: ___cxa_find_matching_catch_3, h: ___cxa_throw, e: ___resumeException, $: __abort_js, qa: __embind_finalize_value_object, _: __embind_register_bigint, na: __embind_register_bool, x: __embind_register_class, w: __embind_register_class_constructor, i: __embind_register_class_function, ma: __embind_register_emval, M: __embind_register_enum, t: __embind_register_enum_value, V: __embind_register_float, o: __embind_register_function, z: __embind_register_integer, s: __embind_register_memory_view, A: __embind_register_optional, U: __embind_register_std_string, L: __embind_register_std_wstring, B: __embind_register_value_object, ra: __embind_register_value_object_field, oa: __embind_register_void, ba: __emscripten_memcpy_js, va: __emval_as, ka: __emval_call_method, xa: __emval_decref, ua: __emval_equals, pa: __emval_get_method_caller, wa: __emval_get_property, ta: __emval_incref, E: __emval_new_cstring, X: __emval_new_object, Y: __emval_run_destructors, ya: __emval_set_property, D: __emval_take_value, aa: _emscripten_resize_heap, y: invoke_dd, G: invoke_dii, ha: invoke_diid, I: invoke_diii, v: invoke_diiiii, H: invoke_i, d: invoke_ii, b: invoke_iii, m: invoke_iiii, n: invoke_iiiii, W: invoke_iiiiii, Z: invoke_iiij, j: invoke_v, f: invoke_vi, T: invoke_vid, ca: invoke_vidi, g: invoke_vii, r: invoke_viid, ja: invoke_viidd, ia: invoke_viiddd, F: invoke_viiddi, N: invoke_viidi, la: invoke_viididi, da: invoke_viidiidid, c: invoke_viii, K: invoke_viiid, sa: invoke_viiidddi, l: invoke_viiii, O: invoke_viiiiddi, ea: invoke_viiiidi, u: invoke_viiiii, S: invoke_viiiiid, p: invoke_viiiiii, Q: invoke_viiiiiii, P: invoke_viiiiiiiii, C: invoke_viiiiiiiiidiii, q: invoke_viiiiiiiiii, R: invoke_viiiiiiiiiiiiiiiiii, ga: _llvm_eh_typeid_for }; var wasmExports = createWasm(); var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["Aa"])(); var ___getTypeName = a0 => (___getTypeName = wasmExports["Ba"])(a0); var _malloc = a0 => (_malloc = wasmExports["Da"])(a0); var _free = a0 => (_free = wasmExports["Ea"])(a0); var _setThrew = (a0, a1) => (_setThrew = wasmExports["Fa"])(a0, a1); var __emscripten_tempret_set = a0 => (__emscripten_tempret_set = wasmExports["Ga"])(a0); var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["Ha"])(a0); var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports["Ia"])(); var ___cxa_decrement_exception_refcount = a0 => (___cxa_decrement_exception_refcount = wasmExports["Ja"])(a0); var ___cxa_increment_exception_refcount = a0 => (___cxa_increment_exception_refcount = wasmExports["Ka"])(a0); var ___cxa_can_catch = (a0, a1, a2) => (___cxa_can_catch = wasmExports["La"])(a0, a1, a2); var ___cxa_get_exception_ptr = a0 => (___cxa_get_exception_ptr = wasmExports["Ma"])(a0); var dynCall_iiij = Module["dynCall_iiij"] = (a0, a1, a2, a3, a4) => (dynCall_iiij = Module["dynCall_iiij"] = wasmExports["Na"])(a0, a1, a2, a3, a4); function invoke_viii(index, a1, a2, a3) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iii(index, a1, a2) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiii(index, a1, a2, a3) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_diiiii(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vi(index, a1) { var sp = stackSave(); try { getWasmTableEntry(index)(a1); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_ii(index, a1) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_diii(index, a1, a2, a3) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vii(index, a1, a2) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiiiii(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiii(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiidddi(index, a1, a2, a3, a4, a5, a6, a7) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_v(index) { var sp = stackSave(); try { getWasmTableEntry(index)(); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiiii(index, a1, a2, a3, a4) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_dd(index, a1) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viididi(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viid(index, a1, a2, a3) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vid(index, a1, a2) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiii(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiiidiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiid(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiiiiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiii(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiii(index, a1, a2, a3, a4, a5, a6, a7) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_i(index) { var sp = stackSave(); try { return getWasmTableEntry(index)(); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiid(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viidd(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiddd(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_diid(index, a1, a2, a3) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_dii(index, a1, a2) { var sp = stackSave(); try { return getWasmTableEntry(index)(a1, a2); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiidi(index, a1, a2, a3, a4, a5, a6) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiiiddi(index, a1, a2, a3, a4, a5, a6, a7) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viidi(index, a1, a2, a3, a4) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viidiidid(index, a1, a2, a3, a4, a5, a6, a7, a8) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_viiddi(index, a1, a2, a3, a4, a5) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3, a4, a5); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_vidi(index, a1, a2, a3) { var sp = stackSave(); try { getWasmTableEntry(index)(a1, a2, a3); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } function invoke_iiij(index, a1, a2, a3, a4) { var sp = stackSave(); try { return dynCall_iiij(index, a1, a2, a3, a4); } catch (e) { stackRestore(sp); if (e !== e + 0) throw e; _setThrew(1, 0); } } Module["addFunction"] = addFunction; Module["removeFunction"] = removeFunction; var calledRun; var calledPrerun; dependenciesFulfilled = function runCaller() { if (!calledRun) run(); if (!calledRun) dependenciesFulfilled = runCaller; }; function run() { if (runDependencies > 0) { return; } if (!calledPrerun) { calledPrerun = 1; preRun(); if (runDependencies > 0) { return; } } function doRun() { if (calledRun) return; calledRun = 1; Module["calledRun"] = 1; if (ABORT) return; initRuntime(); readyPromiseResolve(Module); Module["onRuntimeInitialized"]?.(); postRun(); } if (Module["setStatus"]) { Module["setStatus"]("Running..."); setTimeout(() => { setTimeout(() => Module["setStatus"](""), 1); doRun(); }, 1); } else { doRun(); } } if (Module["preInit"]) { if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]]; while (Module["preInit"].length > 0) { Module["preInit"].pop()(); } } run(); moduleRtn = readyPromise; - return moduleRtn; -} -); + return moduleRtn; + } + ); })(); export default Module; From 1291c569b9abc44c037f1ba981a9748662970f4f Mon Sep 17 00:00:00 2001 From: David Altenburg Date: Fri, 15 Nov 2024 14:23:56 -0800 Subject: [PATCH 3/3] update type defs --- .../wasm/manifold-encapsulated-types.d.ts | 72 +++++++++---------- bindings/wasm/manifold-global-types.d.ts | 7 +- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/bindings/wasm/manifold-encapsulated-types.d.ts b/bindings/wasm/manifold-encapsulated-types.d.ts index 3b09ed841c..9fcb5eb9e9 100644 --- a/bindings/wasm/manifold-encapsulated-types.d.ts +++ b/bindings/wasm/manifold-encapsulated-types.d.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {Box, FillRule, JoinType, Mat3, Mat4, Polygons, Properties, Rect, SealedFloat32Array, SealedUint32Array, SimplePolygon, Smoothness, Vec2, Vec3} from './manifold-global-types'; +import { Box, FillRule, JoinType, EndType, Mat3, Mat4, Polygons, Properties, Rect, SealedFloat32Array, SealedUint32Array, SimplePolygon, Smoothness, Vec2, Vec3 } from './manifold-global-types'; /** * Triangulates a set of /epsilon-valid polygons. @@ -102,7 +102,7 @@ export class CrossSection { * @param size The X, and Y dimensions of the square. * @param center Set to true to shift the center to the origin. */ - static square(size?: Vec2|number, center?: boolean): CrossSection; + static square(size?: Vec2 | number, center?: boolean): CrossSection; /** * Constructs a circle of a given radius. @@ -132,8 +132,8 @@ export class CrossSection { * as opposed to resting on the XY plane as is default. */ extrude( - height: number, nDivisions?: number, twistDegrees?: number, - scaleTop?: Vec2|number, center?: boolean): Manifold; + height: number, nDivisions?: number, twistDegrees?: number, + scaleTop?: Vec2 | number, center?: boolean): Manifold; /** * Constructs a manifold by revolving this cross-section around its Y-axis and @@ -180,7 +180,7 @@ export class CrossSection { * * @param v The vector to multiply every vertex by per component. */ - scale(v: Vec2|number): CrossSection; + scale(v: Vec2 | number): CrossSection; /** @@ -224,8 +224,8 @@ export class CrossSection { * defaults according to the radius. */ offset( - delta: number, joinType?: JoinType, miterLimit?: number, - circularSegments?: number): CrossSection; + delta: number, joinType?: JoinType, endType?: EndType, miterLimit?: number, + circularSegments?: number): CrossSection; /** * Remove vertices from the contours in this CrossSection that are less than @@ -250,50 +250,50 @@ export class CrossSection { /** * Boolean union */ - add(other: CrossSection|Polygons): CrossSection; + add(other: CrossSection | Polygons): CrossSection; /** * Boolean difference */ - subtract(other: CrossSection|Polygons): CrossSection; + subtract(other: CrossSection | Polygons): CrossSection; /** * Boolean intersection */ - intersect(other: CrossSection|Polygons): CrossSection; + intersect(other: CrossSection | Polygons): CrossSection; /** * Boolean union of the cross-sections a and b */ - static union(a: CrossSection|Polygons, b: CrossSection|Polygons): - CrossSection; + static union(a: CrossSection | Polygons, b: CrossSection | Polygons): + CrossSection; /** * Boolean difference of the cross-section b from the cross-section a */ - static difference(a: CrossSection|Polygons, b: CrossSection|Polygons): - CrossSection; + static difference(a: CrossSection | Polygons, b: CrossSection | Polygons): + CrossSection; /** * Boolean intersection of the cross-sections a and b */ - static intersection(a: CrossSection|Polygons, b: CrossSection|Polygons): - CrossSection; + static intersection(a: CrossSection | Polygons, b: CrossSection | Polygons): + CrossSection; /** * Boolean union of a list of cross-sections */ - static union(polygons: (CrossSection|Polygons)[]): CrossSection; + static union(polygons: (CrossSection | Polygons)[]): CrossSection; /** * Boolean difference of the tail of a list of cross-sections from its head */ - static difference(polygons: (CrossSection|Polygons)[]): CrossSection; + static difference(polygons: (CrossSection | Polygons)[]): CrossSection; /** * Boolean intersection of a list of cross-sections */ - static intersection(polygons: (CrossSection|Polygons)[]): CrossSection; + static intersection(polygons: (CrossSection | Polygons)[]): CrossSection; // Convex Hulls @@ -305,7 +305,7 @@ export class CrossSection { /** * Compute the convex hull of all points in a list of polygons/cross-sections. */ - static hull(polygons: (CrossSection|Polygons)[]): CrossSection; + static hull(polygons: (CrossSection | Polygons)[]): CrossSection; // Topological Operations @@ -313,7 +313,7 @@ export class CrossSection { * Construct a CrossSection from a vector of other Polygons (batch * boolean union). */ - static compose(polygons: (CrossSection|Polygons)[]): CrossSection; + static compose(polygons: (CrossSection | Polygons)[]): CrossSection; /** * This operation returns a vector of CrossSections that are topologically @@ -433,7 +433,7 @@ export class Manifold { * @param size The X, Y, and Z dimensions of the box. * @param center Set to true to shift the center to the origin. */ - static cube(size?: Vec3|number, center?: boolean): Manifold; + static cube(size?: Vec3 | number, center?: boolean): Manifold; /** * A convenience constructor for the common case of extruding a circle. Can @@ -449,8 +449,8 @@ export class Manifold { * origin at the bottom. */ static cylinder( - height: number, radiusLow: number, radiusHigh?: number, - circularSegments?: number, center?: boolean): Manifold; + height: number, radiusLow: number, radiusHigh?: number, + circularSegments?: number, center?: boolean): Manifold; /** * Constructs a geodesic sphere of a given radius. @@ -485,9 +485,9 @@ export class Manifold { * as opposed to resting on the XY plane as is default. */ static extrude( - polygons: CrossSection|Polygons, height: number, nDivisions?: number, - twistDegrees?: number, scaleTop?: Vec2|number, - center?: boolean): Manifold; + polygons: CrossSection | Polygons, height: number, nDivisions?: number, + twistDegrees?: number, scaleTop?: Vec2 | number, + center?: boolean): Manifold; /** * Constructs a manifold from a set of polygons/cross-section by revolving @@ -502,8 +502,8 @@ export class Manifold { * @param revolveDegrees Number of degrees to revolve. Default is 360 degrees. */ static revolve( - polygons: CrossSection|Polygons, circularSegments?: number, - revolveDegrees?: number): Manifold; + polygons: CrossSection | Polygons, circularSegments?: number, + revolveDegrees?: number): Manifold; // Mesh Conversion @@ -575,8 +575,8 @@ export class Manifold { * will require more sdf evaluations per output vertex. */ static levelSet( - sdf: (point: Vec3) => number, bounds: Box, edgeLength: number, - level?: number, tolerance?: number): Manifold; + sdf: (point: Vec3) => number, bounds: Box, edgeLength: number, + level?: number, tolerance?: number): Manifold; // Transformations @@ -617,7 +617,7 @@ export class Manifold { * * @param v The vector to multiply every vertex by per component. */ - scale(v: Vec3|number): Manifold; + scale(v: Vec3 | number): Manifold; /** * Mirror this Manifold over the plane described by the unit form of the given @@ -721,9 +721,9 @@ export class Manifold { * @param propFunc A function that modifies the properties of a given vertex. */ setProperties( - numProp: number, - propFunc: (newProp: number[], position: Vec3, oldProp: number[]) => void): - Manifold; + numProp: number, + propFunc: (newProp: number[], position: Vec3, oldProp: number[]) => void): + Manifold; /** * Curvature is the inverse of the radius of curvature, and signed such that @@ -868,7 +868,7 @@ export class Manifold { * Compute the convex hull of all points contained within a set of Manifolds * and point vectors. */ - static hull(points: (Manifold|Vec3)[]): Manifold; + static hull(points: (Manifold | Vec3)[]): Manifold; // Topological Operations diff --git a/bindings/wasm/manifold-global-types.d.ts b/bindings/wasm/manifold-global-types.d.ts index bca9387464..3a71f5a931 100644 --- a/bindings/wasm/manifold-global-types.d.ts +++ b/bindings/wasm/manifold-global-types.d.ts @@ -54,7 +54,7 @@ export type Mat4 = [ number, ]; export type SimplePolygon = Vec2[]; -export type Polygons = SimplePolygon|SimplePolygon[]; +export type Polygons = SimplePolygon | SimplePolygon[]; export type Rect = { min: Vec2, max: Vec2 @@ -71,5 +71,6 @@ export type Properties = { surfaceArea: number, volume: number }; -export type FillRule = 'EvenOdd'|'NonZero'|'Positive'|'Negative' -export type JoinType = 'Square'|'Round'|'Miter' +export type FillRule = 'EvenOdd' | 'NonZero' | 'Positive' | 'Negative' +export type JoinType = 'Square' | 'Round' | 'Miter' +export type EndType = 'Polygon' | 'Square' | 'Round' | 'Butt' | 'Joined'